From 7c50cdd4aaf83fe4dc5f80b8394244dc9a2756cd Mon Sep 17 00:00:00 2001 From: Kim Shinwoo Date: Wed, 12 Sep 2012 08:46:10 +0000 Subject: [PATCH] From: Kim Shinwoo Subject: [E-devel] [patch][elementary] diskselector - text align issue by default diskselector item has space for icon even though the item does not have icon. so in some cases, the text is not located in the center of item and diskselector. the attachment would resolve this issue. please look into it and give feedback. thanks. SVN revision: 76507 --- legacy/elementary/ChangeLog | 2 +- legacy/elementary/NEWS | 1 + .../data/themes/widgets/diskselector.edc | 83 ++++++++++++++++--- legacy/elementary/src/lib/elm_diskselector.c | 30 ++++--- 4 files changed, 92 insertions(+), 24 deletions(-) diff --git a/legacy/elementary/ChangeLog b/legacy/elementary/ChangeLog index 7c97034c2b..d90e426e8c 100644 --- a/legacy/elementary/ChangeLog +++ b/legacy/elementary/ChangeLog @@ -466,7 +466,7 @@ 2012-09-12 Shinwoo Kim (kimcinoo) * Add access features to calendar. - + * Add icon show/hide handling to diskselector ala button etc. 2012-09-12 Thiep Ha diff --git a/legacy/elementary/NEWS b/legacy/elementary/NEWS index ae10460612..7a0eda23ff 100644 --- a/legacy/elementary/NEWS +++ b/legacy/elementary/NEWS @@ -15,6 +15,7 @@ Improvements: * Popup widget is now an elm layout. * Panel widget is now an elm layout. * Improve elm map module loading/searching efficiency. + * Diskselector handles dyanmic show/hide of icons now like buttons. Fixes: diff --git a/legacy/elementary/data/themes/widgets/diskselector.edc b/legacy/elementary/data/themes/widgets/diskselector.edc index a051abdafe..5e3b2ae2d1 100644 --- a/legacy/elementary/data/themes/widgets/diskselector.edc +++ b/legacy/elementary/data/themes/widgets/diskselector.edc @@ -185,6 +185,23 @@ group { name: "elm/diskselector/item/default"; text.size: 8; text.align: 0.8 0.5; } + description { state: "text_only" 0.0; + inherit: "default" 0.0; + visible: 1; + rel1.relative: 0 0; + rel2.relative: 1 1; + } + description { state: "text_only_left_side" 0.0; + inherit: "left_side" 0.0; + rel1.relative: 0 0; + rel2.relative: 1 1; + } + description { state: "text_only_right_side" 0.0; + inherit: "right_side" 0.0; + visible: 1; + rel1.relative: 0 0; + rel2.relative: 1 1; + } } part { name: "over1"; type: RECT; @@ -199,12 +216,23 @@ group { name: "elm/diskselector/item/default"; } programs { + script { + public item_style; // 0:icon and text, 1:text only, 2:con only + } program { name: "center_text"; signal: "elm,state,center"; source: "elm"; - action: STATE_SET "show" 0.0; - target: "elm.text"; - target: "elm.swallow.icon"; + script { + if (get_int(item_style) == 1) + set_state(PART:"elm.text", "text_only", 0.0); + else if (get_int(item_style) == 2) + set_state(PART:"elm.swallow.icon", "icon_only", 0.0); + else + { + set_state(PART:"elm.text", "show", 0.0); + set_state(PART:"elm.swallow.icon", "show", 0.0); + } + } } program { name: "center_small_text"; signal: "elm,state,center_small"; @@ -216,22 +244,55 @@ group { name: "elm/diskselector/item/default"; program { name: "l_side_text"; signal: "elm,state,left_side"; source: "elm"; - action: STATE_SET "left_side" 0.0; - target: "elm.text"; - target: "elm.swallow.icon"; + script { + if (get_int(item_style) == 1) + set_state(PART:"elm.text", "text_only_left_side", 0.0); + else if (get_int(item_style) == 2) + set_state(PART:"elm.swallow.icon", "left_side", 0.0); + else + { + set_state(PART:"elm.text", "left_side", 0.0); + set_state(PART:"elm.swallow.icon", "left_side", 0.0); + } + } } program { name: "r_side_text"; signal: "elm,state,right_side"; source: "elm"; - action: STATE_SET "right_side" 0.0; - target: "elm.text"; - target: "elm.swallow.icon"; + script { + if (get_int(item_style) == 1) + set_state(PART:"elm.text", "text_only_right_side", 0.0); + else if (get_int(item_style) == 2) + set_state(PART:"elm.swallow.icon", "right_side", 0.0); + else + { + set_state(PART:"elm.text", "right_side", 0.0); + set_state(PART:"elm.swallow.icon", "right_side", 0.0); + } + } } program { name: "icon_only"; signal: "elm,state,icon,only"; source: "elm"; - action: STATE_SET "icon_only" 0.0; - target: "elm.swallow.icon"; + script { + set_state(PART:"elm.swallow.icon", "icon_only", 0.0); + set_int(item_style, 2); + } + } + program { name: "text_only"; + signal: "elm,state,text,only"; + source: "elm"; + script { + set_state(PART:"elm.text", "text_only", 0.0); + set_int(item_style, 1); + } + } + program { name: "text_icon"; + signal: "elm,state,text,icon"; + source: "elm"; + script { + set_int(item_style, 0); + } } program { name: "field_click"; signal: "mouse,clicked,1"; diff --git a/legacy/elementary/src/lib/elm_diskselector.c b/legacy/elementary/src/lib/elm_diskselector.c index a7e9144ac2..532038d006 100644 --- a/legacy/elementary/src/lib/elm_diskselector.c +++ b/legacy/elementary/src/lib/elm_diskselector.c @@ -105,6 +105,16 @@ _letters_check(const char *str, return pos; } +static void +_item_signal_emit(Elm_Diskselector_Item *item) +{ + if ((item->icon) && (!item->label)) + edje_object_signal_emit(VIEW(item), "elm,state,icon,only", "elm"); + else if ((!item->icon) && (item->label)) + edje_object_signal_emit(VIEW(item), "elm,state,text,only", "elm"); + else + edje_object_signal_emit(VIEW(item), "elm,state,text,icon", "elm"); +} static Eina_Bool _string_check(void *data) @@ -413,9 +423,7 @@ _item_text_set_hook(Elm_Object_Item *it, eina_stringshare_replace(&item->label, label); edje_object_part_text_escaped_set(VIEW(item), "elm.text", item->label); - // if the label is NULL, the icon should position at center of the item - if (item->icon && (!item->label)) - edje_object_signal_emit(VIEW(item), "elm,state,icon,only", "elm"); + _item_signal_emit(item); } static const char * @@ -435,18 +443,17 @@ _item_icon_set(Elm_Diskselector_Item *it, if (it->icon) evas_object_del(it->icon); it->icon = icon; + if (VIEW(it)) { - // if the label is NULL, the icon should position at center of the item - if (it->icon && (!it->label)) - edje_object_signal_emit(VIEW(it), "elm,state,icon,only", "elm"); - evas_object_size_hint_min_set(it->icon, 24, 24); evas_object_size_hint_max_set(it->icon, 40, 40); edje_object_part_swallow(VIEW(it), "elm.swallow.icon", it->icon); evas_object_show(it->icon); elm_widget_sub_object_add(WIDGET(it), it->icon); } + + _item_signal_emit(it); } static void @@ -606,16 +613,15 @@ _item_new(Evas_Object *obj, evas_object_size_hint_align_set(VIEW(it), EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(VIEW(it)); + if (icon) + _item_content_set_hook((Elm_Object_Item *)it, "icon", icon); + if (it->label) { - edje_object_part_text_escaped_set(VIEW(it), "elm.text", it->label); + _item_text_set_hook((Elm_Object_Item *)it, "default", it->label); edje_object_signal_callback_add (VIEW(it), "elm,action,click", "", _item_click_cb, it); } - if (icon) - { - _item_content_set_hook((Elm_Object_Item *)it, "icon", icon); - } //XXX: ACCESS _elm_access_widget_item_register((Elm_Widget_Item *)it);