summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Williams <andy@andywilliams.me>2016-01-06 20:28:55 +0000
committerAndy Williams <andy@andywilliams.me>2016-01-06 20:28:55 +0000
commitb34b1f896fa3ae7bf3208d1c68fdbda09f7222ba (patch)
tree015f24fd5a9f5b6324a35194e18cfb1c8a48434b
parent242cabee599ec8f6662c9c95819f2942834ee107 (diff)
[ui] Convert equate to Elementary
A few functions that have not been ported but they could not be accessed from the current edc theme. Looking at the possibility of a scientific layout to access these.
-rw-r--r--data/Makefile.am21
-rw-r--r--data/equate.edc271
-rw-r--r--data/images/Makefile.am14
-rw-r--r--data/images/bg.pngbin1114 -> 0 bytes
-rw-r--r--data/images/brushed_texture.pngbin87845 -> 0 bytes
-rw-r--r--data/images/btn_normal.pngbin589 -> 0 bytes
-rw-r--r--data/images/btn_pressed.pngbin456 -> 0 bytes
-rw-r--r--data/images/entry_disabled.pngbin1590 -> 0 bytes
-rw-r--r--data/images/entry_light_overlay.pngbin3537 -> 0 bytes
-rw-r--r--data/images/metalsphere.pngbin2683 -> 0 bytes
-rw-r--r--data/images/shading.pngbin3177 -> 0 bytes
-rw-r--r--data/images/text_button.pngbin123 -> 0 bytes
-rw-r--r--data/images/text_display.pngbin1302 -> 0 bytes
-rw-r--r--data/text.edc359
-rw-r--r--src/main.c143
15 files changed, 76 insertions, 732 deletions
diff --git a/data/Makefile.am b/data/Makefile.am
index a821443..ce02127 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,30 +1,11 @@
1 1
2MAINTAINERCLEANFILES = Makefile.in 2MAINTAINERCLEANFILES = Makefile.in
3 3
4SUBDIRS = . images
5
6EDJE_CC = @edje_cc@
7EDJE_FLAGS = -v -id $(top_srcdir)/data/images
8
9EDCS = equate.edc text.edc
10EDJS = $(EDCS:%.edc=%.edj)
11SUFFIXES = .edc .edj
12
13themedir = $(pkgdatadir)/themes
14theme_DATA = $(EDJS)
15
16all: $(EDCS)
17
18.edc.edj:
19 $(EDJE_CC) $(EDJE_FLAGS) $< $@
20
21desktopdir = $(datadir)/applications 4desktopdir = $(datadir)/applications
22desktop_DATA = equate.desktop 5desktop_DATA = equate.desktop
23 6
24icondir = $(datadir)/icons 7icondir = $(datadir)/icons
25icon_DATA = equate.png 8icon_DATA = equate.png
26 9
27EXTRA_DIST = $(EDCS) equate.png equate.desktop 10EXTRA_DIST = equate.png equate.desktop
28 11
29clean-local:
30 rm -f $(EDJS)
diff --git a/data/equate.edc b/data/equate.edc
deleted file mode 100644
index 52955ad..0000000
--- a/data/equate.edc
+++ /dev/null
@@ -1,271 +0,0 @@
1
2
3#define BUTTON_TABLE_ITEM(pname, x, y, w, h) \
4item { \
5 type: GROUP; \
6 source: pname; \
7 weight: 0.5 0.5; \
8 align: -1 -1; \
9 position: x y; \
10 span: w h; \
11}
12
13
14#define BUTTON(pname, label, emits) \
15group { name: "button/"pname; \
16 images { \
17 image: "btn_normal.png" COMP; \
18 image: "btn_pressed.png" COMP; \
19 } \
20 parts { \
21 part { name: "button_image"; \
22 mouse_events: 1; \
23 description { state: "default" 0.0; \
24 rel1.offset: 3 3; \
25 rel2.offset: -4 -4; \
26 image { \
27 normal: "btn_normal.png"; \
28 border: 7 7 7 7; \
29 } \
30 \
31 } \
32 description { state: "clicked" 0.0; \
33 inherit: "default" 0.0; \
34 image.normal: "btn_pressed.png"; \
35 image.border: 7 7 7 7; \
36 } \
37 } \
38 \
39 part { \
40 name: "elm.text"; \
41 type: TEXT; \
42 effect: SHADOW; \
43 mouse_events: 0; \
44 scale: 1; \
45 description { state: "default" 0.0; \
46 visible: 1; \
47 rel1.offset: 4 4; \
48 rel2.offset: -5 -5; \
49 color: 255 255 255 240; \
50 color3: 20 20 20 128; \
51 /* color: 172 179 191 255; */ \
52 /* color3: 0 0 0 30; */ \
53 text { \
54 font: "Sans"; \
55 size: 25; \
56 min: 1 1; \
57 align: 0.5 0.5; \
58 text_class: "button"; \
59 text: label; \
60 } \
61 } \
62 } \
63 part { \
64 name: "over1"; \
65 mouse_events: 0; \
66 type: RECT; \
67 description { \
68 state: "default" 0.0; \
69 rel2.relative: 1.0 0.5; \
70 color: 0 0 0 0; \
71 } \
72 description { state: "disabled" 0.0; \
73 inherit: "default" 0.0; \
74 } \
75 } \
76 part { name: "over2"; \
77 mouse_events: 1; \
78 repeat_events: 1; \
79 ignore_flags: ON_HOLD; \
80 type: RECT; \
81 description { \
82 state: "default" 0.0; \
83 color: 0 0 0 0; \
84 } \
85 description { \
86 state: "disabled" 0.0; \
87 inherit: "default" 0.0; \
88 visible: 0; \
89 } \
90 } \
91 part { name: "over3"; \
92 mouse_events: 1; \
93 repeat_events: 1; \
94 type: RECT; \
95 description { state: "default" 0.0; \
96 color: 255 255 255 0; \
97 } \
98 description { state: "clicked" 0.0; \
99 inherit: "default" 0.0; \
100 color: 255 255 255 0; \
101 } \
102 } \
103 \
104 \
105 } \
106 programs { \
107 program { \
108 name: "button_click"; \
109 signal: "mouse,down,1"; \
110 source: "over2"; \
111 action: STATE_SET "clicked" 0.0; \
112 target: "button_image"; \
113 } \
114 \
115 program { \
116 name: "button_unclick"; \
117 signal: "mouse,up,1"; \
118 source: "over3"; \
119 action: STATE_SET "default" 0.0; \
120 target: "button_image"; \
121 } \
122 program { \
123 name: "button_click2"; \
124 signal: "mouse,down,1"; \
125 source: "over3"; \
126 action: STATE_SET "clicked" 0.0; \
127 target: "over3"; \
128 } \
129 program { \
130 name: "button_unclick2"; \
131 signal: "mouse,up,1"; \
132 source: "over3"; \
133 action: STATE_SET "default" 0.0; \
134 transition: DECELERATE 0.5; \
135 target: "over3"; \
136 } \
137 program { \
138 name: "button_unclick3"; \
139 signal: "mouse,clicked,1"; \
140 source: "over2"; \
141 action: SIGNAL_EMIT emits ""; \
142 } \
143 } \
144}
145
146images {
147 image: "bg.png" COMP;
148 image: "shading.png" COMP;
149 image: "brushed_texture.png" COMP;
150 image: "metalsphere.png" COMP;
151 image: "entry_disabled.png" COMP;
152 image: "entry_light_overlay.png" COMP;
153}
154collections {
155
156 BUTTON("add", "+", "OP_ADD");
157 BUTTON("min", "-", "OP_SUB");
158 BUTTON("mul", "*", "OP_MUT");
159 BUTTON("div", "/", "OP_DIV");
160
161 BUTTON("seven", "7", "NUM_7");
162 BUTTON("height", "8", "NUM_8");
163 BUTTON("nine", "9", "NUM_9");
164 BUTTON("clear", "C", "OP_CLR");
165
166 BUTTON("four", "4", "NUM_4");
167 BUTTON("five", "5", "NUM_5");
168 BUTTON("six", "6", "NUM_6");
169 BUTTON("obrak", "(", "OP_OBRAK");
170
171 BUTTON("one", "1", "NUM_1");
172 BUTTON("two", "2", "NUM_2");
173 BUTTON("three", "3", "NUM_3");
174 BUTTON("cbrak", ")", "OP_CBRAK");
175
176 BUTTON("zero", "0", "NUM_0");
177 BUTTON("point", ".", "OP_DEC");
178 BUTTON("equal", "=", "OP_EQU");
179
180 group {
181 name: "Main";
182
183 parts {
184 part {
185 name: "bg";
186 type: RECT;
187 mouse_events: 0;
188 description
189 {
190 state: "default" 0.0;
191 visible: 1;
192 color: 255 255 255 255;
193 }
194 }
195
196 part {
197 name: "EquateAnswer";
198 type: TEXT;
199 mouse_events: 0;
200 description
201 {
202 state: "default" 0.0;
203 visible: 1;
204 rel1 {
205 relative: 0.0 0.0;
206 offset: 2 0;
207 } rel2 {
208 relative: 1.0 0.0;
209 offset: -1 0;
210
211 }
212 fixed: 1 1;
213 align: 0.5 0;
214 color: 0 0 0 255;
215 color3: 192 192 192 255;
216 text
217 {
218 text: "";
219 font: "Sans";
220 size: 30;
221 //fit: 0 0;
222 min: 1 1;
223 align: 1.0 0.5;
224 }
225 }
226 }
227
228 part {
229 name : "table_description";
230 type : TABLE;
231 description {
232 state : "default" 0.0;
233 fixed: 0 1;
234 rel1.to: "EquateAnswer";
235 rel1.relative: 0 1;
236 table {
237 homogeneous: TABLE;
238 padding: 0 0;
239 }
240 }
241 table {
242 items {
243 BUTTON_TABLE_ITEM("button/add", 0, 0, 1, 1);
244 BUTTON_TABLE_ITEM("button/min", 1, 0, 1, 1);
245 BUTTON_TABLE_ITEM("button/mul", 2, 0, 1, 1);
246 BUTTON_TABLE_ITEM("button/div", 3, 0, 1, 1);
247
248 BUTTON_TABLE_ITEM("button/seven", 0, 1, 1, 1);
249 BUTTON_TABLE_ITEM("button/height", 1, 1, 1, 1);
250 BUTTON_TABLE_ITEM("button/nine", 2, 1, 1, 1);
251 BUTTON_TABLE_ITEM("button/clear", 3, 1, 1, 1);
252
253 BUTTON_TABLE_ITEM("button/four", 0, 2, 1, 1);
254 BUTTON_TABLE_ITEM("button/five", 1, 2, 1, 1);
255 BUTTON_TABLE_ITEM("button/six", 2, 2, 1, 1);
256 BUTTON_TABLE_ITEM("button/obrak", 3, 2, 1, 1);
257
258 BUTTON_TABLE_ITEM("button/one", 0, 3, 1, 1);
259 BUTTON_TABLE_ITEM("button/two", 1, 3, 1, 1);
260 BUTTON_TABLE_ITEM("button/three", 2, 3, 1, 1);
261 BUTTON_TABLE_ITEM("button/cbrak", 3, 3, 1, 1);
262
263 BUTTON_TABLE_ITEM("button/zero", 0, 4, 1, 1);
264 BUTTON_TABLE_ITEM("button/point", 1, 4, 1, 1);
265 BUTTON_TABLE_ITEM("button/equal", 2, 4, 2, 1);
266 }
267 }
268 }
269 }
270
271}
diff --git a/data/images/Makefile.am b/data/images/Makefile.am
deleted file mode 100644
index ab6db60..0000000
--- a/data/images/Makefile.am
+++ /dev/null
@@ -1,14 +0,0 @@
1
2MAINTAINERCLEANFILES = Makefile.in
3
4EXTRA_DIST = \
5bg.png \
6brushed_texture.png \
7btn_normal.png \
8btn_pressed.png \
9entry_disabled.png \
10entry_light_overlay.png \
11metalsphere.png \
12shading.png \
13text_button.png \
14text_display.png
diff --git a/data/images/bg.png b/data/images/bg.png
deleted file mode 100644
index 8415d46..0000000
--- a/data/images/bg.png
+++ /dev/null
Binary files differ
diff --git a/data/images/brushed_texture.png b/data/images/brushed_texture.png
deleted file mode 100644
index 0a78068..0000000
--- a/data/images/brushed_texture.png
+++ /dev/null
Binary files differ
diff --git a/data/images/btn_normal.png b/data/images/btn_normal.png
deleted file mode 100644
index 487d22c..0000000
--- a/data/images/btn_normal.png
+++ /dev/null
Binary files differ
diff --git a/data/images/btn_pressed.png b/data/images/btn_pressed.png
deleted file mode 100644
index b1d4285..0000000
--- a/data/images/btn_pressed.png
+++ /dev/null
Binary files differ
diff --git a/data/images/entry_disabled.png b/data/images/entry_disabled.png
deleted file mode 100644
index a078d5c..0000000
--- a/data/images/entry_disabled.png
+++ /dev/null
Binary files differ
diff --git a/data/images/entry_light_overlay.png b/data/images/entry_light_overlay.png
deleted file mode 100644
index 694c3f3..0000000
--- a/data/images/entry_light_overlay.png
+++ /dev/null
Binary files differ
diff --git a/data/images/metalsphere.png b/data/images/metalsphere.png
deleted file mode 100644
index 6f8865e..0000000
--- a/data/images/metalsphere.png
+++ /dev/null
Binary files differ
diff --git a/data/images/shading.png b/data/images/shading.png
deleted file mode 100644
index ba22b29..0000000
--- a/data/images/shading.png
+++ /dev/null
Binary files differ
diff --git a/data/images/text_button.png b/data/images/text_button.png
deleted file mode 100644
index d7084b2..0000000
--- a/data/images/text_button.png
+++ /dev/null
Binary files differ
diff --git a/data/images/text_display.png b/data/images/text_display.png
deleted file mode 100644
index 96b5604..0000000
--- a/data/images/text_display.png
+++ /dev/null
Binary files differ
diff --git a/data/text.edc b/data/text.edc
deleted file mode 100644
index f7a21a1..0000000
--- a/data/text.edc
+++ /dev/null
@@ -1,359 +0,0 @@
1images {
2 image, "text_button.png" LOSSY 95;
3 image, "text_display.png" LOSSY 95;
4}
5collections {
6 group {
7 name, "Main";
8 min, 110 160;
9 max, 110 160;
10 parts {
11 part {
12 name, "bg";
13 type, RECT;
14 mouse_events, 0;
15 description
16 {
17 state, "default" 0.0;
18 visible, 1;
19 rel1 {
20 relative, 0.0 0.0;
21 offset, 0 0;
22 } rel2 {
23 relative, 1.0 1.0;
24 offset, 0 0;
25 }
26 color, 0 0 0 255;
27 }
28 }
29 part {
30 name, "answer_buf_clip";
31 type, RECT;
32 mouse_events, 0;
33 description
34 {
35 state, "default" 0.0;
36 visible, 1;
37 rel1 {
38 relative, 0.0 0.0;
39 offset, 5 5;
40 } rel2 {
41 relative, 1.0 0.0;
42 offset, -5 30;
43 }
44 color, 255 255 255 255;
45 }
46 description
47 {
48 state, "hidden" 0.0;
49 visible, 1;
50 rel1 {
51 relative, 0.0 0.0;
52 offset, 5 5;
53 } rel2 {
54 relative, 1.0 0.0;
55 offset, -5 30;
56 }
57 color, 255 255 255 0;
58 }
59 }
60 part {
61 name, "answer_buf_rect";
62 type, IMAGE;
63 mouse_events, 0;
64 clip_to, "answer_buf_clip";
65 description
66 {
67 state, "default" 0.0;
68 visible, 1;
69 rel1 {
70 relative, 0.0 0.0;
71 offset, 0 0;
72 to, "answer_buf_clip";
73 } rel2 {
74 relative, 1.0 1.0;
75 offset, 0 0;
76 to, "answer_buf_clip";
77 }
78 image
79 {
80 normal, "text_display.png";
81 border, 8 8 8 8;
82 }
83 color, 255 255 255 255;
84 }
85 }
86 part {
87 name, "EquateAnswer";
88 type, TEXT;
89 mouse_events, 0;
90 effect, OUTLINE;
91 clip_to, "answer_buf_clip";
92 description
93 {
94 state, "default" 0.0;
95 visible, 1;
96 rel1 {
97 relative, 0.0 0.0;
98 offset, 5 5;
99 to, "answer_buf_clip";
100 } rel2 {
101 relative, 1.0 1.0;
102 offset, -5 -2;
103 to, "answer_buf_clip";
104 }
105 color, 0 0 0 255;
106 color3, 192 192 192 255;
107 text
108 {
109 text, "";
110 font, "Vera";
111 size, 14;
112 fit, 0 0;
113 align, 1.0 0.5;
114 }
115 }
116 }
117 part {
118 name, "clipped_clear";
119 type, RECT;
120 mouse_events, 0;
121 description {
122 state, "default" 0.0;
123 visible, 1;
124 rel1 {
125 relative, 0.0 1.0;
126 offset, 0 0;
127 to, "answer_buf_clip";
128 } rel2 {
129 relative, 0.0 1.0;
130 offset, 24 24;
131 to, "answer_buf_clip";
132 }
133 color, 255 255 255 255;
134 }
135 description {
136 state, "clicked" 0.0;
137 visible, 1;
138 rel1 {
139 relative, 0.0 1.0;
140 offset, 0 0;
141 to, "answer_buf_clip";
142 } rel2 {
143 relative, 0.0 1.0;
144 offset, 24 24;
145 to, "answer_buf_clip";
146 }
147 color, 255 255 255 192;
148 }
149 }
150 part {
151 name, "clear_button_image";
152 type, IMAGE;
153 mouse_events, 1;
154 clip_to, "clipped_clear";
155 description
156 {
157 state, "default" 0.0;
158 visible, 1;
159 rel1 {
160 relative, 0.0 1.0;
161 offset, 0 0;
162 to, "answer_buf_clip";
163 } rel2 {
164 relative, 0.0 1.0;
165 offset, 24 24;
166 to, "answer_buf_clip";
167 }
168 image
169 {
170 normal, "text_button.png";
171 }
172 }
173 }
174 part {
175 name, "clear_button_text";
176 type, TEXT;
177 mouse_events, 1;
178 effect, SOFT_SHADOW;
179 description
180 {
181 state, "default" 0.0;
182 visible, 1;
183 rel1 {
184 relative, 0.0 0.0;
185 offset, 0 0;
186 to, "clear_button_image";
187 } rel2 {
188 relative, 1.0 1.0;
189 offset, 0 0;
190 to, "clear_button_image";
191 }
192 color, 255 255 255 255;
193 color3, 96 96 96 255;
194 text
195 {
196 text, "c";
197 font, "Vera";
198 size, 14;
199 fit, 0 0;
200 align, 0.5 0.5;
201 }
202 }
203 description {
204 state, "clicked" 0.0;
205 visible, 1;
206 rel1 {
207 relative, 0.0 0.0;
208 offset, 1 1;
209 to, "clear_button_image";
210 } rel2 {
211 relative, 1.0 1.0;
212 offset, 1 1;
213 to, "clear_button_image";
214 }
215 color, 255 255 255 255;
216 color3, 96 96 96 255;
217 text {
218 text, "c";
219 font, "Vera";
220 size, 14;
221 fit, 0 0;
222 align, 0.5 0.5;
223 }
224 }
225 }
226#define TEXT_ON(txtrel, txtpname, txtstr) \
227 part { name, txtpname; type, TEXT; mouse_events, 0; \
228 effect, SOFT_SHADOW; description { \
229 state, "default" 0.0; visible, 1; \
230 rel1 { relative, 0.0 0.0; offset, 0 0; to, txtrel; } \
231 rel2 { relative, 1.0 1.0; offset, 0 0; to, txtrel; } \
232 color, 255 255 255 255; color3, 96 96 96 255; \
233 text { text, txtstr; font, "Vera"; size, 14; \
234 fit, 0 0; align, 0.5 0.5; } } \
235 description { \
236 state, "clicked" 0.0; visible, 1; \
237 rel1 { relative, 0.0 0.0; offset, 1 1; to, txtrel; } \
238 rel2 { relative, 1.0 1.0; offset, 1 1; to, txtrel; } \
239 color, 255 255 255 255; color3, 96 96 96 255; \
240 text { text, txtstr; font, "Vera"; size, 14; \
241 fit, 0 0; align, 0.5 0.5; } } }
242
243#define RIGHT_OF(rel, clipname, pname, ptxtname, txt, bw, bh) \
244 part { name, clipname; type, RECT; mouse_events, 0; \
245 description { state, "default" 0.0; visible, 1; \
246 rel1 { relative, 1.0 0.0; offset, 0 0; to, rel; } \
247 rel2 { relative, 1.0 0.0; offset, bw bh; to, rel; } \
248 color, 255 255 255 255; } \
249 description { state, "clicked" 0.0; visible, 1; \
250 rel1 { relative, 1.0 0.0; offset, 0 0; to, rel; } \
251 rel2 { relative, 1.0 0.0; offset, bw bh; to, rel; } \
252 color, 255 255 255 192; } } \
253 part { name, pname; type, IMAGE; mouse_events, 1; \
254 clip_to, clipname ; \
255 description { state, "default" 0.0; visible, 1; \
256 rel1 { relative, 1.0 0.0; offset, 0 0; to, rel; } \
257 rel2 { relative, 1.0 0.0; offset, bw bh; to, rel; } \
258 image { normal, "text_button.png"; border, 0 0 0 6; } \
259 } } \
260 TEXT_ON(pname, ptxtname, txt)
261#define SOUTH_OF(rel, clipname, pname, ptxtname, txt, bw, bh) \
262 part { name, clipname; type, RECT; mouse_events, 0; \
263 description { state, "default" 0.0; visible, 1; \
264 rel1 { relative, 0.0 1.0; offset, 0 0; to, rel; } \
265 rel2 { relative, 0.0 1.0; offset, bw bh; to, rel; } \
266 color, 255 255 255 255; } \
267 description { state, "clicked" 0.0; visible, 1; \
268 rel1 { relative, 0.0 1.0; offset, 0 0; to, rel; } \
269 rel2 { relative, 0.0 1.0; offset, bw bh; to, rel; } \
270 color, 255 255 255 192; } } \
271 part { name, pname; type, IMAGE; mouse_events, 1; \
272 clip_to, clipname ; \
273 description { state, "default" 0.0; visible, 1; \
274 rel1 { relative, 0.0 1.0; offset, 0 0; to, rel; } \
275 rel2 { relative, 0.0 1.0; offset, bw bh; to, rel; } \
276 image { normal, "text_button.png"; border, 0 2 0 0; } \
277 } } \
278 TEXT_ON(pname, ptxtname, txt)
279
280 RIGHT_OF("clear_button_image", "clipped_divide", "divide_button_image",
281 "divide_button_text", "/", 24, 24)
282 RIGHT_OF("divide_button_image", "clipped_times", "times_button_image",
283 "times_button_text", "*", 24, 24);
284 RIGHT_OF("times_button_image", "clipped_minus", "minus_button_image",
285 "minus_button_text", "-", 24, 24);
286 SOUTH_OF("clear_button_image", "clipped_seven", "seven_button_image",
287 "seven_button_text", "7", 24, 24);
288 RIGHT_OF("seven_button_image", "clipped_eight", "eight_button_image",
289 "eight_button_text", "8", 24, 24);
290 RIGHT_OF("eight_button_image", "clipped_nine", "nine_button_image",
291 "nine_button_text", "9", 24, 24);
292 RIGHT_OF("nine_button_image", "clipped_plus", "plus_button_image",
293 "plus_button_text", "+", 24, 48);
294 SOUTH_OF("seven_button_image", "clipped_four", "four_button_image",
295 "four_button_text", "4", 24, 24);
296 RIGHT_OF("four_button_image", "clipped_five", "five_button_image",
297 "five_button_text", "5", 24, 24);
298 RIGHT_OF("five_button_image", "clipped_six", "six_button_image",
299 "six_button_text", "6", 24, 24);
300 SOUTH_OF("four_button_image", "clipped_one", "one_button_image",
301 "one_button_text", "1", 24, 24);
302 RIGHT_OF("one_button_image", "clipped_two", "two_button_image",
303 "two_button_text", "2", 24, 24);
304 RIGHT_OF("two_button_image", "clipped_three", "three_button_image",
305 "three_button_text", "3", 24, 24);
306 SOUTH_OF("three_button_image", "clipped_decimal", "decimal_button_image",
307 "decimal_button_text", ".", 24, 24);
308 SOUTH_OF("one_button_image", "clipped_zero", "zero_button_image",
309 "zero_button_text", "0", 48, 24);
310 RIGHT_OF("three_button_image", "clipped_equals", "equals_button_image",
311 "equals_button_text", "=", 24, 48);
312 }
313 programs {
314#define BUTTON_CB(pname, bclip, bname, emits, cbin, cbout) \
315 program { name, pname; signal, "mouse,clicked,1"; source, bname; \
316 action, SIGNAL_EMIT emits ""; } \
317 program { name, cbout; signal, "mouse,down,1"; source, bname; \
318 action, STATE_SET "clicked" 0.0; target, bclip; \
319 transition, LINEAR 0.1; } \
320 program { name, cbin; signal, "mouse,up,1"; source, bname; \
321 action, STATE_SET "default" 0.0; target, bclip; \
322 transition, DECELERATE 0.2; }
323 BUTTON_CB("clear_clicked", "clear_button_text", \
324 "clear_button_image", "OP_CLR", "clearin", "clearout")
325 BUTTON_CB("divide_clicked", "divide_button_text", \
326 "divide_button_image", "OP_DIV", "dividein", "divideout")
327 BUTTON_CB("multiply_clicked", "times_button_text", \
328 "times_button_image", "OP_MUT", "multiplyin", "multiplyout")
329 BUTTON_CB("addition_clicked", "plus_button_text", \
330 "plus_button_image", "OP_ADD", "additionin", "additionout")
331 BUTTON_CB("subtraction_clicked", "minus_button_text", \
332 "minus_button_image", "OP_SUB", "minusin", "minusout")
333 BUTTON_CB("equals_clicked", "equals_button_text", \
334 "equals_button_image", "OP_EQU", "clippedin", "clippedout")
335 BUTTON_CB("decimal_clicked", "decimal_button_text", \
336 "decimal_button_image", "OP_DEC", "decimalin", "decimalout")
337 BUTTON_CB("zero_clicked", "zero_button_text", \
338 "zero_button_image", "NUM_0", "zeroin", "zerout")
339 BUTTON_CB("one_clicked", "one_button_text", \
340 "one_button_image", "NUM_1", "onein", "oneout")
341 BUTTON_CB("two_clicked", "two_button_text", \
342 "two_button_image", "NUM_2", "twoin", "twoout")
343 BUTTON_CB("three_clicked", "three_button_text", \
344 "three_button_image", "NUM_3", "threein", "threeout")
345 BUTTON_CB("four_clicked", "four_button_text", \
346 "four_button_image", "NUM_4", "fourin", "fourout")
347 BUTTON_CB("five_clicked", "five_button_text", \
348 "five_button_image", "NUM_5", "fivein", "fiveout")
349 BUTTON_CB("six_clicked", "six_button_text", \
350 "six_button_image", "NUM_6", "sixin", "sixout")
351 BUTTON_CB("seven_clicked", "seven_button_text", \
352 "seven_button_image", "NUM_7", "sevenin", "sevenout")
353 BUTTON_CB("eight_clicked", "eight_button_text", \
354 "eight_button_image", "NUM_8", "eightin", "eightout")
355 BUTTON_CB("nine_clicked", "nine_button_text", \
356 "nine_button_image", "NUM_9", "ninein", "nineout")
357 }
358 }
359}
diff --git a/src/main.c b/src/main.c
index d5ef992..96b699a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -5,8 +5,7 @@
5#include "calc.h" 5#include "calc.h"
6 6
7static Evas_Object *win; 7static Evas_Object *win;
8static Evas_Object *ly; 8static Evas_Object *readout;
9
10 9
11static const struct 10static const struct
12{ 11{
@@ -56,8 +55,8 @@ static const struct
56 55
57 56
58static void 57static void
59_signal_cb(void *data, Evas_Object * o, const char *emission, const 58_button_cb(void *data, Evas_Object * o EINA_UNUSED,
60 char *source) 59 void *event_info EINA_UNUSED)
61{ 60{
62 int val = 0; 61 int val = 0;
63 62
@@ -89,7 +88,7 @@ _signal_cb(void *data, Evas_Object * o, const char *emission, const
89 break; 88 break;
90 case OP_EQU: 89 case OP_EQU:
91 snprintf(buf, BUFLEN, "%.10g", equate_eval()); 90 snprintf(buf, BUFLEN, "%.10g", equate_eval());
92 edje_object_part_text_set(o, "EquateAnswer", buf); 91 elm_object_text_set(readout, buf);
93 return; 92 return;
94 break; 93 break;
95 case OP_DEC: 94 case OP_DEC:
@@ -160,84 +159,87 @@ _signal_cb(void *data, Evas_Object * o, const char *emission, const
160 break; 159 break;
161 /* etc */ 160 /* etc */
162 } 161 }
163 edje_object_part_text_set(o, "EquateAnswer", equate_string_get()); 162 elm_object_text_set(readout, equate_string_get());
164 163
165 } 164 }
166} 165}
167 166
167static void
168_create_button(Evas_Object *table, const char *text, int op, int x, int y,
169 int w)
170{
171 Evas_Object *button;
172
173 button = elm_button_add(table);
174 evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
175 evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
176 elm_object_text_set(button, text);
177 evas_object_smart_callback_add(button, "clicked", _button_cb, (void *)op);
178
179 elm_table_pack(table, button, x, y, w, 1);
180 evas_object_show(button);
181}
168 182
169static void 183static void
170_edje_callbacks_define(Evas_Object * o) 184_create_buttons(Evas_Object *o)
171{ 185{
172 /** Equate Application Callbacks **/ 186 /** Equate Operations **/
173 /* EQ_EXIT - Quit Equate */
174 edje_object_signal_callback_add(o, "EQ_EXIT", "*", _signal_cb,
175 (void *) EQ_EXIT);
176 /** Equate Operation Callbacks **/
177 /* OP_CLR - Clear Display */ 187 /* OP_CLR - Clear Display */
178 edje_object_signal_callback_add(o, "OP_CLR", "*", _signal_cb, 188 _create_button(o, "C", OP_CLR, 3, 2, 1);
179 (void *) OP_CLR);
180 /* OP_DIV - Division Operator */ 189 /* OP_DIV - Division Operator */
181 edje_object_signal_callback_add(o, "OP_DIV", "*", _signal_cb, 190 _create_button(o, "/", OP_DIV, 3, 1, 1);
182 (void *) OP_DIV);
183 /* OP_MUT - Mutplication Operator */ 191 /* OP_MUT - Mutplication Operator */
184 edje_object_signal_callback_add(o, "OP_MUT", "*", _signal_cb, 192 _create_button(o, "*", OP_MUT, 2, 1, 1);
185 (void *) OP_MUT);
186 /* OP_ADD - Addition Operator */ 193 /* OP_ADD - Addition Operator */
187 edje_object_signal_callback_add(o, "OP_ADD", "*", _signal_cb, 194 _create_button(o, "+", OP_ADD, 0, 1, 1);
188 (void *) OP_ADD);
189 /* OP_SUB - Subtraction Operator */ 195 /* OP_SUB - Subtraction Operator */
190 edje_object_signal_callback_add(o, "OP_SUB", "*", _signal_cb, 196 _create_button(o, "-", OP_SUB, 1, 1, 1);
191 (void *) OP_SUB);
192 /* OP_EQU - Equals Operator */ 197 /* OP_EQU - Equals Operator */
193 edje_object_signal_callback_add(o, "OP_EQU", "*", _signal_cb, 198 _create_button(o, "=", OP_EQU, 2, 5, 2);
194 (void *) OP_EQU); 199
195 /* OP_DEC - Decimal Operator */ 200 /* OP_DEC - Decimal Operator */
196 edje_object_signal_callback_add(o, "OP_DEC", "*", _signal_cb, 201 _create_button(o, ".", OP_DEC, 1, 5, 1);
197 (void *) OP_DEC);
198 /* OP_SIN - Sin of x in degrees */ 202 /* OP_SIN - Sin of x in degrees */
199 edje_object_signal_callback_add(o, "OP_SIN", "*", _signal_cb, 203// edje_object_signal_callback_add(o, "OP_SIN", "*", _signal_cb,
200 (void *) OP_SIN); 204// (void *) OP_SIN);
201 /* OP_COS - Cos of x in degree */ 205 /* OP_COS - Cos of x in degree */
202 edje_object_signal_callback_add(o, "OP_COS", "*", _signal_cb, 206// edje_object_signal_callback_add(o, "OP_COS", "*", _signal_cb,
203 (void *) OP_COS); 207// (void *) OP_COS);
204 /* OP_TAN - Tan of x in degrees */ 208 /* OP_TAN - Tan of x in degrees */
205 edje_object_signal_callback_add(o, "OP_TAN", "*", _signal_cb, 209// edje_object_signal_callback_add(o, "OP_TAN", "*", _signal_cb,
206 (void *) OP_TAN); 210// (void *) OP_TAN);
207 /* OP_ROOT - The square root of x */ 211 /* OP_ROOT - The square root of x */
208 edje_object_signal_callback_add(o, "OP_ROOT", "*", _signal_cb, 212// edje_object_signal_callback_add(o, "OP_ROOT", "*", _signal_cb,
209 (void *) OP_ROOT); 213// (void *) OP_ROOT);
210 /* OP_POW - Raise x to the y power */ 214 /* OP_POW - Raise x to the y power */
211 edje_object_signal_callback_add(o, "OP_POW", "*", _signal_cb, 215// edje_object_signal_callback_add(o, "OP_POW", "*", _signal_cb,
212 (void *) OP_POW); 216// (void *) OP_POW);
213 /* OP_LOG - Logarithm */ 217 /* OP_LOG - Logarithm */
214 edje_object_signal_callback_add(o, "OP_LOG", "*", _signal_cb, 218// edje_object_signal_callback_add(o, "OP_LOG", "*", _signal_cb,
215 (void *) OP_LOG); 219// (void *) OP_LOG);
216 /* OP_LN - the natural logarithm */ 220 /* OP_LN - the natural logarithm */
217 edje_object_signal_callback_add(o, "OP_LN", "*", _signal_cb, (void *) OP_LN); 221// edje_object_signal_callback_add(o, "OP_LN", "*", _signal_cb, (void *) OP_LN);
218 /* OP_EXP - e to the x */ 222 /* OP_EXP - e to the x */
219 edje_object_signal_callback_add(o, "OP_EXP", "*", _signal_cb, 223// edje_object_signal_callback_add(o, "OP_EXP", "*", _signal_cb,
220 (void *) OP_EXP); 224// (void *) OP_EXP);
221 /* OP_OBRAK - open bracket */ 225 /* OP_OBRAK - open bracket */
222 edje_object_signal_callback_add(o, "OP_OBRAK", "*", _signal_cb, 226 _create_button(o, "(", OP_OBRAK, 3, 3, 1);
223 (void *) OP_OBRAK);
224 /* OP_CBRAK - close bracket */ 227 /* OP_CBRAK - close bracket */
225 edje_object_signal_callback_add(o, "OP_CBRAK", "*", _signal_cb, 228 _create_button(o, ")", OP_CBRAK, 3, 4, 1);
226 (void *) OP_CBRAK);
227 229
228 /** Equate Number Callbacks **/ 230 /** Equate Numbers **/
229 edje_object_signal_callback_add(o, "NUM_0", "*", _signal_cb, (void *) NUM_0); 231 _create_button(o, "7", NUM_7, 0, 2, 1);
230 edje_object_signal_callback_add(o, "NUM_1", "*", _signal_cb, (void *) NUM_1); 232 _create_button(o, "8", NUM_8, 1, 2, 1);
231 edje_object_signal_callback_add(o, "NUM_2", "*", _signal_cb, (void *) NUM_2); 233 _create_button(o, "9", NUM_9, 2, 2, 1);
232 edje_object_signal_callback_add(o, "NUM_3", "*", _signal_cb, (void *) NUM_3); 234 _create_button(o, "4", NUM_4, 0, 3, 1);
233 edje_object_signal_callback_add(o, "NUM_4", "*", _signal_cb, (void *) NUM_4); 235 _create_button(o, "5", NUM_5, 1, 3, 1);
234 edje_object_signal_callback_add(o, "NUM_5", "*", _signal_cb, (void *) NUM_5); 236 _create_button(o, "6", NUM_6, 2, 3, 1);
235 edje_object_signal_callback_add(o, "NUM_6", "*", _signal_cb, (void *) NUM_6); 237 _create_button(o, "1", NUM_1, 0, 4, 1);
236 edje_object_signal_callback_add(o, "NUM_7", "*", _signal_cb, (void *) NUM_7); 238 _create_button(o, "2", NUM_2, 1, 4, 1);
237 edje_object_signal_callback_add(o, "NUM_8", "*", _signal_cb, (void *) NUM_8); 239 _create_button(o, "3", NUM_3, 2, 4, 1);
238 edje_object_signal_callback_add(o, "NUM_9", "*", _signal_cb, (void *) NUM_9); 240 _create_button(o, "0", NUM_0, 0, 5, 1);
239 /* NUM_PI - 3.14159 */ 241 /* NUM_PI - 3.14159 */
240 edje_object_signal_callback_add(o, "NUM_PI", "*", _signal_cb, (void *) NUM_PI); 242// edje_object_signal_callback_add(o, "NUM_PI", "*", _signal_cb, (void *) NUM_PI);
241} 243}
242 244
243static Eina_Bool 245static Eina_Bool
@@ -250,37 +252,42 @@ _key_down_cb(void *data, int type, void *event)
250 { 252 {
251 if (!strcmp(_keymap[i].keyname, ev->key)) 253 if (!strcmp(_keymap[i].keyname, ev->key))
252 { 254 {
253 _signal_cb((void*)_keymap[i].op, elm_layout_edje_get(ly), NULL, NULL); 255 _button_cb((void*)_keymap[i].op, NULL, NULL);
254 } 256 }
255 } 257 }
256 return EINA_TRUE;
257 258
259 return EINA_TRUE;
258} 260}
259 261
260static void 262static void
261_create_gui(void) 263_create_gui(void)
262{ 264{
263 char buf[1024]; 265 Evas_Object *table;
264 266
265 win = elm_win_add(NULL, "equate", ELM_WIN_BASIC); 267 win = elm_win_add(NULL, "equate", ELM_WIN_BASIC);
266 elm_win_title_set(win, "Equate"); 268 elm_win_title_set(win, "Equate");
267 elm_win_autodel_set(win, EINA_TRUE); 269 elm_win_autodel_set(win, EINA_TRUE);
268 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); 270 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
269 271
270 ly = elm_layout_add(win); 272 table = elm_table_add(win);
271 snprintf(buf, sizeof(buf), "%s/themes/equate.edj", elm_app_data_dir_get()); 273 elm_table_homogeneous_set(table, EINA_TRUE);
272 elm_layout_file_set(ly, buf, "Main"); 274 evas_object_size_hint_weight_set(table, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
273 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 275 evas_object_size_hint_align_set(table, EVAS_HINT_FILL, EVAS_HINT_FILL);
274 evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL); 276 elm_win_resize_object_add(win, table);
275 elm_win_resize_object_add(win, ly); 277 evas_object_show(table);
276 evas_object_show(ly);
277 278
278 ecore_event_handler_add (ECORE_EVENT_KEY_DOWN, _key_down_cb, NULL); 279 ecore_event_handler_add (ECORE_EVENT_KEY_DOWN, _key_down_cb, NULL);
279 280
280 evas_object_show(win); 281 evas_object_show(win);
281 evas_object_resize(win, 240, 320); 282 evas_object_resize(win, 240, 320);
282 283
283 _edje_callbacks_define(elm_layout_edje_get(ly)); 284 readout = elm_label_add(table);
285 evas_object_size_hint_weight_set(readout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
286 evas_object_size_hint_align_set(readout, 1.0, EVAS_HINT_FILL);
287 elm_table_pack(table, readout, 0, 0, 4, 1);
288 evas_object_show(readout);
289
290 _create_buttons(table);
284} 291}
285 292
286EAPI_MAIN int 293EAPI_MAIN int