diff options
author | Adam NAILI | 2017-12-31 15:00:23 +0100 |
---|---|---|
committer | Adam NAILI | 2017-12-31 15:00:23 +0100 |
commit | 41da8b54ed619ea869ca286cd8ec02e105e21c19 (patch) | |
tree | f69a6ba2ece9ec4b0b8fa5d6880f61d5f13fc5ee /src/gui/button.c | |
parent | 4b30bfee527edd88e035b93c1230ddf2101291f6 (diff) | |
download | morpher-41da8b54ed619ea869ca286cd8ec02e105e21c19.tar.gz |
Implementing all kinds of buttons. Rendering to fix
Diffstat (limited to 'src/gui/button.c')
-rw-r--r-- | src/gui/button.c | 75 |
1 files changed, 71 insertions, 4 deletions
diff --git a/src/gui/button.c b/src/gui/button.c index a1fa1cf..03addf8 100644 --- a/src/gui/button.c +++ b/src/gui/button.c | |||
@@ -32,21 +32,88 @@ void button_click_test(int x, int y, Component *parameterSelf) { | |||
32 | assert(y >= 0); | 32 | assert(y >= 0); |
33 | assert(parameterSelf != NULL); | 33 | assert(parameterSelf != NULL); |
34 | Button *self = (Button *) parameterSelf; | 34 | Button *self = (Button *) parameterSelf; |
35 | if (button_is_selected(x, y, self) && mode == WAITING_BUTTON) { | 35 | if (button_is_selected(x, y, self) && (mode == WAITING_BUTTON_SHOW || mode == WAITING_BUTTON_HIDE)) { |
36 | printf("OK\n"); | ||
37 | } | 36 | } |
38 | } | 37 | } |
39 | 38 | ||
40 | void button_click_add_constraint(int x, int y, Component *parameterSelf){ | 39 | void button_click_add_constraint(int x, int y, Component *parameterSelf) { |
41 | assert(x >= 0); | 40 | assert(x >= 0); |
42 | assert(y >= 0); | 41 | assert(y >= 0); |
43 | assert(parameterSelf != NULL); | 42 | assert(parameterSelf != NULL); |
44 | Button *self = (Button *) parameterSelf; | 43 | Button *self = (Button *) parameterSelf; |
45 | if (button_is_selected(x, y, self) && mode == WAITING_BUTTON) { | 44 | if (button_is_selected(x, y, self) && (mode == WAITING_BUTTON_SHOW || mode == WAITING_BUTTON_HIDE)) { |
46 | mode = INSERT_ORIGIN; | 45 | mode = INSERT_ORIGIN; |
47 | } | 46 | } |
48 | } | 47 | } |
49 | 48 | ||
49 | void button_click_show_hide(int x, int y, Component *parameterSelf) { | ||
50 | assert(x >= 0); | ||
51 | assert(y >= 0); | ||
52 | assert(parameterSelf != NULL); | ||
53 | Button *self = (Button *) parameterSelf; | ||
54 | if (button_is_selected(x, y, self)) { | ||
55 | if (mode == WAITING_BUTTON_SHOW) { | ||
56 | mode = WAITING_BUTTON_HIDE; | ||
57 | } else if (mode == WAITING_BUTTON_HIDE) { | ||
58 | mode = WAITING_BUTTON_SHOW; | ||
59 | } | ||
60 | } | ||
61 | } | ||
62 | |||
63 | void button_click_exit(int x, int y, Component *parameterSelf) { | ||
64 | assert(x >= 0); | ||
65 | assert(y >= 0); | ||
66 | assert(parameterSelf != NULL); | ||
67 | Button *self = (Button *) parameterSelf; | ||
68 | if (button_is_selected(x, y, self) && (mode == WAITING_BUTTON_SHOW || mode == WAITING_BUTTON_HIDE)) { | ||
69 | mode = EXITING; | ||
70 | } | ||
71 | } | ||
72 | |||
73 | void button_click_less_frame(int x, int y, Component *parameterSelf) { | ||
74 | assert(x >= 0); | ||
75 | assert(y >= 0); | ||
76 | assert(parameterSelf != NULL); | ||
77 | Button *self = (Button *) parameterSelf; | ||
78 | if (button_is_selected(x, y, self) && (mode == WAITING_BUTTON_SHOW || mode == WAITING_BUTTON_HIDE)) { | ||
79 | if (frame > 2) { | ||
80 | frame = frame / 2; | ||
81 | sprintf(labelFrame,"%03d frames", frame); | ||
82 | mode = PRINTING_BUTTONS; | ||
83 | } | ||
84 | } | ||
85 | } | ||
86 | |||
87 | void button_click_more_frame(int x, int y, Component *parameterSelf) { | ||
88 | assert(x >= 0); | ||
89 | assert(y >= 0); | ||
90 | assert(parameterSelf != NULL); | ||
91 | Button *self = (Button *) parameterSelf; | ||
92 | if (button_is_selected(x, y, self) && (mode == WAITING_BUTTON_SHOW || mode == WAITING_BUTTON_HIDE)) { | ||
93 | if (frame < 256) { | ||
94 | frame = frame * 2; | ||
95 | sprintf(labelFrame,"%03d frames", frame); | ||
96 | mode = PRINTING_BUTTONS; | ||
97 | } | ||
98 | } | ||
99 | } | ||
100 | |||
101 | void button_click_rendering(int x,int y, Component *parameterSelf) { | ||
102 | assert(x >= 0); | ||
103 | assert(y >= 0); | ||
104 | assert(parameterSelf != NULL); | ||
105 | Button *self = (Button *) parameterSelf; | ||
106 | if (button_is_selected(x, y, self) && (mode == WAITING_BUTTON_SHOW || mode == WAITING_BUTTON_HIDE)) { | ||
107 | mode = RENDERING; | ||
108 | } | ||
109 | } | ||
110 | |||
111 | void button_click_none(int x, int y, Component *parameterSelf) { | ||
112 | assert(x >= 0); | ||
113 | assert(y >= 0); | ||
114 | assert(parameterSelf != NULL); | ||
115 | } | ||
116 | |||
50 | 117 | ||
51 | void | 118 | void |
52 | button_init(Button *button, const char *text, int sizeInterligne, int x_pos, int y_pos, ClickHandler clickHandler) { | 119 | button_init(Button *button, const char *text, int sizeInterligne, int x_pos, int y_pos, ClickHandler clickHandler) { |