GFXprim
2D bitmap graphics library with emphasis on speed and correctness
|
Widget internals. More...
#include <input/gp_event.h>
#include <utils/gp_bbox.h>
#include <utils/gp_json.h>
#include <widgets/gp_widget.h>
#include <widgets/gp_widget_render.h>
Go to the source code of this file.
Data Structures | |
struct | gp_widget_ops |
Callbacks that implements a widget. More... | |
Enumerations | |
enum | gp_widget_focus_flag { GP_FOCUS_OUT , GP_FOCUS_IN , GP_FOCUS_LEFT , GP_FOCUS_RIGHT , GP_FOCUS_UP , GP_FOCUS_DOWN , GP_FOCUS_NEXT , GP_FOCUS_PREV } |
Flags to move focus around. More... | |
enum | gp_widget_render_flags { GP_WIDGET_REDRAW = 0x01 , GP_WIDGET_REDRAW_CHILDREN = 0x02 , GP_WIDGET_COLOR_SCHEME = 0x04 , GP_WIDGET_RESIZE = 0x08 , GP_WIDGET_DISABLED = 0x10 } |
Widget rendering flags. More... | |
Functions | |
int | gp_widget_ops_event (gp_widget *self, const gp_widget_render_ctx *ctx, gp_event *ev) |
Send an event to a widget. | |
int | gp_widget_ops_render_focus (gp_widget *self, int focus_dir) |
Moves focus, if possible, in the direction requested by the focus_dir. | |
int | gp_widget_ops_render_focus_xy (gp_widget *self, const gp_widget_render_ctx *ctx, unsigned int x, unsigned int y) |
Tries to focus a widget on a given coordinates in a layout. | |
int | gp_widget_ops_focus_widget (gp_widget *self) |
Moves focus to a particular widget. | |
void | gp_widget_ops_for_each_child (gp_widget *self, void(*func)(gp_widget *child)) |
Calls a callback on each child widget. | |
static void | gp_widget_ops_blit (const gp_widget_render_ctx *ctx, gp_coord x, gp_coord y, gp_size w, gp_size h) |
Marks an area to be blit on the screen from a buffer. | |
static int | gp_widget_should_redraw (gp_widget *self, int flags) |
Returns true if widget should be repainted. | |
void | gp_widget_calc_size (gp_widget *layout, const gp_widget_render_ctx *ctx, unsigned int w, unsigned int h, int new_wh) |
Calculates layout size recursively. | |
void | gp_widget_redraw (gp_widget *self) |
Requests widget repaint. | |
void | gp_widget_resize (gp_widget *self) |
Requests widget resize. | |
void | gp_widget_redraw_children (gp_widget *self) |
Redraw all child widgets. | |
void | gp_widget_render (gp_widget *self, const gp_widget_render_ctx *ctx, int new_wh) |
Resizes and redraws changed widgets. | |
Widget internals.
You will not need to understand this part of the library unless you need to add a custom widget types.
Definition in file gp_widget_ops.h.
enum gp_widget_focus_flag |
Flags to move focus around.
Definition at line 27 of file gp_widget_ops.h.
Widget rendering flags.
Definition at line 54 of file gp_widget_ops.h.
void gp_widget_calc_size | ( | gp_widget * | layout, |
const gp_widget_render_ctx * | ctx, | ||
unsigned int | w, | ||
unsigned int | h, | ||
int | new_wh | ||
) |
Calculates layout size recursively.
The size may end up larger than WxH if there is too much widgets or smaller than WxH if align is not set to fill.
layout | Widget layout. |
ctx | Render context, e.g. fonts, pixel type, padding size, etc. |
w | Width we are trying to fit into |
h | Height we are trying to fit into |
new_wh | If set the layout size is recalculated, i.e. the layout size has changed. |
|
inlinestatic |
Marks an area to be blit on the screen from a buffer.
This function is called by widgets so that the render knows which parts of the screen has to be updated after the call to the render function.
Definition at line 324 of file gp_widget_ops.h.
References gp_bbox_empty(), gp_bbox_merge(), and gp_bbox_pack().
int gp_widget_ops_event | ( | gp_widget * | self, |
const gp_widget_render_ctx * | ctx, | ||
gp_event * | ev | ||
) |
Send an event to a widget.
self | A widget to send the event to. |
ctx | A render context. |
ev | An input event. |
int gp_widget_ops_focus_widget | ( | gp_widget * | self | ) |
Moves focus to a particular widget.
Traverses the widget layout tree to the top and sets the focus accordingly.
self | A widget to be focused. |
Calls a callback on each child widget.
All non-leaf widgets must implement for_each_child() callback in its ops which is then called by this function.
This function is no-op for NULL self and non-leaf widgets.
self | A widget. |
func | A function callback |
int gp_widget_ops_render_focus | ( | gp_widget * | self, |
int | focus_dir | ||
) |
Moves focus, if possible, in the direction requested by the focus_dir.
self | A widget layout. |
focus_dir | Direction to move the focus to. |
int gp_widget_ops_render_focus_xy | ( | gp_widget * | self, |
const gp_widget_render_ctx * | ctx, | ||
unsigned int | x, | ||
unsigned int | y | ||
) |
Tries to focus a widget on a given coordinates in a layout.
self | A widget layout. |
ctx | A render context. |
x | X coordinate. |
y | Y coordinate. |
void gp_widget_redraw | ( | gp_widget * | self | ) |
Requests widget repaint.
Marks widget to be repainted on next update.
self | A widget. |
void gp_widget_redraw_children | ( | gp_widget * | self | ) |
Redraw all child widgets.
Marks all children to be repainted on next update. This is used internally by container widgets when layout has changed, e.g. visible tab has changed.
self | A container widget. |
void gp_widget_render | ( | gp_widget * | self, |
const gp_widget_render_ctx * | ctx, | ||
int | new_wh | ||
) |
Resizes and redraws changed widgets.
self | A widget layout. |
ctx | A rendering context. |
new_wh | If set the layout size is recalculated, i.e. the layout size has changed. |
void gp_widget_resize | ( | gp_widget * | self | ) |
Requests widget resize.
Marks widget to be resized on next update. The resize is propagated in the layout to the top. E.g. if widget has to grow, the whole layout will.
self | A widget. |
|
inlinestatic |
Returns true if widget should be repainted.
@self A widget. @flags Render flags passed down to the widget->render() function.
Definition at line 345 of file gp_widget_ops.h.
References GP_WIDGET_REDRAW, and gp_widget::redraw.