Mercurial > molko
diff src/libmlk-ui/ui/button.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 | d74f53299252 |
line wrap: on
line diff
--- a/src/libmlk-ui/ui/button.c Fri Apr 08 15:59:08 2022 +0200 +++ b/src/libmlk-ui/ui/button.c Fri Sep 09 09:27:17 2022 +0200 @@ -19,7 +19,6 @@ #include <assert.h> #include <string.h> -#include <core/action.h> #include <core/event.h> #include <core/maths.h> #include <core/painter.h> @@ -42,18 +41,6 @@ click->x, click->y); } -static void -handle(struct action *act, const union event *ev) -{ - button_handle(act->data, ev); -} - -static void -draw(struct action *act) -{ - button_draw(act->data); -} - void button_draw_default(const struct theme *t, const struct button *button) { @@ -83,7 +70,7 @@ label_draw(&label); } -void +int button_handle(struct button *button, const union event *ev) { assert(button); @@ -108,6 +95,8 @@ default: break; } + + return button->state == BUTTON_STATE_ACTIVATED; } void @@ -125,15 +114,3 @@ theme_draw_button(button->theme, button); } - -void -button_action(struct button *button, struct action *act) -{ - assert(button); - assert(act); - - memset(act, 0, sizeof (*act)); - act->data = button; - act->handle = handle; - act->draw = draw; -}