GFXprim
2D bitmap graphics library with emphasis on speed and correctness
|
Callbacks that implements a widget. More...
#include <gp_widget_ops.h>
Data Fields | |
void(* | free )(gp_widget *self) |
Frees any additional memory a widget has allocated. | |
int(* | event )(gp_widget *self, const gp_widget_render_ctx *ctx, gp_event *ev) |
Widget input event handler. | |
void(* | render )(gp_widget *self, const gp_offset *offset, const gp_widget_render_ctx *ctx, int flags) |
Renders (changes in) widget layout. | |
int(* | focus )(gp_widget *self, int focus_dir) |
Moves focus. | |
int(* | focus_child )(gp_widget *self, gp_widget *child) |
Sets/moves focus to a child specific child widget. | |
unsigned int(* | min_w )(gp_widget *self, const gp_widget_render_ctx *ctx) |
Calculates a minimal widget width. | |
unsigned int(* | min_h )(gp_widget *self, const gp_widget_render_ctx *ctx) |
Calculates a minimal widget height. | |
void(* | distribute_w )(gp_widget *self, const gp_widget_render_ctx *ctx, int new_wh) |
Recursively distributes widgets in a widget container. | |
void(* | for_each_child )(gp_widget *self, void(*func)(gp_widget *child)) |
A callback to iterate over all widget children. | |
gp_widget *(* | from_json )(gp_json_reader *json, gp_json_val *val, gp_widget_json_ctx *ctx) |
A JSON to widget parser. | |
const char * | id |
A widget id, e.g. "checkbox". | |
Callbacks that implements a widget.
Container widgets, i.e. widgets with children, implement callbacks to access its children that are otherwise NULL. These are mostly functions to move focus, distribute any leftover size to the layout, and iterate over widgets. Also most of the callbacks for container widgets are recursive, e.g. the JSON parser internally calls gp_widget_from_json() to parse it's children.
Definition at line 96 of file gp_widget_ops.h.
void(* gp_widget_ops::distribute_w) (gp_widget *self, const gp_widget_render_ctx *ctx, int new_wh) |
Recursively distributes widgets in a widget container.
Implemented only for non-leaf widgets.
self | Widget layout to be distributed. |
ctx | Render configuration. |
new_wh | Force distribute size on layout size change. |
Definition at line 187 of file gp_widget_ops.h.
int(* gp_widget_ops::event) (gp_widget *self, const gp_widget_render_ctx *ctx, gp_event *ev) |
Widget input event handler.
May be NULL for widgets that do not consume input events.
self | A widget. |
ctx | A widget render context. |
ev | An input event to be processed by the widget. |
Definition at line 116 of file gp_widget_ops.h.
int(* gp_widget_ops::focus) (gp_widget *self, int focus_dir) |
Moves focus.
Focused widget is a widget that recieves keyboard input.
self | A widget. |
focus_dir | An enum gp_widget_focus_flag, a direction to move the focus to. |
Definition at line 137 of file gp_widget_ops.h.
Sets/moves focus to a child specific child widget.
self | A container widget. |
child | A child widget to be focused. |
Definition at line 153 of file gp_widget_ops.h.
A callback to iterate over all widget children.
self | A widget. |
func | A function to be called on each child widget. |
Definition at line 201 of file gp_widget_ops.h.
void(* gp_widget_ops::free) (gp_widget *self) |
Frees any additional memory a widget has allocated.
If defined this function is called before widget itself is freed.
self | A widget. |
Definition at line 104 of file gp_widget_ops.h.
gp_widget *(* gp_widget_ops::from_json) (gp_json_reader *json, gp_json_val *val, gp_widget_json_ctx *ctx) |
A JSON to widget parser.
Reads a serialized widget from JSON.
json | A JSON reader. |
val | A JSON value. |
ctx | A widget JSON parser context. |
Definition at line 212 of file gp_widget_ops.h.
unsigned int(* gp_widget_ops::min_h) (gp_widget *self, const gp_widget_render_ctx *ctx) |
Calculates a minimal widget height.
Container widgets call these functions recursively for its children, then the minimal children sizes to compute the overall minimal size.
self | A widget. |
ctx | A widget rendering context. |
Definition at line 176 of file gp_widget_ops.h.
unsigned int(* gp_widget_ops::min_w) (gp_widget *self, const gp_widget_render_ctx *ctx) |
Calculates a minimal widget width.
Container widgets call these functions recursively for its children, then the minimal children sizes to compute the overall minimal size.
self | A widget. |
ctx | A widget rendering context. |
Definition at line 165 of file gp_widget_ops.h.
void(* gp_widget_ops::render) (gp_widget *self, const gp_offset *offset, const gp_widget_render_ctx *ctx, int flags) |
Renders (changes in) widget layout.
ctx | A widget render context. |
offset | Ofset in pixmap to draw to |
flags | Flags enum gp_widget_render_flags. |
Definition at line 125 of file gp_widget_ops.h.