GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
Data Fields
gp_widget_ops Struct Reference

Callbacks that implements a widget. More...

#include <gp_widget_ops.h>

Collaboration diagram for gp_widget_ops:
Collaboration graph
[legend]

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".
 

Detailed Description

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.

Warning
Never call these functions directly use the wrappers defined below.

Definition at line 96 of file gp_widget_ops.h.

Field Documentation

◆ distribute_w

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.

Parameters
selfWidget layout to be distributed.
ctxRender configuration.
new_whForce distribute size on layout size change.

Definition at line 187 of file gp_widget_ops.h.

◆ event

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.

Parameters
selfA widget.
ctxA widget render context.
evAn input event to be processed by the widget.
Returns
Returns non-zero if event was handled.

Definition at line 116 of file gp_widget_ops.h.

◆ focus

int(* gp_widget_ops::focus) (gp_widget *self, int focus_dir)

Moves focus.

Focused widget is a widget that recieves keyboard input.

Parameters
selfA widget.
focus_dirAn enum gp_widget_focus_flag, a direction to move the focus to.

Definition at line 137 of file gp_widget_ops.h.

◆ focus_child

int(* gp_widget_ops::focus_child) (gp_widget *self, gp_widget *child)

Sets/moves focus to a child specific child widget.

Parameters
selfA container widget.
childA child widget to be focused.
Returns
Non-zero if widget was focused successfuly.

Definition at line 153 of file gp_widget_ops.h.

◆ for_each_child

void(* gp_widget_ops::for_each_child) (gp_widget *self, void(*func)(gp_widget *child))

A callback to iterate over all widget children.

Parameters
selfA widget.
funcA function to be called on each child widget.

Definition at line 201 of file gp_widget_ops.h.

◆ free

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.

Parameters
selfA widget.

Definition at line 104 of file gp_widget_ops.h.

◆ from_json

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.

Parameters
jsonA JSON reader.
valA JSON value.
ctxA widget JSON parser context.

Definition at line 212 of file gp_widget_ops.h.

◆ min_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.

Parameters
selfA widget.
ctxA widget rendering context.
Returns
A minimal widget height in pixels.

Definition at line 176 of file gp_widget_ops.h.

◆ min_w

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.

Parameters
selfA widget.
ctxA widget rendering context.
Returns
A minimal widget width in pixels.

Definition at line 165 of file gp_widget_ops.h.

◆ render

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.

Parameters
ctxA widget render context.
offsetOfset in pixmap to draw to
flagsFlags enum gp_widget_render_flags.

Definition at line 125 of file gp_widget_ops.h.


The documentation for this struct was generated from the following file: