From 93174e167a6aa313fca43f4cb0e9b975e1618468 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Fri, 21 May 2021 22:41:11 +0200 Subject: Better window destroying --- apps/paint/main.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'apps/paint') diff --git a/apps/paint/main.c b/apps/paint/main.c index 50234af..e537004 100644 --- a/apps/paint/main.c +++ b/apps/paint/main.c @@ -36,23 +36,20 @@ int main(void) gui_new_window(&win); vec2 win_size = gui_window_size(win); - u32 toolbar; - gui_new_widget(&toolbar, win, vec2(0, 0), vec2(win_size.x, COLOR_SIZE)); + u32 toolbar = gui_new_widget(win, GUI_MAIN, vec2(0, 0), vec2(win_size.x, COLOR_SIZE)); gui_fill(win, toolbar, GUI_LAYER_BG, COLOR_WHITE); u32 color_count = COUNT(colors); for (u32 i = 0; i < color_count; i++) { - u32 color; - gui_add_widget(&color, win, toolbar, vec2(i * (COLOR_SIZE + TOOLBAR_MARGIN), 0), - vec2(COLOR_SIZE, COLOR_SIZE)); + u32 color = gui_new_widget(win, toolbar, vec2(i * (COLOR_SIZE + TOOLBAR_MARGIN), 0), + vec2(COLOR_SIZE, COLOR_SIZE)); gui_fill(win, color, GUI_LAYER_FG, colors[i]); gui_draw_border(win, color, GUI_LAYER_FG, 2, COLOR_BLACK); gui_listen_widget(win, color, GUI_LISTEN_MOUSECLICK, (u32)color_click); } - u32 canvas; - gui_new_widget(&canvas, win, vec2(0, COLOR_SIZE), - vec2(win_size.x, win_size.y - COLOR_SIZE)); + u32 canvas = gui_new_widget(win, GUI_MAIN, vec2(0, COLOR_SIZE), + vec2(win_size.x, win_size.y - COLOR_SIZE)); gui_fill(win, canvas, GUI_LAYER_BG, COLOR_WHITE); gui_listen_widget(win, canvas, GUI_LISTEN_MOUSEMOVE, (u32)mousemove); -- cgit v1.2.3