summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorJaehwan Kim <jae.hwan.kim.neo@gmail.com>2012-03-06 11:35:11 +0000
committerJaehwan Kim <jae.hwan.kim.neo@gmail.com>2012-03-06 11:35:11 +0000
commit044fc4bf0303cabe0b05c117c701665b0ae6b0a4 (patch)
tree18e74419832410d1d0a7dd0a58dfce005e2e871e /legacy
parenta45eee11ee8e9a95dade8714fff4fa0a7382cbc8 (diff)
Add the item_content_set/get/unset_hook for setting the object as the content of the toolbar item.
It's possible the objects(like slider or progressbar and so on) can be shown in toolbar. SVN revision: 68805
Diffstat (limited to 'legacy')
-rw-r--r--legacy/elementary/data/themes/widgets/toolbar.edc11
-rw-r--r--legacy/elementary/src/bin/test_toolbar.c9
-rw-r--r--legacy/elementary/src/lib/elm_toolbar.c74
3 files changed, 81 insertions, 13 deletions
diff --git a/legacy/elementary/data/themes/widgets/toolbar.edc b/legacy/elementary/data/themes/widgets/toolbar.edc
index f148ed0f5e..ae0b6fc081 100644
--- a/legacy/elementary/data/themes/widgets/toolbar.edc
+++ b/legacy/elementary/data/themes/widgets/toolbar.edc
@@ -674,3 +674,14 @@ group { name: "elm/toolbar/separator/default";
674 } 674 }
675} 675}
676 676
677group { name: "elm/toolbar/object/default";
678 parts {
679 part { name: "elm.swallow.object"; // object group
680 type: SWALLOW;
681 description {
682 state: "default" 0.0;
683 }
684 }
685 }
686}
687
diff --git a/legacy/elementary/src/bin/test_toolbar.c b/legacy/elementary/src/bin/test_toolbar.c
index ae2e2656a8..9107eb0196 100644
--- a/legacy/elementary/src/bin/test_toolbar.c
+++ b/legacy/elementary/src/bin/test_toolbar.c
@@ -840,7 +840,7 @@ test_toolbar7(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
840void 840void
841test_toolbar8(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) 841test_toolbar8(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
842{ 842{
843 Evas_Object *win, *bg, *bx, *tb, *ph, *menu; 843 Evas_Object *win, *bg, *bx, *tb, *ph, *sl, *menu;
844 Evas_Object *ph1, *ph2, *ph3, *ph4; 844 Evas_Object *ph1, *ph2, *ph3, *ph4;
845 Elm_Object_Item *item; 845 Elm_Object_Item *item;
846 Elm_Object_Item *menu_it; 846 Elm_Object_Item *menu_it;
@@ -861,7 +861,7 @@ test_toolbar8(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
861 evas_object_show(bx); 861 evas_object_show(bx);
862 862
863 tb = elm_toolbar_add(win); 863 tb = elm_toolbar_add(win);
864 elm_toolbar_homogeneous_set(tb, EINA_TRUE); 864 elm_toolbar_homogeneous_set(tb, EINA_FALSE);
865 elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_EXPAND); 865 elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_EXPAND);
866 evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 866 evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
867 evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL); 867 evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
@@ -881,6 +881,11 @@ test_toolbar8(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
881 item = elm_toolbar_item_append(tb, "object-rotate-right", "H", tb_3, ph4); 881 item = elm_toolbar_item_append(tb, "object-rotate-right", "H", tb_3, ph4);
882 elm_toolbar_item_priority_set(item, -150); 882 elm_toolbar_item_priority_set(item, -150);
883 883
884 sl = elm_slider_add(win);
885 evas_object_size_hint_min_set(sl, 100, 50);
886 item = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL);
887 elm_object_item_part_content_set(item, "object", sl);
888
884 item = elm_toolbar_item_append(tb, "mail-send", "Comes", tb_4, ph4); 889 item = elm_toolbar_item_append(tb, "mail-send", "Comes", tb_4, ph4);
885 elm_toolbar_item_priority_set(item, -200); 890 elm_toolbar_item_priority_set(item, -200);
886 891
diff --git a/legacy/elementary/src/lib/elm_toolbar.c b/legacy/elementary/src/lib/elm_toolbar.c
index ed9dc866ba..ceec8dd841 100644
--- a/legacy/elementary/src/lib/elm_toolbar.c
+++ b/legacy/elementary/src/lib/elm_toolbar.c
@@ -34,6 +34,7 @@ struct _Elm_Toolbar_Item
34 const char *label; 34 const char *label;
35 const char *icon_str; 35 const char *icon_str;
36 Evas_Object *icon; 36 Evas_Object *icon;
37 Evas_Object *object;
37 Evas_Object *o_menu; 38 Evas_Object *o_menu;
38 Evas_Smart_Cb func; 39 Evas_Smart_Cb func;
39 struct { 40 struct {
@@ -170,7 +171,7 @@ _item_select(Elm_Toolbar_Item *it)
170 Eina_Bool sel; 171 Eina_Bool sel;
171 172
172 if (!wd) return; 173 if (!wd) return;
173 if (elm_widget_item_disabled_get(it) || (it->separator)) return; 174 if (elm_widget_item_disabled_get(it) || (it->separator) || (it->object)) return;
174 sel = it->selected; 175 sel = it->selected;
175 176
176 if (!wd->no_select) 177 if (!wd->no_select)
@@ -312,7 +313,7 @@ _theme_hook_item(Evas_Object *obj, Elm_Toolbar_Item *it, double scale, int icon_
312 313
313 _mirrored_set_item(obj, it, elm_widget_mirrored_get(obj)); 314 _mirrored_set_item(obj, it, elm_widget_mirrored_get(obj));
314 edje_object_scale_set(view, scale); 315 edje_object_scale_set(view, scale);
315 if (!it->separator) 316 if (!it->separator && !it->object)
316 { 317 {
317 _elm_theme_object_set(obj, view, "toolbar", "item", style); 318 _elm_theme_object_set(obj, view, "toolbar", "item", style);
318 if (it->selected) 319 if (it->selected)
@@ -338,24 +339,32 @@ _theme_hook_item(Evas_Object *obj, Elm_Toolbar_Item *it, double scale, int icon_
338 } 339 }
339 else 340 else
340 { 341 {
341 _elm_theme_object_set(obj, view, "toolbar", "separator", style); 342 if (!it->object)
342 if (wd->vertical)
343 { 343 {
344 evas_object_size_hint_weight_set(view, EVAS_HINT_EXPAND, -1.0); 344 _elm_theme_object_set(obj, view, "toolbar", "separator", style);
345 evas_object_size_hint_align_set(view, EVAS_HINT_FILL, 0.5); 345 if (wd->vertical)
346 {
347 evas_object_size_hint_weight_set(view, EVAS_HINT_EXPAND, -1.0);
348 evas_object_size_hint_align_set(view, EVAS_HINT_FILL, 0.5);
349 }
350 else
351 {
352 evas_object_size_hint_weight_set(view, -1.0, EVAS_HINT_EXPAND);
353 evas_object_size_hint_align_set(view, 0.5, EVAS_HINT_FILL);
354 }
346 } 355 }
347 else 356 else
348 { 357 {
349 evas_object_size_hint_weight_set(view, -1.0, EVAS_HINT_EXPAND); 358 _elm_theme_object_set(obj, view, "toolbar", "object", style);
350 evas_object_size_hint_align_set(view, 0.5, EVAS_HINT_FILL); 359 edje_object_part_swallow(view, "elm.swallow.object", it->object);
351 } 360 }
352 } 361 }
353 362
354 mw = mh = -1; 363 mw = mh = -1;
355 if (!it->separator) 364 if (!it->separator && !it->object)
356 elm_coords_finger_size_adjust(1, &mw, 1, &mh); 365 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
357 edje_object_size_min_restricted_calc(view, &mw, &mh, mw, mh); 366 edje_object_size_min_restricted_calc(view, &mw, &mh, mw, mh);
358 if (!it->separator) 367 if (!it->separator && !it->object)
359 elm_coords_finger_size_adjust(1, &mw, 1, &mh); 368 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
360 evas_object_size_hint_min_set(view, mw, mh); 369 evas_object_size_hint_min_set(view, mw, mh);
361} 370}
@@ -410,6 +419,45 @@ _item_text_get_hook(const Elm_Object_Item *it, const char *part)
410} 419}
411 420
412static void 421static void
422_item_content_set_hook(Elm_Object_Item *it,
423 const char *part,
424 Evas_Object *content)
425{
426 if (part && strcmp(part, "object")) return;
427 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
428 Evas_Object *obj = WIDGET(item);
429 Widget_Data *wd = elm_widget_data_get(obj);
430 double scale;
431 if (item->object == content) return;
432 item->object = content;
433 elm_widget_sub_object_add(obj, item->object);
434 scale = (elm_widget_scale_get(obj) * _elm_config->scale);
435 _theme_hook_item(obj, item, scale, wd->icon_size);
436}
437
438static Evas_Object *
439_item_content_get_hook(const Elm_Object_Item *it, const char *part)
440{
441 if (part && strcmp(part, "object")) return NULL;
442 return ((Elm_Toolbar_Item *) it)->object;
443}
444
445static Evas_Object *
446_item_content_unset_hook(Elm_Object_Item *it, const char *part)
447{
448 if (part && strcmp(part, "object")) return;
449 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
450 Evas_Object *obj = WIDGET(item);
451 Widget_Data *wd = elm_widget_data_get(obj);
452 double scale;
453 edje_object_part_unswallow(VIEW(it), item->object);
454 elm_widget_sub_object_del(obj, item->object);
455 item->object = NULL;
456 scale = (elm_widget_scale_get(obj) * _elm_config->scale);
457 _theme_hook_item(obj, item, scale, wd->icon_size);
458}
459
460static void
413_translate_hook(Evas_Object *obj) 461_translate_hook(Evas_Object *obj)
414{ 462{
415 evas_object_smart_callback_call(obj, "language,changed", NULL); 463 evas_object_smart_callback_call(obj, "language,changed", NULL);
@@ -882,12 +930,16 @@ _item_new(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb f
882 elm_widget_item_disable_hook_set(it, _item_disable_hook); 930 elm_widget_item_disable_hook_set(it, _item_disable_hook);
883 elm_widget_item_text_set_hook_set(it, _item_text_set_hook); 931 elm_widget_item_text_set_hook_set(it, _item_text_set_hook);
884 elm_widget_item_text_get_hook_set(it, _item_text_get_hook); 932 elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
933 elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
934 elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
935 elm_widget_item_content_unset_hook_set(it, _item_content_unset_hook);
885 936
886 it->label = eina_stringshare_add(label); 937 it->label = eina_stringshare_add(label);
887 it->prio.visible = 1; 938 it->prio.visible = 1;
888 it->prio.priority = 0; 939 it->prio.priority = 0;
889 it->func = func; 940 it->func = func;
890 it->separator = EINA_FALSE; 941 it->separator = EINA_FALSE;
942 it->object = NULL;
891 it->base.data = data; 943 it->base.data = data;
892 VIEW(it) = edje_object_add(evas_object_evas_get(obj)); 944 VIEW(it) = edje_object_add(evas_object_evas_get(obj));
893 _elm_access_item_register(&it->base, VIEW(it)); 945 _elm_access_item_register(&it->base, VIEW(it));
@@ -941,7 +993,7 @@ _item_new(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb f
941 elm_coords_finger_size_adjust(1, &mw, 1, &mh); 993 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
942 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw, mh); 994 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw, mh);
943 elm_coords_finger_size_adjust(1, &mw, 1, &mh); 995 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
944 if (wd->shrink_mode != ELM_TOOLBAR_SHRINK_EXPAND) 996 if (wd->shrink_mode != ELM_TOOLBAR_SHRINK_EXPAND)
945 { 997 {
946 if (wd->vertical) 998 if (wd->vertical)
947 { 999 {