From ee98053ef83869033713c8c7d6d487457d6443d8 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Wed, 27 Dec 2017 17:16:20 +0100 Subject: Implementing the locking system to disable components --- src/gui/button.c | 3 ++- src/gui/group.c | 4 +++- test/gui/group.c | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gui/button.c b/src/gui/button.c index fbdc172..96cbd9a 100644 --- a/src/gui/button.c +++ b/src/gui/button.c @@ -33,7 +33,7 @@ void button_click_test(int x, int y, Component *parameterSelf) { assert(y >= 0); assert(parameterSelf != NULL); Button *self = (Button *) parameterSelf; - if (button_is_selected(x, y, self)) { + if (button_is_selected(x, y, self) && self->component.activated) { printf("OK\n"); } } @@ -51,6 +51,7 @@ button_init(Button *button, const char *text, int sizeInterligne, int x_pos, int MLV_get_size_of_adapted_text_box(text, sizeInterligne, &button->component.width, &button->component.height); button->component.x_pos = x_pos; button->component.y_pos = y_pos; + button->component.activated = true; button->component.print_method = button_print; button->component.click_handler = clickHandler; } diff --git a/src/gui/group.c b/src/gui/group.c index d287205..11a0583 100644 --- a/src/gui/group.c +++ b/src/gui/group.c @@ -21,7 +21,8 @@ void group_print(Component *parameterSelf) { void group_click_handler(int x_pos, int y_pos, Component *parameterSelf) { assert(parameterSelf != NULL); Group *self = (Group *) parameterSelf; - if (self->group_head != NULL) { + + if (self->group_head != NULL && self->component.activated) { GroupElement *p = self->group_head; while (p != NULL) { p->sub_component->click_handler(x_pos, y_pos, p->sub_component); @@ -41,6 +42,7 @@ void group_init(Group *group, int width, int height, int x_pos, int y_pos, int m group->component.height = height; group->component.x_pos = x_pos; group->component.y_pos = y_pos; + group->component.activated = true; group->component.print_method = group_print; group->component.click_handler = group_click_handler; group->margin = margin; diff --git a/test/gui/group.c b/test/gui/group.c index 555c246..99a567e 100644 --- a/test/gui/group.c +++ b/test/gui/group.c @@ -13,7 +13,7 @@ static void test_group() { Button button3; button_init(&button1, "OK", 10, 500, 256, button_click_test); - button_init(&button2,"Bouton magique",10, 500,290, NULL); + button_init(&button2,"Bouton magique",10, 500,290, button_click_test); button_init(&button3,"Très lonnggggg boooouttttooooon",10,0,0,button_click_test); window_add_button(&window,&button1); -- cgit v1.2.3