From 4204583f811b80576f0cf14ed56199d084b197b1 Mon Sep 17 00:00:00 2001 From: Daniel Juyung Seo Date: Thu, 7 Apr 2011 16:44:54 +0000 Subject: [PATCH] Elementary segment_control: Introduced new widget by Govindaraju and Prince. Segment Control Widget is a horizontal control made of multiple segment items together, each segment item is set to equal size, functioning similar to discrete two state button. Only one segment item can be at selected state. SVN revision: 58461 --- legacy/elementary/AUTHORS | 2 + legacy/elementary/data/objects/test.edc | 133 +++ legacy/elementary/data/themes/default.edc | 631 +++++++++++++ .../data/themes/seg_left_normal.png | Bin 0 -> 719 bytes .../data/themes/seg_left_pressed.png | Bin 0 -> 747 bytes .../data/themes/seg_left_selected.png | Bin 0 -> 595 bytes .../data/themes/seg_middle_normal.png | Bin 0 -> 425 bytes .../data/themes/seg_middle_pressed.png | Bin 0 -> 856 bytes .../data/themes/seg_middle_selected.png | Bin 0 -> 709 bytes .../data/themes/seg_right_normal.png | Bin 0 -> 778 bytes .../data/themes/seg_right_pressed.png | Bin 0 -> 756 bytes .../data/themes/seg_right_selected.png | Bin 0 -> 592 bytes .../data/themes/seg_single_normal.png | Bin 0 -> 1428 bytes .../data/themes/seg_single_pressed.png | Bin 0 -> 1404 bytes .../data/themes/seg_single_selected.png | Bin 0 -> 1558 bytes legacy/elementary/src/bin/Makefile.am | 1 + legacy/elementary/src/bin/test.c | 2 + .../elementary/src/bin/test_segment_control.c | 105 +++ legacy/elementary/src/lib/Elementary.h.in | 18 + legacy/elementary/src/lib/Makefile.am | 1 + .../elementary/src/lib/elm_segment_control.c | 849 ++++++++++++++++++ 21 files changed, 1742 insertions(+) create mode 100644 legacy/elementary/data/themes/seg_left_normal.png create mode 100644 legacy/elementary/data/themes/seg_left_pressed.png create mode 100644 legacy/elementary/data/themes/seg_left_selected.png create mode 100644 legacy/elementary/data/themes/seg_middle_normal.png create mode 100644 legacy/elementary/data/themes/seg_middle_pressed.png create mode 100644 legacy/elementary/data/themes/seg_middle_selected.png create mode 100644 legacy/elementary/data/themes/seg_right_normal.png create mode 100644 legacy/elementary/data/themes/seg_right_pressed.png create mode 100644 legacy/elementary/data/themes/seg_right_selected.png create mode 100644 legacy/elementary/data/themes/seg_single_normal.png create mode 100644 legacy/elementary/data/themes/seg_single_pressed.png create mode 100644 legacy/elementary/data/themes/seg_single_selected.png create mode 100644 legacy/elementary/src/bin/test_segment_control.c create mode 100644 legacy/elementary/src/lib/elm_segment_control.c diff --git a/legacy/elementary/AUTHORS b/legacy/elementary/AUTHORS index 25a2683db4..496ed8bdcf 100644 --- a/legacy/elementary/AUTHORS +++ b/legacy/elementary/AUTHORS @@ -38,3 +38,5 @@ Tom Hacohen Aharon Hillel Jonathan Atton (Watchwolf) Shinwoo Kim +Govindaraju SM +Prince Kumar Dubey diff --git a/legacy/elementary/data/objects/test.edc b/legacy/elementary/data/objects/test.edc index 8efdca89c2..c538d728d3 100644 --- a/legacy/elementary/data/objects/test.edc +++ b/legacy/elementary/data/objects/test.edc @@ -610,6 +610,139 @@ collections { } } } + } + group { name: "segment_test"; + parts{ + part { + name: "bg"; + type: RECT; + scale: 1; //allow scaling + description { + state: "default" 0.0; + visible: 0; + min: 480 400; + color: 0 0 0 0; + } + } + part { name: "top_padding"; + type: RECT; + scale: 1; //allow scaling + description { + state: "default" 0.0; + visible: 0; + min : 250 30; //minimum size for gap filler + fixed: 0 1; + rel1 { relative: 0 0; } + rel2 { relative: 1 0; } + color: 0 0 0 0; + align: 0 0; + } + } + part { name: "segment1"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + fixed: 1 1; + rel1 { relative: 0.0 1.0; to_x: "bg"; to_y: "top_padding"; } + rel2 { relative: 1.0 0.25; to: "bg"; } + align: 0.5 0.0; + } + } + part { name: "segment1_bottom_padding"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + visible: 0; + min : 250 10; + max : 250 10; + fixed: 1 1; + align: 0.5 0; + rel1 { relative: 0 1.0; to_y: "segment1"; } + rel2 { relative: 1 1.0; to_y: "segment1"; } + color: 0 255 0 0; + } + } + part { name: "segment2"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + fixed: 1 1; + rel1 { relative: 0.1 1.0; to_x: "bg"; to_y: "segment1_bottom_padding"; } + rel2 { relative: 0.9 160/400; to: "bg"; } + align: 0.5 0.0; + } + } + part { name: "segment2_bottom_padding"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + visible: 0; + min : 250 10; + max : 250 10; + fixed: 1 1; + align: 0.5 0; + rel1 { relative: 0 1.0; to_y: "segment2"; } + rel2 { relative: 1 1.0; to_y: "segment2"; } + color: 0 255 0 0; + } + } + part { name: "segment3"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + fixed: 1 1; + rel1 { relative: 0.2 1.0; to_x: "bg"; to_y: "segment2_bottom_padding"; } + rel2 { relative: 0.8 0.6; to: "bg"; } + align: 0.5 0.0; + } + } + part { name: "segment3_bottom_padding"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + visible: 0; + min : 250 10; + max : 250 10; + fixed: 1 1; + align: 0.5 0; + rel1 { relative: 0 1.0; to_y: "segment3"; } + rel2 { relative: 1 1.0; to_y: "segment3"; } + color: 0 255 0 0; + } + } + part { name: "segment4"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + fixed: 1 1; + rel1 { relative: 0.3 1.0; to_x: "bg"; to_y: "segment3_bottom_padding"; } + rel2 { relative: 0.7 340/400; to: "bg"; } + align: 0.5 0.0; + } + } + part { name: "btn1_bottom_padding"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + visible: 0; + min : 250 100; + max : 250 100; + fixed: 1 1; + align: 0.5 0; + rel1 { relative: 0 1.0; to_y: "segment4"; } + rel2 { relative: 1 1.0; to_y: "segment4"; } + color: 0 255 0 0; + } + } + } } group { name: "bg_overlay"; images { diff --git a/legacy/elementary/data/themes/default.edc b/legacy/elementary/data/themes/default.edc index 497018e2b2..2599027848 100644 --- a/legacy/elementary/data/themes/default.edc +++ b/legacy/elementary/data/themes/default.edc @@ -36048,6 +36048,637 @@ collections { } } +/////////////////////////////////////////////////////////////////////////////// + group { name: "elm/segment_control/base/default"; +#define SEGMENT_TYPE_SINGLE 1 +#define SEGMENT_TYPE_LEFT 2 +#define SEGMENT_TYPE_MIDDLE 3 +#define SEGMENT_TYPE_RIGHT 4 +#define SEGMENT_STATE_NORMAL 1 +#define SEGMENT_STATE_PRESSED 2 +#define SEGMENT_STATE_SELECTED 3 +#define SEGMENT_STATUS_ENABLED 0 +#define SEGMENT_STATUS_DISABLED 1 + parts { + part { name: "bg"; + type: RECT; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + color: 0 0 0 0; + min: 100 40; + } + } + } + } + group { name: "elm/segment_control/item/default"; + data.item: "label.wrap.part" "label.bg"; + styles { + style { name: "seg_text_style_normal"; + base: "font=Sans font_size=16 style=shadow \ + shadow_color=#2924224d \ + align=center \ + color=#ffffffff wrap=char text_class=label"; + tag: "br" "\n"; + tag: "hilight" "+ font=Sans:style=Bold"; + tag: "tab" "\t"; + } + style { name: "seg_text_style_selected"; + base: "font=Sans:style=Bold font_size=16 style=shadow \ + shadow_color=#aaaaaa4d \ + align=center \ + color=#111111ff wrap=char text_class=label"; + tag: "br" "\n"; + tag: "hilight" "+ font=Sans:style=Bold"; + tag: "b" "+ font=Sans:style=Bold"; + tag: "tab" "\t"; + } + style { name: "seg_text_style_disabled"; + base: "font=Sans:style=Medium font_size=16 style=shadow \ + shadow_color=#2924224d \ + align=center color=#2924224d \ + wrap=char text_class=label"; + tag: "br" "\n"; + tag: "hilight" "+ font=Sans:style=Bold"; + tag: "b" "+ font=Sans:style=Bold"; + tag: "tab" "\t"; + } + } + images { + image: "seg_single_pressed.png" COMP; + image: "seg_single_selected.png" COMP; + image: "seg_single_normal.png" COMP; + + image: "seg_left_pressed.png" COMP; + image: "seg_left_selected.png" COMP; + image: "seg_left_normal.png" COMP; + + image: "seg_middle_pressed.png" COMP; + image: "seg_middle_selected.png" COMP; + image: "seg_middle_normal.png" COMP; + + image: "seg_right_pressed.png" COMP; + image: "seg_right_selected.png" COMP; + image: "seg_right_normal.png" COMP; + } + parts { + part { name: "segment"; + mouse_events: 1; + scale: 1; + description { state: "default" 0.0; + min: 1 1; + visible: 0; + image { + normal: "seg_single_normal.png"; + border: 7 7 7 7; + border_scale: 1; + middle: 1; + } + } + description { state: "default_single" 0.0; + inherit: "default" 0.0; + visible: 1; + image { + normal: "seg_single_normal.png"; + border: 7 7 7 7; + } + } + description { state: "default_left" 0.0; + inherit: "default" 0.0; + visible: 1; + image { + normal: "seg_left_normal.png"; + border: 6 1 7 7; + } + } + description { state: "default_right" 0.0; + inherit: "default" 0.0; + visible: 1; + image { + normal: "seg_right_normal.png"; + border: 1 6 7 7; + } + } + description { state: "default_middle" 0.0; + inherit: "default" 0.0; + visible: 1; + image { + normal: "seg_middle_normal.png"; + border: 2 2 2 2; + } + } + description { state: "pressed_single" 0.0; + inherit: "default" 0.0; + visible: 1; + image { + normal: "seg_single_pressed.png"; + border: 7 7 7 7; + } + } + description { state: "pressed_left" 0.0; + inherit: "default" 0.0; + visible: 1; + image { + normal: "seg_left_pressed.png"; + border: 6 1 7 7; + } + } + description { state: "pressed_right" 0.0; + inherit: "default" 0.0; + visible: 1; + image { + normal: "seg_right_pressed.png"; + border: 1 6 7 7; + } + } + description { state: "pressed_middle" 0.0; + inherit: "default" 0.0; + visible: 1; + image { + normal: "seg_middle_pressed.png"; + border: 1 1 2 2; + } + } + description { state: "selected_single" 0.0; + inherit: "default" 0.0; + visible: 1; + image { + normal: "seg_single_selected.png"; + border: 7 7 7 7; + } + } + description { state: "selected_left" 0.0; + inherit: "default" 0.0; + visible: 1; + image { + normal: "seg_left_selected.png"; + border: 6 3 7 7; + } + } + description { state: "selected_right" 0.0; + inherit: "default" 0.0; + visible: 1; + image { + normal: "seg_right_selected.png"; + border: 3 6 7 7; + } + } + description { state: "selected_middle" 0.0; + inherit: "default" 0.0; + visible: 1; + image { + normal: "seg_middle_selected.png"; + border: 3 3 3 3; + } + } + } + part { name: "padding_left"; + type: RECT; + scale: 1; + mouse_events: 0; + description { state: "default" 0.0; + align: 0.0 0.0; + rel1.relative: 0.0 0.0; + rel2.relative: 0.0 1.0; + min: 2 2; + max: 2 2; + fixed: 1 0; + color: 0 0 0 0; + } + } + part { name: "padding_right"; + type: RECT; + scale: 1; + mouse_events: 0; + description { state: "default" 0.0; + align: 1.0 0.0; + rel1.relative: 1.0 0.0; + rel2.relative: 1.0 1.0; + min: 2 2; + max: 2 2; + fixed: 1 0; + color: 0 0 0 0; + } + } + part { name: "padding_top"; + type: RECT; + scale: 1; + mouse_events: 0; + description { state: "default" 0.0; + align: 0.0 0.0; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 0.0; + min: 2 2; + max: 2 2; + fixed: 0 1; + color: 0 0 0 0; + } + } + part { name: "padding_bottom"; + type: RECT; + scale: 1; + mouse_events: 0; + description { state: "default" 0.0; + align: 1.0 1.0; + rel1.relative: 0.0 1.0; + rel2.relative: 1.0 1.0; + min: 2 2; + max: 2 2; + fixed: 0 1; + color: 0 0 0 0; + } + } + part { name: "icon.bg"; + type: RECT; + scale: 1; + mouse_events: 0; + description { state: "default" 0.0; + visible: 1; + fixed: 1 0; + rel1 { + to_x: "padding_left"; + to_y: "padding_top"; + relative: 1.0 1.0; + } + rel2 { + to: "elm.swallow.icon"; + relative: 1.0 1.0; + } + align: 0.0 0.5; + color: 0 0 0 0; + } + } + part { name: "padding_icon_text"; + type: RECT; + scale: 1; + mouse_events: 0; + description { state: "default" 0.0; //when only icon or no icon is there + align: 0.0 0.0; + rel1 { + to: "icon.bg"; + relative: 1.0 0.0; + } + rel2 { + to: "icon.bg"; + relative: 1.0 1.0; + } + fixed: 1 0; + min: 0 0; + color: 0 0 0 0; + } + description { state: "icononly" 0.0; + inherit: "default" 0.0; + } + description { state: "visible" 0.0; //when icon is visible + inherit: "default" 0.0; + min: 2 0; + } + } + part { name: "elm.swallow.icon"; + type: SWALLOW; + scale: 1; + description { state: "default" 0.0; + visible: 0; + align: 0.0 0.5; + rel1 { + to_x: "padding_left"; + to_y: "padding_top"; + relative: 1.0 1.0; + } + rel2 { + to_y: "padding_bottom"; + relative: 0.0 0.0; + } + fixed: 1 0; + aspect: 1.0 1.0; + aspect_preference: BOTH; + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + visible: 1; + rel2 { + to_y: "padding_bottom"; + relative: 0.3 0.0; + } + } + description { state: "icononly" 0.0; + inherit: "default" 0.0; + visible: 1; + rel2 { + to_x: "padding_right"; + to_y: "padding_bottom"; + relative: 0.0 0.0; + } + align: 0.5 0.5; + } + } + part { name: "elm.text"; + type: TEXT; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + visible: 0; + fixed: 1 1; + min: 1 1; + rel1 { + to_x: "padding_icon_text"; + relative: 1.0 1.0; + } + rel2 { + to_x: "padding_right"; + relative: 0.0 0.0; + } + color: 224 224 224 255; + color3: 0 0 0 64; + text { + font: "Sans"; + ellipsis: 0.0; + fit: 1 1; + size: 24; + size_range: 8 36; + min: 0 1; + } + } + description { state: "normal" 0.0; + inherit: "default" 0.0; + visible: 1; + } + description { state: "pressed" 0.0; + inherit: "default" 0.0; + visible: 1; + color: 0 0 0 255; + } + description { state: "selected" 0.0; + inherit: "default" 0.0; + visible: 1; + color: 50 50 50 255; + } + description { state: "disabled" 0.0; + inherit: "default" 0.0; + visible: 1; + color: 200 200 200 255; + } + } + part { name: "disabler"; + repeat_events: 0; + scale: 1; + description { state: "default" 0.0; + visible: 0; + fixed: 1 1; + min: 1 1; + align: 0.0 0.5; + rel1 { relative: 0.0 0.0; to: "segment";} + rel2 { relative: 1.0 1.0; to: "segment";} + color: 255 255 255 150; + } + description { state: "disabled_single" 0.0; + inherit: "default" 0.0; + visible: 1; + image { + normal: "seg_single_normal.png"; + border: 7 7 7 7; + } + } + description { state: "disabled_left" 0.0; + inherit: "default" 0.0; + visible: 1; + image { + normal: "seg_left_normal.png"; + border: 6 1 7 7; + } + } + description { state: "disabled_right" 0.0; + inherit: "default" 0.0; + visible: 1; + image { + normal: "seg_right_normal.png"; + border: 1 6 7 7; + } + } + description { state: "disabled_middle" 0.0; + inherit: "default" 0.0; + visible: 1; + image { + normal: "seg_middle_normal.png"; + border: 2 2 2 2; + } + } + } + } + programs { + script { + public seg_type; // Single, Left, Middle, Right. + public seg_state; // Normal/Default, Pressed, Selected. + public seg_status;// Enabled/Default, Disabled + + public update_state() { + new type, state, disabled; + type = get_int(seg_type); + state = get_int(seg_state); + disabled = get_int(seg_status); + + if(state == SEGMENT_STATE_NORMAL) + { + if(type == SEGMENT_TYPE_SINGLE) + set_state(PART:"segment", "default_single", 0.0); + else if(type == SEGMENT_TYPE_LEFT) + set_state(PART:"segment", "default_left", 0.0); + else if(type == SEGMENT_TYPE_MIDDLE) + set_state(PART:"segment", "default_middle", 0.0); + else if(type == SEGMENT_TYPE_RIGHT) + set_state(PART:"segment", "default_right", 0.0); + set_state(PART:"elm.text", "normal", 0.0); + } + else if(state == SEGMENT_STATE_PRESSED) + { + if(type == SEGMENT_TYPE_SINGLE) + set_state(PART:"segment", "pressed_single", 0.0); + else if(type == SEGMENT_TYPE_LEFT) + set_state(PART:"segment", "pressed_left", 0.0); + else if(type == SEGMENT_TYPE_MIDDLE) + set_state(PART:"segment", "pressed_middle", 0.0); + else if(type == SEGMENT_TYPE_RIGHT) + set_state(PART:"segment", "pressed_right", 0.0); + set_state(PART:"elm.text", "pressed", 0.0); + } + else if(state == SEGMENT_STATE_SELECTED) + { + if(type == SEGMENT_TYPE_SINGLE) + set_state(PART:"segment", "selected_single", 0.0); + else if(type == SEGMENT_TYPE_LEFT) + set_state(PART:"segment", "selected_left", 0.0); + else if(type == SEGMENT_TYPE_MIDDLE) + set_state(PART:"segment", "selected_middle", 0.0); + else if(type == SEGMENT_TYPE_RIGHT) + set_state(PART:"segment", "selected_right", 0.0); + set_state(PART:"elm.text", "selected", 0.0); + } + if(disabled == SEGMENT_STATUS_DISABLED) + { + if(type == SEGMENT_TYPE_SINGLE) + set_state(PART:"disabler", "disabled_single", 0.0); + else if(type == SEGMENT_TYPE_LEFT) + set_state(PART:"disabler", "disabled_left", 0.0); + else if(type == SEGMENT_TYPE_MIDDLE) + set_state(PART:"disabler", "disabled_middle", 0.0); + else if(type == SEGMENT_TYPE_RIGHT) + set_state(PART:"disabler", "disabled_right", 0.0); + set_state(PART:"elm.text", "disabled", 0.0); + } + } + } + program { + name: "segment_type_s"; + signal: "elm,type,segment,single"; + source: "elm"; + script { + set_int(seg_type, SEGMENT_TYPE_SINGLE); + update_state(); + } + } + program { + name: "segment_type_l"; + signal: "elm,type,segment,left"; + source: "elm"; + script { + set_int(seg_type, SEGMENT_TYPE_LEFT); + update_state(); + } + } + program { + name: "segment_type_m"; + signal: "elm,type,segment,middle"; + source: "elm"; + script { + set_int(seg_type, SEGMENT_TYPE_MIDDLE); + update_state(); + } + } + program { + name: "segment_type_r"; + signal: "elm,type,segment,right"; + source: "elm"; + script { + set_int(seg_type, SEGMENT_TYPE_RIGHT); + update_state(); + } + } + program { + name: "normal_segment"; + signal: "elm,state,segment,normal"; + source: "elm"; + script { + set_int(seg_state, SEGMENT_STATE_NORMAL); + update_state(); + } + } + program { + name: "pressed_segment"; + signal: "elm,state,segment,pressed"; + source: "elm"; + script { + set_int(seg_state, SEGMENT_STATE_PRESSED); + update_state(); + } + } + program { + name: "selected_segment"; + signal: "elm,state,segment,selected"; + source: "elm"; + script { + set_int(seg_state, SEGMENT_STATE_SELECTED); + update_state(); + } + } + program { name: "disable_segment"; + signal: "elm,state,disabled"; + source: "elm"; + script { + set_int(seg_status, SEGMENT_STATUS_DISABLED); + update_state(); + } + } + program { name: "enable_segment"; + signal: "elm,state,enabled"; + source: "elm"; + script { + set_int(seg_status, SEGMENT_STATUS_ENABLED); + update_state(); + } + } + program { name: "text_show"; + signal: "elm,state,text,visible"; + source: "elm"; + script { + new st[31]; + new Float:vl; + get_state(PART:"elm.swallow.icon", st, 30, vl); + if (!strcmp(st, "icononly")) + { + set_state(PART:"elm.swallow.icon", "visible", 0.0); + set_state(PART:"padding_icon_text", "visible", 0.0); + } + get_state(PART:"elm.text", st, 30, vl); + if (!strcmp(st, "selected")) + set_state(PART:"elm.text", "selected", 0.0); + else + set_state(PART:"elm.text", "normal", 0.0); + } + } + program { name: "text_hide"; + signal: "elm,state,text,hidden"; + source: "elm"; + script { + new st[31]; + new Float:vl; + get_state(PART:"elm.swallow.icon", st, 30, vl); + if (!strcmp(st, "visible")) + { + set_state(PART:"elm.swallow.icon", "icononly", 0.0); + set_state(PART:"padding_icon_text", "icononly", 0.0); + } + set_state(PART:"elm.text", "default", 0.0); + } + } + program { name: "icon_show"; + signal: "elm,state,icon,visible"; + source: "elm"; + script { + new st[31]; + new Float:vl; + get_state(PART:"elm.text", st, 30, vl); + if ((!strcmp(st, "normal")) || (!strcmp(st, "selected"))) + { + set_state(PART:"elm.swallow.icon", "visible", 0.0); + set_state(PART:"padding_icon_text", "visible", 0.0); + } + else + { + set_state(PART:"elm.swallow.icon", "icononly", 0.0); + set_state(PART:"padding_icon_text", "icononly", 0.0); + } + } + } + program { name: "icon_hide"; + signal: "elm,state,icon,hidden"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.swallow.icon"; + } + } +#undef SEGMENT_TYPE_SINGLE +#undef SEGMENT_TYPE_LEFT +#undef SEGMENT_TYPE_MIDDLE +#undef SEGMENT_TYPE_RIGHT +#undef SEGMENT_STATE_NORMAL +#undef SEGMENT_STATE_PRESSED +#undef SEGMENT_STATE_SELECTED +#undef SEGMENT_STATUS_ENABLED +#undef SEGMENT_STATUS_DISABLED + } + /* a simple title layout, with a label and two icons */ group { name: "elm/layout/application/titlebar"; images { diff --git a/legacy/elementary/data/themes/seg_left_normal.png b/legacy/elementary/data/themes/seg_left_normal.png new file mode 100644 index 0000000000000000000000000000000000000000..703c36320e2f3ef964fb658ba13323591d692d4c GIT binary patch literal 719 zcmV;=0xPx#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0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ct~B>pMEV>RgG$o zJ~}$$?(Pl|p{{EtlSz)9ogH>}cRS$u`8oIZ_uSmvFr7{*ih`=DsOviS0P5-KNxnZm z^6mPX7$bXodz584dRPEzKA-bzHj|$(FTB3KviMlwg9A~Zg#H$&rfKlb@w;hc@v)$F dE$bBy;18KChIW<4Wi9{!002ovPDHLkV1hJ%O(FmQ literal 0 HcmV?d00001 diff --git a/legacy/elementary/data/themes/seg_left_selected.png b/legacy/elementary/data/themes/seg_left_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..c2e15467fbb02d2b602dc836c50018c8ac3c5e64 GIT binary patch literal 595 zcmV-Z0<8UsP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipS@ z4G|bY@Qa-Q00GlUL_t(I%Z*e)j@vK{98$CqCzl|(=8#LUePkEiw`?DiM|5)w0zY6k zE7y|MgH73zogy>@$mEbiiXf?J8UTd1w_kyovDs`uL zR7t4whzWJxs-;vGsUM{>qkdErFVijnmvf7n;Q;da^@*eQL70(Y)*K0-AbW|YuPgg)W+7f-m6(-NX8=vn^mK6y@i=~T zs$*ZX0gvl{{&%6fo=l2qxxFF%p}yb zxb@+xoL6h(^rm;KDlF0Qep0!Q`)VmKW5d4p{mM)Z*GtVdzZ(!OB z$ERB!G31m5yQmd>dA!L=Z4v8*Ilum=GI=nZQgCjt>i(dYJcY=0$Z zvp*JK*m3{8*@tf|lG8<{wlzdfyXm0UxA9|^8pDG*o3DC&s(w($U-I-{Ses|Lr|!OU z_G>>j+wE&g{QTpdRqWF|mmFoQ=MGG(f=gJRt=>3s=D*o*L~H6^uR8U@#%*P|WZH)k ztG!$Mf|eiHf7j_G%ggBn%FN699PgB6&U$9>_VLGtIp@=Zd)KTw^<~3*h` R_5#C^!PC{xWt~$(69DpHuw4KE literal 0 HcmV?d00001 diff --git a/legacy/elementary/data/themes/seg_middle_pressed.png b/legacy/elementary/data/themes/seg_middle_pressed.png new file mode 100644 index 0000000000000000000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Vg6|2KQ|9$2?Cms~rq`38tF7M2h~^XXC_vl(!|-#1?EE4Mq!LBH13 rw>9_c>ucNBPx#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipS@ z4HggpYL#dJ00N3hL_t(Y$F)|?PU27${!XWWLJTZa;>y*KfU{H+92dSF&*M%XfH%nNrJn(J4~lj?Ck7d zI2?kR5d%P)rl_j>`+E!q1MKeZB93DZczb(8U8QLXRYjI%9*|{OExJ9rRsBzZKqsdpBJ~>BTP`9#hp$u|T=4U-@Xx})u=9b6ex|eppd7`_U|A4dXrQH~ z!vr%kgaxKnC))Cs!B#Wd%%#;Fq#_5Sd^DB-Dq2e^jJ(zdw*Z*$lMN^Z4Gt`uh_)g) zW(T!-2UA_^k~k?kJU#uc1w1@FAWi=ueSiPQ;ZrLpmCc`X4vqz|IUu6)MgeSQP*qSA zc|dr1Rh6njMLwbjgu;2Mnv>fQn(;*Z>LimvOBWf_PF+uPd#&?sF!e0Q*8Y_+y< zaB$$qn`re~bSHBThlht4kH?6o)9Fe`{$YWcr#l#Y$Ir7f{5U#7-0Ss9htJH=Y&NmK zzmM^FjL~q2cDoI_y1KH@pFP33PN#!zuZM28i%z?ZR;xvS0WQha>Gvcrj{pDw07*qo IM6N<$f{sC0`v3p{ literal 0 HcmV?d00001 diff --git a/legacy/elementary/data/themes/seg_right_pressed.png b/legacy/elementary/data/themes/seg_right_pressed.png new file mode 100644 index 0000000000000000000000000000000000000000..e93ae2005125505f7aeabab9f6fbbd90fcc736cc GIT binary patch literal 756 zcmVPx#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipS@ z4Hp4(!GzlY00MMLL_t(I%Z-#vPUJ8UhCe&D;|{22kPw93u%!>fESW>VmLqVRz5%Q_ z0%DH@NGy<$P$Tkk%_40l-D!=+QOQ>P`LFV$N-dX50Z>X2`w#-JudlRi%kT4ZRi2!{ z)zy{kYE9F~!^4Bz+}z01(-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00007bV*G`2ipS? z4H__o1XV%+00jI=L_t(Y$DLQbZWKEd{(S7QXO_Exz1n7llnSMSTR;&}Lxn^E5`Er* z7sv}B@doe&6qlA1+$L$@1yBlt0I>*ZqeNspp>(@a1yFdBzx9566Ie;32N{t~;N`T63!8P9F39m9IS))VG4==qfZ%;Y%5aAs=H^#K@bq2|hs0bKX1A{yk2Gfu z%K@>==*V;A@P|3P?Cj{BBM|`Bk83all(l7Vw`n$l3bv|H*$Q=Cp{i<}m1l6?!~4cV zB0`qgX03aN7$dB;P~VnIIOlM7c81f_Q><1itd3Xs`ST|#Tfth3(v~aL(b|@*7A9(PNq0L*w(L?Mufx1h|ht0wU!w?I!%=$q*nx>A4x# zzE9-?G#(Bm#_!m0E(syhnR~fi{%4Gl0As{pa@WSe*()w=Aq0qPONg%Q5Iy6Bw_y%L z=DD#c?2$4ZX?G15#8eVcLQs#4abjr1%VF5@ylezg4%TgI;gF!7R!zIQVuw8NlqJAIucb6^+wCD_?lu8bgGP?wfzsS|>B6F>OrxBQAI)rA#WyXpKBKaIWqNA|e6r8yRPe zL7wN083SVslu{{8s+%*dHHxC>$u$<30FY%FwARS;97R!}C<^3x0b>lFY-V^5+_r(^lEK4kxOMLnA1-JgWg{`eE zh)9F$@B9x6S_w2Q))`U&0000< KMNUMnLSTYT^_Lm| literal 0 HcmV?d00001 diff --git a/legacy/elementary/data/themes/seg_single_selected.png b/legacy/elementary/data/themes/seg_single_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..116ce68b7dafe7fc699b71dfb1f99bdef40f03a3 GIT binary patch literal 1558 zcmV+x2I={UP)k zAVmbuL0q_Ug$r-P!ZG5M9DoxNiLuAd%yiWr+C3hRon2aLjon@Ib#?vus>T4EoSf)n zGQm85{#*|Z4(Rv$xT~uxX0sXATHM9O1xb?NoWmwbLXspHW3bLShQlGdySvyoZ{8Sy z#bSXuIXO`Px4*wnQ54wue9m+_#TG@u#l;2I7!wW{3_be6*=JPqKimGB&6%oOEkBA^5t;MC{04`!)US1+TywTXoT8l9zU>Xzjv({ji ze=L}#RD!h@RmEjl#_sMes>)z62=2_XjL~SsjT<*`&T)Qrj+;y-T>Q9zCH8N>|Mt-w zA0NNHfB*iYG))0e)y6pS;Ip$coOA9G(74EZPhHnd_@rsdcsvf5^xkuIbwyd0)OAf& zRU}D5nx^dR?2u(yFs6t!0`Vy#7-R6>hby)X8>jbvO{fu!muQ5&N320LK}3S!Y&N5+ zDi(_cMNv?eC5y#^G)>9#oFs9eVY_UcP*(&;Zaf}S*L7pqDBR?~b9nC`IiQIc?|tL87!&|` zp3?}%+qMPcQ$&J!+JbdmHv%y*L?j@_h>24~h$qD?webRR#!Iy?r=r+smW|Dp1sY~( z3vWXek#$5>MReVs4dTjS%S}~OH&t*VLZJF0WMWm~YfqMCs0uqfJAt#KyPC=Bcccnq z%<3}RB7H6DyP?(IY!AB@o|z_sgu4P>r0!+Mu1Y z){>IBTdr~kLTy-+`fGqYweN%R(5sH z1#(D|P^nK(PwDsjO~6J$5#jsy@BDRmh#il|A48RcSj3Yg)QBw0x%cOvJbCgYnDgn= zr~ll%dGq1k-X6|5es#orn@lEr`SRuC>({UUHb+NCdhg!7M#UJ=?U%NNL$qY{Q&ALr z{`?u2=Q;g;pDyKh6J!+;Y;dxw((m^JpR_Z*4H|hRY8~rI1c@{qsXFqHYbSi0(IRlW z8)ySY;)G1OuIsh3(*}!;kBF=Q+fL|~&#qm&ple*xUAS&W!03eQc(JkJ zHX;=fL|4EUGi+(cDmHCy|;~vmrn6( z3n4^gqjB`LM{TTkv66baVdsiv3mUtovMjkOuR=NYt8!PC|LXudlO_p-W8d=2Q;zBHZG0@`yNs@%m5^FX%u-l>< zV{q+qo2F?)M_mew^c4$JthBK~du?VRKBgJpcdz07*qo IM6N<$f-<81v;Y7A literal 0 HcmV?d00001 diff --git a/legacy/elementary/src/bin/Makefile.am b/legacy/elementary/src/bin/Makefile.am index cd124a7821..b3bb98ed91 100644 --- a/legacy/elementary/src/bin/Makefile.am +++ b/legacy/elementary/src/bin/Makefile.am @@ -94,6 +94,7 @@ test_diskselector.c \ test_colorselector.c \ test_ctxpopup.c \ test_bubble.c \ +test_segment_control.c \ test_store.c elementary_test_LDADD = $(top_builddir)/src/lib/libelementary.la \ diff --git a/legacy/elementary/src/bin/test.c b/legacy/elementary/src/bin/test.c index 78577ee4d3..1b8e2b331e 100644 --- a/legacy/elementary/src/bin/test.c +++ b/legacy/elementary/src/bin/test.c @@ -120,6 +120,7 @@ void test_diskselector(void *data, Evas_Object *obj, void *event_info); void test_colorselector(void *data, Evas_Object *obj, void *event_info); void test_ctxpopup(void *data, Evas_Object *obj, void *event_info); void test_bubble(void *data, Evas_Object *obj, void *event_info); +void test_segment_control(void *data, Evas_Object *obj, void *event_info); void test_store(void *data, Evas_Object *obj, void *event_info); struct elm_test @@ -373,6 +374,7 @@ my_win_main(char *autorun) ADD_TEST("Color Selector", test_colorselector); ADD_TEST("Ctxpopup", test_ctxpopup); ADD_TEST("Bubble", test_bubble); + ADD_TEST("Segment Control", test_segment_control); ADD_TEST("Store", test_store); #undef ADD_TEST diff --git a/legacy/elementary/src/bin/test_segment_control.c b/legacy/elementary/src/bin/test_segment_control.c new file mode 100644 index 0000000000..4a45fb8eb2 --- /dev/null +++ b/legacy/elementary/src/bin/test_segment_control.c @@ -0,0 +1,105 @@ +#include +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif +#ifndef ELM_LIB_QUICKLAUNCH + +void +test_segment_control(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + Evas_Object *win, *bg, *ic, *ic1, *ic2, *ic3, *ic4, *ic5; + Elm_Segment_Item *it1, *it2, *it3, *it4, *it5; + + Evas_Object * in_layout; + Evas_Object *segment1, *segment2, *segment3, *segment4; + char buf[PATH_MAX]; + char buf1[PATH_MAX]; + char buf2[PATH_MAX]; + char buf3[PATH_MAX]; + char buf4[PATH_MAX]; + char buf5[PATH_MAX]; + char buf6[PATH_MAX]; + + win = elm_win_add(NULL, "segmentcontrol", ELM_WIN_BASIC); + elm_win_title_set(win, "Segment Control"); + elm_win_autodel_set(win, 1); + + bg = elm_bg_add(win); + elm_win_resize_object_add(win, bg); + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(bg); + + in_layout = elm_layout_add( win ); + elm_win_resize_object_add(win, in_layout); + snprintf(buf, sizeof(buf), "%s/objects/test.edj", PACKAGE_DATA_DIR); + elm_layout_file_set(in_layout, buf, "segment_test"); + evas_object_size_hint_weight_set(in_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + ic = elm_icon_add(in_layout); + snprintf(buf1, sizeof(buf1), "%s/images/logo.png", PACKAGE_DATA_DIR); + elm_icon_file_set(ic, buf1, NULL); + evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_BOTH, 1, 1); + + ic1 = elm_icon_add(in_layout); + snprintf(buf2, sizeof(buf2), "%s/images/logo.png", PACKAGE_DATA_DIR); + elm_icon_file_set(ic1, buf2, NULL); + evas_object_size_hint_aspect_set(ic1, EVAS_ASPECT_CONTROL_BOTH, 1, 1); + + segment1 = elm_segment_control_add(win); + it1 = elm_segment_control_item_add(segment1, NULL, "Only Text"); + it2 = elm_segment_control_item_add(segment1, ic, NULL); + elm_segment_control_item_selected_set(it2, EINA_TRUE); + it3 = elm_segment_control_item_add(segment1, ic1, "Text_Icon_test"); + it4 = elm_segment_control_item_add(segment1, NULL, "Seg4"); + it5 = elm_segment_control_item_add(segment1, NULL, "Seg5"); + + segment2 = elm_segment_control_add(win); + it1 = elm_segment_control_item_add(segment2, NULL, "SegmentItem"); + it2 = elm_segment_control_item_add(segment2, NULL, "SegmentItem"); + elm_segment_control_item_selected_set(it2, EINA_TRUE); + it3 = elm_segment_control_item_add(segment2, NULL, "SegmentControlItem"); + it4 = elm_segment_control_item_add(segment2, NULL, "SegmentItem"); + + ic2 = elm_icon_add(in_layout); + snprintf(buf3, sizeof(buf3), "%s/images/logo.png", PACKAGE_DATA_DIR); + elm_icon_file_set(ic2, buf3, NULL); + evas_object_size_hint_aspect_set(ic2, EVAS_ASPECT_CONTROL_BOTH, 1, 1); + + ic3 = elm_icon_add(in_layout); + snprintf(buf4, sizeof(buf4), "%s/images/logo.png", PACKAGE_DATA_DIR); + elm_icon_file_set(ic3, buf4, NULL); + evas_object_size_hint_aspect_set(ic3, EVAS_ASPECT_CONTROL_BOTH, 1, 1); + + ic4 = elm_icon_add(in_layout); + snprintf(buf5, sizeof(buf5), "%s/images/logo.png", PACKAGE_DATA_DIR); + elm_icon_file_set(ic4, buf5, NULL); + evas_object_size_hint_aspect_set(ic4, EVAS_ASPECT_CONTROL_BOTH, 1, 1); + + segment3 = elm_segment_control_add(win); + it1 = elm_segment_control_item_add(segment3, ic2, NULL); + it2 = elm_segment_control_item_add(segment3, ic3, NULL); + elm_segment_control_item_selected_set(it2, EINA_TRUE); + it3 = elm_segment_control_item_add(segment3, ic4, NULL); + + ic5 = elm_icon_add(in_layout); + snprintf(buf6, sizeof(buf6), "%s/images/logo.png", PACKAGE_DATA_DIR); + elm_icon_file_set(ic5, buf6, NULL); + evas_object_size_hint_aspect_set(ic5, EVAS_ASPECT_CONTROL_BOTH, 1, 1); + + segment4 = elm_segment_control_add(win); + it1 = elm_segment_control_item_add(segment4, NULL, "Disabled"); + it2 = elm_segment_control_item_add(segment4, ic5, "Disabled"); + elm_segment_control_item_selected_set(it2, EINA_TRUE); + it3 = elm_segment_control_item_add(segment4, NULL, "Disabled"); + elm_object_disabled_set(segment4, EINA_TRUE); + + elm_layout_content_set(in_layout, "segment1", segment1); + elm_layout_content_set(in_layout, "segment2", segment2); + elm_layout_content_set(in_layout, "segment3", segment3); + elm_layout_content_set(in_layout, "segment4", segment4); + + evas_object_show(in_layout); + + evas_object_show(win); +} +#endif diff --git a/legacy/elementary/src/lib/Elementary.h.in b/legacy/elementary/src/lib/Elementary.h.in index 72722f746c..89c12b6464 100644 --- a/legacy/elementary/src/lib/Elementary.h.in +++ b/legacy/elementary/src/lib/Elementary.h.in @@ -2780,6 +2780,24 @@ extern "C" { EAPI const Elm_Store *elm_store_item_store_get(const Elm_Store_Item *sti) EINA_ARG_NONNULL(1); EAPI const Elm_Genlist_Item *elm_store_item_genlist_item_get(const Elm_Store_Item *sti) EINA_ARG_NONNULL(1); + /* SegmentControl */ + typedef struct _Elm_Segment_Item Elm_Segment_Item; + EAPI Evas_Object *elm_segment_control_add(Evas_Object *parent) EINA_ARG_NONNULL(1); + EAPI Elm_Segment_Item *elm_segment_control_item_add(Evas_Object *obj, Evas_Object *icon, const char *label) EINA_ARG_NONNULL(1); + EAPI Elm_Segment_Item *elm_segment_control_item_insert_at(Evas_Object *obj, Evas_Object *icon, const char *label, int index) EINA_ARG_NONNULL(1); + EAPI void elm_segment_control_item_del(Elm_Segment_Item *it) EINA_ARG_NONNULL(1); + EAPI void elm_segment_control_item_del_at(Evas_Object *obj, int index) EINA_ARG_NONNULL(1); + EAPI int elm_segment_control_item_count_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); + EAPI Elm_Segment_Item *elm_segment_control_item_get(const Evas_Object *obj, int index) EINA_ARG_NONNULL(1); + EAPI const char *elm_segment_control_item_label_get(const Evas_Object *obj, int index) EINA_ARG_NONNULL(1); + EAPI void elm_segment_control_item_label_set(Elm_Segment_Item* it, const char* label) EINA_ARG_NONNULL(1); + EAPI Evas_Object *elm_segment_control_item_icon_get(const Evas_Object *obj, int index) EINA_ARG_NONNULL(1); + EAPI void elm_segment_control_item_icon_set(Elm_Segment_Item *it, Evas_Object *icon) EINA_ARG_NONNULL(1); + EAPI int elm_segment_control_item_index_get(const Elm_Segment_Item *it) EINA_ARG_NONNULL(1); + EAPI Evas_Object *elm_segment_control_item_object_get(const Elm_Segment_Item *it) EINA_ARG_NONNULL(1); + EAPI Elm_Segment_Item *elm_segment_control_item_selected_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); + EAPI void elm_segment_control_item_selected_set(Elm_Segment_Item *it, Eina_Bool select) EINA_ARG_NONNULL(1); + #ifdef __cplusplus } #endif diff --git a/legacy/elementary/src/lib/Makefile.am b/legacy/elementary/src/lib/Makefile.am index 5708e56a53..0d0ac23275 100644 --- a/legacy/elementary/src/lib/Makefile.am +++ b/legacy/elementary/src/lib/Makefile.am @@ -94,6 +94,7 @@ elm_calendar.c \ elm_flipselector.c \ elm_diskselector.c \ elm_colorselector.c \ +elm_segment_control.c \ \ elc_anchorblock.c \ elc_anchorview.c \ diff --git a/legacy/elementary/src/lib/elm_segment_control.c b/legacy/elementary/src/lib/elm_segment_control.c new file mode 100644 index 0000000000..809b38d69d --- /dev/null +++ b/legacy/elementary/src/lib/elm_segment_control.c @@ -0,0 +1,849 @@ +#include +#include "elm_priv.h" + +/** + * @defgroup SegmentControl SegmentControl + * + * SegmentControl Widget is a horizontal control made of multiple segment items, + * each segment item functioning similar to discrete two state button. A segment + * control groups the the items together and provides compact single button with + * multiple equal size segments. Segment item size is determined by base widget + * size and the number of items added. + * Only one Segment item can be at selected state. A segment item can display + * combination of Text and any Evas_Object like Images or other widget. + * + * Signals that you can add callbacks for are: + * + * "changed" -when the user clicks on a segment item which is not previously + * selected and get selected. The event_info parameter is the + * segment item index. + */ +typedef struct _Widget_Data Widget_Data; + +struct _Widget_Data +{ + Evas_Object *obj; + Evas_Object *base; + Eina_List *seg_items; + int item_count; + Elm_Segment_Item *selected_item; + int item_width; +}; + +struct _Elm_Segment_Item +{ + Elm_Widget_Item base; + Evas_Object *icon; + const char *label; + int seg_index; +}; + +static const char *widtype = NULL; +static void _sizing_eval(Evas_Object *obj); +static void _del_hook(Evas_Object *obj); +static void _theme_hook(Evas_Object *obj); +static void _disable_hook(Evas_Object *obj); +static void _item_free(Elm_Segment_Item *it); +static void _segment_off(Elm_Segment_Item *it); +static void _segment_on(Elm_Segment_Item *it); +static void _position_items(Widget_Data *wd); +static void _on_move_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj + __UNUSED__, void *event_info __UNUSED__); +static void _mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj + __UNUSED__, void *event_info __UNUSED__); +static void _mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj + __UNUSED__, void *event_info __UNUSED__); +static void _swallow_item_objects(Elm_Segment_Item *it); +static void _update_list(Widget_Data *wd); +static Elm_Segment_Item * _item_find(const Evas_Object *obj, int index); +static Elm_Segment_Item* _item_new(Evas_Object *obj, Evas_Object *icon, + const char *label); + +static void +_sizing_eval(Evas_Object *obj) +{ + Widget_Data *wd; + Evas_Coord minw = -1, minh = -1; + Evas_Coord w, h; + + wd = elm_widget_data_get(obj); + if (!wd) return; + + elm_coords_finger_size_adjust(wd->item_count, &minw, 1, &minh); + edje_object_size_min_restricted_calc(wd->base, &minw, &minh, minw, minh); + elm_coords_finger_size_adjust(wd->item_count, &minw, 1, &minh); + + evas_object_size_hint_min_get(obj, &w, &h); + if (w > minw) minw = w; + if (h > minh) minh = h; + evas_object_size_hint_min_set(obj, minw, minh); +} + +static void +_del_hook(Evas_Object *obj) +{ + Elm_Segment_Item *it; + Widget_Data *wd; + + wd = elm_widget_data_get(obj); + if (!wd) return; + + EINA_LIST_FREE(wd->seg_items, it) _item_free(it); + + free(wd); +} + +static void +_theme_hook(Evas_Object *obj) +{ + Eina_List *l; + Eina_Bool rtl; + Elm_Segment_Item *it; + Widget_Data *wd; + + wd = elm_widget_data_get(obj); + if (!wd) return; + + _elm_widget_mirrored_reload(obj); + rtl = elm_widget_mirrored_get(obj); + edje_object_mirrored_set(wd->base, rtl); + + _elm_theme_object_set(obj, wd->base, "segment_control", "base", + elm_widget_style_get(obj)); + edje_object_scale_set(wd->base, elm_widget_scale_get(wd->base) + *_elm_config->scale); + + EINA_LIST_FOREACH(wd->seg_items, l, it) + { + _elm_theme_object_set(obj, it->base.view, "segment_control", + "item", elm_widget_style_get(obj)); + edje_object_scale_set(it->base.view, elm_widget_scale_get(it->base.view) + *_elm_config->scale); + edje_object_mirrored_set(it->base.view, rtl); + } + + _update_list(wd); +} + +static void +_disable_hook(Evas_Object *obj) +{ + Widget_Data *wd; + + wd = elm_widget_data_get(obj); + if (!wd) return; + _update_list(wd); +} + +// TODO: Elm_widget elm_widget_focus_list_next_get supports only Elm_widget list, +// Not the Elm_Widget_item. Focus switching with in widget not supported until +// it is supported in elm_widget +#if 0 +static void * +_elm_list_data_get(const Eina_List *list) +{ + Elm_Segment_Item *it = eina_list_data_get(list); + + if (it) return NULL; + + edje_object_signal_emit(it->base.view, "elm,state,segment,selected", "elm"); + return it->base.view; +} + +static Eina_Bool +_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, + Evas_Object **next) +{ + static int count=0; + Widget_Data *; + const Eina_List *items; + void *(*list_data_get) (const Eina_List *list); + + wd = elm_widget_data_get(obj); + if ((!wd)) return EINA_FALSE; + + /* Focus chain */ + /* TODO: Change this to use other chain */ + if ((items = elm_widget_focus_custom_chain_get(obj))) + list_data_get = eina_list_data_get; + else + { + items = wd->seg_items; + list_data_get = _elm_list_data_get; + if (!items) return EINA_FALSE; + } + return elm_widget_focus_list_next_get(obj, items, list_data_get, dir, next); +} +#endif + +static void +_item_free(Elm_Segment_Item *it) +{ + Widget_Data *wd; + + if (!it) return; + + wd = elm_widget_item_data_get(it); + if (!wd) return; + + if (wd->selected_item == it) wd->selected_item = NULL; + if (wd->seg_items) wd->seg_items = eina_list_remove(wd->seg_items, it); + + elm_widget_item_pre_notify_del(it); + + if (it->icon) evas_object_del(it->icon); + if (it->label) eina_stringshare_del(it->label); + + elm_widget_item_del(it); +} + +static void +_segment_off(Elm_Segment_Item *it) +{ + Widget_Data *wd; + + if (!it) return; + + wd = elm_widget_item_data_get(it); + if (!wd) return; + + edje_object_signal_emit(it->base.view, "elm,state,segment,normal", "elm"); + + if (wd->selected_item == it) wd->selected_item = NULL; +} + +static void +_segment_on(Elm_Segment_Item *it) +{ + Widget_Data *wd; + + if (!it) return; + + wd = elm_widget_item_data_get(it); + if (!wd) return; + if (it == wd->selected_item) return; + + if (wd->selected_item) _segment_off(wd->selected_item); + + edje_object_signal_emit(it->base.view, "elm,state,segment,selected", "elm"); + + wd->selected_item = it; + evas_object_smart_callback_call(wd->obj, "changed", (void*) it->seg_index); +} + +static void +_position_items(Widget_Data *wd) +{ + Eina_List *l; + Elm_Segment_Item *it; + Eina_Bool rtl; + int bx, by, bw, bh, pos; + + wd->item_count = eina_list_count(wd->seg_items); + if (wd->item_count <= 0) return; + + evas_object_geometry_get(wd->base, &bx, &by, &bw, &bh); + wd->item_width = bw / wd->item_count; + rtl = elm_widget_mirrored_get(wd->obj); + + if (rtl) + pos = bx + bw - wd->item_width; + else + pos = bx; + + EINA_LIST_FOREACH(wd->seg_items, l, it) + { + evas_object_move(it->base.view, pos, by); + evas_object_resize(it->base.view, wd->item_width, bh); + if (rtl) + pos -= wd->item_width; + else + pos += wd->item_width; + } + _sizing_eval(wd->obj); +} + +static void +_on_move_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, + void *event_info __UNUSED__) +{ + Widget_Data *wd; + + wd = elm_widget_data_get(data); + if (!wd) return; + + _position_items(wd); + +} + +static void +_mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, + void *event_info) +{ + Widget_Data *wd; + Elm_Segment_Item *it; + Evas_Event_Mouse_Up *ev; + Evas_Coord x, y, w, h; + + it = data; + if (!it) return; + + wd = elm_widget_item_data_get(it); + if (!wd) return; + + if (elm_widget_disabled_get(wd->obj)) return; + + if (it == wd->selected_item) return; + + ev = event_info; + evas_object_geometry_get(it->base.view, &x, &y, &w, &h); + + if ((ev->output.x >= x) && (ev->output.x <= (x + w)) && (ev->output.y >= y) + && (ev->output.y <= (y + h))) + _segment_on(it); + else + edje_object_signal_emit(it->base.view, "elm,state,segment,normal", "elm"); +} + +static void +_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, + void *event_info __UNUSED__) +{ + Widget_Data *wd; + Elm_Segment_Item *it; + + it = data; + if (!it) return; + + wd = elm_widget_item_data_get(it); + if (!wd) return; + + if (elm_widget_disabled_get(wd->obj)) return; + + if (it == wd->selected_item) return; + + edje_object_signal_emit(it->base.view, "elm,state,segment,pressed", "elm"); +} + +static void +_swallow_item_objects(Elm_Segment_Item *it) +{ + if (!it) return; + + if (it->icon) + { + edje_object_part_swallow(it->base.view, "elm.swallow.icon", it->icon); + edje_object_signal_emit(it->base.view, "elm,state,icon,visible", "elm"); + } + else + edje_object_signal_emit(it->base.view, "elm,state,icon,hidden", "elm"); + + if (it->label) + edje_object_signal_emit(it->base.view, "elm,state,text,visible", "elm"); + else + edje_object_signal_emit(it->base.view, "elm,state,text,hidden", "elm"); + edje_object_message_signal_process(it->base.view); +} + +static void +_update_list(Widget_Data *wd) +{ + Eina_List *l; + Elm_Segment_Item *it; + Eina_Bool rtl; + int index = 0; + + _position_items(wd); + + if (wd->item_count == 1) + { + it = eina_list_nth(wd->seg_items, 0); + it->seg_index = 0; + + //Set the segment type + edje_object_signal_emit(it->base.view, + "elm,type,segment,single", "elm"); + + //Set the segment state + if (wd->selected_item == it) + edje_object_signal_emit(it->base.view, + "elm,state,segment,selected", "elm"); + else + edje_object_signal_emit(it->base.view, + "elm,state,segment,normal", "elm"); + + if (elm_widget_disabled_get(wd->obj)) + edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm"); + + _swallow_item_objects(it); + return; + } + + rtl = elm_widget_mirrored_get(wd->obj); + EINA_LIST_FOREACH(wd->seg_items, l, it) + { + it->seg_index = index; + + //Set the segment type + if (index == 0) + { + if (rtl) + edje_object_signal_emit(it->base.view, + "elm,type,segment,right", "elm"); + else + edje_object_signal_emit(it->base.view, + "elm,type,segment,left", "elm"); + } + else if (index == (wd->item_count - 1)) + { + if (rtl) + edje_object_signal_emit(it->base.view, + "elm,type,segment,left", "elm"); + else + edje_object_signal_emit(it->base.view, + "elm,type,segment,right", "elm"); + } + else + edje_object_signal_emit(it->base.view, + "elm,type,segment,middle", "elm"); + + //Set the segment state + if (wd->selected_item == it) + edje_object_signal_emit(it->base.view, + "elm,state,segment,selected", "elm"); + else + edje_object_signal_emit(it->base.view, + "elm,state,segment,normal", "elm"); + + if (elm_widget_disabled_get(wd->obj)) + edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm"); + + _swallow_item_objects(it); + index++; + } +} + +static Elm_Segment_Item * +_item_find(const Evas_Object *obj, int index) +{ + Widget_Data *wd; + Elm_Segment_Item *it; + + wd = elm_widget_data_get(obj); + if (!wd) return NULL; + + it = eina_list_nth(wd->seg_items, index); + return it; +} + +static Elm_Segment_Item* +_item_new(Evas_Object *obj, Evas_Object *icon, const char *label) +{ + Elm_Segment_Item *it; + Widget_Data *wd; + + wd = elm_widget_data_get(obj); + if (!wd) return NULL; + + it = elm_widget_item_new(obj, Elm_Segment_Item); + if (!it) return NULL; + elm_widget_item_data_set(it, wd); + + it->base.view = edje_object_add(evas_object_evas_get(obj)); + edje_object_scale_set(it->base.view, elm_widget_scale_get(it->base.view) + *_elm_config->scale); + evas_object_smart_member_add(it->base.view, obj); + elm_widget_sub_object_add(obj, it->base.view); + _elm_theme_object_set(obj, it->base.view, "segment_control", "item", + elm_object_style_get(obj)); + edje_object_mirrored_set(it->base.view, + elm_widget_mirrored_get(it->base.widget)); + + if (label) + eina_stringshare_replace(&it->label, label); + if (it->label) + edje_object_signal_emit(it->base.view, "elm,state,text,visible", "elm"); + else + edje_object_signal_emit(it->base.view, "elm,state,text,hidden", "elm"); + edje_object_message_signal_process(it->base.view); + edje_object_part_text_set(it->base.view, "elm.text", label); + + it->icon = icon; + if (it->icon) elm_widget_sub_object_add(it->base.view, it->icon); + evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN, + _mouse_down, it); + evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP, + _mouse_up, it); + evas_object_show(it->base.view); + + return it; +} + +/** + * Create new SegmentControl. + * @param [in] parent The parent object + * @return The new object or NULL if it cannot be created + * + * @ingroup SegmentControl + */ +EAPI Evas_Object * +elm_segment_control_add(Evas_Object *parent) +{ + Evas_Object *obj; + Evas *e; + Widget_Data *wd; + + ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); + + ELM_SET_WIDTYPE(widtype, "segment_control"); + elm_widget_type_set(obj, "segment_control"); + elm_widget_sub_object_add(parent, obj); + 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); + + // TODO: Focus switch support to Elm_widget_Item not supported yet. +#if 0 + elm_widget_focus_next_hook_set(obj, _focus_next_hook); +#endif + + wd->obj = obj; + + wd->base = edje_object_add(e); + edje_object_scale_set(wd->base, elm_widget_scale_get(wd->base) + *_elm_config->scale); + _elm_theme_object_set(obj, wd->base, "segment_control", "base", "default"); + elm_widget_resize_object_set(obj, wd->base); + + evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, + _on_move_resize, obj); + evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, + _on_move_resize, obj); + return obj; +} + +/** + * Add new segment item to SegmentControl. + * @param [in] obj The SegmentControl object + * @param [in] icon Any Objects like icon, Label, layout etc + * @param [in] label The label for added segment item. + * Note that, NULL is different from empty string "". + * @return The new segment item or NULL if it cannot be created + * + * @ingroup SegmentControl + */ +EAPI Elm_Segment_Item * +elm_segment_control_item_add(Evas_Object *obj, Evas_Object *icon, + const char *label) +{ + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Elm_Segment_Item *it; + Widget_Data *wd; + + wd = elm_widget_data_get(obj); + if (!wd) return NULL; + + it = _item_new(obj, icon, label); + if (!it) return NULL; + + wd->seg_items = eina_list_append(wd->seg_items, it); + _update_list(wd); + + return it; +} + +/** + * Insert a new segment item to SegmentControl. + * @param [in] obj The SegmentControl object + * @param [in] icon Any Objects like icon, Label, layout etc + * @param [in] label The label for added segment item. + * Note that, NULL is different from empty string "". + * @param [in] index Segment item location. Value should be between 0 and + * Existing total item count( @see elm_segment_control_item_count_get() ) + * @return The new segment item or NULL if it cannot be created + * + * @ingroup SegmentControl + */ +EAPI Elm_Segment_Item * +elm_segment_control_item_insert_at(Evas_Object *obj, Evas_Object *icon, + const char *label, int index) +{ + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Elm_Segment_Item *it, *it_rel; + Widget_Data *wd; + + wd = elm_widget_data_get(obj); + if (!wd) return NULL; + if (index < 0) index = 0; + + it = _item_new(obj, icon, label); + if (!it) return NULL; + + it_rel = _item_find(obj, index); + if (it_rel) + wd->seg_items = eina_list_prepend_relative(wd->seg_items, it, it_rel); + else + wd->seg_items = eina_list_append(wd->seg_items, it); + + _update_list(wd); + return it; +} + +/** + * Delete a segment item from SegmentControl + * @param [in] obj The SegmentControl object + * @param [in] it The segment item to be deleted + * + * @ingroup SegmentControl + */ +EAPI void +elm_segment_control_item_del(Elm_Segment_Item *it) +{ + ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it); + Widget_Data *wd; + + wd = elm_widget_item_data_get(it); + if (!wd) return; + + _item_free(it); + _update_list(wd); +} + +/** + * Delete a segment item of given index from SegmentControl + * @param [in] obj The SegmentControl object + * @param [in] index The position at which segment item to be deleted. + * + * @ingroup SegmentControl + */ +EAPI void +elm_segment_control_item_del_at(Evas_Object *obj, int index) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Elm_Segment_Item *it; + Widget_Data *wd; + + wd = elm_widget_data_get(obj); + if (!wd) return; + + it = _item_find(obj, index); + if (!it) return; + _item_free(it); + _update_list(wd); +} + +/** + * Get the label of a segment item. + * @param [in] obj The SegmentControl object + * @param [in] index The index of the segment item + * @return The label of the segment item + * + * @ingroup SegmentControl + */ +EAPI const char* +elm_segment_control_item_label_get(const Evas_Object *obj, int index) +{ + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Elm_Segment_Item *it; + + it = _item_find(obj, index); + if (it) return it->label; + + return NULL; +} + +/** + * Set the label of a segment item. + * @param [in] it The SegmentControl Item + * @param [in] label New label text. + * + * @ingroup SegmentControl + */ +EAPI void +elm_segment_control_item_label_set(Elm_Segment_Item* it, const char* label) +{ + ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it); + Widget_Data *wd; + + wd = elm_widget_item_data_get(it); + if (!wd) return; + + eina_stringshare_replace(&it->label, label); + if (it->label) + edje_object_signal_emit(it->base.view, "elm,state,text,visible", "elm"); + else + edje_object_signal_emit(it->base.view, "elm,state,text,hidden", "elm"); + edje_object_message_signal_process(it->base.view); + //label can be NULL also. + edje_object_part_text_set(it->base.view, "elm.text", it->label); +} + +/** + * Get the icon of a segment item of SegmentControl + * @param [in] obj The SegmentControl object + * @param [in] index The index of the segment item + * @return The icon object. + * + * @ingroup SegmentControl + */ +EAPI Evas_Object * +elm_segment_control_item_icon_get(const Evas_Object *obj, int index) +{ + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Elm_Segment_Item *it; + + it = _item_find(obj, index); + if (it) return it->icon; + + return NULL; +} + +/** + * Set the Icon to the segment item + * @param [in] it The SegmentControl Item + * @param [in] icon Objects like Layout, Icon, Label etc... + * + * @ingroup SegmentControl + */ +EAPI void +elm_segment_control_item_icon_set(Elm_Segment_Item *it, Evas_Object *icon) +{ + ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it); + + //Remove the existing icon + if (it->icon) + { + edje_object_part_unswallow(it->base.view, it->icon); + evas_object_del(it->icon); + it->icon = NULL; + } + + it->icon = icon; + if (it->icon) + { + elm_widget_sub_object_add(it->base.view, it->icon); + edje_object_part_swallow(it->base.view, "elm.swallow.icon", it->icon); + edje_object_signal_emit(it->base.view, "elm,state,icon,visible", "elm"); + } + else + edje_object_signal_emit(it->base.view, "elm,state,icon,hidden", "elm"); +} + +/** + * Get the Segment items count from SegmentControl + * @param [in] obj The SegmentControl object + * @return Segment items count. + * + * @ingroup SegmentControl + */ +EAPI int +elm_segment_control_item_count_get(const Evas_Object *obj) +{ + ELM_CHECK_WIDTYPE(obj, widtype) 0; + Widget_Data *wd; + + wd = elm_widget_data_get(obj); + if (!wd) return 0; + + return eina_list_count(wd->seg_items); +} + +/** + * Get the base object of segment item. + * @param [in] it The Segment item + * @return obj The base object of the segment item. + * + * @ingroup SegmentControl + */ +EAPI Evas_Object* +elm_segment_control_item_object_get(const Elm_Segment_Item *it) +{ + ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL); + + return it->base.view; +} + +/** + * Get the selected segment item in the SegmentControl + * @param [in] obj The SegmentControl object + * @return Selected Segment Item. NULL if none of segment item is selected. + * + * @ingroup SegmentControl + */ +EAPI Elm_Segment_Item* +elm_segment_control_item_selected_get(const Evas_Object *obj) +{ + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd; + + wd = elm_widget_data_get(obj); + if (!wd) return NULL; + + return wd->selected_item; +} + +/** + * Select/unselect a particular segment item of SegmentControl + * @param [in] it The Segment item that is to be selected or unselected. + * @param [in] select Passing EINA_TRUE will select the segment item and + * EINA_FALSE will unselect. + * + * @ingroup SegmentControl + */ +EAPI void +elm_segment_control_item_selected_set(Elm_Segment_Item *it, Eina_Bool select) +{ + ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it); + Widget_Data *wd; + + wd = elm_widget_item_data_get(it); + if (!wd) return; + + if (it == wd->selected_item) + { + //already in selected state. + if (select) return; + + //unselect case + _segment_off(it); + } + else if (select) + _segment_on(it); + + return; +} + +/** + * Get the Segment Item from the specified Index. + * @param [in] obj The Segment Control object. + * @param [in] index The index of the segment item. + * @return The Segment item. + * + * @ingroup SegmentControl + */ +EAPI Elm_Segment_Item * +elm_segment_control_item_get(const Evas_Object *obj, int index) +{ + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Elm_Segment_Item *it; + + it = _item_find(obj, index); + + return it; +} + +/** + * Get the index of a Segment item in the SegmentControl + * @param [in] it The Segment Item. + * @return Segment Item index. + * + * @ingroup SegmentControl + */ +EAPI int +elm_segment_control_item_index_get(const Elm_Segment_Item *it) +{ + ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, -1); + + return it->seg_index; +}