diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/gui/button.h | 63 | ||||
-rw-r--r-- | include/gui/component.h | 46 | ||||
-rw-r--r-- | include/gui/group.h | 78 | ||||
-rw-r--r-- | include/gui/pictureframe.h | 73 | ||||
-rw-r--r-- | include/gui/window.h | 93 |
5 files changed, 337 insertions, 16 deletions
diff --git a/include/gui/button.h b/include/gui/button.h index 62f75a3..6f91e37 100644 --- a/include/gui/button.h +++ b/include/gui/button.h | |||
@@ -3,14 +3,73 @@ | |||
3 | 3 | ||
4 | /** | 4 | /** |
5 | * File: button.h | 5 | * File: button.h |
6 | * Buttons handling | ||
6 | */ | 7 | */ |
7 | 8 | ||
9 | #include <stdbool.h> | ||
10 | #include "component.h" | ||
11 | |||
12 | /** | ||
13 | * Struct: Button | ||
14 | * Component that can be triggered by click to execute a specific action. | ||
15 | * | ||
16 | * Fields: | ||
17 | * component - component that will acted as a button thanks to a rightful initialization | ||
18 | * *label - title on the button | ||
19 | * sizeInterligne - parameter that change padding of the button | ||
20 | */ | ||
8 | typedef struct { | 21 | typedef struct { |
9 | Component component; | 22 | Component component; |
23 | char *label; | ||
24 | int sizeInterligne; | ||
10 | } Button; | 25 | } Button; |
11 | 26 | ||
12 | void button_init(Button *button, char *text); | 27 | /** |
28 | * Function: button_init | ||
29 | * Initializes the button. | ||
30 | * | ||
31 | * Parameters: | ||
32 | * *button - pointer to the input button | ||
33 | * text - label for the button | ||
34 | * sizeInterligne - parameter to initialize padding inside the button | ||
35 | * x_pos - position of the button on x axis | ||
36 | * y_pos - position of the button on y axis | ||
37 | * clickHandler - pointer of function that will be loaded inside our button to perform its purpose | ||
38 | */ | ||
39 | void button_init(Button *button, const char *text, int sizeInterligne, int x_pos, int y_pos, ClickHandler clickHandler); | ||
13 | 40 | ||
14 | void button_free(Button *button); | 41 | /** |
42 | * Function: button_print | ||
43 | * Prints the button. | ||
44 | * | ||
45 | * Parameters: | ||
46 | * *parameterSelf - pointer to the button | ||
47 | */ | ||
48 | void button_print(Component *parameterSelf); | ||
49 | |||
50 | /** | ||
51 | * Function: button_click_test | ||
52 | * Debug function to test if the click is working on the current button. | ||
53 | * | ||
54 | * Parameters: | ||
55 | * x - position of the click on x axis | ||
56 | * y - position of the click on y axis | ||
57 | * *parameterSelf - pointer on the button that is clicked | ||
58 | */ | ||
59 | void button_click_test(int x, int y, Component *parameterSelf); | ||
60 | |||
61 | /** | ||
62 | * Function: button_is_selected | ||
63 | * Checks if the button is selected or not. | ||
64 | * | ||
65 | * Parameters: | ||
66 | * x - position in x for the check | ||
67 | * y - position in y for the check | ||
68 | * *button - pointer to the current button | ||
69 | * | ||
70 | * Returns: | ||
71 | * A bool from stdbool | ||
72 | */ | ||
73 | bool button_is_selected(int x, int y, Button *button); | ||
15 | 74 | ||
16 | #endif | 75 | #endif |
diff --git a/include/gui/component.h b/include/gui/component.h new file mode 100644 index 0000000..dd101dc --- /dev/null +++ b/include/gui/component.h | |||
@@ -0,0 +1,46 @@ | |||
1 | #ifndef UPEM_C_COMPONENT_H | ||
2 | #define UPEM_C_COMPONENT_H | ||
3 | |||
4 | #include <stdbool.h> | ||
5 | /** | ||
6 | * File: component.h | ||
7 | * Windows and components handling. | ||
8 | * | ||
9 | * See also: | ||
10 | * The famous OS | ||
11 | */ | ||
12 | struct Component; | ||
13 | |||
14 | /** | ||
15 | * Type: ClickHandler | ||
16 | * Type of functions that handle mouse's clicks. | ||
17 | */ | ||
18 | typedef void (*ClickHandler)(int x_pos, int y_pos, struct Component *parameter); | ||
19 | |||
20 | /** | ||
21 | * Type: PrintMethod | ||
22 | * Type of functions that will be used to print our component. This must be initialized by the initialization function of the component. | ||
23 | */ | ||
24 | typedef void (*PrintMethod)(struct Component *); | ||
25 | |||
26 | /** | ||
27 | * Struct: Component | ||
28 | * Represents an abstract module handling clicks and a way to be print on the screen. | ||
29 | * | ||
30 | * Fields: | ||
31 | * width - width of the component | ||
32 | * height - height of the component | ||
33 | * x_pos - position on the x axis from the origin meant to be placed in top left | ||
34 | * y_pos - position on the y axis from the origin meant to be placed in top left | ||
35 | * click_handler - pointer of function that is called on mouse click | ||
36 | * print_method - pointer of function that handle the component's print | ||
37 | */ | ||
38 | typedef struct Component { | ||
39 | int width, height; | ||
40 | int x_pos, y_pos; | ||
41 | bool activated; | ||
42 | ClickHandler click_handler; | ||
43 | PrintMethod print_method; | ||
44 | } Component; | ||
45 | |||
46 | #endif //UPEM_C_COMPONENT_H | ||
diff --git a/include/gui/group.h b/include/gui/group.h index 6914d55..2a02ee4 100644 --- a/include/gui/group.h +++ b/include/gui/group.h | |||
@@ -3,17 +3,91 @@ | |||
3 | 3 | ||
4 | /** | 4 | /** |
5 | * File: group.h | 5 | * File: group.h |
6 | * Group of components | ||
6 | */ | 7 | */ |
8 | #include "component.h" | ||
7 | 9 | ||
10 | /** | ||
11 | * Struct: _GroupElement | ||
12 | * Node of the linked list that is involved in the Group behavior | ||
13 | * | ||
14 | * Parameters: | ||
15 | * *component - component | ||
16 | * *sub_component - sub component | ||
17 | * *next - link to the next node | ||
18 | */ | ||
19 | typedef struct _GroupElement { | ||
20 | Component *sub_component; | ||
21 | struct _GroupElement *next; | ||
22 | } GroupElement; | ||
23 | |||
24 | /** | ||
25 | * Struct: Group | ||
26 | * Group representation | ||
27 | * | ||
28 | * Parameters: | ||
29 | * component - Component used for the Group to catch clicks and handle print to delegate to the components contented in it | ||
30 | * *group_head - pointer to the head of the list that regroup all the components contained inside of the group | ||
31 | * margin - margin for all components | ||
32 | */ | ||
8 | typedef struct { | 33 | typedef struct { |
9 | Component component; | 34 | Component component; |
10 | Component *sub_components; | 35 | GroupElement *group_head; |
36 | int margin; | ||
11 | } Group; | 37 | } Group; |
12 | 38 | ||
13 | void group_init(Group *group, int padding); | 39 | /** |
40 | * Function: group_print | ||
41 | * Print method for a group that will print all components contained in. | ||
42 | * | ||
43 | * Parameters: | ||
44 | * *parameterSelf - pointer that will be casted into a Group to print | ||
45 | */ | ||
46 | void group_print(Component *parameterSelf); | ||
47 | |||
48 | /** | ||
49 | * Function: group_click_handler | ||
50 | * Delegates the click handling to the component contained inside. | ||
51 | * | ||
52 | * Parameters: | ||
53 | * x_pos - position of the mouse on x axis | ||
54 | * y_pos - position of the mouse on y axis | ||
55 | * *parameterSelf - pointer that will be casted into a Group to print | ||
56 | */ | ||
57 | void group_click_handler(int x_pos, int y_pos, Component *parameterSelf); | ||
58 | |||
59 | /** | ||
60 | * Function: group_init | ||
61 | * Initializes fields of a Group that must be allocated before. | ||
62 | * | ||
63 | * Parameters: | ||
64 | * *group - group that must be initialized | ||
65 | * width - width of the current group | ||
66 | * height - height of the current group | ||
67 | * x_pos - position on the x axis from the upper left corner | ||
68 | * y_pos - position on the y axis from the upper left corner | ||
69 | * margin - space between each components | ||
70 | */ | ||
71 | void group_init(Group *group, int width, int height, int x_pos, int y_pos, int margin); | ||
14 | 72 | ||
73 | /** | ||
74 | * Function: group_free | ||
75 | * Frees the resources held by the group like the linked list. | ||
76 | * | ||
77 | * Parameters: | ||
78 | * *group - group that must be freed | ||
79 | */ | ||
15 | void group_free(Group *group); | 80 | void group_free(Group *group); |
16 | 81 | ||
82 | /** | ||
83 | * Function: group_add_component | ||
84 | * Adds the component at the end of the chained list held by group_head. | ||
85 | * | ||
86 | * Parameters: | ||
87 | * *group - group in which we add the component | ||
88 | * *component - component which is added to the group | ||
89 | */ | ||
17 | void group_add_component(Group *group, Component *component); | 90 | void group_add_component(Group *group, Component *component); |
18 | 91 | ||
92 | |||
19 | #endif | 93 | #endif |
diff --git a/include/gui/pictureframe.h b/include/gui/pictureframe.h index 59aaf3b..1f5407c 100644 --- a/include/gui/pictureframe.h +++ b/include/gui/pictureframe.h | |||
@@ -1,22 +1,87 @@ | |||
1 | #ifndef UPEM_MORPHING_PITUREFRAME | 1 | #ifndef UPEM_MORPHING_PITUREFRAME |
2 | #define UPEM_MORPHING_PITUREFRAME | 2 | #define UPEM_MORPHING_PITUREFRAME |
3 | 3 | ||
4 | #include <blender/canvas.h> | ||
5 | #include <morpher/morphing.h> | ||
6 | #include "component.h" | ||
7 | |||
4 | /** | 8 | /** |
5 | * File: pictureframe.h | 9 | * File: pictureframe.h |
6 | */ | 10 | */ |
11 | /** | ||
12 | * Type: CartesianMappingDivision | ||
13 | * Type of functions needed to split CartesianMapping and keep only the CartesianVector needed, related to the type of PictureFrame involved | ||
14 | */ | ||
15 | typedef CartesianVector (*CartesianMappingDivision)(const CartesianMapping *cartesianMapping); |