NetSurf
Data Structures | Macros | Functions | Variables
progress_bar.c File Reference

Progress bar (implementation). More...

#include <assert.h>
#include <stdbool.h>
#include <string.h>
#include "swis.h"
#include "oslib/colourtrans.h"
#include "oslib/os.h"
#include "oslib/osspriteop.h"
#include "oslib/wimp.h"
#include "oslib/wimpspriteop.h"
#include "utils/log.h"
#include "utils/utils.h"
#include "netsurf/plotters.h"
#include "riscos/gui.h"
#include "riscos/tinct.h"
#include "riscos/wimp_event.h"
#include "riscos/gui/progress_bar.h"
Include dependency graph for progress_bar.c:

Go to the source code of this file.

Data Structures

struct  progress_bar
 

Macros

#define MARGIN   6
 

Functions

static void ro_gui_progress_bar_calculate (struct progress_bar *pb, int width, int height)
 Calculate the position of the progress bar. More...
 
static void ro_gui_progress_bar_redraw (wimp_draw *redraw)
 Process a WIMP redraw request. More...
 
static void ro_gui_progress_bar_redraw_window (wimp_draw *redraw, struct progress_bar *pb)
 Redraw a section of a progress bar window. More...
 
static void ro_gui_progress_bar_animate (void *p)
 Animate the progress bar. More...
 
void ro_gui_progress_bar_init (osspriteop_area *icons)
 Initialise the progress bar. More...
 
struct progress_barro_gui_progress_bar_create (void)
 Create a new progress bar. More...
 
void ro_gui_progress_bar_destroy (struct progress_bar *pb)
 Destroy a progress bar and free all associated resources. More...
 
wimp_w ro_gui_progress_bar_get_window (struct progress_bar *pb)
 Get the handle of the window that represents a progress bar. More...
 
void ro_gui_progress_bar_set_icon (struct progress_bar *pb, const char *icon)
 Set the icon for a progress bar. More...
 
void ro_gui_progress_bar_set_value (struct progress_bar *pb, unsigned int value)
 Set the value of a progress bar. More...
 
unsigned int ro_gui_progress_bar_get_value (struct progress_bar *pb)
 Get the value of a progress bar. More...
 
void ro_gui_progress_bar_set_range (struct progress_bar *pb, unsigned int range)
 Set the range of a progress bar. More...
 
unsigned int ro_gui_progress_bar_get_range (struct progress_bar *pb)
 Get the range of a progress bar. More...
 
void ro_gui_progress_bar_update (struct progress_bar *pb, int width, int height)
 Update the progress bar to a new dimension. More...
 

Variables

static char progress_animation_sprite [] = "progress"
 
static osspriteop_header * progress_icon
 
static unsigned int progress_width
 
static unsigned int progress_height
 
struct wimp_window_base progress_bar_definition
 

Detailed Description

Progress bar (implementation).

Definition in file progress_bar.c.

Macro Definition Documentation

◆ MARGIN

#define MARGIN   6

Definition at line 42 of file progress_bar.c.

Function Documentation

◆ ro_gui_progress_bar_animate()

void ro_gui_progress_bar_animate ( void *  p)
static

Animate the progress bar.

Parameters
pthe progress bar to animate

Definition at line 371 of file progress_bar.c.

References progress_bar::animating, NSLOG, progress_bar::offset, progress_icon, progress_width, riscos_schedule(), ro_gui_progress_bar_animate(), ro_gui_progress_bar_redraw_window(), progress_bar::visible, and progress_bar::w.

Referenced by ro_gui_progress_bar_animate(), ro_gui_progress_bar_destroy(), and ro_gui_progress_bar_update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_progress_bar_calculate()

void ro_gui_progress_bar_calculate ( struct progress_bar pb,
int  width,
int  height 
)
static

Calculate the position of the progress bar.

Parameters
pbthe progress bar to recalculate
widththe width of the progress bar
heightthe height of the progress bar
Returns
the address of the associated icon, or NULL

Definition at line 409 of file progress_bar.c.

References progress_bar::cur_height, progress_bar::cur_width, height, progress_bar::icon, progress_bar::icon_img, progress_bar::icon_obscured, progress_bar::icon_x0, progress_bar::icon_y0, MARGIN, progress_bar_definition, progress_bar::range, progress_bar::recalculate, progress_bar::value, progress_bar::visible, progress_bar::w, and width.

Referenced by ro_gui_progress_bar_redraw_window(), and ro_gui_progress_bar_update().

Here is the caller graph for this function:

◆ ro_gui_progress_bar_create()

struct progress_bar * ro_gui_progress_bar_create ( void  )

Create a new progress bar.

Definition at line 128 of file progress_bar.c.

References NSLOG, progress_bar_definition, ro_gui_progress_bar_redraw(), ro_gui_wimp_event_register_redraw_window(), ro_gui_wimp_event_set_user_data(), and progress_bar::w.

Referenced by ro_gui_status_bar_create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_progress_bar_destroy()

void ro_gui_progress_bar_destroy ( struct progress_bar pb)

Destroy a progress bar and free all associated resources.

Parameters
pbthe progress bar to destroy

Definition at line 158 of file progress_bar.c.

References progress_bar::animating, NSLOG, riscos_schedule(), ro_gui_progress_bar_animate(), ro_gui_wimp_event_finalise(), and progress_bar::w.

Referenced by ro_gui_status_bar_destroy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_progress_bar_get_range()

unsigned int ro_gui_progress_bar_get_range ( struct progress_bar pb)

Get the range of a progress bar.

Parameters
pbthe progress bar to get the range of
Returns
the current range

Definition at line 269 of file progress_bar.c.

References progress_bar::range.

Referenced by ro_gui_status_bar_set_progress_range(), ro_gui_status_bar_set_progress_value(), and ro_gui_status_position_progress_bar().

Here is the caller graph for this function:

◆ ro_gui_progress_bar_get_value()

unsigned int ro_gui_progress_bar_get_value ( struct progress_bar pb)

Get the value of a progress bar.

Parameters
pbthe progress bar to get the value of
Returns
the current value

Definition at line 238 of file progress_bar.c.

References progress_bar::value.

◆ ro_gui_progress_bar_get_window()

wimp_w ro_gui_progress_bar_get_window ( struct progress_bar pb)

Get the handle of the window that represents a progress bar.

Parameters
pbthe progress bar to get the window handle of
Returns
the progress bar's window handle

Definition at line 183 of file progress_bar.c.

References progress_bar::w.

Referenced by ro_gui_status_bar_set_progress_range(), and ro_gui_status_position_progress_bar().

Here is the caller graph for this function:

◆ ro_gui_progress_bar_init()

void ro_gui_progress_bar_init ( osspriteop_area *  icons)

Initialise the progress bar.

Parameters
iconsthe sprite area to use for icons

Definition at line 104 of file progress_bar.c.

References progress_animation_sprite, progress_bar_definition, progress_height, progress_icon, and progress_width.

◆ ro_gui_progress_bar_redraw()

void ro_gui_progress_bar_redraw ( wimp_draw *  redraw)
static

Process a WIMP redraw request.

Parameters
redrawthe redraw request to process

Definition at line 346 of file progress_bar.c.

References NSLOG, ro_gui_progress_bar_redraw_window(), and ro_gui_wimp_event_get_user_data().

Referenced by ro_gui_progress_bar_create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_progress_bar_redraw_window()

void ro_gui_progress_bar_redraw_window ( wimp_draw *  redraw,
struct progress_bar pb 
)
static

Redraw a section of a progress bar window.

Parameters
redrawthe section of the window to redraw
pbthe progress bar to redraw

Definition at line 484 of file progress_bar.c.

References clip(), plotter_table::clip, progress_bar::icon, progress_bar::icon_img, progress_bar::icon_obscured, progress_bar::icon_x0, progress_bar::icon_y0, redraw_context::interactive, max, min, NSLOG, progress_bar::offset, redraw_context::plot, plot_style_fill_red, progress_height, progress_icon, plotter_table::rectangle, ro_gui_progress_bar_calculate(), ro_plot_origin_x, ro_plot_origin_y, ro_plotters, tinct_ERROR_DIFFUSE, tinct_FILL_HORIZONTALLY, Tinct_Plot, Tinct_PlotAlpha, and progress_bar::visible.

Referenced by ro_gui_progress_bar_animate(), ro_gui_progress_bar_redraw(), and ro_gui_progress_bar_update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_progress_bar_set_icon()

void ro_gui_progress_bar_set_icon ( struct progress_bar pb,
const char *  icon 
)

Set the icon for a progress bar.

Parameters
pbthe progress bar to set the icon for
iconthe icon to use, or NULL for no icon

Definition at line 197 of file progress_bar.c.

References progress_bar::cur_height, progress_bar::cur_width, progress_bar::icon, progress_bar::recalculate, ro_gui_progress_bar_update(), and progress_bar::w.

Referenced by ro_gui_status_bar_set_progress_icon().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_progress_bar_set_range()

void ro_gui_progress_bar_set_range ( struct progress_bar pb,
unsigned int  range 
)

Set the range of a progress bar.

Parameters
pbthe progress bar to set the range for
rangethe range to use

Definition at line 252 of file progress_bar.c.

References progress_bar::cur_height, progress_bar::cur_width, progress_bar::range, ro_gui_progress_bar_update(), and progress_bar::value.

Referenced by ro_gui_status_bar_set_progress_range().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_progress_bar_set_value()

void ro_gui_progress_bar_set_value ( struct progress_bar pb,
unsigned int  value 
)

Set the value of a progress bar.

Parameters
pbthe progress bar to set the value for
valuethe value to use

Definition at line 221 of file progress_bar.c.

References progress_bar::cur_height, progress_bar::cur_width, progress_bar::range, ro_gui_progress_bar_update(), and progress_bar::value.

Referenced by ro_gui_status_bar_set_progress_value().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_progress_bar_update()

void ro_gui_progress_bar_update ( struct progress_bar pb,
int  width,
int  height 
)

Update the progress bar to a new dimension.

Parameters
pbthe progress bar to update
widththe new progress bar width
heightthe new progress bar height

Definition at line 284 of file progress_bar.c.

References progress_bar::animating, height, max, NSLOG, progress_bar::range, progress_bar::recalculate, riscos_schedule(), ro_gui_progress_bar_animate(), ro_gui_progress_bar_calculate(), ro_gui_progress_bar_redraw_window(), progress_bar::value, progress_bar::visible, progress_bar::w, and width.

Referenced by ro_gui_progress_bar_set_icon(), ro_gui_progress_bar_set_range(), ro_gui_progress_bar_set_value(), and ro_gui_status_position_progress_bar().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ progress_animation_sprite

char progress_animation_sprite[] = "progress"
static

Definition at line 61 of file progress_bar.c.

Referenced by ro_gui_progress_bar_init().

◆ progress_bar_definition

struct wimp_window_base progress_bar_definition
Initial value:
= {
{0, 0, 1, 1},
0,
0,
wimp_TOP,
wimp_WINDOW_NEW_FORMAT | wimp_WINDOW_MOVEABLE | wimp_WINDOW_NO_BOUNDS,
0xff,
wimp_COLOUR_LIGHT_GREY,
wimp_COLOUR_LIGHT_GREY,
wimp_COLOUR_VERY_LIGHT_GREY,
wimp_COLOUR_DARK_GREY,
wimp_COLOUR_MID_LIGHT_GREY,
wimp_COLOUR_CREAM,
wimp_WINDOW_NEVER3D | 0x16u ,
{0, 0, 65535, 65535},
0,
0,
wimpspriteop_AREA,
1,
1,
{""},
0
}

Definition at line 66 of file progress_bar.c.

Referenced by ro_gui_progress_bar_calculate(), ro_gui_progress_bar_create(), and ro_gui_progress_bar_init().

◆ progress_height

unsigned int progress_height
static

Definition at line 64 of file progress_bar.c.

Referenced by ro_gui_progress_bar_init(), and ro_gui_progress_bar_redraw_window().

◆ progress_icon

osspriteop_header* progress_icon
static

◆ progress_width

unsigned int progress_width
static

Definition at line 63 of file progress_bar.c.

Referenced by ro_gui_progress_bar_animate(), and ro_gui_progress_bar_init().