/* * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved. * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://floralicense.org/license/ * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ group { name: "elm/floatingbutton/base/default"; alias: "efl/floatingbutton"; script { public mouse_down, g_prev_x, g_width, g_btns; public left_timer, right_timer; public g_visible; public g_expand; public message(Msg_Type:type, id, ...) { if ((type == MSG_INT) && (id == 0)) { new width; width = getarg(2); set_int(g_width, width); } } public left_anim_go() { run_program(PROGRAM:"left_spacer_animation"); } public right_anim_go() { run_program(PROGRAM:"right_spacer_animation"); } } parts { part { name: "elm.swallow.vg"; type: SWALLOW; scale: 1; clip_to: "vg_clipper"; description { state: "default" 0.0; fixed: 1 1; rel1.to: "left_expand"; rel2.to: "right_expand"; } description { state: "hidden" 0.0; inherit: "default" 0.0; visible: 0; } } part { name: "vg_clipper"; type: RECT; clip_to: "clipper"; description { state: "default" 0.0; fixed: 1 1; rel1.to: "elm.swallow.vg"; rel2.to: "elm.swallow.vg"; color_class: "floatingbutton/default/bg"; } description { state: "pressed" 0.0; inherit: "default" 0.0; color_class: "floatingbutton/default/bg_pressed"; } description { state: "disabled" 0.0; inherit: "default" 0.0; color_class: "floatingbutton/default/bg_disabled"; } } part { name: "elm.track.left_hidden"; type: SPACER; scale: 1; description { state: "default" 0.0; min: (FLOATINGBUTTON_1BTN_WIDTH_INC+FLOATINGBUTTON_SIDE_MARGIN_INC-FLOATINGBUTTON_HANDLER_SIZE_INC) 0; fixed: 1 1; align: 1.0 0.5; rel1.relative: 0.0 0.0; rel2.relative: 0.0 1.0; } description { state: "2buttons" 0.0; inherit: "default" 0.0; min: (FLOATINGBUTTON_2BTN_WIDTH_INC+FLOATINGBUTTON_SIDE_MARGIN_INC-FLOATINGBUTTON_HANDLER_SIZE_INC) 0; } } part { name: "elm.track.right_hidden"; type: SPACER; scale: 1; description { state: "default" 0.0; min: (FLOATINGBUTTON_1BTN_WIDTH_INC+FLOATINGBUTTON_SIDE_MARGIN_INC-FLOATINGBUTTON_HANDLER_SIZE_INC) 0; fixed: 1 1; align: 0.0 0.5; rel1.relative: 1.0 0.0; rel2.relative: 1.0 1.0; } description { state: "2buttons" 0.0; inherit: "default" 0.0; min: (FLOATINGBUTTON_2BTN_WIDTH_INC+FLOATINGBUTTON_SIDE_MARGIN_INC-FLOATINGBUTTON_HANDLER_SIZE_INC) 0; } } part { name: "elm.track.fb"; type: SPACER; scale: 1; description { state: "default" 0.0; rel1.to: "elm.track.left_hidden"; rel2.to: "elm.track.right_hidden"; } } part { name: "left_expand"; type: SPACER; description { state: "default" 0.0; fixed: 1 1; align: 1.0 0.5; rel1 { to: "left_spacer"; relative: 0.0 0.0; } rel2 { to: "left_spacer"; relative: 0.0 1.0; } } } part { name: "right_expand"; type: SPACER; description { state: "default" 0.0; fixed: 1 1; align: 0.0 0.5; rel1 { to: "right_spacer"; relative: 1.0 0.0; } rel2 { to: "right_spacer"; relative: 1.0 1.0; } } } part { name: "left_spacer"; type: SPACER; scale: 1; description { state: "default" 0.0; min: FLOATINGBUTTON_LR_WIDTH_INC 0; fixed: 1 1; align: 1.0 0.5; rel1 { to_x: "elm.swallow.box"; to_y: "elm.dragable.fb"; relative: 0.0 0.0; } rel2 { to_x: "elm.swallow.box"; to_y: "elm.dragable.fb"; relative: 0.0 1.0; } } description { state: "expand" 0.0; inherit: "default" 0.0; min: (FLOATINGBUTTON_LR_WIDTH_INC+FLOATINGBUTTON_LAYOUT_SIDE_MARGIN_INC) 0; } } part { name: "right_spacer"; type: SPACER; scale: 1; description { state: "default" 0.0; min: FLOATINGBUTTON_LR_WIDTH_INC 0; fixed: 1 1; align: 0.0 0.5; rel1 { to_x: "elm.swallow.box"; to_y: "elm.dragable.fb"; relative: 1.0 0.0; } rel2 { to_x: "elm.swallow.box"; to_y: "elm.dragable.fb"; relative: 1.0 1.0; } } description { state: "expand" 0.0; inherit: "default" 0.0; min: (FLOATINGBUTTON_LR_WIDTH_INC+FLOATINGBUTTON_LAYOUT_SIDE_MARGIN_INC) 0; } } part { name: "elm.swallow.box"; type: SWALLOW; scale: 1; clip_to: "clipper"; description { state: "default" 0.0; min: 0 0; fixed: 1 1; align: 0.5 0.5; rel1 { to: "elm.dragable.fb"; relative: 0.5 0.5; } rel2 { to: "elm.dragable.fb"; relative: 0.5 0.5; } } description { state: "hidden" 0.0; inherit: "default" 0.0; visible: 0; } } part { name: "elm.dragable.fb"; type: RECT; scale: 1; clip_to: "clipper"; repeat_events: 1; description { state: "default" 0.0; min: FLOATINGBUTTON_1BTN_WIDTH_INC FLOATINGBUTTON_HEIGHT_INC; fixed: 1 1; align: 0.5 0.5; rel1 { to: "elm.track.fb"; relative: 0.5 0.0; } rel2 { to: "elm.track.fb"; relative: 0.5 1.0; } color: 0 0 0 0; } description { state: "expand" 0.0; inherit: "default" 0.0; min: (FLOATINGBUTTON_1BTN_WIDTH_INC+FLOATINGBUTTON_SIDE_MARGIN_INC) FLOATINGBUTTON_HEIGHT_INC; } description { state: "2buttons" 0.0; inherit: "default" 0.0; min: FLOATINGBUTTON_2BTN_WIDTH_INC FLOATINGBUTTON_HEIGHT_INC; } description { state: "2buttons_expand" 0.0; inherit: "default" 0.0; min: (FLOATINGBUTTON_2BTN_WIDTH_INC+FLOATINGBUTTON_SIDE_MARGIN_INC) FLOATINGBUTTON_HEIGHT_INC; } description { state: "hidden" 0.0; inherit: "default" 0.0; visible: 0; } dragable { x: 1 1 0; y: 0 0 0; confine: "elm.track.fb"; threshold: "elm.threshold.fb"; } } part { name : "elm.threshold.fb"; type: SPACER; scale: 1; mouse_events: 0; description { state: "default" 0.0; min: 0 FLOATINGBUTTON_HEIGHT_INC; fixed: 1 1; align: 0.5 0.5; rel1 { to: "elm.track.fb"; relative: 0.5 0.0; } rel2 { to: "elm.track.fb"; relative: 0.5 1.0; } } } part { name: "clipper"; type: RECT; mouse_events: 0; description { state: "default" 0.0; color: 255 255 255 255; } } } programs { program { signal: "load"; script { custom_state(PART:"left_expand", "default", 0.0); custom_state(PART:"right_expand", "default", 0.0); custom_state(PART:"elm.threshold.fb", "default", 0.0); set_state(PART:"elm.threshold.fb", "custom", 0.0); set_int(g_visible, 1); } } program { signal: "elm,state,floatingbutton,*,1btn"; source: "elm"; script { set_state(PART:"elm.track.left_hidden", "default", 0.0); set_state(PART:"elm.track.right_hidden", "default", 0.0); set_int(g_btns, 1); } } program { signal: "elm,state,floatingbutton,*,2btn"; source: "elm"; script { set_state(PART:"elm.track.left_hidden", "2buttons", 0.0); set_state(PART:"elm.track.right_hidden", "2buttons", 0.0); set_int(g_btns, 2); } } program { signal: "elm,floatingbutton,threshold,update"; source: "elm"; script { new width, Float:pos; new x, y, w, h; new x1, y1, w1, h1; width = get_int(g_width); set_state_val(PART:"elm.threshold.fb", STATE_MIN, width, 0); get_geometry(PART:"elm.track.fb", x, y, w, h); get_geometry(PART:"elm.dragable.fb", x1, y1, w1, h1); pos = ((x1 - x) + float(w1) / 2) / w; set_state_val(PART:"elm.threshold.fb", STATE_REL1, pos, 0.0); set_state_val(PART:"elm.threshold.fb", STATE_REL2, pos, 1.0); } } program { name: "mouse_down"; signal: "mouse,down,1"; source: "elm.dragable.fb"; script { new x, y, w, h; get_geometry(PART:"elm.dragable.fb", x, y, w, h); set_int(g_prev_x, x); set_int(mouse_down, 1); set_state(PART:"vg_clipper", "pressed", 0.0); } } program { name: "mouse_up"; signal: "mouse,up,1"; source: "elm.dragable.fb"; script { set_int(mouse_down, 0); set_state(PART:"vg_clipper", "default", 0.0); } } program { name: "mouse_move"; signal: "mouse,move"; source: "elm.dragable.fb"; script { new prev_x; prev_x = get_int(g_prev_x); if (get_int(mouse_down) == 1) { new x, y, w, h; new x1, y1, w1, h1; get_geometry(PART:"elm.dragable.fb", x, y, w, h); if (prev_x < x) { get_geometry(PART:"left_expand", x1, y1, w1, h1); if ((w1 + x - prev_x) < FLOATINGBUTTON_LR_MAX_VARIATION_INC) set_state_val(PART:"left_expand", STATE_MIN, (w1 + x - prev_x), 0); else set_state_val(PART:"left_expand", STATE_MIN, FLOATINGBUTTON_LR_MAX_VARIATION_INC, 0); set_state(PART:"left_expand", "custom", 0.0); new id; id = get_int(left_timer); cancel_timer(id); id = timer(0.01, "left_anim_go", 1); set_int(left_timer, id); } else if (prev_x > x) { get_geometry(PART:"right_expand", x1, y1, w1, h1); if ((w1 + prev_x - x) < FLOATINGBUTTON_LR_MAX_VARIATION_INC) set_state_val(PART:"right_expand", STATE_MIN, (w1 + prev_x - x), 0); else set_state_val(PART:"right_expand", STATE_MIN, FLOATINGBUTTON_LR_MAX_VARIATION_INC, 0); set_state(PART:"right_expand", "custom", 0.0); new id; id = get_int(right_timer); cancel_timer(id); id = timer(0.01, "right_anim_go", 1); set_int(right_timer, id); } set_int(g_prev_x, x); } } } program { name: "left_spacer_animation"; action: STATE_SET "default" 0.0; transition: DECEL 0.4; target: "left_expand"; } program { name: "right_spacer_animation"; action: STATE_SET "default" 0.0; transition: DECEL 0.4; target: "right_expand"; } program { name: "left_spacer_stretch"; action: STATE_SET "custom" 0.0; transition: ACCEL 0.2; target: "left_expand"; after: "left_spacer_animation"; } program { name: "right_spacer_stretch"; action: STATE_SET "custom" 0.0; transition: ACCEL 0.2; target: "right_expand"; after: "right_spacer_animation"; } program { name: "block"; signal: "elm,state,floatingbutton,block"; source: "elm"; script { set_mouse_events(PART:"elm.dragable.fb", 0); } } program { name: "unblock"; signal: "elm,state,floatingbutton,unblock"; source: "elm"; script { set_mouse_events(PART:"elm.dragable.fb", 1); } } program { signal: "elm,state,floatingbutton,freeze"; source: "elm"; script { set_mask_flags(PART:"elm.dragable.fb", 1); } } program { signal: "elm,state,floatingbutton,thaw"; source: "elm"; script { set_mask_flags(PART:"elm.dragable.fb", 0); } } program { signal: "elm,state,show"; source: ""; script { set_int(g_visible, 1); run_program(PROGRAM:"visible"); } } program { signal: "elm,state,hide"; source: ""; script { set_int(g_visible, 0); run_program(PROGRAM:"hidden"); } } program { name: "visible"; signal: "elm,state,floatingbutton,visible"; source: "elm"; script { if (get_int(g_visible) == 1) { set_state(PART:"elm.swallow.vg", "default", 0.0); set_state(PART:"elm.swallow.box", "default", 0.0); if (get_int(g_btns) < 2) { if (get_int(g_expand) == 0) { set_state(PART:"elm.dragable.fb", "default", 0.0); } else { set_state(PART:"elm.dragable.fb", "expand", 0.0); } } else { if (get_int(g_expand) == 0) { set_state(PART:"elm.dragable.fb", "2buttons", 0.0); } else { set_state(PART:"elm.dragable.fb", "2buttons_expand", 0.0); } } } } } program { name: "hidden"; signal: "elm,state,floatingbutton,hidden"; source: "elm"; script { set_state(PART:"elm.swallow.vg", "hidden", 0.0); set_state(PART:"elm.swallow.box", "hidden", 0.0); set_state(PART:"elm.dragable.fb", "hidden", 0.0); } } program { name: "left_bring_in"; signal: "elm,action,floatingbutton,left"; source: "elm"; script { set_state_val(PART:"right_expand", STATE_MIN, FLOATINGBUTTON_LR_MAX_VARIATION_INC, 0); run_program(PROGRAM:"right_spacer_stretch"); } } program { name: "right_bring_in"; signal: "elm,action,floatingbutton,right"; source: "elm"; script { set_state_val(PART:"left_expand", STATE_MIN, FLOATINGBUTTON_LR_MAX_VARIATION_INC, 0); run_program(PROGRAM:"left_spacer_stretch"); } } program { name: "move_to_left"; signal: "elm,state,floatingbutton,left,*"; source: "elm"; action: STATE_SET "expand" 0.0; target: "left_spacer"; transition: DECEL 0.4; } program { signal: "elm,state,floatingbutton,left,*"; source: "elm"; script { set_int(g_expand, 1); } } program { name: "move_to_left_1btn"; signal: "elm,state,floatingbutton,left,1btn"; source: "elm"; action: STATE_SET "expand" 0.0; target: "elm.dragable.fb"; transition: DECEL 0.4; } program { name: "move_to_left_2btn"; signal: "elm,state,floatingbutton,left,2btn"; source: "elm"; action: STATE_SET "2buttons_expand" 0.0; target: "elm.dragable.fb"; transition: DECEL 0.4; } program { name: "move_to_right"; signal: "elm,state,floatingbutton,right,*"; source: "elm"; action: STATE_SET "expand" 0.0; target: "right_spacer"; transition: DECEL 0.4; } program { signal: "elm,state,floatingbutton,right,*"; source: "elm"; script { set_int(g_expand, 1); } } program { name: "move_to_right_1btn"; signal: "elm,state,floatingbutton,right,1btn"; source: "elm"; action: STATE_SET "expand" 0.0; target: "elm.dragable.fb"; transition: DECEL 0.4; } program { name: "move_to_right_2btn"; signal: "elm,state,floatingbutton,right,2btn"; source: "elm"; action: STATE_SET "2buttons_expand" 0.0; target: "elm.dragable.fb"; transition: DECEL 0.4; } program { name: "move_to_center"; signal: "elm,state,floatingbutton,center,*"; source: "elm"; action: STATE_SET "default" 0.0; target: "left_spacer"; target: "right_spacer"; transition: DECEL 0.4; } program { signal: "elm,state,floatingbutton,center,*"; source: "elm"; script { set_int(g_expand, 0); } } program { name: "move_to_center_1btn"; signal: "elm,state,floatingbutton,center,1btn"; source: "elm"; action: STATE_SET "default" 0.0; target: "elm.dragable.fb"; transition: DECEL 0.4; } program { name: "move_to_center_2btn"; signal: "elm,state,floatingbutton,center,2btn"; source: "elm"; action: STATE_SET "2buttons" 0.0; target: "elm.dragable.fb"; transition: DECEL 0.4; } } } group { name: "elm/floatingbutton/base/white"; alias: "elm/floatingbutton/base/white_bg"; inherit: "elm/floatingbutton/base/default"; parts { part { name: "vg_clipper"; type: RECT; clip_to: "clipper"; description { state: "default" 0.0; fixed: 1 1; rel1.to: "elm.swallow.vg"; rel2.to: "elm.swallow.vg"; color_class: "floatingbutton/white/bg"; } description { state: "pressed" 0.0; inherit: "default" 0.0; color_class: "floatingbutton/white/bg_pressed"; } description { state: "disabled" 0.0; inherit: "default" 0.0; color_class: "floatingbutton/white/bg_disabled"; } } } }