commit 67403f6611c8ebab0c6e76c156369d3948d97ad8 from: Onana Onana Xavier Manuel date: Fri Jun 26 00:39:17 2026 UTC Man page changed to have clearer example * Canvas skeleton added * Some primitive templates * Mild layout fix commit - 8a5e9b3a1aa94d81042445f7bf7d8249bc96b3ba commit + 67403f6611c8ebab0c6e76c156369d3948d97ad8 blob - 8e3ec3a29101299f9cf370fa6520b90f76b78e8a blob + 5478f814f30df4a2b77cc9130f094a17671faa85 --- aui.h +++ aui.h @@ -59,17 +59,21 @@ struct aui_button; struct aui_windowconfig { unsigned int width; unsigned int height; - const char *title; /* Should not be allocated, string literal */ + const char *title; /* Not allocated by libaui */ }; struct aui_buttonconfig { - const char *text; /* Should not be allocated, string literal */ + const char *text; /* Not allocated by libaui */ }; struct aui_frameconfig { struct aui_color bg; }; +struct aui_canvasconfig { + struct aui_color bg; +}; + void aui_run(void); void aui_destroy(struct aui_widget *); struct aui_window *aui_window_new(struct aui_windowconfig *); blob - 844239ab871c615cc6564884c48db1188ccffbcc blob + b39ada7eed8b8720e3f6c99144a31c9033dd8ce4 --- aui_run.3 +++ aui_run.3 @@ -1,4 +1,4 @@ -.Dd $Mdocdate: June 02 2026$ +.Dd $Mdocdate: June 25 2026$ .Dt AUI_RUN 3 .Os .Sh NAME @@ -44,20 +44,44 @@ created. The containers can be a window or a frame. On created it can be mapped using place, grid or pack. .Pp Canvases are also containers although they cannot take widgets as childrens. -.Sh SIMPLE EXAMPLE -.Bd -literal -offset -#include - -int -main(void) -{ - struct aui_window *aw = aui_window_new(NULL); - - aui_run(); - - return 0; -} +.Sh EXAMPLES +Creating a basic window is done with the following. +.Bd -literal -offset indent +struct aui_window *aw = aui_window_new(NULL); .Ed +.Pp +Afterwards the mainloop can be started using: +.Bd -literal -offset indent +aui_run(); +.Ed +.Pp +As for buttons they can be created using the following: +.Bd -literal -offset indent +struct aui_button *btn = aui_button_new(AUI_WIDGET(aw)); +.Ed +.Pp +The AUI_WIDGET macro must be used in order to pass widgets so the +.Nm aui +library can understand. In the example above aw can be switched for a +container like frame. Here is an example. +.Pp +.Bd -literal -offset indent +struct aui_frame *frame = aui_frame_new(AUI_WIDGET(aw)); +struct aui_button *btn = aui_button_new(AUI_WIDGET(frame)); +.Ed +.Pp +Adding widgets to containers does not make them directly visible. You must +first pack, place or grid them for them to be mapped. +.Pp +.Bd -literal -offset indent +aui_pack(AUI_WIDGET(btn), NULL); +.Ed +.Pp +It is important to keep in mind that operations for +.Nm aui +must be done before +.Nm aui_run +in a single threaded program. .Sh RETURN VALUES For all these function, if the output is -1 or NULL it means an error. Otherwise, the function was successful. blob - e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 blob + cda5e4d2bc2b51a23cb45a44999a998fcc430751 --- canvas.c +++ canvas.c @@ -0,0 +1,81 @@ +/* + * Canvases do not store pixels but rather the operations taking + * place within them. This makes resizing easier. + */ + +#include +#include +#include + +#include "driver.h" +#include "widget.h" + +static void canvas_mouse_hover(struct aui_widget *, uint16_t, uint16_t); +static void canvas_mouse_unhover(struct aui_widget *); +static void canvas_mouse_press(struct aui_widget *, uint16_t, uint16_t, uint8_t); +static void canvas_mouse_release(struct aui_widget *, uint16_t, uint16_t, uint8_t); +static void canvas_set_geometry(struct aui_widget *, struct aui_geometry *); +static void canvas_free(struct aui_widget *); +static struct aui_geometry canvas_get_min_size(struct aui_widget *); + +static struct widget_ops canvas_ops = { + canvas_mouse_hover, + canvas_mouse_unhover, + canvas_mouse_press, + canvas_mouse_release, + canvas_set_geometry, /* set geometry */ + canvas_free, + canvas_get_min_size, +}; + +struct aui_canvas* +aui_canvas_new() +{ + struct aui_canvas *canvas; + + return canvas; +} + + +static void +canvas_mouse_hover(struct aui_widget *widget, uint16_t dx, uint16_t dy) +{ + +} + +static void +canvas_mouse_unhover(struct aui_widget *widget) +{ + +} + +static void +canvas_mouse_press(struct aui_widget *widget, uint16_t x, uint16_t y, uint8_t button) +{ + +} + +static void +canvas_mouse_release(struct aui_widget *widget, uint16_t x, uint16_t y, uint8_t button) +{ + +} + +static void +canvas_set_geometry(struct aui_widget *widget, struct aui_geometry *geom) +{ + +} + +static void +canvas_free(struct aui_widget *widget) +{ + +} + +static struct aui_geometry +canvas_get_min_size(struct aui_widget *widget) +{ + struct aui_geometry geom; + return geom; +} blob - 6459d7e0ee558315dd667e8f5aeae620a782e001 blob + c52ab9fae4608dd3cfc0d746b7daac487c1a7ca7 --- layout.c +++ layout.c @@ -389,6 +389,7 @@ layout_organize(struct aui_widget *widget) hexpand--; } } + break; default: break; } blob - ede1ed63d3bbaa8855fba5620134082e59e9d449 blob + edd3117b9e9802fc1c80378cf86ad3ffb7b9016e --- primitive.h +++ primitive.h @@ -4,6 +4,13 @@ enum primitive_type { PRIMITIVE_TYPE_RECTANGLE, PRIMITIVE_TYPE_TEXT, + PRIMITIVE_TYPE_ARC, + PRIMITIVE_TYPE_BITMAP, + PRIMITIVE_TYPE_IMAGE, + PRIMITIVE_TYPE_LINE, + PRIMITIVE_TYPE_OVAL, + PRIMITIVE_TYPE_POLYGON, + PRIMITIVE_TYPE_WINDOW, }; struct primitive {