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/button.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/gui/button.c') diff --git a/src/gui/button.c b/src/gui/button.c index 96cbd9a..a1fa1cf 100644 --- a/src/gui/button.c +++ b/src/gui/button.c @@ -6,7 +6,6 @@ #include #include - bool button_is_selected(int x, int y, Button *button) { assert(x >= 0); assert(y >= 0); @@ -33,11 +32,22 @@ 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) && self->component.activated) { + if (button_is_selected(x, y, self) && mode == WAITING_BUTTON) { printf("OK\n"); } } +void button_click_add_constraint(int x, int y, Component *parameterSelf){ + assert(x >= 0); + assert(y >= 0); + assert(parameterSelf != NULL); + Button *self = (Button *) parameterSelf; + if (button_is_selected(x, y, self) && mode == WAITING_BUTTON) { + mode = INSERT_ORIGIN; + } +} + + void button_init(Button *button, const char *text, int sizeInterligne, int x_pos, int y_pos, ClickHandler clickHandler) { assert(button != NULL); @@ -51,7 +61,6 @@ 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; } -- cgit v1.2.3