10#define GP_WIDGET_OPS_H
12#include <input/gp_event.h>
15#include <widgets/gp_widget.h>
16#include <widgets/gp_widget_render.h>
18enum gp_widget_focus_flag {
31typedef struct gp_offset {
36enum gp_widget_render_flags {
37 GP_WIDGET_REDRAW = 0x01,
38 GP_WIDGET_REDRAW_CHILDREN = 0x02,
40 GP_WIDGET_COLOR_SCHEME = 0x04,
42 GP_WIDGET_RESIZE = 0x08,
44 GP_WIDGET_DISABLED = 0x10,
55 void (*free)(gp_widget *self);
62 int (*event)(gp_widget *self,
const gp_widget_render_ctx *ctx, gp_event *ev);
71 void (*render)(gp_widget *self,
const gp_offset *offset,
72 const gp_widget_render_ctx *ctx,
int flags);
77 int (*focus)(gp_widget *self,
int focus_dir);
82 int (*focus_xy)(gp_widget *self,
const gp_widget_render_ctx *ctx,
83 unsigned int x,
unsigned int y);
93 int (*focus_child)(gp_widget *self, gp_widget *child);
98 unsigned int (*min_w)(gp_widget *self,
const gp_widget_render_ctx *ctx);
99 unsigned int (*min_h)(gp_widget *self,
const gp_widget_render_ctx *ctx);
110 void (*distribute_w)(gp_widget *self,
111 const gp_widget_render_ctx *ctx,
114 void (*distribute_h)(gp_widget *self,
115 const gp_widget_render_ctx *ctx,
124 void (*for_each_child)(gp_widget *self, void (*func)(gp_widget *child));
135const struct gp_widget_ops *gp_widget_ops(gp_widget *self);
137const struct gp_widget_ops *gp_widget_ops_by_id(
const char *
id);
139const char *gp_widget_type_id(gp_widget *self);
141const char *gp_widget_type_name(
enum gp_widget_type type);
143unsigned int gp_widget_min_w(gp_widget *self,
const gp_widget_render_ctx *ctx);
145unsigned int gp_widget_min_h(gp_widget *self,
const gp_widget_render_ctx *ctx);
147unsigned int gp_widget_align(gp_widget *self);
149int gp_widget_input_event(gp_widget *self,
const gp_widget_render_ctx *ctx, gp_event *ev);
151void gp_widget_ops_render(gp_widget *self,
const gp_offset *offset,
152 const gp_widget_render_ctx *ctx,
int flags);
163int gp_widget_ops_event(gp_widget *self,
const gp_widget_render_ctx *ctx, gp_event *ev);
179int gp_widget_ops_event_offset(gp_widget *self,
const gp_widget_render_ctx *ctx,
190int gp_widget_ops_render_focus(gp_widget *self,
int focus_dir);
202int gp_widget_ops_render_focus_xy(gp_widget *self,
const gp_widget_render_ctx *ctx,
203 unsigned int x,
unsigned int y);
214int gp_widget_ops_focus_widget(gp_widget *self);
216void gp_widget_ops_distribute_w(gp_widget *self,
const gp_widget_render_ctx *ctx,
unsigned int w,
int new_wh);
217void gp_widget_ops_distribute_h(gp_widget *self,
const gp_widget_render_ctx *ctx,
unsigned int h,
int new_wh);
230void gp_widget_ops_for_each_child(gp_widget *self,
void (*func)(gp_widget *child));
239static inline void gp_widget_ops_blit(
const gp_widget_render_ctx *ctx,
260static inline int gp_widget_should_redraw(gp_widget *self,
int flags)
262 return self->redraw || (flags & GP_WIDGET_REDRAW);
265static inline int gp_widget_is_disabled(gp_widget *self,
int flags)
267 return self->disabled || (flags & GP_WIDGET_DISABLED);
282void gp_widget_calc_size(gp_widget *layout,
const gp_widget_render_ctx *ctx,
283 unsigned int w,
unsigned int h,
int new_wh);
292void gp_widget_redraw(gp_widget *self);
302void gp_widget_resize(gp_widget *self);
312void gp_widget_redraw_children(gp_widget *self);
317void gp_widget_render(gp_widget *self,
const gp_widget_render_ctx *ctx,
int new_wh);
int gp_coord
Integer type for coordinates i.e. x, y, ...
unsigned int gp_size
Integer type for sizes i.e. w, h, ...
A bounding box implementation.
static gp_bbox gp_bbox_merge(gp_bbox box1, gp_bbox box2)
Merges two bounding boxes.
static int gp_bbox_empty(gp_bbox box)
Returns true if bounding box is empty.
static gp_bbox gp_bbox_pack(gp_coord x, gp_coord y, gp_coord w, gp_coord h)
Creates a bounding box from coordinates and size.
Includes all JSON headers.
A JSON parser internal state.
A parsed JSON key value pair.