diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/gui/button.h | 90 | ||||
-rw-r--r-- | include/gui/component.h | 13 | ||||
-rw-r--r-- | include/gui/gui.h | 53 | ||||
-rw-r--r-- | include/gui/pictureframe.h | 52 | ||||
-rw-r--r-- | include/gui/window.h | 62 |
5 files changed, 189 insertions, 81 deletions
diff --git a/include/gui/button.h b/include/gui/button.h index 41008c1..b5908cb 100644 --- a/include/gui/button.h +++ b/include/gui/button.h | |||
@@ -5,7 +5,6 @@ | |||
5 | * Buttons handling | 5 | * Buttons handling |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include <stdbool.h> | ||
9 | #include "component.h" | 8 | #include "component.h" |
10 | 9 | ||
11 | /** | 10 | /** |
@@ -24,67 +23,108 @@ typedef struct { | |||
24 | } Button; | 23 | } Button; |
25 | 24 | ||
26 | /** | 25 | /** |
27 | * Function: button_init | 26 | * Function: button_create |
28 | * Initializes the button. | 27 | * Allocates and initializes the button. |
29 | * | 28 | * |
30 | * Parameters: | 29 | * Parameters: |
31 | * *button - pointer to the input button | ||
32 | * text - label for the button | 30 | * text - label for the button |
33 | * sizeInterligne - parameter to initialize padding inside the button | 31 | * sizeInterligne - parameter to initialize padding inside the button |
34 | * x_pos - position of the button on x axis | 32 | * x_pos - position of the button on x axis |
35 | * y_pos - position of the button on y axis | 33 | * y_pos - position of the button on y axis |
36 | * clickHandler - pointer of function that will be loaded inside our button to perform its purpose | 34 | * clickHandler - pointer of function that will be loaded inside our button to perform its purpose |
35 | * | ||
36 | * Returns: | ||
37 | * A pointer of Button | ||
37 | */ | 38 | */ |
38 | void button_init(Button *button, const char *text, int sizeInterligne, int x_pos, int y_pos, ClickHandler clickHandler); | 39 | Button * |
40 | button_create(const char *text, int sizeInterligne, int x_pos, int y_pos, ClickHandler clickHandler); | ||
39 | 41 | ||
40 | /** | 42 | /** |
41 | * Function: button_print | 43 | * Function: button_destroy |
42 | * Prints the button. | 44 | * Frees the resources for the Button |
43 | * | 45 | * |
44 | * Parameters: | 46 | * Parameters: |
45 | * *parameterSelf - pointer to the button | 47 | * *button - pointer to the button |
46 | */ | 48 | */ |
47 | void button_print(Component *parameterSelf); | 49 | void button_destroy(Button *button); |
48 | 50 | ||
49 | /** | 51 | /** |
50 | * Function: button_click_test | 52 | * Function: button_click_add_constraint |
51 | * Debug function to test if the click is working on the current button. | 53 | * Allows to add a constraint point in order on the first picture, then on the second. |
52 | * | 54 | * |
53 | * Parameters: | 55 | * Parameters: |
54 | * x - position of the click on x axis | 56 | * x - position of the click on x axis |
55 | * y - position of the click on y axis | 57 | * y - position of the click on y axis |
56 | * *parameterSelf - pointer on the button that is clicked | 58 | * *parameterSelf - pointer on the button that is clicked |
57 | */ | 59 | */ |
58 | void button_click_test(int x, int y, Component *parameterSelf); | ||
59 | |||
60 | void button_click_add_constraint(int x, int y, Component *parameterSelf); | 60 | void button_click_add_constraint(int x, int y, Component *parameterSelf); |
61 | 61 | ||
62 | /** | ||
63 | * Function: button_click_show_hide | ||
64 | * Allows to show and hide the constraint points and triangles. | ||
65 | * | ||
66 | * Parameters: | ||
67 | * x - position of the click on x axis | ||
68 | * y - position of the click on y axis | ||
69 | * *parameterSelf - pointer on the button that is clicked | ||
70 | */ | ||
62 | void button_click_show_hide(int x, int y, Component *parameterSelf); | 71 | void button_click_show_hide(int x, int y, Component *parameterSelf); |
63 | 72 | ||
73 | /** | ||
74 | * Function: button_click_exit | ||
75 | * Quit the program. | ||
76 | * | ||
77 | * Parameters: | ||
78 | * x - position of the click on x axis | ||
79 | * y - position of the click on y axis | ||
80 | * *parameterSelf - pointer on the button that is clicked. | ||
81 | */ | ||
64 | void button_click_exit(int x, int y, Component *parameterSelf); | 82 | void button_click_exit(int x, int y, Component *parameterSelf); |
65 | 83 | ||
84 | /** | ||
85 | * Function: button_click_none | ||
86 | * Allows the button to do nothing on click. | ||
87 | * | ||
88 | * Parameters: | ||
89 | * x - position of the click on x axis | ||
90 | * y - position of the click on y axis | ||
91 | * *parameterSelf - pointer on the button that is clicked | ||
92 | */ | ||
66 | void button_click_none(int x, int y, Component *parameterSelf); | 93 | void button_click_none(int x, int y, Component *parameterSelf); |
67 | 94 | ||
95 | |||
96 | /** | ||
97 | * Function: button_click_more_frame | ||
98 | * Multiplies by two the number of frames to create when rendering. | ||
99 | * | ||
100 | * Parameters: | ||
101 | * x - position of the click on x axis | ||
102 | * y - position of the click on y axis | ||
103 | * *parameterSelf - pointer on the button that is clicked | ||
104 | */ | ||
68 | void button_click_more_frame(int x, int y, Component *parameterSelf); | 105 | void button_click_more_frame(int x, int y, Component *parameterSelf); |
69 | 106 | ||
107 | /** | ||
108 | * Function: button_click_less_frame | ||
109 | * Divides by two the number of frames to create when rendering. | ||
110 | * | ||
111 | * Parameters: | ||
112 | * x - position of the click on x axis | ||
113 | * y - position of the click on y axis | ||
114 | * *parameterSelf - pointer on the button that is clicked | ||
115 | */ | ||
70 | void button_click_less_frame(int x, int y, Component *parameterSelf); | 116 | void button_click_less_frame(int x, int y, Component *parameterSelf); |
71 | 117 | ||
72 | void button_click_rendering(int x, int y, Component *parameterSelf); | ||
73 | |||
74 | |||
75 | /** | 118 | /** |
76 | * Function: button_is_selected | 119 | * Function: button_click_rendering |
77 | * Checks if the button is selected or not. | 120 | * Launches the rendering of the morphing |
78 | * | 121 | * |
79 | * Parameters: | 122 | * Parameters: |
80 | * x - position in x for the check | 123 | * x - position of the click on x axis |
81 | * y - position in y for the check | 124 | * y - position of the click on y axis |
82 | * *button - pointer to the current button | 125 | * *parameterSelf - pointer on the button that is clicked |
83 | * | ||
84 | * Returns: | ||
85 | * A bool from stdbool | ||
86 | */ | 126 | */ |
127 | void button_click_rendering(int x, int y, Component *parameterSelf); | ||
87 | 128 | ||
88 | bool button_is_selected(int x, int y, Button *button); | ||
89 | 129 | ||
90 | #endif | 130 | #endif |
diff --git a/include/gui/component.h b/include/gui/component.h index 0275d45..9700dfe 100644 --- a/include/gui/component.h +++ b/include/gui/component.h | |||
@@ -1,5 +1,18 @@ | |||
1 | #ifndef UPEM_C_COMPONENT_H | 1 | #ifndef UPEM_C_COMPONENT_H |
2 | #define UPEM_C_COMPONENT_H | 2 | #define UPEM_C_COMPONENT_H |
3 | |||
4 | /** | ||
5 | * Enum: Mode | ||
6 | * | ||
7 | * WAITING_BUTTON_SHOW - Waits a click on buttons to perform actions and paints the constraint points on the GUI | ||
8 | * WAITING_BUTTON_HIDE - Waits a click on buttons to perform actions and does not print the constraint points on the GUI | ||
9 | * INSERT_ORIGIN - Waits a click on the origin pictureframe and lock other components | ||
10 | * INSERT_TARGET - Waits a click on the target pictureframe and lock other components | ||
11 | * PRINTING - Force the application to paint the pictureframes | ||
12 | * EXITING - Exits the programme | ||
13 | * PRINTING_BUTTONS - paints the buttons | ||
14 | * RENDERING - launches the rendering mode | ||
15 | */ | ||
3 | typedef enum { | 16 | typedef enum { |
4 | WAITING_BUTTON_SHOW, WAITING_BUTTON_HIDE, INSERT_ORIGIN, INSERT_TARGET, PRINTING, EXITING, PRINTING_BUTTONS, RENDERING | 17 | WAITING_BUTTON_SHOW, WAITING_BUTTON_HIDE, INSERT_ORIGIN, INSERT_TARGET, PRINTING, EXITING, PRINTING_BUTTONS, RENDERING |
5 | } Mode; | 18 | } Mode; |
diff --git a/include/gui/gui.h b/include/gui/gui.h index daaf8de..10f59e8 100644 --- a/include/gui/gui.h +++ b/include/gui/gui.h | |||
@@ -1,11 +1,32 @@ | |||
1 | #ifndef UPEM_MORPHING_GUI | 1 | #ifndef UPEM_MORPHING_GUI |
2 | #define UPEM_MORPHING_GUI | 2 | #define UPEM_MORPHING_GUI |
3 | 3 | ||
4 | #include <gui/window.h> | 4 | #include "gui/window.h" |
5 | |||
5 | /** | 6 | /** |
6 | * File: gui.h | 7 | * File: gui.h |
7 | */ | 8 | */ |
8 | 9 | ||
10 | |||
11 | /** | ||
12 | * Struct: GUI | ||
13 | * Supports all the parts of the GUI | ||
14 | * | ||
15 | * Fields: | ||
16 | * *window - pointer to the Window | ||
17 | * *button1 - pointer to the button 1 | ||
18 | * *button2 - pointer to the button 2 | ||
19 | * *button3 - pointer to the button 3 | ||
20 | * *button4 - pointer to the button 4 | ||
21 | * *button5 - pointer to the button 5 | ||
22 | * *button6 - pointer to the button 6 | ||
23 | * *button7 - pointer to the button 7 | ||
24 | * *pictureFrame1 - pointer to the picture frame 1 | ||
25 | * *pictureFrame2 - pointer to the picture frame 2 | ||
26 | * *canvasSrc - pointer to the canvas 1 | ||
27 | * *canvasTrg - pointer to the canvas 2 | ||
28 | * *morphing - pointer to the current morphing | ||
29 | */ | ||
9 | typedef struct { | 30 | typedef struct { |
10 | Window *window; | 31 | Window *window; |
11 | Button *button1; | 32 | Button *button1; |
@@ -20,20 +41,36 @@ typedef struct { | |||
20 | Canvas *canvasSrc; | 41 | Canvas *canvasSrc; |
21 | Canvas *canvasTrg; | 42 | Canvas *canvasTrg; |
22 | Morphing *morphing; | 43 | Morphing *morphing; |
23 | MLV_Keyboard_button keyboardButton; | ||
24 | MLV_Keyboard_modifier keyboardModifier; | ||
25 | int unicode; | ||
26 | int mouse_x; | ||
27 | int mouse_y; | ||
28 | } GUI; | 44 | } GUI; |
29 | 45 | ||
46 | /** | ||
47 | * Function: gui_create | ||
48 | * | ||
49 | * | ||
50 | * Parameters: | ||
51 | * *fpath1 - path to the first picture | ||
52 | * *fpath2 - path to the second picture | ||
53 | * | ||