comparison src/libmlk-ui/ui/frame.c @ 409:6011ad866e99

ui: delete action functions The handling of actions is done without taking care of the return value which make it impossible to detect UI elements since it's a immediate mode like implementation. Users are encouraged to write code like instead: ``` if (button_handle(&b, &ev)) { // Do something. } ```
author David Demelier <markand@malikania.fr>
date Fri, 09 Sep 2022 09:27:17 +0200
parents 460c78706989
children 8f59201dc76b
comparison
equal deleted inserted replaced
408:0ea90751a62d 409:6011ad866e99
17 */ 17 */
18 18
19 #include <assert.h> 19 #include <assert.h>
20 #include <string.h> 20 #include <string.h>
21 21
22 #include <core/action.h>
23 #include <core/painter.h> 22 #include <core/painter.h>
24 23
25 #include "frame.h" 24 #include "frame.h"
26 #include "theme.h" 25 #include "theme.h"
27
28 static void
29 draw(struct action *act)
30 {
31 frame_draw(act->data);
32 }
33 26
34 void 27 void
35 frame_draw_default(const struct theme *t, const struct frame *frame) 28 frame_draw_default(const struct theme *t, const struct frame *frame)
36 { 29 {
37 assert(t); 30 assert(t);
52 { 45 {
53 assert(frame); 46 assert(frame);
54 47
55 theme_draw_frame(frame->theme, frame); 48 theme_draw_frame(frame->theme, frame);
56 } 49 }
57
58 void
59 frame_action(struct frame *frame, struct action *act)
60 {
61 assert(frame);
62 assert(act);
63
64 memset(act, 0, sizeof (*act));
65 act->data = frame;
66 act->draw = draw;
67 }