From 0a52cd20ba690303958c29e94ef526442789effa Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Wed, 6 Dec 2017 21:02:36 +0100 Subject: Update doc on window.h --- include/gui/window.h | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/gui/window.h b/include/gui/window.h index 9394c84..defc6f7 100644 --- a/include/gui/window.h +++ b/include/gui/window.h @@ -3,24 +3,58 @@ /** * File: window.h + * Windows and components handling. + * + * See also: + * The famous OS */ typedef void (*ClickHandler)(int x_pos, int y_pos); - +/** + * Type: Component + * Abstract component that handles clicks. + */ typedef struct { int width, height; ClickHandler click_handler; } Component; - +/** + * Type: Window + * Supports and handles components. + */ typedef struct { int width, height; Component *components; } Window; - +/** + * Function: window_init + * Initializes a window. + * + * Parameters: + * *window - pointer to the input window + * width - width of the window to initialize + * height - height of the window to initialize + * *title - title of the actual window + */ void window_init(Window *window, int width, int height, char *title); - +/** + * Function: window_free + * Frees the resources supported by the window and the window itself. + * + * Parameters: + * *window - pointer to the input window + */ void window_free(Window *window); - +/** + * Function: window_add_component + * Adds components to the current window at the position specified in x and y. + * + * Parameters: + * *window - pointer to the input window + * *component - pointer to the input component + * x_pos - coordinate on x axis to place the component + * y_pos - coordinate on y axis to place the component + */ void window_add_component(Window *window, Component *component, int x_pos, int y_pos); #endif -- cgit v1.2.3 From 68672a10cc01c5f0c50aaa5779eab8af33046f43 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Wed, 6 Dec 2017 21:02:50 +0100 Subject: Update doc on button.h --- include/gui/button.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'include') diff --git a/include/gui/button.h b/include/gui/button.h index 62f75a3..4d3bfe5 100644 --- a/include/gui/button.h +++ b/include/gui/button.h @@ -3,14 +3,34 @@ /** * File: button.h + * Buttons handling */ +/** + * Type: Button + * Component that can be triggered by click to execute a specific action. + */ typedef struct { Component component; } Button; +/** + * Function: button_init + * Initializes the button. + * + * Parameters: + * *button - pointer to the input button + * text - label for the button + */ void button_init(Button *button, char *text); +/** + * Function: button_free + * Frees the resources for the button. + * + * Parameters: + * *button - pointer to the input button + */ void button_free(Button *button); #endif -- cgit v1.2.3 From 81eb171910e03ecb06b3b984375622efbe48b739 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Fri, 8 Dec 2017 21:31:50 +0100 Subject: Updating window.h doc and rework of the Component struct (adding a pointer of function to print) --- include/gui/window.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/gui/window.h b/include/gui/window.h index defc6f7..c7e12cf 100644 --- a/include/gui/window.h +++ b/include/gui/window.h @@ -9,14 +9,27 @@ * The famous OS */ +/** + * Type: ClickHandler + * Type of functions that handle mouse's clicks. + */ typedef void (*ClickHandler)(int x_pos, int y_pos); + +/** + * Type: PrintMethod + * Type of functions that will be used to print our component. This must be initialized by the initialization function of the component. + */ +typedef void (*PrintMethod)(void); + /** * Type: Component * Abstract component that handles clicks. */ typedef struct { int width, height; + int x_pos, y_pos; ClickHandler click_handler; + PrintMethod print_method; } Component; /** * Type: Window @@ -26,6 +39,7 @@ typedef struct { int width, height; Component *components; } Window; + /** * Function: window_init * Initializes a window. @@ -37,6 +51,7 @@ typedef struct { * *title - title of the actual window */ void window_init(Window *window, int width, int height, char *title); + /** * Function: window_free * Frees the resources supported by the window and the window itself. @@ -45,6 +60,7 @@ void window_init(Window *window, int width, int height, char *title); * *window - pointer to the input window */ void window_free(Window *window); + /** * Function: window_add_component * Adds components to the current window at the position specified in x and y. @@ -52,9 +68,8 @@ void window_free(Window *window); * Parameters: * *window - pointer to the input window * *component - pointer to the input component - * x_pos - coordinate on x axis to place the component - * y_pos - coordinate on y axis to place the component */ -void window_add_component(Window *window, Component *component, int x_pos, int y_pos); +void window_add_component(Window *window, Component *component); + #endif -- cgit v1.2.3 From 4bb6d10d3ffe0376389f9e6f08c90e155687aa91 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Fri, 8 Dec 2017 21:34:40 +0100 Subject: Including window.h --- include/gui/button.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/gui/button.h b/include/gui/button.h index 4d3bfe5..8537151 100644 --- a/include/gui/button.h +++ b/include/gui/button.h @@ -1,6 +1,7 @@ #ifndef UPEM_MORPHING_BUTTON #define UPEM_MORPHING_BUTTON +#include "window.h" /** * File: button.h * Buttons handling -- cgit v1.2.3 From c9f0cce6b9e6c50fdda1cb94a6ac1831264ab020 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Sat, 9 Dec 2017 02:37:14 +0100 Subject: Rework of the structure Group --- include/gui/group.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/gui/group.h b/include/gui/group.h index 6914d55..45ec3b2 100644 --- a/include/gui/group.h +++ b/include/gui/group.h @@ -1,13 +1,20 @@ #ifndef UPEM_MORPHING_GROUP #define UPEM_MORPHING_GROUP +#include "window.h" + /** * File: group.h */ +typedef struct _GroupElement { + Component *c; + struct _GroupElement *next; +} GroupElement; + typedef struct { Component component; - Component *sub_components; + GroupElement *group_head; } Group; void group_init(Group *group, int padding); -- cgit v1.2.3 From 16b67f89eccc78ed6d04f889cae8c2e5c2a3b49d Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Sat, 9 Dec 2017 02:38:36 +0100 Subject: Rework of the structure Window --- include/gui/window.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/gui/window.h b/include/gui/window.h index c7e12cf..6ccf00a 100644 --- a/include/gui/window.h +++ b/include/gui/window.h @@ -9,6 +9,8 @@ * The famous OS */ +#include "group.h" + /** * Type: ClickHandler * Type of functions that handle mouse's clicks. @@ -37,7 +39,8 @@ typedef struct { */ typedef struct { int width, height; - Component *components; + Group *group_buttons; + Group *group_images; } Window; /** -- cgit v1.2.3 From e94826bd09fd785c8ae80c132c3e0a8f4125892b Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Sun, 10 Dec 2017 12:59:10 +0100 Subject: Updating button documentation --- include/gui/button.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/gui/button.h b/include/gui/button.h index 8537151..4e8ad95 100644 --- a/include/gui/button.h +++ b/include/gui/button.h @@ -1,15 +1,18 @@ #ifndef UPEM_MORPHING_BUTTON #define UPEM_MORPHING_BUTTON -#include "window.h" /** * File: button.h * Buttons handling */ +#include "window.h" /** - * Type: Button + * Struct: Button * Component that can be triggered by click to execute a specific action. + * + * Fields: + * component - component that will acted as a button thanks to a rightful initialization. */ typedef struct { Component component; -- cgit v1.2.3 From 6e91c1be2b0abddb6cfe16152b35cd0559b83c4a Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Sun, 10 Dec 2017 13:00:32 +0100 Subject: Updating documentation and reworking the structure of the Window --- include/gui/window.h | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/gui/window.h b/include/gui/window.h index 6ccf00a..a20456d 100644 --- a/include/gui/window.h +++ b/include/gui/window.h @@ -24,8 +24,16 @@ typedef void (*ClickHandler)(int x_pos, int y_pos); typedef void (*PrintMethod)(void); /** - * Type: Component - * Abstract component that handles clicks. + * Struct: Component + * Represents an abstract module handling clicks and a way to be print on the screen. + * + * Fields: + * width - width of the component + * height - height of the component + * x_pos - position on the x axis from the origin meant to be placed in top left + * y_pos - position on the y axis from the origin meant to be placed in top left + * click_handler - pointer of function that is called on mouse click + * print_method - pointer of function that handle the component's print */ typedef struct { int width, height; @@ -34,13 +42,21 @@ typedef struct { PrintMethod print_method; } Component; /** - * Type: Window + * Struct: Window * Supports and handles components. + * + * Fields: + * width - width of the window + * height - height of the window + * *title - string printed as name for the window + * *group_buttons - group that handles the buttons added to the window + * *group_pictureframe - group that handles the picture frames added to the window */ typedef struct { int width, height; + char *title; Group *group_buttons; - Group *group_images; + Group *group_pictureframe; } Window; /** @@ -65,14 +81,24 @@ void window_init(Window *window, int width, int height, char *title); void window_free(Window *window); /** - * Function: window_add_component - * Adds components to the current window at the position specified in x and y. + * Function: window_add_button + * Adds Button component to the group of buttons of the current window. + * + * Parameters: + * *window - pointer to the input window + * *component - pointer to the input component + */ +void window_add_button(Window *window, Component *component); + +/** + * Function: window_add_pictureframe + * Adds PictureFrame component to the group of picture frames of the current window. * * Parameters: * *window - pointer to the input window * *component - pointer to the input component */ -void window_add_component(Window *window, Component *component); +void window_add_pictureframe(Window *window, Component *component); #endif -- cgit v1.2.3 From 3449e695fa8885bb8150e105c267d92ab8a3d4ee Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Sun, 10 Dec 2017 13:28:40 +0100 Subject: Updating documentation of group.h --- include/gui/group.h | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/gui/group.h b/include/gui/group.h index 45ec3b2..bd46852 100644 --- a/include/gui/group.h +++ b/include/gui/group.h @@ -1,17 +1,35 @@ #ifndef UPEM_MORPHING_GROUP #define UPEM_MORPHING_GROUP -#include "window.h" - /** * File: group.h + * Group of components */ +#include "window.h" +/** + * Struct: _GroupElement + * Nod of the linked list that is involved in the Group behavior + * + * Parameters: + * *component - component + * *sub_component - sub component + * *next - link to the next nod + */ typedef struct _GroupElement { - Component *c; + Component *component; + Component *sub_component; struct _GroupElement *next; } GroupElement; +/** + * Struct: Group + * Group representation + * + * Parameters: + * component - Component used for the Group to catch clicks and handle print to delegate to the components contented in it + * *group_head - pointer to the head of the list that regroup all the components contained inside of the group + */ typedef struct { Component component; GroupElement *group_head; -- cgit v1.2.3 From 27b78c91216f397e9aed3c0dd87db2c54dca50fa Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Sun, 10 Dec 2017 17:03:55 +0100 Subject: Creation of component.h and move the content about Component to this header file --- include/gui/component.h | 45 ++++++++++++++++++++++++++++++++++++++ include/gui/group.h | 2 +- include/gui/window.h | 57 +++++++++++++++++++++++-------------------------- 3 files changed, 73 insertions(+), 31 deletions(-) create mode 100644 include/gui/component.h (limited to 'include') diff --git a/include/gui/component.h b/include/gui/component.h new file mode 100644 index 0000000..d61b713 --- /dev/null +++ b/include/gui/component.h @@ -0,0 +1,45 @@ +#ifndef UPEM_C_COMPONENT_H +#define UPEM_C_COMPONENT_H + +/** + * File: component.h + * Windows and components handling. + * + * See also: + * The famous OS + */ + +#include "group.h" + +/** + * Type: ClickHandler + * Type of functions that handle mouse's clicks. + */ +typedef void (*ClickHandler)(int x_pos, int y_pos); + +/** + * Type: PrintMethod + * Type of functions that will be used to print our component. This must be initialized by the initialization function of the component. + */ +typedef void (*PrintMethod)(void); + +/** + * Struct: Component + * Represents an abstract module handling clicks and a way to be print on the screen. + * + * Fields: + * width - width of the component + * height - height of the component + * x_pos - position on the x axis from the origin meant to be placed in top left + * y_pos - position on the y axis from the origin meant to be placed in top left + * click_handler - pointer of function that is called on mouse click + * print_method - pointer of function that handle the component's print + */ +typedef struct { + int width, height; + int x_pos, y_pos; + ClickHandler click_handler; + PrintMethod print_method; +} Component; + +#endif //UPEM_C_COMPONENT_H diff --git a/include/gui/group.h b/include/gui/group.h index bd46852..b766ded 100644 --- a/include/gui/group.h +++ b/include/gui/group.h @@ -5,7 +5,7 @@ * File: group.h * Group of components */ -#include "window.h" +#include "component.h" /** * Struct: _GroupElement diff --git a/include/gui/window.h b/include/gui/window.h index a20456d..3212a49 100644 --- a/include/gui/window.h +++ b/include/gui/window.h @@ -10,37 +10,8 @@ */ #include "group.h" +#include "component.h" -/** - * Type: ClickHandler - * Type of functions that handle mouse's clicks. - */ -typedef void (*ClickHandler)(int x_pos, int y_pos); - -/** - * Type: PrintMethod - * Type of functions that will be used to print our component. This must be initialized by the initialization function of the component. - */ -typedef void (*PrintMethod)(void); - -/** - * Struct: Component - * Represents an abstract module handling clicks and a way to be print on the screen. - * - * Fields: - * width - width of the component - * height - height of the component - * x_pos - position on the x axis from the origin meant to be placed in top left - * y_pos - position on the y axis from the origin meant to be placed in top left - * click_handler - pointer of function that is called on mouse click - * print_method - pointer of function that handle the component's print - */ -typedef struct { - int width, height; - int x_pos, y_pos; - ClickHandler click_handler; - PrintMethod print_method; -} Component; /** * Struct: Window * Supports and handles components. @@ -100,5 +71,31 @@ void window_add_button(Window *window, Component *component); */ void window_add_pictureframe(Window *window, Component *component); +/** + * Function: window_create + * Initializes the resources to create a window. + * + * Parameters: + * *window - pointer to the input window + */ +void window_create(Window *window); + +/** + * Function: window_print_buttons + * Prints all the buttons to the screen + * + * Parameters: + * *window - pointer to the input window + */ +void window_print_buttons(Window *window); + +/** + * Function: window_print_pictureframes + * Prints all the picture frames to the screen + * + * Parameters: + * *window - pointer to the input window + */ +void window_print_pictureframes(Window *window); #endif -- cgit v1.2.3 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 --- include/gui/button.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'include') diff --git a/include/gui/button.h b/include/gui/button.h index 4e8ad95..fda83e9 100644 --- a/include/gui/button.h +++ b/include/gui/button.h @@ -28,13 +28,5 @@ typedef struct { */ void button_init(Button *button, char *text); -/** - * Function: button_free - * Frees the resources for the button. - * - * Parameters: - * *button - pointer to the input button - */ -void button_free(Button *button); #endif -- 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 --- include/gui/group.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/gui/group.h b/include/gui/group.h index b766ded..1887bf6 100644 --- a/include/gui/group.h +++ b/include/gui/group.h @@ -29,13 +29,15 @@ typedef struct _GroupElement { * Parameters: * component - Component used for the Group to catch clicks and handle print to delegate to the components contented in it * *group_head - pointer to the head of the list that regroup all the components contained inside of the group + * padding - padding for all components */ typedef struct { Component component; GroupElement *group_head; + int padding; } Group; -void group_init(Group *group, int padding); +void group_init(Group *group, int width, int height, int x_pos, int y_pos, int padding); void group_free(Group *group); -- cgit v1.2.3 From 00a6e1d29ad8dae2d769810b9af65c3934788487 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Tue, 12 Dec 2017 13:08:47 +0100 Subject: Reworking on the signature of PrintMethod --- include/gui/component.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/gui/component.h b/include/gui/component.h index d61b713..50aee63 100644 --- a/include/gui/component.h +++ b/include/gui/component.h @@ -21,7 +21,7 @@ typedef void (*ClickHandler)(int x_pos, int y_pos); * Type: PrintMethod * Type of functions that will be used to print our component. This must be initialized by the initialization function of the component. */ -typedef void (*PrintMethod)(void); +typedef void (*PrintMethod)(void*); /** * Struct: Component -- cgit v1.2.3 From 45800d79fb2fd74542daeda29e2cb2467f46399a Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Tue, 12 Dec 2017 13:09:53 +0100 Subject: Reworking on the _GroupElement structure and updating doc --- include/gui/group.h | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/gui/group.h b/include/gui/group.h index 1887bf6..88fffbc 100644 --- a/include/gui/group.h +++ b/include/gui/group.h @@ -9,15 +9,14 @@ /** * Struct: _GroupElement - * Nod of the linked list that is involved in the Group behavior + * Node of the linked list that is involved in the Group behavior * * Parameters: * *component - component * *sub_component - sub component - * *next - link to the next nod + * *next - link to the next node */ typedef struct _GroupElement { - Component *component; Component *sub_component; struct _GroupElement *next; } GroupElement; @@ -37,10 +36,46 @@ typedef struct { int padding; } Group; +/** + * Function: group_print + * Print method for a group (BETA VERSION). + * + * Parameters: + * *parameter - pointer that will be casted into a Group to print + */ +void group_print(void *parameter); + +/** + * Function: group_init + * Initializes fields of a Group that must be allocated before. + * + * Parameters: + * *group - group that must be initialized + * width - width of the current group + * height - height of the current group + * x_pos - position on the x axis from the upper left corner + * y_pos - position on the y axis from the upper left corner + * padding - space between each components + */ void group_init(Group *group, int width, int height, int x_pos, int y_pos, int padding); +/** + * Function: group_free + * Frees the resources held by the group like the linked list. + * + * Parameters: + * *group - group that must be freed + */ void group_free(Group *group); +/** + * Function: group_add_component + * Adds the component at the end of the chained list held by group_head. + * + * Parameters: + * *group - group in which we add the component + * *component - component which is added to the group + */ void group_add_component(Group *group, Component *component); #endif -- cgit v1.2.3 From a05d3ad97d513c03d671059a5bae18487af23e24 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Fri, 22 Dec 2017 18:31:33 +0100 Subject: Updating doc of button, implementing button_is_selected, button_print, button_click_test (debug click handling), button_init --- include/gui/button.h | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/gui/button.h b/include/gui/button.h index fda83e9..6f91e37 100644 --- a/include/gui/button.h +++ b/include/gui/button.h @@ -5,17 +5,23 @@ * File: button.h * Buttons handling */ -#include "window.h" + +#include +#include "component.h" /** * Struct: Button * Component that can be triggered by click to execute a specific action. * * Fields: - * component - component that will acted as a button thanks to a rightful initialization. + * component - component that will acted as a button thanks to a rightful initialization + * *label - title on the button + * sizeInterligne - parameter that change padding of the button */ typedef struct { Component component; + char *label; + int sizeInterligne; } Button; /** @@ -25,8 +31,45 @@ typedef struct { * Parameters: * *button - pointer to the input button * text - label for the button + * sizeInterligne - parameter to initialize padding inside the button + * x_pos - position of the button on x axis + * y_pos - position of the button on y axis + * clickHandler - pointer of function that will be loaded inside our button to perform its purpose + */ +void button_init(Button *button, const char *text, int sizeInterligne, int x_pos, int y_pos, ClickHandler clickHandler); + +/** + * Function: button_print + * Prints the button. + * + * Parameters: + * *parameterSelf - pointer to the button + */ +void button_print(Component *parameterSelf); + +/** + * Function: button_click_test + * Debug function to test if the click is working on the current button. + * + * Parameters: + * x - position of the click on x axis + * y - position of the click on y axis + * *parameterSelf - pointer on the button that is clicked */ -void button_init(Button *button, char *text); +void button_click_test(int x, int y, Component *parameterSelf); +/** + * Function: button_is_selected + * Checks if the button is selected or not. + * + * Parameters: + * x - position in x for the check + * y - position in y for the check + * *button - pointer to the current button + * + * Returns: + * A bool from stdbool + */ +bool button_is_selected(int x, int y, Button *button); #endif -- cgit v1.2.3 From 1a4d7b44eaefd7831860b2ffdf178b00af3e1c7e Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Fri, 22 Dec 2017 18:56:31 +0100 Subject: Modifying signature of ClickHandler pointer of function, PrintMethod pointer of function, adding a boolean to lock a component --- include/gui/component.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/gui/component.h b/include/gui/component.h index 50aee63..dd101dc 100644 --- a/include/gui/component.h +++ b/include/gui/component.h @@ -1,6 +1,7 @@ #ifndef UPEM_C_COMPONENT_H #define UPEM_C_COMPONENT_H +#include /** * File: component.h * Windows and components handling. @@ -8,20 +9,19 @@ * See also: * The famous OS */ - -#include "group.h" +struct Component; /** * Type: ClickHandler * Type of functions that handle mouse's clicks. */ -typedef void (*ClickHandler)(int x_pos, int y_pos); +typedef void (*ClickHandler)(int x_pos, int y_pos, struct Component *parameter); /** * Type: PrintMethod * Type of functions that will be used to print our component. This must be initialized by the initialization function of the component. */ -typedef void (*PrintMethod)(void*); +typedef void (*PrintMethod)(struct Component *); /** * Struct: Component @@ -35,9 +35,10 @@ typedef void (*PrintMethod)(void*); * click_handler - pointer of function that is called on mouse click * print_method - pointer of function that handle the component's print */ -typedef struct { +typedef struct Component { int width, height; int x_pos, y_pos; + bool activated; ClickHandler click_handler; PrintMethod print_method; } Component; -- 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 --- include/gui/group.h | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/gui/group.h b/include/gui/group.h index 88fffbc..2a02ee4 100644 --- a/include/gui/group.h +++ b/include/gui/group.h @@ -28,22 +28,33 @@ typedef struct _GroupElement { * Parameters: * component - Component used for the Group to catch clicks and handle print to delegate to the components contented in it * *group_head - pointer to the head of the list that regroup all the components contained inside of the group - * padding - padding for all components + * margin - margin for all components */ typedef struct { Component component; GroupElement *group_head; - int padding; + int margin; } Group; /** * Function: group_print - * Print method for a group (BETA VERSION). + * Print method for a group that will print all components contained in. * * Parameters: - * *parameter - pointer that will be casted into a Group to print + * *parameterSelf - pointer that will be casted into a Group to print */ -void group_print(void *parameter); +void group_print(Component *parameterSelf); + +/** + * Function: group_click_handler + * Delegates the click handling to the component contained inside. + * + * Parameters: + * x_pos - position of the mouse on x axis + * y_pos - position of the mouse on y axis + * *parameterSelf - pointer that will be casted into a Group to print + */ +void group_click_handler(int x_pos, int y_pos, Component *parameterSelf); /** * Function: group_init @@ -55,9 +66,9 @@ void group_print(void *parameter); * height - height of the current group * x_pos - position on the x axis from the upper left corner * y_pos - position on the y axis from the upper left corner - * padding - space between each components + * margin - space between each components */ -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); /** * Function: group_free @@ -78,4 +89,5 @@ void group_free(Group *group); */ void group_add_component(Group *group, Component *component); + #endif -- cgit v1.2.3 From 629928d374812c69392879a6c4aca5d6479c33cb Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Fri, 22 Dec 2017 19:12:49 +0100 Subject: Including blender/canvas.h for type resolution in pictureframe.h --- include/gui/pictureframe.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/gui/pictureframe.h b/include/gui/pictureframe.h index 59aaf3b..f194feb 100644 --- a/include/gui/pictureframe.h +++ b/include/gui/pictureframe.h @@ -1,6 +1,8 @@ #ifndef UPEM_MORPHING_PITUREFRAME #define UPEM_MORPHING_PITUREFRAME +#include + /** * File: pictureframe.h */ -- cgit v1.2.3 From e84ae1203b8cd7a51d93ec77a5a2663e7496eef5 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Fri, 22 Dec 2017 19:14:55 +0100 Subject: Adding asserts, modifying signatures of function for more precise type, implementing window_add functions, window_print functions --- include/gui/window.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/gui/window.h b/include/gui/window.h index 3212a49..329997b 100644 --- a/include/gui/window.h +++ b/include/gui/window.h @@ -11,6 +11,8 @@ #include "group.h" #include "component.h" +#include "button.h" +#include "pictureframe.h" /** * Struct: Window @@ -57,9 +59,9 @@ void window_free(Window *window); * * Parameters: * *window - pointer to the input window - * *component - pointer to the input component + * *button - pointer to the input button */ -void window_add_button(Window *window, Component *component); +void window_add_button(Window *window, Button *button); /** * Function: window_add_pictureframe @@ -67,9 +69,9 @@ void window_add_button(Window *window, Component *component); * * Parameters: * *window - pointer to the input window - * *component - pointer to the input component + * *pictureFrame - pointer to the input picture frame */ -void window_add_pictureframe(Window *window, Component *component); +void window_add_pictureframe(Window *window, PictureFrame *pictureFrame); /** * Function: window_create -- cgit v1.2.3 From 46fecbfedfc61658caeb721565fd36f49c0d3db9 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Wed, 27 Dec 2017 18:31:16 +0100 Subject: Updating documentation of PictureFrame. Defining structures, types, methods signatures --- include/gui/pictureframe.h | 70 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/gui/pictureframe.h b/include/gui/pictureframe.h index f194feb..de9ae1c 100644 --- a/include/gui/pictureframe.h +++ b/include/gui/pictureframe.h @@ -2,23 +2,83 @@ #define UPEM_MORPHING_PITUREFRAME #include +#include /** * File: pictureframe.h */ - +/** + * Type: CartesianMappingDivision + * Type of functions needed to split CartesianMapping and keep only the CartesianVector needed, related to the type of PictureFrame involved + */ +typedef CartesianVector (*CartesianMappingDivision)(const CartesianMapping *cartesianMapping); +/** + * Struct: PictureFrame + * Represents a component to print pictures. + * + * Fields: + * component - inherent component management of the PictureFrame + * morphing - abstract coordinate transform + * canvas - image that will be printed + * cartesianMappingDivision - pointer of function that gives the role of the current PictureFrame to retrieve the right CartesianVector related to its usage + */ typedef struct { Component component; + Morphing *morphing; + Canvas *canvas; + CartesianMappingDivision cartesianMappingDivision; } PictureFrame; -void pictureframe_init(PictureFrame *pictureFrame, int length); +/** + * Function: pictureframe_origin_split + * Splits the CartesianMapping to get the CartesianVector related to the origin PictureFrame. + * + * Parameters: + * *cartesianMapping - CartesianMapping that contains the origin and target CartesianVector needed to be split + */ +CartesianVector pictureframe_origin_split(const CartesianMapping *cartesianMapping); + +/** + * Function: pictureframe_target_split + * Splits the CartesianMapping to get the CartesianVector related to the target PictureFrame. + * + * Parameters: + * *cartesianMapping - CartesianMapping that contains the origin and target CartesianVector needed to be split + */ +CartesianVector pictureframe_target_split(const CartesianMapping *cartesianMapping); + +void pictureframe_init(PictureFrame *pictureFrame, int width, int height, int x_pos, int y_pos, CartesianMappingDivision cartesianMappingDivision); void pictureframe_free(PictureFrame *pictureFrame); -void pictureframe_draw_canvas(PictureFrame *pictureFrame, Canvas *canvas); +/** + * Function: pictureframe_draw_canvas + * Draws the contained Canvas of the PictureFrame. + * + * Parameters: + * *pictureFrame - current PictureFrame containing the Canvas to print. + */ +void pictureframe_draw_canvas(PictureFrame *pictureFrame); -void pictureframe_draw_triangulation(PictureFrame *pictureFrame, void *triangulation); +/** + * Function: pictureframe_print + * Prints the PictureFrame (The Canvas involved, plus the triangles and points of the Morphing) + * + * Parameters: + * *parameterSelf - pointer that will be casted into a PictureFrame to be printed + */ +void pictureframe_print(Component *parameterSelf); + +/** + * Function: pictureframe_click_handler + * Adds a point on the coordinate of the picture that the mouse is pointing. + * + * Parameters: + * x_pos - coordinate on x axis of the mouse + * y_pos - coordinate on y axis of the mouse + * *parameterSelf - pointer that will be casted into a PictureFrame + */ +void pictureframe_click_handler(int x_pos, int y_pos, Component *parameterSelf); -void pictureframe_draw_point(PictureFrame *pictureFrame, int x_pos, int y_pos); #endif -- cgit v1.2.3 From aaf57e5ee1e0cf74afdbdf56293f1afd7e79e6b0 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Thu, 28 Dec 2017 16:22:43 +0100 Subject: Reworking signatures of pictureframe function, beginning of implementation, debug tests --- include/gui/pictureframe.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/gui/pictureframe.h b/include/gui/pictureframe.h index de9ae1c..1f5407c 100644 --- a/include/gui/pictureframe.h +++ b/include/gui/pictureframe.h @@ -3,6 +3,7 @@ #include #include +#include "component.h" /** * File: pictureframe.h @@ -12,6 +13,7 @@ * Type of functions needed to split CartesianMapping and keep only the CartesianVector needed, related to the type of PictureFrame involved */ typedef CartesianVector (*CartesianMappingDivision)(const CartesianMapping *cartesianMapping); + /** * Struct: PictureFrame * Represents a component to print pictures. @@ -47,7 +49,8 @@ CartesianVector pictureframe_origin_split(const CartesianMapping *cartesianMappi */ CartesianVector pictureframe_target_split(const CartesianMapping *cartesianMapping); -void pictureframe_init(PictureFrame *pictureFrame, int width, int height, int x_pos, int y_pos, CartesianMappingDivision cartesianMappingDivision); +void pictureframe_init(PictureFrame *pictureFrame, int width, int height, int x_pos, int y_pos, + CartesianMappingDivision cartesianMappingDivision, Morphing *morphing, Canvas *canvas); void pictureframe_free(PictureFrame *pictureFrame); -- 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 --- include/gui/button.h | 3 ++- include/gui/component.h | 6 ++++-- include/gui/pictureframe.h | 38 +++++++++++++++++++++++++++++++++----- 3 files changed, 39 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/gui/button.h b/include/gui/button.h index 6f91e37..26d7970 100644 --- a/include/gui/button.h +++ b/include/gui/button.h @@ -1,6 +1,5 @@ #ifndef UPEM_MORPHING_BUTTON #define UPEM_MORPHING_BUTTON - /** * File: button.h * Buttons handling @@ -58,6 +57,7 @@ void button_print(Component *parameterSelf); */ void button_click_test(int x, int y, Component *parameterSelf); +void button_click_add_constraint(int x, int y, Component *parameterSelf); /** * Function: button_is_selected * Checks if the button is selected or not. @@ -70,6 +70,7 @@ void button_click_test(int x, int y, Component *parameterSelf); * Returns: * A bool from stdbool */ + bool button_is_selected(int x, int y, Button *button); #endif diff --git a/include/gui/component.h b/include/gui/component.h index dd101dc..0e8f437 100644 --- a/include/gui/component.h +++ b/include/gui/component.h @@ -1,7 +1,10 @@ #ifndef UPEM_C_COMPONENT_H #define UPEM_C_COMPONENT_H +typedef enum { + WAITING_BUTTON, INSERT_ORIGIN, INSERT_TARGET,PRINTING +} Mode; -#include +extern Mode mode; /** * File: component.h * Windows and components handling. @@ -38,7 +41,6 @@ typedef void (*PrintMethod)(struct Component *); typedef struct Component { int width, height; int x_pos, y_pos; - bool activated; ClickHandler click_handler; PrintMethod print_method; } Component; diff --git a/include/gui/pictureframe.h b/include/gui/pictureframe.h index 1f5407c..f06a530 100644 --- a/include/gui/pictureframe.h +++ b/include/gui/pictureframe.h @@ -1,13 +1,14 @@ #ifndef UPEM_MORPHING_PITUREFRAME #define UPEM_MORPHING_PITUREFRAME -#include #include +#include #include "component.h" - /** * File: pictureframe.h */ + +CartesianVector savedPoint; /** * Type: CartesianMappingDivision * Type of functions needed to split CartesianMapping and keep only the CartesianVector needed, related to the type of PictureFrame involved @@ -49,8 +50,24 @@ CartesianVector pictureframe_origin_split(const CartesianMapping *cartesianMappi */ CartesianVector pictureframe_target_split(const CartesianMapping *cartesianMapping); +bool pictureframe_is_selected(int x, int y, PictureFrame *pictureFrame); + +/** + * Function: pictureframe_conversion_to_origin + * Returns the relative coordinate on the picture corresponding to the input values + * + * Parameters: + * x - value on x axis from the origin of the window to convert + * y - value on y axis from the origin of the window to convert + * *pictureFrame - pointer to the reference pictureframe that will give his relative coordinates + */ +CartesianVector pictureframe_conversion_to_origin(int x, int y, PictureFrame *pictureFrame); + +CartesianVector pictureframe_conversion_to_picture(int x, int y, PictureFrame *pictureFrame); + void pictureframe_init(PictureFrame *pictureFrame, int width, int height, int x_pos, int y_pos, - CartesianMappingDivision cartesianMappingDivision, Morphing *morphing, Canvas *canvas); + CartesianMappingDivision cartesianMappingDivision, Morphing *morphing, Canvas *canvas, + ClickHandler clickHandler); void pictureframe_free(PictureFrame *pictureFrame); @@ -73,7 +90,18 @@ void pictureframe_draw_canvas(PictureFrame *pictureFrame); void pictureframe_print(Component *parameterSelf); /** - * Function: pictureframe_click_handler + * Function: pictureframe_click_handler_origin + * Adds a point on the coordinate of the picture that the mouse is pointing. + * + * Parameters: + * x_pos - coordinate on x axis of the mouse + * y_pos - coordinate on y axis of the mouse + * *parameterSelf - pointer that will be casted into a PictureFrame + */ +void pictureframe_click_handler_origin(int x_pos, int y_pos, Component *parameterSelf); + +/** + * Function: pictureframe_click_handler_target * Adds a point on the coordinate of the picture that the mouse is pointing. * * Parameters: @@ -81,7 +109,7 @@ void pictureframe_print(Component *parameterSelf); * y_pos - coordinate on y axis of the mouse * *parameterSelf - pointer that will be casted into a PictureFrame */ -void pictureframe_click_handler(int x_pos, int y_pos, Component *parameterSelf); +void pictureframe_click_handler_target(int x_pos, int y_pos, Component *parameterSelf); #endif -- cgit v1.2.3 From 4b30bfee527edd88e035b93c1230ddf2101291f6 Mon Sep 17 00:00:00 2001 From: pacien Date: Fri, 29 Dec 2017 03:30:26 +0100 Subject: Use 64 bits integers (avoiding overflows when computing the Delaunay criteria) Signed-off-by: pacien --- include/common/geom.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/common/geom.h b/include/common/geom.h index 334e95c..66e6c08 100644 --- a/include/common/geom.h +++ b/include/common/geom.h @@ -12,7 +12,7 @@ * Type: IntVector * An abstract 1-D vector. */ -typedef int32_t IntVector; +typedef int64_t IntVector; /** * Type: RealVector -- cgit v1.2.3 From 41da8b54ed619ea869ca286cd8ec02e105e21c19 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Sun, 31 Dec 2017 15:00:23 +0100 Subject: Implementing all kinds of buttons. Rendering to fix --- include/gui/button.h | 14 ++++++++++++++ include/gui/component.h | 4 +++- include/gui/textview.h | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/gui/button.h b/include/gui/button.h index 26d7970..41008c1 100644 --- a/include/gui/button.h +++ b/include/gui/button.h @@ -58,6 +58,20 @@ void button_print(Component *parameterSelf); void button_click_test(int x, int y, Component *parameterSelf); void button_click_add_constraint(int x, int y, Component *parameterSelf); + +void button_click_show_hide(int x, int y, Component *parameterSelf); + +void button_click_exit(int x, int y, Component *parameterSelf); + +void button_click_none(int x, int y, Component *parameterSelf); + +void button_click_more_frame(int x, int y, Component *parameterSelf); + +void button_click_less_frame(int x, int y, Component *parameterSelf); + +void button_click_rendering(int x, int y, Component *parameterSelf); + + /** * Function: button_is_selected * Checks if the button is selected or not. diff --git a/include/gui/component.h b/include/gui/component.h index 0e8f437..0275d45 100644 --- a/include/gui/component.h +++ b/include/gui/component.h @@ -1,10 +1,12 @@ #ifndef UPEM_C_COMPONENT_H #define UPEM_C_COMPONENT_H typedef enum { - WAITING_BUTTON, INSERT_ORIGIN, INSERT_TARGET,PRINTING + WAITING_BUTTON_SHOW, WAITING_BUTTON_HIDE, INSERT_ORIGIN, INSERT_TARGET, PRINTING, EXITING, PRINTING_BUTTONS, RENDERING } Mode; extern Mode mode; +extern int frame; +extern char labelFrame[20]; /** * File: component.h * Windows and components handling. diff --git a/include/gui/textview.h b/include/gui/textview.h index 7a07eb3..7414336 100644 --- a/include/gui/textview.h +++ b/include/gui/textview.h @@ -1,6 +1,8 @@ #ifndef UPEM_MORPHING_TEXTVIEW #define UPEM_MORPHING_TEXTVIEW +#include "component.h" + /** * File: textview.h */ -- cgit v1.2.3