summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam NAILI2017-12-27 17:16:20 +0100
committerAdam NAILI2017-12-27 17:16:20 +0100
commitee98053ef83869033713c8c7d6d487457d6443d8 (patch)
treeaf20ee900e1de387941e2dee1c2dd102277a1d86
parent92c999f56a86f221e6d3dc2182b5b7f7e0e08231 (diff)
downloadmorpher-ee98053ef83869033713c8c7d6d487457d6443d8.tar.gz
Implementing the locking system to disable components
-rw-r--r--src/gui/button.c3
-rw-r--r--src/gui/group.c4
-rw-r--r--test/gui/group.c2
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) {
33 assert(y >= 0); 33 assert(y >= 0);
34 assert(parameterSelf != NULL); 34 assert(parameterSelf != NULL);
35 Button *self = (Button *) parameterSelf; 35 Button *self = (Button *) parameterSelf;
36 if (button_is_selected(x, y, self)) { 36 if (button_is_selected(x, y, self) && self->component.activated) {
37 printf("OK\n"); 37 printf("OK\n");
38 } 38 }
39} 39}
@@ -51,6 +51,7 @@ button_init(Button *button, const char *text, int sizeInterligne, int x_pos, int
51 MLV_get_size_of_adapted_text_box(text, sizeInterligne, &button->component.width, &button->component.height); 51 MLV_get_size_of_adapted_text_box(text, sizeInterligne, &button->component.width, &button->component.height);
52 button->component.x_pos = x_pos; 52 button->component.x_pos = x_pos;
53 button->component.y_pos = y_pos; 53 button->component.y_pos = y_pos;
54 button->component.activated = true;
54 button->component.print_method = button_print; 55 button->component.print_method = button_print;
55 button->component.click_handler = clickHandler; 56 button->component.click_handler = clickHandler;
56} 57}
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) {
21void group_click_handler(int x_pos, int y_pos, Component *parameterSelf) { 21void group_click_handler(int x_pos, int y_pos, Component *parameterSelf) {
22 assert(parameterSelf != NULL); 22 assert(parameterSelf != NULL);
23 Group *self = (Group *) parameterSelf; 23 Group *self = (Group *) parameterSelf;
24 if (self->group_head != NULL) { 24
25 if (self->group_head != NULL && self->component.activated) {
25 GroupElement *p = self->group_head; 26 GroupElement *p = self->group_head;
26 while (p != NULL) { 27 while (p != NULL) {
27 p->sub_component->click_handler(x_pos, y_pos, p->sub_component); 28 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
41 group->component.height = height; 42 group->component.height = height;
42 group->component.x_pos = x_pos; 43 group->component.x_pos = x_pos;
43 group->component.y_pos = y_pos; 44 group->component.y_pos = y_pos;
45 group->component.activated = true;
44 group->component.print_method = group_print; 46 group->component.print_method = group_print;
45 group->component.click_handler = group_click_handler; 47 group->component.click_handler = group_click_handler;
46 group->margin = margin; 48 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() {
13 Button button3; 13 Button button3;
14 14
15 button_init(&button1, "OK", 10, 500, 256, button_click_test); 15 button_init(&button1, "OK", 10, 500, 256, button_click_test);
16 button_init(&button2,"Bouton magique",10, 500,290, NULL); 16 button_init(&button2,"Bouton magique",10, 500,290, button_click_test);
17 button_init(&button3,"Très lonnggggg boooouttttooooon",10,0,0,button_click_test); 17 button_init(&button3,"Très lonnggggg boooouttttooooon",10,0,0,button_click_test);
18 18
19 window_add_button(&window,&button1); 19 window_add_button(&window,&button1);