From fc2f13fc6a1f45a5b041520c976d9a002b0a9711 Mon Sep 17 00:00:00 2001 From: Jonathan Atton Date: Tue, 6 Oct 2009 15:08:41 +0000 Subject: [PATCH] elm toolbar: add menu. See the last item in the tollbar test. Thi implementation is simple: each item are a button with a custom style SVN revision: 42904 --- data/themes/default.edc | 942 +++++++++++++++++++++++++++++++++------- src/bin/test_toolbar.c | 18 +- src/lib/Elementary.h.in | 8 + src/lib/elm_toolbar.c | 192 +++++++- 4 files changed, 1004 insertions(+), 156 deletions(-) diff --git a/data/themes/default.edc b/data/themes/default.edc index 56c473f07..e16eb7c14 100644 --- a/data/themes/default.edc +++ b/data/themes/default.edc @@ -1612,6 +1612,316 @@ collections { } } } + + group { name: "elm/button/base/menu"; + images { + image: "bt_base1.png" COMP; + image: "bt_base2.png" COMP; + image: "bt_hilight.png" COMP; + image: "bt_shine.png" COMP; + image: "bt_glow.png" COMP; + image: "bt_dis_base.png" COMP; + image: "bt_dis_hilight.png" COMP; + } + parts { + part { name: "button_image"; + mouse_events: 1; + description { state: "default" 0.0; + color: 255 255 255 0; + image { + normal: "bt_base2.png"; + border: 7 7 7 7; + } + image.middle: SOLID; + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + color: 255 255 255 255; + } + description { state: "clicked" 0.0; + inherit: "default" 0.0; + inherit: "visible" 0.0; + image.normal: "bt_base1.png"; + image.middle: SOLID; + } + description { state: "disabled" 0.0; + inherit: "default" 0.0; + inherit: "visible" 0.0; + image { + normal: "bt_dis_base.png"; + border: 4 4 4 4; + } + } + } + part { name: "elm.swallow.content"; + type: SWALLOW; + description { state: "default" 0.0; + fixed: 1 0; + visible: 0; + align: 0.0 0.5; + rel1.offset: 4 4; + rel2.offset: 3 -5; + rel2.relative: 0.0 1.0; + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + fixed: 1 0; + visible: 1; + aspect: 1.0 1.0; + aspect_preference: VERTICAL; + rel2.offset: 4 -5; + } + description { state: "icononly" 0.0; + inherit: "default" 0.0; + fixed: 0 0; + visible: 1; + align: 0.5 0.5; + aspect: 1.0 1.0; + rel2.offset: -5 -5; + rel2.relative: 1.0 1.0; + aspect_preference: VERTICAL; + } + } + part { + name: "elm.text"; + type: TEXT; + effect: SOFT_SHADOW; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + visible: 0; + rel1.to_x: "elm.swallow.content"; + rel1.relative: 1.0 0.0; + rel1.offset: 0 4; + rel2.offset: -5 -5; + color: 224 224 224 255; + color3: 0 0 0 64; + text { + font: "Sans,Edje-Vera"; + size: 10; + min: 0 0; + align: 0.0 0.5; + } + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + visible: 1; + text.min: 1 1; + } + description { state: "disabled" 0.0; + inherit: "default" 0.0; + color: 0 0 0 128; + color3: 0 0 0 0; + } + description { state: "disabled_visible" 0.0; + inherit: "default" 0.0; + color: 0 0 0 128; + color3: 0 0 0 0; + visible: 1; + text.min: 1 1; + } + } + part { name: "over1"; + mouse_events: 0; + description { state: "default" 0.0; + color: 255 255 255 0; + rel2.relative: 1.0 0.5; + image { + normal: "bt_hilight.png"; + border: 7 7 7 0; + } + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + color: 255 255 255 255; + } + description { state: "disabled" 0.0; + inherit: "default" 0.0; + inherit: "visible" 0.0; + image { + normal: "bt_dis_hilight.png"; + border: 4 4 4 0; + } + } + } + part { name: "over2"; + mouse_events: 1; + repeat_events: 1; + ignore_flags: ON_HOLD; + description { state: "default" 0.0; + image { + normal: "bt_shine.png"; + border: 7 7 7 7; + } + } + description { state: "disabled" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } + part { name: "over3"; + mouse_events: 1; + repeat_events: 1; + description { state: "default" 0.0; + color: 255 255 255 0; + image { + normal: "bt_glow.png"; + border: 12 12 12 12; + } + fill.smooth : 0; + } + description { state: "clicked" 0.0; + inherit: "default" 0.0; + visible: 1; + color: 255 255 255 255; + } + } + 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 { + program { + name: "button_mouse_in"; + signal: "mouse,in"; + source: "over2"; + action: STATE_SET "visible" 0.0; + target: "button_image"; + target: "over1"; + transition: DECELERATE 0.5; + } + program { + name: "button_mouse_out"; + signal: "mouse,out"; + source: "over2"; + action: STATE_SET "default" 0.0; + target: "button_image"; + target: "over1"; + transition: DECELERATE 0.5; + } + program { + name: "button_unclick"; + signal: "mouse,up,1"; + source: "over2"; + action: STATE_SET "visible" 0.0; + target: "button_image"; + } + program { + name: "button_click2"; + signal: "mouse,down,1"; + source: "over3"; + action: STATE_SET "clicked" 0.0; + target: "over3"; + } + program { + name: "button_unclick2"; + signal: "mouse,up,1"; + source: "over3"; + action: STATE_SET "default" 0.0; + transition: DECELERATE 0.5; + target: "over3"; + } + program { + name: "button_unclick3"; + signal: "mouse,up,1"; + source: "over2"; + action: SIGNAL_EMIT "elm,action,click" ""; + } + program { name: "text_show"; + signal: "elm,state,text,visible"; + source: "elm"; + script { + new st[31]; + new Float:vl; + get_state(PART:"elm.swallow.content", st, 30, vl); + if (!strcmp(st, "icononly")) + set_state(PART:"elm.swallow.content", "visible", 0.0); + set_state(PART:"elm.text", "visible", 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.content", st, 30, vl); + if (!strcmp(st, "visible")) + set_state(PART:"elm.swallow.content", "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, "visible")) + set_state(PART:"elm.swallow.content", "visible", 0.0); + else + set_state(PART:"elm.swallow.content", "icononly", 0.0); + } + } + program { name: "icon_hide"; + signal: "elm,state,icon,hidden"; + source: "elm"; + 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: "button_image"; + target: "over1"; + target: "over2"; + 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); + } + } + program { name: "enable"; + signal: "elm,state,enabled"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "button_image"; + target: "over1"; + target: "over2"; + 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); + } + } + } + } /////////////////////////////////////////////////////////////////////////////// group { name: "elm/toggle/base/default"; images { @@ -3479,43 +3789,162 @@ collections { fill.smooth: 0; } } - part { name: "elm.swallow.content"; - type: SWALLOW; + part { name: "elm.swallow.content"; + type: SWALLOW; + description { state: "default" 0.0; + rel1.offset: 2 2; + rel2.offset: -3 -13; + } + } + } + } + + group { name: "elm/frame/base/outdent_bottom"; + images { + image: "outdent-bottom.png" COMP; + } + parts { + part { name: "base0"; + mouse_events: 0; + description { state: "default" 0.0; + image.normal: "outdent-bottom.png"; + image.border: 0 0 13 0; + fill.smooth: 0; + } + } + part { name: "elm.swallow.content"; + type: SWALLOW; + description { state: "default" 0.0; + rel1.offset: 2 12; + rel2.offset: -3 -3; + } + } + } + } + +/////////////////////////////////////////////////////////////////////////////// + group { name: "elm/hover/base/default"; + images { + image: "shad_circ.png" COMP; + } + parts { + part { name: "elm.swallow.offset"; + type: SWALLOW; + description { state: "default" 0.0; + align: 0.0 0.0; + rel1.relative: 0.0 0.0; + rel2.relative: 0.0 0.0; + } + } + part { name: "elm.swallow.size"; + type: SWALLOW; + description { state: "default" 0.0; + align: 0.0 0.0; + rel1.to: "elm.swallow.offset"; + rel1.relative: 1.0 1.0; + rel2.to: "elm.swallow.offset"; + rel2.relative: 1.0 1.0; + } + } + part { name: "base"; + type: RECT; + mouse_events: 1; + description { state: "default" 0.0; + color: 0 0 0 64; + } + } + part { name: "shad"; + mouse_events: 0; + description { state: "default" 0.0; + image.normal: "shad_circ.png"; + rel1.to: "elm.swallow.size"; + rel1.offset: -32 -32; + rel2.to: "elm.swallow.size"; + rel2.offset: 31 31; + fill.smooth: 0; + } + } + part { name: "box"; + type: RECT; + mouse_events: 0; + description { state: "default" 0.0; + color: 0 0 0 0; + rel1.to: "elm.swallow.size"; + rel1.offset: -2 -2; + rel2.to: "elm.swallow.size"; + rel2.offset: 1 1; + } + } + part { name: "elm.swallow.slot.left"; + type: SWALLOW; + description { state: "default" 0.0; + align: 1.0 0.5; + rel1.to: "elm.swallow.slot.middle"; + rel1.relative: 0.0 0.0; + rel1.offset: -1 0; + rel2.to: "elm.swallow.slot.middle"; + rel2.relative: 0.0 1.0; + rel2.offset: -1 -1; + } + } + part { name: "elm.swallow.slot.right"; + type: SWALLOW; + description { state: "default" 0.0; + align: 0.0 0.5; + rel1.to: "elm.swallow.slot.middle"; + rel1.relative: 1.0 0.0; + rel1.offset: 0 0; + rel2.to: "elm.swallow.slot.middle"; + rel2.relative: 1.0 1.0; + rel2.offset: 0 -1; + } + } + part { name: "elm.swallow.slot.top"; + type: SWALLOW; + description { state: "default" 0.0; + align: 0.5 1.0; + rel1.to: "elm.swallow.slot.middle"; + rel1.relative: 0.0 0.0; + rel1.offset: 0 -1; + rel2.to: "elm.swallow.slot.middle"; + rel2.relative: 1.0 0.0; + rel2.offset: -1 -1; + } + } + part { name: "elm.swallow.slot.bottom"; + type: SWALLOW; description { state: "default" 0.0; - rel1.offset: 2 2; - rel2.offset: -3 -13; + align: 0.5 0.0; + rel1.to: "elm.swallow.slot.middle"; + rel1.relative: 0.0 1.0; + rel1.offset: 0 0; + rel2.to: "elm.swallow.slot.middle"; + rel2.relative: 1.0 1.0; + rel2.offset: -1 0; } } - } - } - - group { name: "elm/frame/base/outdent_bottom"; - images { - image: "outdent-bottom.png" COMP; - } - parts { - part { name: "base0"; - mouse_events: 0; + part { name: "elm.swallow.slot.middle"; + type: SWALLOW; description { state: "default" 0.0; - image.normal: "outdent-bottom.png"; - image.border: 0 0 13 0; - fill.smooth: 0; + rel1.to: "elm.swallow.size"; + rel2.to: "elm.swallow.size"; } } - part { name: "elm.swallow.content"; - type: SWALLOW; - description { state: "default" 0.0; - rel1.offset: 2 12; - rel2.offset: -3 -3; - } + } + programs { + program { name: "end"; + signal: "mouse,up,1"; + source: "base"; + action: SIGNAL_EMIT "elm,action,dismiss" ""; } } } -/////////////////////////////////////////////////////////////////////////////// - group { name: "elm/hover/base/default"; + group { name: "elm/hover/base/popout"; images { image: "shad_circ.png" COMP; + image: "bt_dis_base.png" COMP; + image: "bt_dis_hilight.png" COMP; } parts { part { name: "elm.swallow.offset"; @@ -3540,77 +3969,273 @@ collections { type: RECT; mouse_events: 1; description { state: "default" 0.0; + color: 0 0 0 0; + } + description { state: "visible" 0.0; + inherit: "default" 1.0; color: 0 0 0 64; } } - part { name: "shad"; - mouse_events: 0; + part { name: "leftclip"; + type: RECT; description { state: "default" 0.0; - image.normal: "shad_circ.png"; - rel1.to: "elm.swallow.size"; - rel1.offset: -32 -32; - rel2.to: "elm.swallow.size"; - rel2.offset: 31 31; - fill.smooth: 0; + rel2.to_x: "pop"; + rel2.relative: 0.0 1.0; + rel2.offset: 1 -1; } } - part { name: "box"; + part { name: "left"; + clip_to: "leftclip"; + description { state: "default" 0.0; + visible: 0; + rel1.to: "elm.swallow.slot.left"; + rel1.offset: -5 -5; + rel2.to: "elm.swallow.slot.left"; + rel2.offset: 4 4; + image { + normal: "bt_dis_base.png"; + border: 4 4 4 4; + } + image.middle: SOLID; + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + part { name: "elm.swallow.slot.left"; + type: SWALLOW; + clip_to: "leftclip"; + description { state: "default" 0.0; + align: 0.0 0.5; + rel1.to: "elm.swallow.slot.middle"; + rel1.relative: 0.0 0.0; + rel1.offset: -1 0; + rel2.to: "elm.swallow.slot.middle"; + rel2.relative: 0.0 1.0; + rel2.offset: -1 -1; + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + rel1.offset: -7 0; + rel2.offset: -7 -1; + align: 1.0 0.5; + } + } + part { name: "leftover"; + clip_to: "leftclip"; + mouse_events: 0; + description { state: "default" 0.0; + rel1.to: "left"; + rel2.to: "left"; + rel2.relative: 1.0 0.5; + image { + normal: "bt_dis_hilight.png"; + border: 4 4 4 0; + } + } + } + part { name: "rightclip"; + type: RECT; + description { state: "default" 0.0; + rel1.to_x: "pop"; + rel1.relative: 1.0 0.0; + rel1.offset: -2 0; + } + } + part { name: "right"; + clip_to: "rightclip"; + description { state: "default" 0.0; + visible: 0; + rel1.to: "elm.swallow.slot.right"; + rel1.offset: -5 -5; + rel2.to: "elm.swallow.slot.right"; + rel2.offset: 4 4; + image { + normal: "bt_dis_base.png"; + border: 4 4 4 4; + } + image.middle: SOLID; + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + part { name: "elm.swallow.slot.right"; + type: SWALLOW; + clip_to: "rightclip"; + description { state: "default" 0.0; + align: 1.0 0.5; + rel1.to: "elm.swallow.slot.middle"; + rel1.relative: 1.0 0.0; + rel1.offset: 0 0; + rel2.to: "elm.swallow.slot.middle"; + rel2.relative: 1.0 1.0; + rel2.offset: 0 -1; + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + rel1.offset: 6 0; + rel2.offset: 6 -1; + align: 0.0 0.5; + } + } + part { name: "rightover"; + clip_to: "rightclip"; + mouse_events: 0; + description { state: "default" 0.0; + rel1.to: "right"; + rel2.to: "right"; + rel2.relative: 1.0 0.5; + image { + normal: "bt_dis_hilight.png"; + border: 4 4 4 0; + } + } + } + part { name: "topclip"; type: RECT; + description { state: "default" 0.0; + rel2.to_y: "pop"; + rel2.relative: 1.0 0.0; + rel2.offset: -1 1; + } + } + part { name: "top"; + clip_to: "topclip"; + description { state: "default" 0.0; + visible: 0; + rel1.to: "elm.swallow.slot.top"; + rel1.offset: -5 -5; + rel2.to: "elm.swallow.slot.top"; + rel2.offset: 4 4; + image { + normal: "bt_dis_base.png"; + border: 4 4 4 4; + } + image.middle: SOLID; + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + part { name: "elm.swallow.slot.top"; + type: SWALLOW; + clip_to: "topclip"; + description { state: "default" 0.0; + visible: 1; + align: 0.5 0.0; + rel1.to: "elm.swallow.slot.middle"; + rel1.relative: 0.0 0.0; + rel1.offset: 0 -1; + rel2.to: "elm.swallow.slot.middle"; + rel2.relative: 1.0 0.0; + rel2.offset: -1 -1; + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + rel1.offset: 0 -7; + rel2.offset: -1 -7; + align: 0.5 1.0; + } + } + part { name: "topover"; + clip_to: "topclip"; mouse_events: 0; description { state: "default" 0.0; - color: 0 0 0 0; - rel1.to: "elm.swallow.size"; - rel1.offset: -2 -2; - rel2.to: "elm.swallow.size"; - rel2.offset: 1 1; + rel1.to: "top"; + rel2.to: "top"; + rel2.relative: 1.0 0.5; + image { + normal: "bt_dis_hilight.png"; + border: 4 4 4 0; + } + } + } + part { name: "bottomclip"; + type: RECT; + description { state: "default" 0.0; + rel1.to_y: "pop"; + rel1.relative: 0.0 1.0; + rel1.offset: -1 -2; + } + } + part { name: "bottom"; + clip_to: "bottomclip"; + description { state: "default" 0.0; + visible: 0; + rel1.to: "elm.swallow.slot.bottom"; + rel1.offset: -5 -5; + rel2.to: "elm.swallow.slot.bottom"; + rel2.offset: 4 4; + image { + normal: "bt_dis_base.png"; + border: 4 4 4 4; + } + image.middle: SOLID; } - } - part { name: "elm.swallow.slot.left"; - type: SWALLOW; - description { state: "default" 0.0; - align: 1.0 0.5; - rel1.to: "elm.swallow.slot.middle"; - rel1.relative: 0.0 0.0; - rel1.offset: -1 0; - rel2.to: "elm.swallow.slot.middle"; - rel2.relative: 0.0 1.0; - rel2.offset: -1 -1; + description { state: "visible" 0.0; + inherit: "default" 0.0; + visible: 1; } } - part { name: "elm.swallow.slot.right"; + part { name: "elm.swallow.slot.bottom"; type: SWALLOW; + clip_to: "bottomclip"; description { state: "default" 0.0; - align: 0.0 0.5; + align: 0.5 1.0; rel1.to: "elm.swallow.slot.middle"; - rel1.relative: 1.0 0.0; + rel1.relative: 0.0 1.0; rel1.offset: 0 0; rel2.to: "elm.swallow.slot.middle"; rel2.relative: 1.0 1.0; - rel2.offset: 0 -1; + rel2.offset: -1 0; + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + rel1.offset: 0 6; + rel2.offset: -1 6; + align: 0.5 0.0; } } - part { name: "elm.swallow.slot.top"; - type: SWALLOW; + part { name: "bottomover"; + clip_to: "bottomclip"; + mouse_events: 0; description { state: "default" 0.0; - align: 0.5 1.0; - rel1.to: "elm.swallow.slot.middle"; - rel1.relative: 0.0 0.0; - rel1.offset: 0 -1; - rel2.to: "elm.swallow.slot.middle"; - rel2.relative: 1.0 0.0; - rel2.offset: -1 -1; + rel1.to: "bottom"; + rel2.to: "bottom"; + rel2.relative: 1.0 0.5; + image { + normal: "bt_dis_hilight.png"; + border: 4 4 4 0; + } } } - part { name: "elm.swallow.slot.bottom"; - type: SWALLOW; + part { name: "shad"; + mouse_events: 0; + description { state: "default" 0.0; + image.normal: "shad_circ.png"; + rel1.to: "elm.swallow.size"; + rel1.offset: -64 -64; + rel2.to: "elm.swallow.size"; + rel2.offset: 63 63; + fill.smooth: 0; + } + } + part { name: "pop"; + mouse_events: 1; description { state: "default" 0.0; - align: 0.5 0.0; rel1.to: "elm.swallow.slot.middle"; - rel1.relative: 0.0 1.0; - rel1.offset: 0 0; + rel1.offset: -5 -5; rel2.to: "elm.swallow.slot.middle"; - rel2.relative: 1.0 1.0; - rel2.offset: -1 0; + rel2.offset: 4 4; + image { + normal: "bt_dis_base.png"; + border: 4 4 4 4; + } + image.middle: SOLID; } } part { name: "elm.swallow.slot.middle"; @@ -3620,6 +4245,18 @@ collections { rel2.to: "elm.swallow.size"; } } + part { name: "popover"; + mouse_events: 0; + description { state: "default" 0.0; + rel1.to: "pop"; + rel2.to: "pop"; + rel2.relative: 1.0 0.5; + image { + normal: "bt_dis_hilight.png"; + border: 4 4 4 0; + } + } + } } programs { program { name: "end"; @@ -3627,14 +4264,93 @@ collections { source: "base"; action: SIGNAL_EMIT "elm,action,dismiss" ""; } + + program { name: "show"; + signal: "elm,action,show"; + source: "elm"; + action: STATE_SET "visible" 0.0; +// transition: DECELERATE 0.5; + target: "base"; + } + program { name: "hide"; + signal: "elm,action,hide"; + source: "elm"; + action: STATE_SET "default" 0.0; +// transition: DECELERATE 0.5; + target: "base"; + } + + program { name: "leftshow"; + signal: "elm,action,slot,left,show"; + source: "elm"; + action: STATE_SET "visible" 0.0; + transition: DECELERATE 0.5; + target: "left"; + target: "elm.swallow.slot.left"; + } + program { name: "lefthide"; + signal: "elm,action,slot,left,hide"; + source: "elm"; + action: STATE_SET "default" 0.0; + transition: DECELERATE 0.5; + target: "left"; + target: "elm.swallow.slot.left"; + } + program { name: "rightshow"; + signal: "elm,action,slot,right,show"; + source: "elm"; + action: STATE_SET "visible" 0.0; + transition: DECELERATE 0.5; + target: "right"; + target: "elm.swallow.slot.right"; + } + program { name: "righthide"; + signal: "elm,action,slot,right,hide"; + source: "elm"; + action: STATE_SET "default" 0.0; + transition: DECELERATE 0.5; + target: "right"; + target: "elm.swallow.slot.right"; + } + program { name: "topshow"; + signal: "elm,action,slot,top,show"; + source: "elm"; + action: STATE_SET "visible" 0.0; + transition: DECELERATE 0.5; + target: "top"; + target: "elm.swallow.slot.top"; + } + program { name: "tophide"; + signal: "elm,action,slot,top,hide"; + source: "elm"; + action: STATE_SET "default" 0.0; + transition: DECELERATE 0.5; + target: "top"; + target: "elm.swallow.slot.top"; + } + program { name: "bottomshow"; + signal: "elm,action,slot,bottom,show"; + source: "elm"; + action: STATE_SET "visible" 0.0; + transition: DECELERATE 0.5; + target: "bottom"; + target: "elm.swallow.slot.bottom"; + } + program { name: "bottomhide"; + signal: "elm,action,slot,bottom,hide"; + source: "elm"; + action: STATE_SET "default" 0.0; + transition: DECELERATE 0.5; + target: "bottom"; + target: "elm.swallow.slot.bottom"; + } } } - group { name: "elm/hover/base/popout"; + group { name: "elm/hover/base/menu"; images { image: "shad_circ.png" COMP; image: "bt_dis_base.png" COMP; - image: "bt_dis_hilight.png" COMP; } parts { part { name: "elm.swallow.offset"; @@ -3712,19 +4428,6 @@ collections { align: 1.0 0.5; } } - part { name: "leftover"; - clip_to: "leftclip"; - mouse_events: 0; - description { state: "default" 0.0; - rel1.to: "left"; - rel2.to: "left"; - rel2.relative: 1.0 0.5; - image { - normal: "bt_dis_hilight.png"; - border: 4 4 4 0; - } - } - } part { name: "rightclip"; type: RECT; description { state: "default" 0.0; @@ -3771,19 +4474,6 @@ collections { align: 0.0 0.5; } } - part { name: "rightover"; - clip_to: "rightclip"; - mouse_events: 0; - description { state: "default" 0.0; - rel1.to: "right"; - rel2.to: "right"; - rel2.relative: 1.0 0.5; - image { - normal: "bt_dis_hilight.png"; - border: 4 4 4 0; - } - } - } part { name: "topclip"; type: RECT; description { state: "default" 0.0; @@ -3831,19 +4521,6 @@ collections { align: 0.5 1.0; } } - part { name: "topover"; - clip_to: "topclip"; - mouse_events: 0; - description { state: "default" 0.0; - rel1.to: "top"; - rel2.to: "top"; - rel2.relative: 1.0 0.5; - image { - normal: "bt_dis_hilight.png"; - border: 4 4 4 0; - } - } - } part { name: "bottomclip"; type: RECT; description { state: "default" 0.0; @@ -3890,30 +4567,6 @@ collections { align: 0.5 0.0; } } - part { name: "bottomover"; - clip_to: "bottomclip"; - mouse_events: 0; - description { state: "default" 0.0; - rel1.to: "bottom"; - rel2.to: "bottom"; - rel2.relative: 1.0 0.5; - image { - normal: "bt_dis_hilight.png"; - border: 4 4 4 0; - } - } - } - part { name: "shad"; - mouse_events: 0; - description { state: "default" 0.0; - image.normal: "shad_circ.png"; - rel1.to: "elm.swallow.size"; - rel1.offset: -64 -64; - rel2.to: "elm.swallow.size"; - rel2.offset: 63 63; - fill.smooth: 0; - } - } part { name: "pop"; mouse_events: 1; description { state: "default" 0.0; @@ -3921,12 +4574,7 @@ collections { rel1.offset: -5 -5; rel2.to: "elm.swallow.slot.middle"; rel2.offset: 4 4; - image { - normal: "bt_dis_base.png"; - border: 4 4 4 4; - } - image.middle: SOLID; - } + } } part { name: "elm.swallow.slot.middle"; type: SWALLOW; @@ -3935,18 +4583,6 @@ collections { rel2.to: "elm.swallow.size"; } } - part { name: "popover"; - mouse_events: 0; - description { state: "default" 0.0; - rel1.to: "pop"; - rel2.to: "pop"; - rel2.relative: 1.0 0.5; - image { - normal: "bt_dis_hilight.png"; - border: 4 4 4 0; - } - } - } } programs { program { name: "end"; diff --git a/src/bin/test_toolbar.c b/src/bin/test_toolbar.c index 14a9f27d0..2427f04c3 100644 --- a/src/bin/test_toolbar.c +++ b/src/bin/test_toolbar.c @@ -95,11 +95,27 @@ test_toolbar(void *data, Evas_Object *obj, void *event_info) elm_icon_file_set(ic, buf, NULL); elm_toolbar_item_add(tb, ic, "Elementary", tb_5, ph4); + ic = elm_icon_add(win); + snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR); + elm_icon_file_set(ic, buf, NULL); + item = elm_toolbar_item_add(tb, ic, "Menu", NULL, NULL); + elm_toolbar_item_menu_set(item, 1); + elm_toolbar_menu_parent_set(tb, win); + + snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR); + elm_toolbar_item_menu_item_add(item, buf, NULL, "Here", tb_3, ph4); + + snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR); + elm_toolbar_item_menu_item_add(item, buf, NULL, "Comes", tb_4, ph4); + + snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR); + elm_toolbar_item_menu_item_add(item, buf, NULL, "Elementary", tb_5, ph4); + elm_box_pack_end(bx, tb); evas_object_show(tb); tb = elm_table_add(win); -// elm_table_homogenous_set(tb, 1); + //elm_table_homogenous_set(tb, 1); evas_object_size_hint_weight_set(tb, 0.0, EVAS_HINT_EXPAND); evas_object_size_hint_fill_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL); diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index 0ce570f85..7accba72c 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -312,8 +312,10 @@ extern "C" { EAPI void elm_button_style_set(Evas_Object *obj, const char *style); /* available styles: * default + * anchor * hoversel_vertical * hoversel_vertical_entry + * menu */ /* smart callbacks called: * "clicked" - the user clicked the button @@ -445,6 +447,7 @@ extern "C" { /* available styles: * default * popout + * menu * hoversel_vertical */ /* smart callbacks called: @@ -594,6 +597,7 @@ extern "C" { */ typedef struct _Elm_Toolbar_Item Elm_Toolbar_Item; + typedef struct _Elm_Toolbar_Menu_Item Elm_Toolbar_Menu_Item; EAPI Evas_Object *elm_toolbar_add(Evas_Object *parent); EAPI void elm_toolbar_icon_size_set(Evas_Object *obj, int icon_size); EAPI int elm_toolbar_icon_size_get(Evas_Object *obj); @@ -607,6 +611,10 @@ extern "C" { EAPI void elm_toolbar_item_disabled_set(Elm_Toolbar_Item *item, Eina_Bool disabled); EAPI void elm_toolbar_item_separator_set(Elm_Toolbar_Item *item, Eina_Bool separator); EAPI Eina_Bool elm_toolbar_item_separator_get(Elm_Toolbar_Item *item); + EAPI void elm_toolbar_item_menu_set(Elm_Toolbar_Item *item, Eina_Bool menu); + EAPI void elm_toolbar_menu_parent_set(Evas_Object *obj, Evas_Object *parent); + EAPI Elm_Toolbar_Menu_Item *elm_toolbar_item_menu_item_add(Elm_Toolbar_Item *item, const char *icon_path, const char *icon_group, const char *label, void (*func) (void *data, Evas_Object *obj, void *event_info), const void *data); + EAPI void elm_toolbar_menu_item_del(Elm_Toolbar_Menu_Item *item); EAPI void elm_toolbar_scrollable_set(Evas_Object *obj, Eina_Bool scrollable); EAPI void elm_toolbar_homogenous_set(Evas_Object *obj, Eina_Bool homogenous); /* smart callbacks called: diff --git a/src/lib/elm_toolbar.c b/src/lib/elm_toolbar.c index e1ea85f34..8db6c6168 100644 --- a/src/lib/elm_toolbar.c +++ b/src/lib/elm_toolbar.c @@ -1,3 +1,6 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ #include #include "elm_priv.h" @@ -9,9 +12,21 @@ struct _Widget_Data Eina_List *items; int icon_size; Eina_Bool scrollable : 1; + Evas_Object *menu_parent; Eina_Bool homogeneous : 1; }; +struct _Elm_Toolbar_Menu_Item +{ + Elm_Toolbar_Item *parent; + + const char *icon_group; + const char *icon_path; + const char *label; + void (*func) (void *data, Evas_Object *obj, void *event_info); + const void *data; +}; + struct _Elm_Toolbar_Item { Evas_Object *obj; @@ -23,6 +38,11 @@ struct _Elm_Toolbar_Item Eina_Bool selected : 1; Eina_Bool disabled : 1; Eina_Bool separator : 1; + + Eina_Bool menu; + Eina_List *menu_items; + Evas_Object *menu_position; + Evas_Object *menu_hover; }; static void _item_show(Elm_Toolbar_Item *it); @@ -32,6 +52,10 @@ static void _del_hook(Evas_Object *obj); static void _theme_hook(Evas_Object *obj); static void _sizing_eval(Evas_Object *obj); +static void _menu_move_resize(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void _menu_hide(void *data, Evas_Object *obj, void *event_info); +static void _menu_item_select(void *data, Evas_Object *obj, void *event_info); + static void _item_show(Elm_Toolbar_Item *it) { @@ -48,9 +72,11 @@ static void _item_select(Elm_Toolbar_Item *it) { Elm_Toolbar_Item *it2; + Elm_Toolbar_Menu_Item *it_menu; Widget_Data *wd = elm_widget_data_get(it->obj); - Evas_Object *obj2; + Evas_Object *obj2, *bt, *hv, *bx, *ic; const Eina_List *l; + Evas_Coord x,y,w,h; if (!wd) return; if ((it->selected) || (it->disabled) || (it->separator)) return; @@ -67,10 +93,94 @@ _item_select(Elm_Toolbar_Item *it) edje_object_signal_emit(it->base, "elm,state,selected", "elm"); _item_show(it); obj2 = it->obj; + if(it->menu) + { + it->menu_position = elm_icon_add(it->base); + + hv = elm_hover_add(it->base); + it->menu_hover = hv; + if(wd->menu_parent) + elm_hover_parent_set(hv, wd->menu_parent); + elm_hover_target_set(hv, it->menu_position); + elm_hover_style_set(hv, "menu"); + + bx = elm_box_add(it->base); + evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(bx); + + EINA_LIST_FOREACH(it->menu_items, l, it_menu) + { + ic = elm_icon_add(it->base); + elm_icon_file_set(ic, it_menu->icon_path, it_menu->icon_group); + + bt = elm_button_add(it->base); + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_fill_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_style_set(bt, "menu"); + elm_button_label_set(bt, it_menu->label); + elm_button_icon_set(bt, ic); + evas_object_smart_callback_add(bt, "clicked", _menu_item_select, it_menu); + elm_box_pack_end(bx, bt); + evas_object_show(bt); + } + elm_hover_content_set(hv, elm_hover_best_content_location_get(hv, ELM_HOVER_AXIS_VERTICAL), bx); + evas_object_event_callback_add(hv, EVAS_CALLBACK_RESIZE, _menu_move_resize, it); + evas_object_event_callback_add(hv, EVAS_CALLBACK_MOVE, _menu_move_resize, it); + evas_object_smart_callback_add(hv, "clicked", _menu_hide, it); + evas_object_show(hv); + + evas_object_geometry_get(it->base, &x, &y, &w, &h); + evas_object_move(it->menu_position, x, y); + evas_object_resize(it->menu_position, w , h); + } if (it->func) it->func((void *)(it->data), it->obj, it); evas_object_smart_callback_call(obj2, "clicked", it); } +static void +_menu_item_select(void *data, Evas_Object *obj, void *event_info) +{ + Elm_Toolbar_Menu_Item *it = data; + if (it->func) it->func((void *)(it->data), it->parent->obj, it); + + _menu_hide(it->parent, NULL, NULL); +} + +static void +_menu_hide(void *data, Evas_Object *obj, void *event_info) +{ + Elm_Toolbar_Item *it = data; + + evas_object_del(it->menu_position); + it->menu_position = NULL; + evas_object_del(it->menu_hover); + it->menu_hover = NULL; +} + +static void +_menu_move_resize(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + Elm_Toolbar_Item *it = data; + Evas_Coord x_p,y_p,x,y,w,h,x2,y2,w2,h2; + Widget_Data *wd = elm_widget_data_get(it->obj); + if (!wd || !wd->menu_parent) return; + evas_object_geometry_get(it->menu_position, &x_p, &y_p, NULL, NULL); + evas_object_geometry_get(it->menu_hover, &x, &y, &w, &h); + evas_object_geometry_get(wd->menu_parent, &x2, &y2, &w2, &h2); + + if(x+w > x2+w2) + x_p -= x+w - x2+w2; + if(x < x2) + x_p += x2 - x; + + if(y+h > y2+h2) + y_p -= y+h - y2+h2; + if(y < y2) + y_p += y2 - y; + + evas_object_move(it->menu_position, x_p, y_p); +} + static void _item_disable(Elm_Toolbar_Item *it, Eina_Bool disabled) { @@ -90,6 +200,7 @@ _del_hook(Evas_Object *obj) { Widget_Data *wd = elm_widget_data_get(obj); Elm_Toolbar_Item *it; + Elm_Toolbar_Menu_Item *it_menu; if (!wd) return; EINA_LIST_FREE(wd->items, it) @@ -97,6 +208,20 @@ _del_hook(Evas_Object *obj) eina_stringshare_del(it->label); if (it->icon) evas_object_del(it->icon); evas_object_del(it->base); + if(it->menu_position) + evas_object_del(it->menu_position); + if(it->menu_hover) + evas_object_del(it->menu_hover); + EINA_LIST_FREE(it->menu_items, it_menu) + { + if(it_menu->icon_path) + eina_stringshare_del(it_menu->icon_path); + if(it_menu->icon_group) + eina_stringshare_del(it_menu->icon_group); + if(it_menu->label) + eina_stringshare_del(it_menu->label); + free(it_menu); + } free(it); } free(wd); @@ -191,7 +316,7 @@ static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info) { Widget_Data *wd = elm_widget_data_get(data); - Evas_Coord mw, mh, vw, vh, w, h; + Evas_Coord mw, mh, vw, vh, x, y, w, h; const Eina_List *l; Elm_Toolbar_Item *it; @@ -208,6 +333,12 @@ _resize(void *data, Evas *e, Evas_Object *obj, void *event_info) if (it->selected) { _item_show(it); + if(it->menu_position) + { + evas_object_geometry_get(it->base, &x, &y, &w, &h); + evas_object_move(it->menu_position, x, y); + evas_object_resize(it->menu_position, w , h); + } break; } } @@ -431,3 +562,60 @@ elm_toolbar_homogenous_set(Evas_Object *obj, Eina_Bool homogenous) evas_object_smart_calculate(wd->bx); } +EAPI void +elm_toolbar_menu_parent_set(Evas_Object *obj, Evas_Object *parent) +{ + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + wd->menu_parent = parent; +} + + +EAPI void +elm_toolbar_item_menu_set(Elm_Toolbar_Item *item, Eina_Bool menu) +{ + if (!item) return; + if (item->menu == menu) return; + item->menu = menu; +} + +EAPI Elm_Toolbar_Menu_Item * +elm_toolbar_item_menu_item_add(Elm_Toolbar_Item *item, const char *icon_path, const char *icon_group, const char *label, void (*func) (void *data, Evas_Object *obj, void *event_info), const void *data) +{ + Elm_Toolbar_Menu_Item *menu_item; + if (!item) return NULL; + + menu_item = calloc(1, sizeof(Elm_Toolbar_Menu_Item)); + if(!menu_item) return NULL; + if(label) + menu_item->label = eina_stringshare_add(label); + if(icon_path) + menu_item->icon_path = eina_stringshare_add(icon_path); + if(icon_group) + menu_item->icon_group = eina_stringshare_add(icon_group); + menu_item->func = func; + menu_item->data = data; + menu_item->parent = item; + + item->menu_items = eina_list_append(item->menu_items, menu_item); + return menu_item; +} + +EAPI void +elm_toolbar_menu_item_del(Elm_Toolbar_Menu_Item *menu_item) +{ + Elm_Toolbar_Item *item; + if(!menu_item) return; + + item = menu_item->parent; + item->menu_items = eina_list_remove(item->menu_items, menu_item); + + if(menu_item->icon_path) + eina_stringshare_del(menu_item->icon_path); + if(menu_item->icon_group) + eina_stringshare_del(menu_item->icon_group); + if(menu_item->label) + eina_stringshare_del(menu_item->label); + free(menu_item); +} + -- 2.34.1