From: Viktor Kojouharov Date: Sun, 13 Sep 2009 11:51:11 +0000 (+0000) Subject: added a disable state for the toggle. the design could use a more experienced hand... X-Git-Tag: v1.0.0~5249 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fc196da838fad1e4a2bb9234857fe57521157eed;p=platform%2Fupstream%2Felementary.git added a disable state for the toggle. the design could use a more experienced hand though SVN revision: 42457 --- diff --git a/data/themes/default.edc b/data/themes/default.edc index 5a51d3b..39533fe 100644 --- a/data/themes/default.edc +++ b/data/themes/default.edc @@ -1310,6 +1310,7 @@ collections { image: "bt_bases.png" COMP; image: "bt_hilightw.png" COMP; image: "tog_base.png" COMP; + image: "tog_dis_base.png" COMP; } parts { part { name: "bg"; @@ -1407,6 +1408,10 @@ collections { rel2.to: "offrect"; image.normal: "tog_base.png"; } + description { state: "disabled" 0.0; + inherit: "default" 0.0; + image.normal: "tog_dis_base.png"; + } } part { name: "elm.offtext"; type: TEXT; @@ -1426,6 +1431,10 @@ collections { text: "OFF"; } } + description { state: "disabled" 0.0; + inherit: "default" 0.0; + color: 128 128 128 128; + } } part { name: "elm.ontext"; type: TEXT; @@ -1449,6 +1458,11 @@ collections { text: "ON"; } } + description { state: "disabled" 0.0; + inherit: "default" 0.0; + color: 128 128 128 128; + color3: 0 0 0 24; + } } part { name: "conf_over"; mouse_events: 0; @@ -1527,6 +1541,17 @@ collections { aspect_preference: VERTICAL; rel2.offset: 4 -5; } + description { state: "disabled" 0.0; + inherit: "default" 0.0; + color: 128 128 128 128; + } + description { state: "disabled_visible" 0.0; + inherit: "default" 0.0; + color: 128 128 128 128; + fixed: 1 1; + visible: 1; + aspect: 1.0 1.0; + } } part { name: "elm.text"; type: TEXT; @@ -1553,6 +1578,26 @@ collections { visible: 1; text.min: 1 1; } + description { state: "disabled" 0.0; + inherit: "default" 0.0; + color: 128 128 128 128; + } + description { state: "disabled_visible" 0.0; + inherit: "default" 0.0; + color: 128 128 128 128; + visible: 1; + } + } + part { name: "disabler"; + type: RECT; + description { state: "default" 0.0; + color: 0 0 0 0; + visible: 0; + } + description { state: "disabled" 0.0; + inherit: "default" 0.0; + visible: 1; + } } } programs { @@ -1612,6 +1657,57 @@ collections { action: STATE_SET "default" 0.0; target: "elm.swallow.content"; } + program { name: "disable"; + signal: "elm,state,disabled"; + source: "elm"; + action: STATE_SET "disabled" 0.0; + target: "togbase"; + target: "elm.offtext"; + target: "elm.ontext"; + target: "disabler"; + after: "disable_text"; + } + program { name: "disable_text"; + script { + new st[31]; + new Float:vl; + get_state(PART:"elm.text", st, 30, vl); + if (!strcmp(st, "visible")) + set_state(PART:"elm.text", "disabled_visible", 0.0); + else + set_state(PART:"elm.text", "disabled", 0.0); + + get_state(PART:"elm.swallow.content", st, 30, vl); + if (!strcmp(st, "visible")) + set_state(PART:"elm.swallow.content", "disabled_visible", 0.0); + else + set_state(PART:"elm.swallow.content", "disabled", 0.0); + } + } + program { name: "enable"; + signal: "elm,state,enabled"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "disabler"; + after: "enable_text"; + } + program { name: "enable_text"; + script { + new st[31]; + new Float:vl; + get_state(PART:"elm.text", st, 30, vl); + if (!strcmp(st, "disabled_visible")) + set_state(PART:"elm.text", "visible", 0.0); + else + set_state(PART:"elm.text", "default", 0.0); + + get_state(PART:"elm.swallow.content", st, 30, vl); + if (!strcmp(st, "visible")) + set_state(PART:"elm.swallow.content", "visible", 0.0); + else + set_state(PART:"elm.swallow.content", "default", 0.0); + } + } } } @@ -11213,7 +11309,9 @@ collections { description { state: "disabled_visible" 0.0; inherit: "default" 0.0; color: 128 128 128 128; + fixed: 1 1; visible: 1; + aspect: 1.0 1.0; } } part { name: "elm.text"; diff --git a/src/bin/test_toggle.c b/src/bin/test_toggle.c index 4e524c7..7703f29 100644 --- a/src/bin/test_toggle.c +++ b/src/bin/test_toggle.c @@ -46,6 +46,18 @@ test_toggle(void *data, Evas_Object *obj, void *event_info) evas_object_show(tg); evas_object_show(ic); + ic = elm_icon_add(win); + snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR); + elm_icon_file_set(ic, buf, NULL); + elm_icon_scale_set(ic, 0, 0); + tg = elm_toggle_add(win); + elm_toggle_label_set(tg, "Icon no scale"); + elm_toggle_icon_set(tg, ic); + elm_object_disabled_set(tg, 1); + elm_box_pack_end(bx, tg); + evas_object_show(tg); + evas_object_show(ic); + tg = elm_toggle_add(win); elm_toggle_label_set(tg, "Label Only"); elm_toggle_states_labels_set(tg, "Big long fun times label", "Small long happy fun label"); diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index c7bde1c..63c4ed4 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -857,7 +857,7 @@ extern "C" { // * table doesnt do homogenous properly // //// (incomplete - medium priority) -// * need to add support for disabled in all widgets. Button, toolbar, hoversel, radio, check, spinner and entry are currently done. +// * need to add support for disabled in all widgets. Button, toolbar, hoversel, radio, check, toggle, spinner and entry are currently done. // * on the fly theme changes - test (should work) // * hoversel only vertical right now - make horizontal // * when entries are in a scroller and change size, the scroller shows scrollbars. fix. same for selecting. for 1 line entries in a scroller should only have scroll arrow indicators. diff --git a/src/lib/elm_toggle.c b/src/lib/elm_toggle.c index 04d975f..e0ddedf 100644 --- a/src/lib/elm_toggle.c +++ b/src/lib/elm_toggle.c @@ -14,6 +14,7 @@ struct _Widget_Data }; static void _del_hook(Evas_Object *obj); +static void _disable_hook(Evas_Object *obj); static void _theme_hook(Evas_Object *obj); static void _sizing_eval(Evas_Object *obj); static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info); @@ -32,6 +33,16 @@ _del_hook(Evas_Object *obj) } static void +_disable_hook(Evas_Object *obj) +{ + Widget_Data *wd = elm_widget_data_get(obj); + if (elm_widget_disabled_get(obj)) + edje_object_signal_emit(wd->tgl, "elm,state,disabled", "elm"); + else + edje_object_signal_emit(wd->tgl, "elm,state,enabled", "elm"); +} + +static void _theme_hook(Evas_Object *obj) { Widget_Data *wd = elm_widget_data_get(obj); @@ -128,6 +139,7 @@ elm_toggle_add(Evas_Object *parent) elm_widget_data_set(obj, wd); elm_widget_del_hook_set(obj, _del_hook); elm_widget_theme_hook_set(obj, _theme_hook); + elm_widget_disable_hook_set(obj, _disable_hook); wd->tgl = edje_object_add(e); _elm_theme_set(wd->tgl, "toggle", "base", "default");