comparison libmlk-ui/mlk/ui/button.c @ 450:b26dd49f69ff

core: event -> mlk_event (and friends)
author David Demelier <markand@malikania.fr>
date Sat, 18 Feb 2023 13:37:11 +0100
parents 773a082f0b91
children c4f31658104d
comparison
equal deleted inserted replaced
449:f2f0e73ea9da 450:b26dd49f69ff
28 #include "button.h" 28 #include "button.h"
29 #include "label.h" 29 #include "label.h"
30 #include "theme.h" 30 #include "theme.h"
31 31
32 static int 32 static int
33 is_boxed(const struct button *button, const struct event_click *click) 33 is_boxed(const struct button *button, const struct mlk_event_click *click)
34 { 34 {
35 assert(button); 35 assert(button);
36 assert(click); 36 assert(click);
37 assert(click->type == EVENT_CLICKDOWN || click->type == EVENT_CLICKUP); 37 assert(click->type == MLK_EVENT_CLICKDOWN || click->type == MLK_EVENT_CLICKUP);
38 38
39 return maths_is_boxed(button->x, button->y, button->w, button->h, 39 return maths_is_boxed(button->x, button->y, button->w, button->h,
40 click->x, click->y); 40 click->x, click->y);
41 } 41 }
42 42
68 68
69 label_draw(&label); 69 label_draw(&label);
70 } 70 }
71 71
72 int 72 int
73 button_handle(struct button *button, const union event *ev) 73 button_handle(struct button *button, const union mlk_event *ev)
74 { 74 {
75 assert(button); 75 assert(button);
76 assert(ev); 76 assert(ev);
77 77
78 switch (ev->type) { 78 switch (ev->type) {
79 case EVENT_CLICKDOWN: 79 case MLK_EVENT_CLICKDOWN:
80 if (is_boxed(button, &ev->click)) 80 if (is_boxed(button, &ev->click))
81 button->state = BUTTON_STATE_PRESSED; 81 button->state = BUTTON_STATE_PRESSED;
82 break; 82 break;
83 case EVENT_CLICKUP: 83 case MLK_EVENT_CLICKUP:
84 /* 84 /*
85 * If the button was pressed, indicate that the button is 85 * If the button was pressed, indicate that the button is
86 * finally activated. This let the user to move the cursor 86 * finally activated. This let the user to move the cursor
87 * outside the button to "forget" the press. 87 * outside the button to "forget" the press.
88 */ 88 */