From ed99a651c4e0c1a162f416ec384cef7df4268a88 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Sun, 10 Dec 2017 18:31:02 +0100 Subject: Deleting the documentation button_free and the prototype --- src/gui/group.c | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/gui/group.c (limited to 'src/gui/group.c') diff --git a/src/gui/group.c b/src/gui/group.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/gui/group.c @@ -0,0 +1 @@ + -- cgit v1.2.3 From 8ad5554529a9f1a6d128582af5aec13c792f0932 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Sun, 10 Dec 2017 18:33:11 +0100 Subject: Update doc and reworking structure and signature of init function for group --- src/gui/group.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/gui/group.c') diff --git a/src/gui/group.c b/src/gui/group.c index 8b13789..dc48c50 100644 --- a/src/gui/group.c +++ b/src/gui/group.c @@ -1 +1,26 @@ +#include +#include +void group_init(Group *group, int width, int height, int x_pos, int y_pos, int padding) { + group->component.width = width; + group->component.height = height; + group->component.x_pos = x_pos; + group->component.y_pos = y_pos; + group->padding = padding; +} + +void group_free(Group *group) { + if (group->group_head != NULL) { + GroupElement *p = group->group_head; + while (p->next != NULL) { + GroupElement *tmp = group->group_head; + p = p->next; + free(tmp); + } + group->group_head = NULL; + } +} + +void group_add_component(Group *group, Component *component) { + +} \ No newline at end of file -- cgit v1.2.3 From 26bb3df365ed43dd415be8ac870da8ac8991b425 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Tue, 12 Dec 2017 13:13:24 +0100 Subject: Adding beta version of print function, working on implementation of the linked list (add + free) --- src/gui/group.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'src/gui/group.c') diff --git a/src/gui/group.c b/src/gui/group.c index dc48c50..ac2c440 100644 --- a/src/gui/group.c +++ b/src/gui/group.c @@ -1,11 +1,31 @@ #include #include +#include +#include +#include "MLV/MLV_shape.h" +#include "MLV/MLV_window.h" + +void group_print(void *parameter) { + Group *group = (Group *) parameter; + /*DEBUG*/ + MLV_draw_filled_rectangle(group->component.x_pos, group->component.y_pos, group->component.width, + group->component.height, MLV_COLOR_AQUAMARINE); + /**/ + MLV_actualise_window(); +} void group_init(Group *group, int width, int height, int x_pos, int y_pos, int padding) { + assert(group != NULL); + assert(width>0); + assert(height>0); + assert(x_pos>=0); + assert(y_pos>=0); + assert(padding>=0); group->component.width = width; group->component.height = height; group->component.x_pos = x_pos; group->component.y_pos = y_pos; + group->component.print_method = group_print; group->padding = padding; } @@ -22,5 +42,20 @@ void group_free(Group *group) { } void group_add_component(Group *group, Component *component) { - + if (group->group_head != NULL) { + /*Initialize the new node*/ + GroupElement *tmp = malloc_or_die(sizeof(GroupElement)); + tmp->sub_component = component; + tmp->next = NULL; + GroupElement *p = group->group_head; + /*Browsing*/ + while (p->next != NULL) { + p = p->next; + } + p->next = tmp; + } else { + group->group_head = malloc_or_die(sizeof(GroupElement)); + group->group_head->sub_component = component; + group->group_head->next = NULL; + } } \ No newline at end of file -- cgit v1.2.3 From a42fdf7d5c9712297f1bbe3dd0951baa8ee32447 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Tue, 12 Dec 2017 13:25:56 +0100 Subject: Formatting files --- src/gui/group.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/gui/group.c') diff --git a/src/gui/group.c b/src/gui/group.c index ac2c440..cb50b1c 100644 --- a/src/gui/group.c +++ b/src/gui/group.c @@ -16,11 +16,11 @@ void group_print(void *parameter) { void group_init(Group *group, int width, int height, int x_pos, int y_pos, int padding) { assert(group != NULL); - assert(width>0); - assert(height>0); - assert(x_pos>=0); - assert(y_pos>=0); - assert(padding>=0); + assert(width > 0); + assert(height > 0); + assert(x_pos >= 0); + assert(y_pos >= 0); + assert(padding >= 0); group->component.width = width; group->component.height = height; group->component.x_pos = x_pos; -- cgit v1.2.3 From f3e1ec505dab2d68f7d5ce542f1693d00d7f0537 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Fri, 22 Dec 2017 19:11:06 +0100 Subject: Updating doc of group, correcting chained list behaviour, completing implementation of group_init, implementing group_print and group_click_handler to delegate on components --- src/gui/group.c | 65 +++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 20 deletions(-) (limited to 'src/gui/group.c') diff --git a/src/gui/group.c b/src/gui/group.c index cb50b1c..d287205 100644 --- a/src/gui/group.c +++ b/src/gui/group.c @@ -2,38 +2,56 @@ #include #include #include +#include #include "MLV/MLV_shape.h" #include "MLV/MLV_window.h" -void group_print(void *parameter) { - Group *group = (Group *) parameter; - /*DEBUG*/ - MLV_draw_filled_rectangle(group->component.x_pos, group->component.y_pos, group->component.width, - group->component.height, MLV_COLOR_AQUAMARINE); - /**/ - MLV_actualise_window(); +void group_print(Component *parameterSelf) { + assert(parameterSelf != NULL); + Group *self = (Group *) parameterSelf; + if (self->group_head != NULL) { + GroupElement *p = self->group_head; + while (p != NULL) { + p->sub_component->print_method(p->sub_component); + p = p->next; + } + } +} + +void group_click_handler(int x_pos, int y_pos, Component *parameterSelf) { + assert(parameterSelf != NULL); + Group *self = (Group *) parameterSelf; + if (self->group_head != NULL) { + GroupElement *p = self->group_head; + while (p != NULL) { + p->sub_component->click_handler(x_pos, y_pos, p->sub_component); + p = p->next; + } + } } -void group_init(Group *group, int width, int height, int x_pos, int y_pos, int padding) { +void group_init(Group *group, int width, int height, int x_pos, int y_pos, int margin) { assert(group != NULL); assert(width > 0); assert(height > 0); assert(x_pos >= 0); assert(y_pos >= 0); - assert(padding >= 0); + assert(margin >= 0); group->component.width = width; group->component.height = height; group->component.x_pos = x_pos; group->component.y_pos = y_pos; group->component.print_method = group_print; - group->padding = padding; + group->component.click_handler = group_click_handler; + group->margin = margin; } void group_free(Group *group) { + assert(group != NULL); if (group->group_head != NULL) { GroupElement *p = group->group_head; - while (p->next != NULL) { - GroupElement *tmp = group->group_head; + while (p != NULL) { + GroupElement *tmp = p; p = p->next; free(tmp); } @@ -42,20 +60,27 @@ void group_free(Group *group) { } void group_add_component(Group *group, Component *component) { + assert(group != NULL); + assert(component != NULL); + /*Initialize the new node*/ + GroupElement *tmp = malloc_or_die(sizeof(GroupElement)); + tmp->sub_component = component; + tmp->next = NULL; if (group->group_head != NULL) { - /*Initialize the new node*/ - GroupElement *tmp = malloc_or_die(sizeof(GroupElement)); - tmp->sub_component = component; - tmp->next = NULL; GroupElement *p = group->group_head; /*Browsing*/ while (p->next != NULL) { p = p->next; } p->next = tmp; + /*Modifying for margin*/ + tmp->sub_component->y_pos = p->sub_component->y_pos; + tmp->sub_component->x_pos = p->sub_component->x_pos + p->sub_component->width + group->margin; } else { - group->group_head = malloc_or_die(sizeof(GroupElement)); - group->group_head->sub_component = component; - group->group_head->next = NULL; + tmp->sub_component->y_pos = group->component.y_pos; + tmp->sub_component->x_pos = group->component.x_pos; + group->group_head = tmp; + } -} \ No newline at end of file +} + -- cgit v1.2.3 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/group.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/gui/group.c') 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; -- cgit v1.2.3 From 9ed3c28a0335137d34e51d5fd49be6e523f65a89 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Thu, 28 Dec 2017 22:52:28 +0100 Subject: Implementing the add constraint feature, need to be fixed --- src/gui/group.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/gui/group.c') diff --git a/src/gui/group.c b/src/gui/group.c index 11a0583..af9abac 100644 --- a/src/gui/group.c +++ b/src/gui/group.c @@ -22,7 +22,7 @@ void group_click_handler(int x_pos, int y_pos, Component *parameterSelf) { assert(parameterSelf != NULL); Group *self = (Group *) parameterSelf; - if (self->group_head != NULL && self->component.activated) { + if (self->group_head != NULL) { GroupElement *p = self->group_head; while (p != NULL) { p->sub_component->click_handler(x_pos, y_pos, p->sub_component); @@ -42,7 +42,6 @@ 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; -- cgit v1.2.3