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

A button widget. More...

#include <widgets/gp_widget_class_bool.h>

Go to the source code of this file.

Enumerations

enum  gp_widget_button_type {
  GP_BUTTON_LABEL = 0 , GP_BUTTON_OK , GP_BUTTON_CANCEL , GP_BUTTON_YES ,
  GP_BUTTON_NO , GP_BUTTON_OPEN , GP_BUTTON_SAVE , GP_BUTTON_NEW_DIR ,
  GP_BUTTON_PREV , GP_BUTTON_NEXT , GP_BUTTON_FIRST , GP_BUTTON_LAST ,
  GP_BUTTON_TOP , GP_BUTTON_BOTTOM , GP_BUTTON_PLAY , GP_BUTTON_PAUSE ,
  GP_BUTTON_STOP , GP_BUTTON_REC , GP_BUTTON_FFORWARD , GP_BUTTON_FBACKWARD ,
  GP_BUTTON_STEP_FORWARD , GP_BUTTON_STEP_BACKWARD , GP_BUTTON_RANDOMIZE , GP_BUTTON_UP ,
  GP_BUTTON_DOWN , GP_BUTTON_LEFT , GP_BUTTON_RIGHT , GP_BUTTON_ADD ,
  GP_BUTTON_REM , GP_BUTTON_CLEAR , GP_BUTTON_BACKSPACE , GP_BUTTON_ZOOM_IN ,
  GP_BUTTON_ZOOM_OUT , GP_BUTTON_ZOOM_FIT , GP_BUTTON_ZOOM_NORMAL , GP_BUTTON_ROTATE_CW ,
  GP_BUTTON_ROTATE_CCW , GP_BUTTON_SETTINGS , GP_BUTTON_HOME , GP_BUTTON_DOWNLOAD ,
  GP_BUTTON_TYPE_MASK = 0x7fff , GP_BUTTON_ALIGN_MASK = 0x8000 , GP_BUTTON_TEXT_LEFT = 0x8000 , GP_BUTTON_TEXT_RIGHT = 0x0000
}
 A button type. More...
 
enum  gp_widget_button_event_type { GP_WIDGET_BUTTON_TRIGGER }
 A gp_widget_event::sub_type for a button widget. More...
 

Functions

gp_widgetgp_widget_button_new (const char *label, enum gp_widget_button_type type)
 Allocates and initializes a new button widget.
 
static gp_widgetgp_widget_button_new2 (const char *label, enum gp_widget_button_type type, int(*on_event)(gp_widget_event *ev), void *priv)
 Allocates a initialize new button widget.
 
enum gp_widget_button_type gp_widget_button_type_get (gp_widget *self)
 Returns a button type.
 
void gp_widget_button_type_set (gp_widget *self, enum gp_widget_button_type type)
 Sets a button type.
 

Detailed Description

A button widget.

Button types

Buttons with a specific type include a stock image in the rendered button, they can have label as well but it's not required.

Button widget JSON attributes

Attribute Type Default Description
label string A button label.
btype string "label" Button type, gp_widget_button_type.
text_align string depends Button text alignment, "left" or "right" from the stock image.

The 'text_align' can be either 'left' or 'right' and the default value depends on the 'btype'.

Definition in file gp_widget_button.h.

Enumeration Type Documentation

◆ gp_widget_button_event_type

A gp_widget_event::sub_type for a button widget.

Enumerator
GP_WIDGET_BUTTON_TRIGGER 

Emitted when button is pressed.

Definition at line 144 of file gp_widget_button.h.

◆ gp_widget_button_type

A button type.

Enumerator
GP_BUTTON_LABEL 

Button with a label without specific type.

GP_BUTTON_OK 

An OK button.

GP_BUTTON_CANCEL 

A Cancel button.

GP_BUTTON_YES 

A Yes button.

GP_BUTTON_NO 

A No button.

GP_BUTTON_OPEN 

An open file or directory button.

GP_BUTTON_SAVE 

A save file button.

GP_BUTTON_NEW_DIR 

A create new directory button.

GP_BUTTON_PREV 

A previous button.

GP_BUTTON_NEXT 

A next button.

GP_BUTTON_FIRST 

A first button.

GP_BUTTON_LAST 

A last button.

GP_BUTTON_TOP 

A top button.

GP_BUTTON_BOTTOM 

A bottom button.

GP_BUTTON_PLAY 

A play button.

GP_BUTTON_PAUSE 

A pause button.

GP_BUTTON_STOP 

A stop button.

GP_BUTTON_REC 

A record button.

GP_BUTTON_FFORWARD 

A fast forward button.

GP_BUTTON_FBACKWARD 

A fast backward button.

GP_BUTTON_STEP_FORWARD 

A step forward button.

GP_BUTTON_STEP_BACKWARD 

A step backward button.

GP_BUTTON_RANDOMIZE 

A randomize button.

GP_BUTTON_UP 

An arrow up button.

GP_BUTTON_DOWN 

An arrow down button.

GP_BUTTON_LEFT 

An arrow left button.

GP_BUTTON_RIGHT 

An arrow right button.

GP_BUTTON_ADD 

An add button.

GP_BUTTON_REM 

A remove button.

GP_BUTTON_CLEAR 

A clear button.

GP_BUTTON_BACKSPACE 

A backspace button.

GP_BUTTON_ZOOM_IN 

A zoom in button.

GP_BUTTON_ZOOM_OUT 

A zoom out button.

GP_BUTTON_ZOOM_FIT 

A zoom fit button.

GP_BUTTON_ZOOM_NORMAL 

A zoom normal button.

GP_BUTTON_ROTATE_CW 

A rotate clockwise button.

GP_BUTTON_ROTATE_CCW 

A rotate counter clockwise button.

GP_BUTTON_SETTINGS 

A settings button.

GP_BUTTON_HOME 

A home (directory) button.

GP_BUTTON_DOWNLOAD 

A download button.

Definition at line 44 of file gp_widget_button.h.

Function Documentation

◆ gp_widget_button_new()

gp_widget * gp_widget_button_new ( const char *  label,
enum gp_widget_button_type  type 
)

Allocates and initializes a new button widget.

Parameters
labelA button label.
typeA button type.
Returns
A button widget.

Referenced by gp_widget_button_new2().

◆ gp_widget_button_new2()

static gp_widget * gp_widget_button_new2 ( const char *  label,
enum gp_widget_button_type  type,
int(*)(gp_widget_event *ev)  on_event,
void *  priv 
)
inlinestatic

Allocates a initialize new button widget.

Parameters
labelA button label. Optional for buttons with type other than GP_BUTTON_LABEL.
typeA button type.
on_eventAn widget event handler.
privUser private data.
Returns
A button widget.

Definition at line 172 of file gp_widget_button.h.

References gp_widget_button_new(), and gp_widget_on_event_set().

◆ gp_widget_button_type_get()

enum gp_widget_button_type gp_widget_button_type_get ( gp_widget self)

Returns a button type.

The aligment is masked out of the return value.

Parameters
selfA button widget.
Returns
A button type.

◆ gp_widget_button_type_set()

void gp_widget_button_type_set ( gp_widget self,
enum gp_widget_button_type  type 
)

Sets a button type.

Parameters
selfA button widget.
typeNew button type.