diff options
author | Adam NAILI | 2018-01-03 19:40:51 +0100 |
---|---|---|
committer | Adam NAILI | 2018-01-03 19:40:51 +0100 |
commit | 2f3d8ebc9b5e10e56bed5da316f5ef098dda0997 (patch) | |
tree | e2df4b6eaf81cb72f6fef75f6cf7324b0e671f23 | |
parent | 54dac24c8f7be833124a90bafdca78810fc0d96a (diff) | |
download | morpher-2f3d8ebc9b5e10e56bed5da316f5ef098dda0997.tar.gz |
Updating documentation, cleaning includes, updating report
-rw-r--r-- | doc/project-report.md | 16 | ||||
-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 | ||||
-rw-r--r-- | src/gui/button.c | 44 | ||||
-rw-r--r-- | src/gui/gui.c | 97 | ||||
-rw-r--r-- | src/gui/pictureframe.c | 76 | ||||
-rw-r--r-- | src/gui/window.c | 35 | ||||
-rw-r--r-- | src/main.c | 8 | ||||
-rw-r--r-- | test/gui/button.c | 2 | ||||
-rw-r--r-- | test/gui/group.c | 2 | ||||
-rw-r--r-- | test/gui/pictureframe.c | 103 | ||||
-rw-r--r-- | test/gui/window.c | 2 |
15 files changed, 381 insertions, 274 deletions
diff --git a/doc/project-report.md b/doc/project-report.md index e48c204..3851150 100644 --- a/doc/project-report.md +++ b/doc/project-report.md | |||
@@ -130,9 +130,19 @@ RBGa vectors from the two base images: each component is square-rooted back to i | |||
130 | 130 | ||
131 | ### GUI | 131 | ### GUI |
132 | 132 | ||
133 | TODO: modular component-based architecture, wrapping libMLV low level functions\ | 133 | The Graphical User Interface is designed with a modular component-based architecture. That architecture implies an |
134 | based on delegated click handlers and painting functions\ | 134 | Object-Oriented Programming's vision. Thanks to that, the application is very flexible for adding components and |
135 | computing intermediate morphing between each frame, combined with a times, thus not using MLV_Animation | 135 | placing them. The components created are groups, buttons, and picture frames that are all based on a common structure |
136 | called Component. Groups federate Components of any type and place them by a margin management. | ||
137 | |||
138 | Thanks to a click handler and a printing function stored inside Components, it is possible to perform the actions on | ||
139 | click or to paint the component without knowing what is stored inside the group. The group is a component that handles | ||
140 | clicks and is able to paint itself by using the click handler and the painter function of the Component contained inside | ||
141 | its list. In other words, it delegates to the Components the action to perform. | ||
142 | |||
143 | It also wraps some libMLV low level functions to create basic application features that can be used to create coherent | ||
144 | state for the application and components. The rendering process is done by computing intermediate morphing between each | ||
145 | frame combined with a time. By this implementation, the application is not using MLV_Animation. | ||
136 | 146 | ||
137 | \newpage | 147 | \newpage |
138 | 148 | ||
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 | |||