Mercurial > molko
comparison examples/example-ui/example-ui.c @ 493:fce3b3c4b496
ui: label -> mlk_label
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 28 Feb 2023 13:26:53 +0100 |
parents | 734b598534c4 |
children | 2af25db99273 |
comparison
equal
deleted
inserted
replaced
492:c7b18475f640 | 493:fce3b3c4b496 |
---|---|
70 struct { | 70 struct { |
71 struct mlk_frame frame; | 71 struct mlk_frame frame; |
72 } panel; | 72 } panel; |
73 | 73 |
74 struct { | 74 struct { |
75 struct label label; | 75 struct mlk_label label; |
76 } header; | 76 } header; |
77 | 77 |
78 struct { | 78 struct { |
79 struct mlk_checkbox cb; | 79 struct mlk_checkbox cb; |
80 struct label label; | 80 struct mlk_label label; |
81 } autosave; | 81 } autosave; |
82 | 82 |
83 struct { | 83 struct { |
84 struct mlk_button button; | 84 struct mlk_button button; |
85 } quit; | 85 } quit; |
95 .header = { | 95 .header = { |
96 .label = { | 96 .label = { |
97 .text = "Preferences", | 97 .text = "Preferences", |
98 .x = FRAME_ORIGIN_X, | 98 .x = FRAME_ORIGIN_X, |
99 .y = FRAME_ORIGIN_Y, | 99 .y = FRAME_ORIGIN_Y, |
100 .flags = LABEL_FLAGS_SHADOW, | 100 .flags = MLK_LABEL_FLAGS_SHADOW, |
101 } | 101 } |
102 }, | 102 }, |
103 .autosave = { | 103 .autosave = { |
104 .cb = { | 104 .cb = { |
105 .w = ELEMENT_HEIGHT, | 105 .w = ELEMENT_HEIGHT, |
106 .h = ELEMENT_HEIGHT | 106 .h = ELEMENT_HEIGHT |
107 }, | 107 }, |
108 .label = { | 108 .label = { |
109 .text = "Auto save game", | 109 .text = "Auto save game", |
110 .flags = LABEL_FLAGS_SHADOW, | 110 .flags = MLK_LABEL_FLAGS_SHADOW, |
111 } | 111 } |
112 }, | 112 }, |
113 .quit = { | 113 .quit = { |
114 .button = { | 114 .button = { |
115 .text = "Quit", | 115 .text = "Quit", |
131 | 131 |
132 static void | 132 static void |
133 resize_header(void) | 133 resize_header(void) |
134 { | 134 { |
135 struct mlk_frame *f = &ui.panel.frame; | 135 struct mlk_frame *f = &ui.panel.frame; |
136 struct label *l = &ui.header.label; | 136 struct mlk_label *l = &ui.header.label; |
137 unsigned int w, h; | 137 unsigned int w, h; |
138 | 138 |
139 /* Header. */ | 139 /* Header. */ |
140 label_query(l, &w, &h); | 140 mlk_label_query(l, &w, &h); |
141 mlk_align(MLK_ALIGN_LEFT, &l->x, &l->y, w, h, f->x, f->y, f->w, HEADER_HEIGHT); | 141 mlk_align(MLK_ALIGN_LEFT, &l->x, &l->y, w, h, f->x, f->y, f->w, HEADER_HEIGHT); |
142 | 142 |
143 l->x += theme_default()->padding; | 143 l->x += theme_default()->padding; |
144 } | 144 } |
145 | 145 |
147 resize_autosave(void) | 147 resize_autosave(void) |
148 { | 148 { |
149 unsigned int padding = theme_default()->padding; | 149 unsigned int padding = theme_default()->padding; |
150 struct mlk_frame *f = &ui.panel.frame; | 150 struct mlk_frame *f = &ui.panel.frame; |
151 struct mlk_checkbox *c = &ui.autosave.cb; | 151 struct mlk_checkbox *c = &ui.autosave.cb; |
152 struct label *l = &ui.autosave.label; | 152 struct mlk_label *l = &ui.autosave.label; |
153 | 153 |
154 c->x = f->x + padding; | 154 c->x = f->x + padding; |
155 c->y = f->y + HEADER_HEIGHT + padding; | 155 c->y = f->y + HEADER_HEIGHT + padding; |
156 | 156 |
157 l->x = c->x + c->w + padding; | 157 l->x = c->x + c->w + padding; |
242 (void)st; | 242 (void)st; |
243 | 243 |
244 mlk_painter_set_color(0xffffffff); | 244 mlk_painter_set_color(0xffffffff); |
245 mlk_painter_clear(); | 245 mlk_painter_clear(); |
246 mlk_frame_draw(&ui.panel.frame); | 246 mlk_frame_draw(&ui.panel.frame); |
247 label_draw(&ui.header.label); | 247 mlk_label_draw(&ui.header.label); |
248 mlk_checkbox_draw(&ui.autosave.cb); | 248 mlk_checkbox_draw(&ui.autosave.cb); |
249 label_draw(&ui.autosave.label); | 249 mlk_label_draw(&ui.autosave.label); |
250 mlk_button_draw(&ui.quit.button); | 250 mlk_button_draw(&ui.quit.button); |
251 mlk_painter_present(); | 251 mlk_painter_present(); |
252 } | 252 } |
253 | 253 |
254 static void | 254 static void |