Commit Diff


commit - e03104e024b9ca60bfd297fefd8835c3265538f7
commit + eba3e008079f374a80e2e6ccdc8269b75ccfdd3b
blob - fbb8bb7084e2803bef965e8d4a7caa3015a23f38
blob + 007ac1fbc08e587305285f44656e1fba47d6fe95
--- aui.h
+++ aui.h
@@ -14,8 +14,8 @@ struct aui_placepar {
 	int x, y;
 	float relx;
 	float rely;
-	unsigned int width;
-	unsigned int height;
+	int width;
+	int height;
 	float relwidth;
 	float relheight;
 #define AUI_ANCHOR_NW	   	0
blob - 1afaa1f144e8a23216d36f361fcfe57234537502
blob + 016592c046dfed387af078b98bac594ee3a6d94c
--- examples/Makefile
+++ examples/Makefile
@@ -1,16 +1,23 @@
 ACALC_BIN=		acalc/acalc
 ACALC_SRC=		acalc/acalc.c
 
+APAINT_BIN=		apaint/apaint
+APAINT_SRC=		apaint/apaint.c
+
 INCS=			-I /usr/local/include
 LIBS=			-L /usr/local/lib -laui
 CFLAGS=			-O0
 
-all: acalc
+all: acalc apaint
 
 acalc:
 	${CC} ${ACALC_SRC} -o ${ACALC_BIN} ${CFLAGS} ${LIBS} ${INCS}
 
+apaint:
+	${CC} ${APAINT_SRC} -o ${APAINT_BIN} ${CFLAGS} ${LIBS} ${INCS}
+
 clean:
 	rm -rf ${ACALC_BIN} ${ACALC_BIN}.core
+	rm -rf ${APAINT_BIN} ${APAINT_BIN}.core
 
-.PHONY: acalc
+.PHONY: acalc apaint
blob - /dev/null
blob + 2d9d9adc41a7f6e16466473faff7aaf1161f98d0 (mode 644)
--- /dev/null
+++ examples/README
@@ -0,0 +1,9 @@
+This directory contains programs that are purposely
+limited to both demonstrate how the library can be
+used and for testing purpose.
+
+They are not intended to be used for general purpose.
+
+To compile each program either run `make` to compile
+them all or make `PROGRAM_DIRECTORY_NAME` from this
+directory to compile a specific one.
blob - /dev/null
blob + 309742f5bd0fe5e5ce5fc0ca82689e45f3c0d7c1 (mode 644)
--- /dev/null
+++ examples/apaint/apaint.c
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2026 Onana Onana Xavier Manuel <xavier@onana.net>
+ * 
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ * 
+ * THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <aui.h>
+
+struct app {
+	struct aui_window *aw;
+	struct aui_canvas *canvas;
+};
+
+static struct app app;
+
+int
+main()
+{
+	struct aui_frame *status_frame; 
+	struct aui_frame *menu_frame;
+	struct aui_frame *palette_frame;
+	struct aui_frame *tool_frame;
+	struct aui_label *version_label;
+
+	{
+		struct aui_window_config cfg = { .title = "apaint", .width = 640, .height = 480 };
+		app.aw = aui_window_new(&cfg);
+	}
+
+	{
+		struct aui_canvas_config cfg = { .background = { 255, 255, 255, 255 } };
+		struct aui_placepar place = {
+			.width = 256,
+			.height = 256,
+			.x = 60,
+			.y = 30,
+			.relx = 0.5,
+			.rely = 0.5,
+			.anchor = AUI_ANCHOR_CENTER,
+		};
+
+		app.canvas = aui_canvas_new(AUI_WIDGET(app.aw), &cfg);
+		aui_place(AUI_WIDGET(app.canvas), &place);
+	}
+
+	/*
+	 * Status bar
+	 */
+	{
+		struct aui_frame_config cfg = { .background = { 0x5a, 0x5a, 0x5a, 0xff } };
+		struct aui_placepar place = { 
+			.relwidth = 1, 
+			.rely = 1, 
+			.height = 20, 
+			.anchor = AUI_ANCHOR_SW 
+		};
+		status_frame = aui_frame_new(AUI_WIDGET(app.aw), &cfg);
+		aui_place(AUI_WIDGET(status_frame), &place);
+	}
+
+	{
+		struct aui_label_config cfg = { 
+			.text = "apaint v.0.0",
+			.foreground = { 175, 175, 175, 255 } 
+		};
+		struct aui_gridpar grid = { .column = 0, .row = 0 };
+
+		version_label = aui_label_new(AUI_WIDGET(status_frame), &cfg);
+		aui_grid(AUI_WIDGET(version_label), &grid);
+	}
+
+	{
+		struct aui_gridconfigure cfg = { .weight = 1 };
+
+		aui_rowconfigure(AUI_WIDGET(status_frame), 0, &cfg);
+	}
+
+	/*
+	 * Tools
+	 */
+	{
+		struct aui_frame_config cfg = { .background = { 140, 140, 140, 255 } };
+		struct aui_placepar place = {
+			.y = 55,
+			.width = 120,
+			.height = -75,
+			.relheight = 1,
+		};
+
+		tool_frame = aui_frame_new(AUI_WIDGET(app.aw), &cfg);
+		aui_place(AUI_WIDGET(tool_frame), &place);
+	}
+	
+	{
+		struct aui_frame_config cfg = { .background = { 190, 190, 190, 255 } };
+		struct aui_placepar place = {
+			.relwidth = 1,
+			.height = 30,
+			.y = 25,
+		};
+
+		palette_frame = aui_frame_new(AUI_WIDGET(app.aw), &cfg);
+		aui_place(AUI_WIDGET(palette_frame), &place);
+	}
+
+	/*
+	 * Menu
+	 */
+	{
+		struct aui_frame_config cfg = { .background = { 150, 150, 150, 255 } };
+		struct aui_placepar place = {
+			.relwidth = 1,
+			.height = 25,
+		};
+
+		menu_frame = aui_frame_new(AUI_WIDGET(app.aw), &cfg);
+		aui_place(AUI_WIDGET(menu_frame), &place);
+	}
+
+	aui_run();
+	return 0;
+}
blob - a75e978fa3653449f0abf805f3abdfdfd0a5cea3
blob + 555ddb0a70f0668d13e9e8bb1c84268a21fe67ca
--- widget.c
+++ widget.c
@@ -50,7 +50,7 @@ widget_draw(struct aui_widget *widget)
 
 	struct primitive *prim;
 
-	if (widget->geom.width == 0 || widget->geom.height == 0)
+	if (widget->geom.width <= 0 || widget->geom.height <= 0)
 		return;
 
 	for (int i = 0; i < widget->primitives.count; i++) {
blob - 58662b34a7f8eebec0d48b0ebb26d2ca780ad000
blob + 5c9e3dc1db37d438449e821fd6a4b704ca36087a
--- widget.h
+++ widget.h
@@ -10,8 +10,8 @@
  */
 struct aui_geometry {
 	int x, y;
-	uint16_t width;
-	uint16_t height;
+	int16_t width;
+	int16_t height;
 };
 
 enum widget_type {