summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Williams <andy@andywilliams.me>2016-04-15 21:13:26 +0100
committerAndy Williams <andy@andywilliams.me>2016-04-15 21:13:26 +0100
commitde1f864988ed2726f711007f58052cdc6e832846 (patch)
tree42692e1543480f33f4a604fc192ef78f1f0463dd
parent07e9e8a092d9c0ba5cfb55f887315c2c21871653 (diff)
fix glitch with long numbers
Add the readout to a scroller so we don't force the UI to expand with long numbers @fix T3439
-rw-r--r--src/main.c68
1 files changed, 44 insertions, 24 deletions
diff --git a/src/main.c b/src/main.c
index 3c83cc4..f36bfe3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -6,8 +6,8 @@
6#include "Equate.h" 6#include "Equate.h"
7#include "calc.h" 7#include "calc.h"
8 8
9#define EQUATE_WIDTH 200 9#define EQUATE_WIDTH 170
10#define EQUATE_HEIGHT 250 10#define EQUATE_HEIGHT 275
11#define EQUATE_TEXT_SCALE 1.6 11#define EQUATE_TEXT_SCALE 1.6
12 12
13static Evas_Object *win, *table; 13static Evas_Object *win, *table;
@@ -184,7 +184,7 @@ _create_button(Evas_Object *table, const char *text, int op, int x, int y,
184 184
185 evas_object_smart_callback_add(button, "clicked", _button_cb, (void *)(uintptr_t)op); 185 evas_object_smart_callback_add(button, "clicked", _button_cb, (void *)(uintptr_t)op);
186 186
187 elm_table_pack(table, button, x, y, w, 1); 187 elm_table_pack(table, button, x, y, w, 2);
188 evas_object_show(button); 188 evas_object_show(button);
189} 189}
190 190
@@ -193,20 +193,20 @@ _create_buttons(Evas_Object *o)
193{ 193{
194 /** Equate Operations **/ 194 /** Equate Operations **/
195 /* OP_CLR - Clear Display */ 195 /* OP_CLR - Clear Display */
196 _create_button(o, "C", OP_CLR, 3, 2, 1); 196 _create_button(o, "C", OP_CLR, 3, 5, 1);
197 /* OP_DIV - Division Operator */ 197 /* OP_DIV - Division Operator */
198 _create_button(o, "/", OP_DIV, 3, 1, 1); 198 _create_button(o, "/", OP_DIV, 3, 3, 1);
199 /* OP_MUT - Mutplication Operator */ 199 /* OP_MUT - Mutplication Operator */
200 _create_button(o, "*", OP_MUT, 2, 1, 1); 200 _create_button(o, "*", OP_MUT, 2, 3, 1);
201 /* OP_ADD - Addition Operator */ 201 /* OP_ADD - Addition Operator */
202 _create_button(o, "+", OP_ADD, 0, 1, 1); 202 _create_button(o, "+", OP_ADD, 0, 3, 1);
203 /* OP_SUB - Subtraction Operator */ 203 /* OP_SUB - Subtraction Operator */
204 _create_button(o, "-", OP_SUB, 1, 1, 1); 204 _create_button(o, "-", OP_SUB, 1, 3, 1);
205 /* OP_EQU - Equals Operator */ 205 /* OP_EQU - Equals Operator */
206 _create_button(o, "=", OP_EQU, 2, 5, 2); 206 _create_button(o, "=", OP_EQU, 2, 11, 2);
207 207
208 /* OP_DEC - Decimal Operator */ 208 /* OP_DEC - Decimal Operator */
209 _create_button(o, ".", OP_DEC, 1, 5, 1); 209 _create_button(o, ".", OP_DEC, 1, 11, 1);
210 /* OP_SIN - Sin of x in degrees */ 210 /* OP_SIN - Sin of x in degrees */
211// edje_object_signal_callback_add(o, "OP_SIN", "*", _signal_cb, 211// edje_object_signal_callback_add(o, "OP_SIN", "*", _signal_cb,
212// (void *) OP_SIN); 212// (void *) OP_SIN);
@@ -231,21 +231,21 @@ _create_buttons(Evas_Object *o)
231// edje_object_signal_callback_add(o, "OP_EXP", "*", _signal_cb, 231// edje_object_signal_callback_add(o, "OP_EXP", "*", _signal_cb,
232// (void *) OP_EXP); 232// (void *) OP_EXP);
233 /* OP_OBRAK - open bracket */ 233 /* OP_OBRAK - open bracket */
234 _create_button(o, "(", OP_OBRAK, 3, 3, 1); 234 _create_button(o, "(", OP_OBRAK, 3, 7, 1);
235 /* OP_CBRAK - close bracket */ 235 /* OP_CBRAK - close bracket */
236 _create_button(o, ")", OP_CBRAK, 3, 4, 1); 236 _create_button(o, ")", OP_CBRAK, 3, 9, 1);
237 237
238 /** Equate Numbers **/ 238 /** Equate Numbers **/
239 _create_button(o, "7", NUM_7, 0, 2, 1); 239 _create_button(o, "7", NUM_7, 0, 5, 1);
240 _create_button(o, "8", NUM_8, 1, 2, 1); 240 _create_button(o, "8", NUM_8, 1, 5, 1);
241 _create_button(o, "9", NUM_9, 2, 2, 1); 241 _create_button(o, "9", NUM_9, 2, 5, 1);
242 _create_button(o, "4", NUM_4, 0, 3, 1); 242 _create_button(o, "4", NUM_4, 0, 7, 1);
243 _create_button(o, "5", NUM_5, 1, 3, 1); 243 _create_button(o, "5", NUM_5, 1, 7, 1);
244 _create_button(o, "6", NUM_6, 2, 3, 1); 244 _create_button(o, "6", NUM_6, 2, 7, 1);
245 _create_button(o, "1", NUM_1, 0, 4, 1); 245 _create_button(o, "1", NUM_1, 0, 9, 1);
246 _create_button(o, "2", NUM_2, 1, 4, 1); 246 _create_button(o, "2", NUM_2, 1, 9, 1);
247 _create_button(o, "3", NUM_3, 2, 4, 1); 247 _create_button(o, "3", NUM_3, 2, 9, 1);
248 _create_button(o, "0", NUM_0, 0, 5, 1); 248 _create_button(o, "0", NUM_0, 0, 11, 1);
249 /* NUM_PI - 3.14159 */ 249 /* NUM_PI - 3.14159 */
250// edje_object_signal_callback_add(o, "NUM_PI", "*", _signal_cb, (void *) NUM_PI); 250// edje_object_signal_callback_add(o, "NUM_PI", "*", _signal_cb, (void *) NUM_PI);
251} 251}
@@ -283,18 +283,28 @@ _resize_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj,
283static void 283static void
284_create_gui(void) 284_create_gui(void)
285{ 285{
286 Evas_Object *scroller, *bg;
287
286 win = elm_win_add(NULL, "equate", ELM_WIN_BASIC); 288 win = elm_win_add(NULL, "equate", ELM_WIN_BASIC);
287 elm_win_title_set(win, "Equate"); 289 elm_win_title_set(win, "Equate");
288 elm_win_autodel_set(win, EINA_TRUE); 290 elm_win_autodel_set(win, EINA_TRUE);
289 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); 291 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
290 292
293 bg = elm_bg_add(win);
294 evas_object_color_set(bg, 0, 0, 0, 255);
295 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
296 evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
297 elm_win_resize_object_add(win, bg);
298 evas_object_show(bg);
299
291 table = elm_table_add(win); 300 table = elm_table_add(win);
292 elm_table_homogeneous_set(table, EINA_TRUE); 301 elm_table_homogeneous_set(table, EINA_TRUE);
293 evas_object_size_hint_weight_set(table, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 302 evas_object_size_hint_weight_set(table, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
294 evas_object_size_hint_align_set(table, EVAS_HINT_FILL, EVAS_HINT_FILL); 303 evas_object_size_hint_align_set(table, EVAS_HINT_FILL, EVAS_HINT_FILL);
295 304
296 evas_object_move(table, 0, 0); 305 evas_object_move(table, 0, 0);
297 evas_object_resize(table, EQUATE_WIDTH, EQUATE_HEIGHT); 306 evas_object_resize(table, EQUATE_WIDTH * elm_config_scale_get(),
307 EQUATE_HEIGHT * elm_config_scale_get());
298 evas_object_show(table); 308 evas_object_show(table);
299 309
300 ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _key_down_cb, NULL); 310 ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _key_down_cb, NULL);
@@ -306,11 +316,21 @@ _create_gui(void)
306 evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _resize_cb, NULL); 316 evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _resize_cb, NULL);
307 317
308 readout = elm_label_add(table); 318 readout = elm_label_add(table);
319 elm_object_scale_set(readout, 2 * EQUATE_TEXT_SCALE);
309 evas_object_size_hint_weight_set(readout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 320 evas_object_size_hint_weight_set(readout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
310 evas_object_size_hint_align_set(readout, 1.0, EVAS_HINT_FILL); 321 evas_object_size_hint_align_set(readout, 1.0, EVAS_HINT_FILL);
311 elm_table_pack(table, readout, 0, 0, 4, 1);
312 evas_object_show(readout); 322 evas_object_show(readout);
313 323
324 scroller = elm_scroller_add(table);
325 elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
326 elm_scroller_gravity_set(scroller, 1.0, 1.0);
327 elm_object_scale_set(scroller, 1.0);
328 evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
329 evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
330 elm_object_content_set(scroller, readout);
331 elm_table_pack(table, scroller, 0, 0, 4, 3);
332 evas_object_show(scroller);
333
314 _create_buttons(table); 334 _create_buttons(table);
315} 335}
316 336