Mercurial > molko
comparison examples/example-ui/example-ui.c @ 506:e205625015ba
ui: gridmenu is stylable
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 02 Mar 2023 08:54:00 +0100 |
parents | 6100c643dba0 |
children | d49a05e7a5b5 |
comparison
equal
deleted
inserted
replaced
505:6100c643dba0 | 506:e205625015ba |
---|---|
36 #include <mlk/ui/label.h> | 36 #include <mlk/ui/label.h> |
37 #include <mlk/ui/notify.h> | 37 #include <mlk/ui/notify.h> |
38 #include <mlk/ui/ui.h> | 38 #include <mlk/ui/ui.h> |
39 | 39 |
40 #include <mlk/example/example.h> | 40 #include <mlk/example/example.h> |
41 #include <mlk/example/glower.h> | |
41 #include <mlk/example/registry.h> | 42 #include <mlk/example/registry.h> |
42 | 43 |
43 #include "button-style-glow.h" | 44 #include "button-style-glow.h" |
44 | 45 |
45 #define FRAME_ORIGIN_X (10) | 46 #define FRAME_ORIGIN_X (10) |
96 struct mlk_button quit; | 97 struct mlk_button quit; |
97 | 98 |
98 /* | 99 /* |
99 * [Download free RAM] with custom style drawing. | 100 * [Download free RAM] with custom style drawing. |
100 */ | 101 */ |
101 struct button_style_glow download_glow; | 102 struct mlk_glower download_glow; |
103 struct button_style_glow download_style; | |
102 struct mlk_button download; | 104 struct mlk_button download; |
103 } buttons; | 105 } buttons; |
104 } ui = { | 106 } ui = { |
105 .panel = { | 107 .panel = { |
106 .frame = { | 108 .frame = { |
143 .h = ELEMENT_HEIGHT, | 145 .h = ELEMENT_HEIGHT, |
144 .style = &ui.buttons.quit_style, | 146 .style = &ui.buttons.quit_style, |
145 .text_style = &ui.buttons.quit_text_style | 147 .text_style = &ui.buttons.quit_text_style |
146 }, | 148 }, |
147 .download_glow = { | 149 .download_glow = { |
148 .colors = { | 150 .start = BUTTON_STYLE_GLOW_COLOR_1, |
149 BUTTON_STYLE_GLOW_COLOR_1, | 151 .end = BUTTON_STYLE_GLOW_COLOR_2, |
150 BUTTON_STYLE_GLOW_COLOR_2 | 152 .delay = BUTTON_STYLE_GLOW_DELAY |
151 }, | 153 }, |
154 .download_style = { | |
155 .glow = &ui.buttons.download_glow, | |
152 .style = { | 156 .style = { |
153 .border_color = BUTTON_STYLE_GLOW_COLOR_1 | 157 .border_color = BUTTON_STYLE_GLOW_COLOR_1 |
154 }, | 158 } |
155 .delay = BUTTON_STYLE_GLOW_DELAY | |
156 }, | 159 }, |
157 .download = { | 160 .download = { |
158 .w = 180, | 161 .w = 180, |
159 .h = 32, | 162 .h = 32, |
160 .text = "!! Download free RAM !!", | 163 .text = "!! Download free RAM !!", |
161 .style = &ui.buttons.download_glow.style, | 164 .style = &ui.buttons.download_style.style, |
162 .text_style = &ui.buttons.quit_text_style | 165 .text_style = &ui.buttons.quit_text_style |
163 } | 166 } |
164 } | 167 } |
165 }; | 168 }; |
166 | 169 |
307 static void | 310 static void |
308 draw(struct mlk_state *st) | 311 draw(struct mlk_state *st) |
309 { | 312 { |
310 (void)st; | 313 (void)st; |
311 | 314 |
312 mlk_painter_set_color(0x88d6ffff); | 315 mlk_painter_set_color(MLK_EXAMPLE_BG); |
313 mlk_painter_clear(); | 316 mlk_painter_clear(); |
314 mlk_frame_draw(&ui.panel.frame); | 317 mlk_frame_draw(&ui.panel.frame); |
315 mlk_label_draw(&ui.header.label); | 318 mlk_label_draw(&ui.header.label); |
316 mlk_checkbox_draw(&ui.autosave.cb); | 319 mlk_checkbox_draw(&ui.autosave.cb); |
317 mlk_label_draw(&ui.autosave.label); | 320 mlk_label_draw(&ui.autosave.label); |
328 int err; | 331 int err; |
329 | 332 |
330 if ((err = mlk_example_init("example-ui")) < 0) | 333 if ((err = mlk_example_init("example-ui")) < 0) |
331 mlk_panicf("mlk_example_init: %s", mlk_err_string(err)); | 334 mlk_panicf("mlk_example_init: %s", mlk_err_string(err)); |
332 | 335 |
333 button_style_glow_init(&ui.buttons.download_glow); | 336 button_style_glow_init(&ui.buttons.download_style); |
334 | 337 |
335 mlk_button_init(&ui.buttons.hello); | 338 mlk_button_init(&ui.buttons.hello); |
336 mlk_button_init(&ui.buttons.quit); | 339 mlk_button_init(&ui.buttons.quit); |
337 mlk_button_init(&ui.buttons.download); | 340 mlk_button_init(&ui.buttons.download); |
338 } | 341 } |