From 8365bd3e5d61808b3e564273ffdb9c85a478c5ca Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Sun, 21 Aug 2011 01:59:09 +0000 Subject: [PATCH] clock: provide placement orientation and width-for-height and vice-versa. If no minimum size is provided in the group, it will allocate the height (for horizontal shelves) or width (for vertical shelves) and then calculate the required size of the gadget. It will also send messages to notify the gadget about it's orientation, if horizontal, vertical or floating. This way it can adapt its "fit" and relative-to properly. NOTE: depends on Edje at revision greater than r62640. SVN revision: 62641 --- src/modules/clock/e_mod_main.c | 111 ++++++++++++++++++++++----------- 1 file changed, 76 insertions(+), 35 deletions(-) diff --git a/src/modules/clock/e_mod_main.c b/src/modules/clock/e_mod_main.c index f82393b19..3d63c6a88 100644 --- a/src/modules/clock/e_mod_main.c +++ b/src/modules/clock/e_mod_main.c @@ -321,6 +321,78 @@ _clock_popup_new(Instance *inst) e_gadcon_popup_show(inst->popup); } +static void +_eval_instance_size(Instance *inst) +{ + Evas_Coord mw, mh, omw, omh; + + edje_object_size_min_get(inst->o_clock, &mw, &mh); + omw = mw; + omh = mh; + + if ((mw < 1) || (mh < 1)) + { + Evas_Coord x, y, sw = 0, sh = 0, ow, oh; + Eina_Bool horiz; + const char *orient; + + switch (inst->gcc->gadcon->orient) + { + case E_GADCON_ORIENT_TOP: + case E_GADCON_ORIENT_CORNER_TL: + case E_GADCON_ORIENT_CORNER_TR: + case E_GADCON_ORIENT_BOTTOM: + case E_GADCON_ORIENT_CORNER_BL: + case E_GADCON_ORIENT_CORNER_BR: + case E_GADCON_ORIENT_HORIZ: + horiz = EINA_TRUE; + orient = "e,state,horizontal"; + break; + + case E_GADCON_ORIENT_LEFT: + case E_GADCON_ORIENT_CORNER_LB: + case E_GADCON_ORIENT_CORNER_LT: + case E_GADCON_ORIENT_RIGHT: + case E_GADCON_ORIENT_CORNER_RB: + case E_GADCON_ORIENT_CORNER_RT: + case E_GADCON_ORIENT_VERT: + horiz = EINA_FALSE; + orient = "e,state,vertical"; + break; + + default: + horiz = EINA_TRUE; + orient = "e,state,float"; + } + + if (inst->gcc->gadcon->shelf) + { + if (horiz) + sh = inst->gcc->gadcon->shelf->h; + else + sw = inst->gcc->gadcon->shelf->w; + } + + evas_object_geometry_get(inst->o_clock, NULL, NULL, &ow, &oh); + if (orient) + edje_object_signal_emit(inst->o_clock, orient, "e"); + evas_object_resize(inst->o_clock, sw, sh); + edje_object_message_signal_process(inst->o_clock); + + edje_object_parts_extends_calc(inst->o_clock, &x, &y, &mw, &mh); + evas_object_resize(inst->o_clock, ow, oh); + } + + if (mw < 4) mw = 4; + if (mh < 4) mh = 4; + + if (mw < omw) mw = omw; + if (mh < omh) mh = omh; + + e_gadcon_client_aspect_set(inst->gcc, mw, mh); + e_gadcon_client_min_size_set(inst->gcc, mw, mh); +} + void e_int_clock_instances_redo(void) { @@ -337,8 +409,6 @@ e_int_clock_instances_redo(void) EINA_LIST_FOREACH(clock_instances, l, inst) { Evas_Object *o = inst->o_clock; - Evas_Coord mw, mh; - if (inst->cfg->digital_clock) e_theme_edje_object_set(o, "base/theme/modules/clock", @@ -356,15 +426,7 @@ e_int_clock_instances_redo(void) edje_object_signal_emit(o, "e,state,seconds,off", "e"); edje_object_part_text_set(o, "e.text.today", todaystr); - edje_object_message_signal_process(o); - mw = 0, mh = 0; - edje_object_size_min_get(o, &mw, &mh); - if ((mw < 1) || (mh < 1)) - edje_object_size_min_calc(o, &mw, &mh); - if (mw < 4) mw = 4; - if (mh < 4) mh = 4; - e_gadcon_client_aspect_set(inst->gcc, mw, mh); - e_gadcon_client_min_size_set(inst->gcc, mw, mh); + _eval_instance_size(inst); if (inst->o_popclock) { @@ -386,7 +448,6 @@ e_int_clock_instances_redo(void) edje_object_signal_emit(o, "e,state,seconds,off", "e"); edje_object_part_text_set(o, "e.text.today", todaystr); - edje_object_message_signal_process(o); } } } @@ -492,20 +553,11 @@ _clock_cb_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSE EVAS_BUTTON_NONE, ev->timestamp, NULL); } } + static void _clock_sizing_changed_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) { - Instance *inst = data; - Evas_Coord mw, mh; - - mw = 0, mh = 0; - edje_object_size_min_get(inst->o_clock, &mw, &mh); - if ((mw < 1) || (mh < 1)) - edje_object_size_min_calc(inst->o_clock, &mw, &mh); - if (mw < 4) mw = 4; - if (mh < 4) mh = 4; - e_gadcon_client_aspect_set(inst->gcc, mw, mh); - e_gadcon_client_min_size_set(inst->gcc, mw, mh); + _eval_instance_size(data); } static E_Gadcon_Client * @@ -592,18 +644,7 @@ _gc_shutdown(E_Gadcon_Client *gcc) static void _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient __UNUSED__) { - Instance *inst; - Evas_Coord mw, mh; - - inst = gcc->data; - mw = 0, mh = 0; - edje_object_size_min_get(inst->o_clock, &mw, &mh); - if ((mw < 1) || (mh < 1)) - edje_object_size_min_calc(inst->o_clock, &mw, &mh); - if (mw < 4) mw = 4; - if (mh < 4) mh = 4; - e_gadcon_client_aspect_set(gcc, mw, mh); - e_gadcon_client_min_size_set(gcc, mw, mh); + _eval_instance_size(gcc->data); } static char *