GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
Enumerations | Functions
gp_widget_pbar.h File Reference

A progress bar widget. More...

#include <stdint.h>

Go to the source code of this file.

Enumerations

enum  gp_widget_pbar_unit {
  GP_WIDGET_PBAR_NONE , GP_WIDGET_PBAR_PERCENTS , GP_WIDGET_PBAR_SECONDS , GP_WIDGET_PBAR_UNIT_MASK = 0x7f ,
  GP_WIDGET_PBAR_INVERSE = 0x80
}
 A progress bar widget units. More...
 
enum  gp_widget_pbar_event_type { GP_WIDGET_PBAR_VAL_CHANGED }
 A gp_widget_event::sub_type for a progress bar widget. More...
 

Functions

gp_widgetgp_widget_pbar_new (uint64_t val, uint64_t max, enum gp_widget_pbar_unit unit)
 Allocate and initialize new progress bar widget.
 
void gp_widget_pbar_val_set (gp_widget *self, uint64_t val)
 Sets a progress bar value.
 
void gp_widget_pbar_max_set (gp_widget *self, uint64_t max)
 Sets a progress bar maximum.
 
uint64_t gp_widget_pbar_val_get (gp_widget *self)
 Returns progressbar value.
 
uint64_t gp_widget_pbar_max_get (gp_widget *self)
 Returns progress bar max value.
 

Detailed Description

A progress bar widget.

Progressbar is a widget that shows a progress. The progress is internally stored as a 64-bit integer number that starts at 0 and ends at max.

The value can be associated with a unit currently none, percents and seconds are supported.

Progressbar can also be set to be inverse which means that the value used for unit display will be max - val instead of val. The default unit is percents.

If progressbar has an gp_widget::on_event() handler set it's seekable, i.e. the user can change it's value and the handler is called for each value change.

Progress bar widget JSON attributes

Attribute Type Default Description
val uint 0 Initial value
max uint 10000 Maximal value
inverse bool false Inverse progress
unit string "percents" Value units

Definition in file gp_widget_pbar.h.

Enumeration Type Documentation

◆ gp_widget_pbar_event_type

A gp_widget_event::sub_type for a progress bar widget.

Enumerator
GP_WIDGET_PBAR_VAL_CHANGED 

Emitted when progress bar value is changed.

E.g. music player can have a seekable progress showing the time left in a song.

Definition at line 79 of file gp_widget_pbar.h.

◆ gp_widget_pbar_unit

A progress bar widget units.

Enumerator
GP_WIDGET_PBAR_NONE 

No unit.

GP_WIDGET_PBAR_PERCENTS 

Progress bar is in percents.

The percentage shown to user is computed as 100 * val / max.

GP_WIDGET_PBAR_SECONDS 

Progress bar is in seconds.

Widget automatically converts the value into hours, minutes and seconds when shown on the screen.

GP_WIDGET_PBAR_UNIT_MASK 

Unit mask.

GP_WIDGET_PBAR_INVERSE 

Inverse the value shown on the screen.

When set the progress starts at max and counts down towards zero as val grows.

Definition at line 43 of file gp_widget_pbar.h.

Function Documentation

◆ gp_widget_pbar_max_get()

uint64_t gp_widget_pbar_max_get ( gp_widget self)

Returns progress bar max value.

Parameters
selfA progress bar widget.
Returns
A progress bar max value.

◆ gp_widget_pbar_max_set()

void gp_widget_pbar_max_set ( gp_widget self,
uint64_t  max 
)

Sets a progress bar maximum.

Parameters
selfA progress bar widget.
maxNew maximal progress bar value.

◆ gp_widget_pbar_new()

gp_widget * gp_widget_pbar_new ( uint64_t  val,
uint64_t  max,
enum gp_widget_pbar_unit  unit 
)

Allocate and initialize new progress bar widget.

Parameters
valInitial progress bar value.
maxMaximal progress bar value.
unitProgress bar value unit.
Returns
A progress bar widget.

◆ gp_widget_pbar_val_get()

uint64_t gp_widget_pbar_val_get ( gp_widget self)

Returns progressbar value.

Parameters
selfA progress bar widget.
Returns
A progress bar value.

◆ gp_widget_pbar_val_set()

void gp_widget_pbar_val_set ( gp_widget self,
uint64_t  val 
)

Sets a progress bar value.

Parameters
selfA progress bar widget.
valNew progress bar value.