summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam NAILI2017-12-31 17:52:59 +0100
committerAdam NAILI2017-12-31 17:52:59 +0100
commit3e6c3cea17042e83d8e48b87abd89c617a2f70f3 (patch)
tree0d6b22c672e670daa3cb464668500535af0ee988
parente275a679a1fb9377dd1a74329420ce6e95a03da3 (diff)
parentf1d17a0bb9d1ba98cc94488ecbdb539f123b33ab (diff)
downloadmorpher-3e6c3cea17042e83d8e48b87abd89c617a2f70f3.tar.gz
Merge remote-tracking branch 'origin/gui'
-rw-r--r--include/common/geom.h2
-rw-r--r--include/gui/button.h80
-rw-r--r--include/gui/component.h50
-rw-r--r--include/gui/group.h78
-rw-r--r--include/gui/pictureframe.h101
-rw-r--r--include/gui/textview.h2
-rw-r--r--include/gui/window.h93
-rw-r--r--src/gui/button.c133
-rw-r--r--src/gui/component.c7
-rw-r--r--src/gui/group.c87
-rw-r--r--src/gui/pictureframe.c117
-rw-r--r--src/gui/window.c60
-rw-r--r--src/morpher/quadrilateral.c8
-rw-r--r--test/gui/button.c30
-rw-r--r--test/gui/group.c39
-rw-r--r--test/gui/pictureframe.c110
-rw-r--r--test/gui/window.c15
-rw-r--r--test/morpher/quadrilateral.c1
18 files changed, 991 insertions, 22 deletions
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 @@
12 * Type: IntVector 12 * Type: IntVector
13 * An abstract 1-D vector. 13 * An abstract 1-D vector.
14 */ 14 */
15typedef int32_t IntVector; 15typedef int64_t IntVector;
16 16
17/** 17/**
18 * Type: RealVector 18 * Type: RealVector
diff --git a/include/gui/button.h b/include/gui/button.h
index 62f75a3..41008c1 100644
--- a/include/gui/button.h
+++ b/include/gui/button.h
@@ -1,16 +1,90 @@
1#ifndef UPEM_MORPHING_BUTTON 1#ifndef UPEM_MORPHING_BUTTON
2#define UPEM_MORPHING_BUTTON 2#define UPEM_MORPHING_BUTTON
3
4/** 3/**
5 * File: button.h 4 * File: button.h
5 * Buttons handling
6 */ 6 */
7 7
8#include <stdbool.h>
9#include "component.h"
10
11/**
12 * Struct: Button
13 * Component that can be triggered by click to execute a specific action.
14 *
15 * Fields:
16 * component - component that will acted as a button thanks to a rightful initialization
17 * *label - title on the button
18 * sizeInterligne - parameter that change padding of the button
19 */
8typedef struct { 20typedef struct {
9 Component component; 21 Component component;
22 char *label;
23 int sizeInterligne;
10} Button; 24} Button;
11 25
12void button_init(Button *button, char *text); 26/**
27 * Function: button_init
28 * Initializes the button.
29 *
30 * Parameters:
31 * *button - pointer to the input button
32 * text - label for the button
33 * sizeInterligne - parameter to initialize padding inside the button
34 * x_pos - position of the button on x axis
35 * 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
37 */
38void button_init(Button *button, const char *text, int sizeInterligne, int x_pos, int y_pos, ClickHandler clickHandler);
39
40/**
41 * Function: button_print
42 * Prints the button.
43 *
44 * Parameters:
45 * *parameterSelf - pointer to the button
46 */
47void button_print(Component *parameterSelf);
48
49/**
50 * Function: button_click_test
51 * Debug function to test if the click is working on the current button.
52 *
53 * Parameters:
54 * x - position of the click on x axis
55 * y - position of the click on y axis
56 * *parameterSelf - pointer on the button that is clicked
57 */
58void button_click_test(int x, int y, Component *parameterSelf);
59
60void button_click_add_constraint(int x, int y, Component *parameterSelf);
61
62void button_click_show_hide(int x, int y, Component *parameterSelf);
63
64void button_click_exit(int x, int y, Component *parameterSelf);
65
66void button_click_none(int x, int y, Component *parameterSelf);
67
68void button_click_more_frame(int x, int y, Component *parameterSelf);
69
70void button_click_less_frame(int x, int y, Component *parameterSelf);
71
72void button_click_rendering(int x, int y, Component *parameterSelf);
73
74
75/**
76 * Function: button_is_selected
77 * Checks if the button is selected or not.
78 *
79 * Parameters:
80 * x - position in x for the check
81 * y - position in y for the check
82 * *button - pointer to the current button
83 *
84 * Returns:
85 * A bool from stdbool
86 */
13 87
14void button_free(Button *button); 88bool button_is_selected(int x, int y, Button *button);
15 89
16#endif 90#endif
diff --git a/include/gui/component.h b/include/gui/component.h
new file mode 100644
index 0000000..0275d45
--- /dev/null
+++ b/include/gui/component.h
@@ -0,0 +1,50 @@
1#ifndef UPEM_C_COMPONENT_H
2#define UPEM_C_COMPONENT_H
3typedef enum {
4 WAITING_BUTTON_SHOW, WAITING_BUTTON_HIDE, INSERT_ORIGIN, INSERT_TARGET, PRINTING, EXITING, PRINTING_BUTTONS, RENDERING
5} Mode;
6
7extern Mode mode;
8extern int frame;
9extern char labelFrame[20];
10/**
11 * File: component.h
12 * Windows and components handling.
13 *
14 * See also:
15 * The famous OS
16 */
17struct Component;
18
19/**
20 * Type: ClickHandler
21 * Type of functions that handle mouse's clicks.
22 */
23typedef void (*ClickHandler)(int x_pos, int y_pos, struct Component *parameter);
24
25/**
26 * Type: PrintMethod
27 * Type of functions that will be used to print our component. This must be initialized by the initialization function of the component.
28 */
29typedef void (*PrintMethod)(struct Component *);
30
31/**
32 * Struct: Component
33 * Represents an abstract module handling clicks and a way to be print on the screen.
34 *
35 * Fields:
36 * width - width of the component
37 * height - height of the component
38 * x_pos - position on the x axis from the origin meant to be placed in top left
39 * y_pos - position on the y axis from the origin meant to be placed in top left
40 * click_handler - pointer of function that is called on mouse click
41 * print_method - pointer of function that handle the component's print
42 */
43typedef struct Component {
44 int width, height;
45 int x_pos, y_pos;
46 ClickHandler click_handler;
47 PrintMethod print_method;
48} Component;
49
50#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 */
19typedef 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 */
8typedef struct { 33typedef struct {
9 Component component; 34 Component component;
10 Component *sub_components; 35 GroupElement *group_head;
36 int margin;
11} Group; 37} Group;
12 38
13void 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 */
46void 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 th