forked from enlightenment/equate
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
This commit is contained in:
parent
07e9e8a092
commit
de1f864988
68
src/main.c
68
src/main.c
|
@ -6,8 +6,8 @@
|
|||
#include "Equate.h"
|
||||
#include "calc.h"
|
||||
|
||||
#define EQUATE_WIDTH 200
|
||||
#define EQUATE_HEIGHT 250
|
||||
#define EQUATE_WIDTH 170
|
||||
#define EQUATE_HEIGHT 275
|
||||
#define EQUATE_TEXT_SCALE 1.6
|
||||
|
||||
static Evas_Object *win, *table;
|
||||
|
@ -184,7 +184,7 @@ _create_button(Evas_Object *table, const char *text, int op, int x, int y,
|
|||
|
||||
evas_object_smart_callback_add(button, "clicked", _button_cb, (void *)(uintptr_t)op);
|
||||
|
||||
elm_table_pack(table, button, x, y, w, 1);
|
||||
elm_table_pack(table, button, x, y, w, 2);
|
||||
evas_object_show(button);
|
||||
}
|
||||
|
||||
|
@ -193,20 +193,20 @@ _create_buttons(Evas_Object *o)
|
|||
{
|
||||
/** Equate Operations **/
|
||||
/* OP_CLR - Clear Display */
|
||||
_create_button(o, "C", OP_CLR, 3, 2, 1);
|
||||
_create_button(o, "C", OP_CLR, 3, 5, 1);
|
||||
/* OP_DIV - Division Operator */
|
||||
_create_button(o, "/", OP_DIV, 3, 1, 1);
|
||||
_create_button(o, "/", OP_DIV, 3, 3, 1);
|
||||
/* OP_MUT - Mutplication Operator */
|
||||
_create_button(o, "*", OP_MUT, 2, 1, 1);
|
||||
_create_button(o, "*", OP_MUT, 2, 3, 1);
|
||||
/* OP_ADD - Addition Operator */
|
||||
_create_button(o, "+", OP_ADD, 0, 1, 1);
|
||||
_create_button(o, "+", OP_ADD, 0, 3, 1);
|
||||
/* OP_SUB - Subtraction Operator */
|
||||
_create_button(o, "-", OP_SUB, 1, 1, 1);
|
||||
_create_button(o, "-", OP_SUB, 1, 3, 1);
|
||||
/* OP_EQU - Equals Operator */
|
||||
_create_button(o, "=", OP_EQU, 2, 5, 2);
|
||||
_create_button(o, "=", OP_EQU, 2, 11, 2);
|
||||
|
||||
/* OP_DEC - Decimal Operator */
|
||||
_create_button(o, ".", OP_DEC, 1, 5, 1);
|
||||
_create_button(o, ".", OP_DEC, 1, 11, 1);
|
||||
/* OP_SIN - Sin of x in degrees */
|
||||
// edje_object_signal_callback_add(o, "OP_SIN", "*", _signal_cb,
|
||||
// (void *) OP_SIN);
|
||||
|
@ -231,21 +231,21 @@ _create_buttons(Evas_Object *o)
|
|||
// edje_object_signal_callback_add(o, "OP_EXP", "*", _signal_cb,
|
||||
// (void *) OP_EXP);
|
||||
/* OP_OBRAK - open bracket */
|
||||
_create_button(o, "(", OP_OBRAK, 3, 3, 1);
|
||||
_create_button(o, "(", OP_OBRAK, 3, 7, 1);
|
||||
/* OP_CBRAK - close bracket */
|
||||
_create_button(o, ")", OP_CBRAK, 3, 4, 1);
|
||||
_create_button(o, ")", OP_CBRAK, 3, 9, 1);
|
||||
|
||||
/** Equate Numbers **/
|
||||
_create_button(o, "7", NUM_7, 0, 2, 1);
|
||||
_create_button(o, "8", NUM_8, 1, 2, 1);
|
||||
_create_button(o, "9", NUM_9, 2, 2, 1);
|
||||
_create_button(o, "4", NUM_4, 0, 3, 1);
|
||||
_create_button(o, "5", NUM_5, 1, 3, 1);
|
||||
_create_button(o, "6", NUM_6, 2, 3, 1);
|
||||
_create_button(o, "1", NUM_1, 0, 4, 1);
|
||||
_create_button(o, "2", NUM_2, 1, 4, 1);
|
||||
_create_button(o, "3", NUM_3, 2, 4, 1);
|
||||
_create_button(o, "0", NUM_0, 0, 5, 1);
|
||||
_create_button(o, "7", NUM_7, 0, 5, 1);
|
||||
_create_button(o, "8", NUM_8, 1, 5, 1);
|
||||
_create_button(o, "9", NUM_9, 2, 5, 1);
|
||||
_create_button(o, "4", NUM_4, 0, 7, 1);
|
||||
_create_button(o, "5", NUM_5, 1, 7, 1);
|
||||
_create_button(o, "6", NUM_6, 2, 7, 1);
|
||||
_create_button(o, "1", NUM_1, 0, 9, 1);
|
||||
_create_button(o, "2", NUM_2, 1, 9, 1);
|
||||
_create_button(o, "3", NUM_3, 2, 9, 1);
|
||||
_create_button(o, "0", NUM_0, 0, 11, 1);
|
||||
/* NUM_PI - 3.14159 */
|
||||
// edje_object_signal_callback_add(o, "NUM_PI", "*", _signal_cb, (void *) NUM_PI);
|
||||
}
|
||||
|
@ -283,18 +283,28 @@ _resize_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj,
|
|||
static void
|
||||
_create_gui(void)
|
||||
{
|
||||
Evas_Object *scroller, *bg;
|
||||
|
||||
win = elm_win_add(NULL, "equate", ELM_WIN_BASIC);
|
||||
elm_win_title_set(win, "Equate");
|
||||
elm_win_autodel_set(win, EINA_TRUE);
|
||||
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
|
||||
|
||||
bg = elm_bg_add(win);
|
||||
evas_object_color_set(bg, 0, 0, 0, 255);
|
||||
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_win_resize_object_add(win, bg);
|
||||
evas_object_show(bg);
|
||||
|
||||
table = elm_table_add(win);
|
||||
elm_table_homogeneous_set(table, EINA_TRUE);
|
||||
evas_object_size_hint_weight_set(table, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(table, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
|
||||
evas_object_move(table, 0, 0);
|
||||
evas_object_resize(table, EQUATE_WIDTH, EQUATE_HEIGHT);
|
||||
evas_object_resize(table, EQUATE_WIDTH * elm_config_scale_get(),
|
||||
EQUATE_HEIGHT * elm_config_scale_get());
|
||||
evas_object_show(table);
|
||||
|
||||
ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _key_down_cb, NULL);
|
||||
|
@ -306,11 +316,21 @@ _create_gui(void)
|
|||
evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _resize_cb, NULL);
|
||||
|
||||
readout = elm_label_add(table);
|
||||
elm_object_scale_set(readout, 2 * EQUATE_TEXT_SCALE);
|
||||
evas_object_size_hint_weight_set(readout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(readout, 1.0, EVAS_HINT_FILL);
|
||||
elm_table_pack(table, readout, 0, 0, 4, 1);
|
||||
evas_object_show(readout);
|
||||
|
||||
scroller = elm_scroller_add(table);
|
||||
elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
|
||||
elm_scroller_gravity_set(scroller, 1.0, 1.0);
|
||||
elm_object_scale_set(scroller, 1.0);
|
||||
evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_object_content_set(scroller, readout);
|
||||
elm_table_pack(table, scroller, 0, 0, 4, 3);
|
||||
evas_object_show(scroller);
|
||||
|
||||
_create_buttons(table);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue