/* * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved * * BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #define FLIP_PICKER_MAX_LEN (3 + 1) #define FLIP_PICKER_MAX_LEN_STR "3" group { "elm/flipselector/event/default"; inherit_only: 1; parts { rect { "event_top"; mouse; desc { "default"; color: 0 0 0 0; } desc { "disabled"; inherit: "default"; hid; } } rect { "event_bottom"; mouse; desc { "default"; color: 0 0 0 0; } desc { "disabled"; inherit: "default"; hid; } } } programs { program { "pressed_top"; signal: "mouse,down,1"; source: "event_top"; action: SIGNAL_EMIT "elm,action,down,start" "elm"; } program { "unpressed_top"; signal: "mouse,up,1"; source: "event_top"; action: SIGNAL_EMIT "elm,action,down,stop" "elm"; } program { "pressed_bottom"; signal: "mouse,down,1"; source: "event_bottom"; action: SIGNAL_EMIT "elm,action,up,start" "elm"; } program { "unpressed_bottom"; signal: "mouse,up,1"; source: "event_bottom"; action: SIGNAL_EMIT "elm,action,up,stop" "elm"; } program { "disabled"; signal: "elm,state,disabled"; source: "elm"; action: STATE_SET "disabled"; target: "event_top"; target: "event_bottom"; after: "on_disabled"; } program { "enabled"; signal: "elm,state,enabled"; source: "elm"; action: STATE_SET "default"; target: "event_top"; target: "event_bottom"; after: "on_enabled"; } program { "hidden_button"; signal: "elm,state,button,hidden"; source: "elm"; after: "on_hidden_button"; } program { "visible_button"; signal: "elm,state,button,visible"; source: "elm"; after: "on_visible_button"; } } } group { "elm/flipselector/base/template"; inherit_only: 1; parts { spacer { "base"; desc { "default"; } } text { "elm.top"; desc { "default"; } desc { "disabled"; } } text { "elm.bottom"; desc { "default"; } desc { "disabled"; } } } } group { "elm/flipselector/base/default"; images { image: "core_picker_arrow_up.png" COMP; image: "core_picker_arrow_down.png" COMP; image: "core_picker_bg_up.png" COMP; image: "core_picker_bg_down.png" COMP; image: "core_picker_bg_fixed.png" COMP; image: "core_picker_stroke_up.png" COMP; image: "core_picker_stroke_down.png" COMP; image: "core_picker_stroke_fixed.png" COMP; } data.item: "max_len" FLIP_PICKER_MAX_LEN_STR; parts { spacer { "base"; scale; desc { "default"; min: FLIPSELECTOR_BASE_SIZE_INC; max: FLIPSELECTOR_BASE_SIZE_INC; } } spacer { "base_top"; scale; desc { "default"; min: FLIPSELECTOR_TOP_SIZE_INC; max: FLIPSELECTOR_TOP_SIZE_INC; align: 0.5 0.0; fixed: 1 1; rel.to: "base"; rel2.relative: 1.0 0.0; } } spacer { "base_bottom_fixed"; scale; desc { "default"; min: FLIPSELECTOR_BOTTOM_FIXED_SIZE_INC; max: FLIPSELECTOR_BOTTOM_FIXED_SIZE_INC; align: 0.5 1.0; fixed: 1 1; rel.to: "base"; rel1.relative: 0.0 1.0; } } spacer { "base_bottom"; scale; desc { "default"; min: FLIPSELECTOR_BOTTOM_SIZE_INC; max: FLIPSELECTOR_BOTTOM_SIZE_INC; align: 0.5 0.0; fixed: 1 1; rel.to: "base_bottom_fixed"; rel2.relative: 1.0 0.0; } } spacer { "text_width"; nomouse; scale; desc { "default"; fixed: 1 1; min: FLIPSELECTOR_TEXT_WIDTH_INC; rel.to: "divider"; rel1.relative: 0.5 0.5; rel2.relative: 0.5 0.5; } } rect { "perspective"; nomouse; scale; desc { "default"; color: 0 0 0 0; rel.to: "divider"; rel2.relative: 1.0 0.0; perspective { zplane: 0; focal: 1000; } } } image { "bg_top_fixed"; nomouse; scale; desc { "default"; rel.to: "base_top"; image.normal: "core_picker_bg_up.png"; color_class: "flipselector/default/bg_top"; } } image { "stroke_top_fixed"; nomouse; scale; desc { "default"; rel.to: "base_top"; image.normal: "core_picker_stroke_up.png"; color_class: "flipselector/default/stroke"; } } spacer { "padding_top_arrow"; scale; desc { "default"; fixed: 0 1; align: 0.5 0.0; min: FLIPSELECTOR_ARROW_TOP_PADDING_SIZE_INC; max: FLIPSELECTOR_ARROW_TOP_PADDING_SIZE_INC; rel.to: "base_top"; rel2.relative: 1.0 0.0; } } image { "arrow_top_fixed"; nomouse; scale; desc { "default"; fixed: 1 1; min: FLIPSELECTOR_ARROW_TOP_BOTTOM_SIZE_INC; max: FLIPSELECTOR_ARROW_TOP_BOTTOM_SIZE_INC; align: 0.5 0.0; rel.to: "padding_top_arrow"; rel1.relative: 0.0 1.0; image.normal: "core_picker_arrow_up.png"; color_class: "flipselector/default/arrow"; } desc { "hidden"; inherit: "default"; hid; } } text { "text_top_fixed"; nomouse; scale; clip: "clipper_top"; desc { "default"; fixed: 1 1; rel.to: "text_width"; rel2.relative: 1.0 0.0; text { font: "Tizen:weight=Light"; size: FLIPSELECTOR_TEXT_MAX_SIZE_INC; size_range: FLIPSELECTOR_TEXT_MIN_SIZE_INC FLIPSELECTOR_TEXT_MAX_SIZE_INC; fit: 1 0; ellipsis: -1; align: 0.5 0.5; source: "elm.top"; text_class: "tizen"; } color_class: "flipselector/default/text"; } desc { "disabled"; inherit: "default"; color_class: "flipselector/default/text_disabled"; } } image { "bg_top"; nomouse; scale; desc { "default"; rel.to: "base_top"; image.normal: "core_picker_bg_up.png"; color_class: "flipselector/default/bg_top"; map { on: 1; perspective_on: 1; perspective: "perspective"; smooth: 1; rotation { center: "divider"; x: 360; } } } desc { "shrinked"; inherit: "default"; map { on: 1; perspective_on: 1; perspective: "perspective"; smooth: 1; rotation { center: "divider"; x: 270; } } } } image { "stroke_top"; nomouse; scale; desc { "default"; rel.to: "base_top"; image.normal: "core_picker_stroke_up.png"; color_class: "flipselector/default/stroke"; map { on: 1; perspective_on: 1; perspective: "perspective"; smooth: 1; rotation { center: "divider"; x: 360; } } } desc { "shrinked"; inherit: "default"; map { on: 1; perspective_on: 1; perspective: "perspective"; smooth: 1; rotation { center: "divider"; x: 270; } } } } image { "arrow_top"; nomouse; scale; desc { "default"; fixed: 1 1; min: FLIPSELECTOR_ARROW_TOP_BOTTOM_SIZE_INC; max: FLIPSELECTOR_ARROW_TOP_BOTTOM_SIZE_INC; align: 0.5 0.0; rel.to: "padding_top_arrow"; rel1.relative: 0.0 1.0; image.normal: "core_picker_arrow_up.png"; color_class: "flipselector/default/arrow"; map { on: 1; perspective_on: 1; perspective: "perspective"; smooth: 1; rotation { center: "divider"; x: 360; } } } desc { "shrinked"; inherit: "default"; map { on: 1; perspective_on: 1; perspective: "perspective"; smooth: 1; rotation { center: "divider"; x: 270; } } } desc { "hidden"; inherit: "default"; hid; } } text { "elm.top"; nomouse; scale; clip: "clipper_top"; desc { "default"; fixed: 1 1; rel.to: "text_width"; rel2.relative: 1.0 0.0; text { font: "Tizen:weight=Light"; size: FLIPSELECTOR_TEXT_MAX_SIZE_INC; size_range: FLIPSELECTOR_TEXT_MIN_SIZE_INC FLIPSELECTOR_TEXT_MAX_SIZE_INC; fit: 1 0; ellipsis: -1; align: 0.5 0.5; text_class: "tizen"; } color_class: "flipselector/default/text"; map { on: 1; perspective_on: 1; perspective: "perspective"; smooth: 1; rotation { center: "divider"; x: 360; } } } desc { "shrinked"; inherit: "default"; map { on: 1; perspective_on: 1; perspective: "perspective"; smooth: 1; rotation { center: "divider"; x: 270; } } } desc { "disabled"; inherit: "default"; color_class: "flipselector/default/text_disabled"; } } rect { "clipper_top"; nomouse; scale; desc { "default"; rel.to: "base_top"; color: 255 255 255 255; } } image { "bg_bottom_fixed"; nomouse; scale; desc { "default"; rel.to: "base_bottom_fixed"; image.normal: "core_picker_bg_fixed.png"; color_class: "flipselector/default/bg_bottom"; } } image { "stroke_bottom_fixed"; nomouse; scale; desc { "default"; rel.to: "base_bottom_fixed"; image.normal: "core_picker_stroke_fixed.png"; color_class: "flipselector/default/stroke"; } } spacer { "padding_bottom_arrow"; scale; desc { "default"; fixed: 0 1; align: 0.5 1.0; min: FLIPSELECTOR_ARROW_BOTTOM_PADDING_SIZE_INC; max: FLIPSELECTOR_ARROW_BOTTOM_PADDING_SIZE_INC; rel.to: "base_bottom"; rel1.relative: 0.0 1.0; } } image { "arrow_bottom_fixed"; nomouse; scale; desc { "default"; fixed: 1 1; min: FLIPSELECTOR_ARROW_TOP_BOTTOM_SIZE_INC; max: FLIPSELECTOR_ARROW_TOP_BOTTOM_SIZE_INC; align: 0.5 1.0; rel.to: "padding_bottom_arrow"; rel2.relative: 1.0 0.0; image.normal: "core_picker_arrow_down.png"; color_class: "flipselector/default/arrow"; } desc { "hidden"; inherit: "default"; hid; } } text { "text_bottom_fixed"; nomouse; scale; clip: "clipper_bottom"; desc { "default"; fixed: 1 1; rel.to: "text_width"; rel2.relative: 1.0 0.0; text { font: "Tizen:weight=Light"; size: FLIPSELECTOR_TEXT_MAX_SIZE_INC; size_range: FLIPSELECTOR_TEXT_MIN_SIZE_INC FLIPSELECTOR_TEXT_MAX_SIZE_INC; fit: 1 0; ellipsis: -1; align: 0.5 0.5; source: "elm.bottom"; text_class: "tizen"; } color_class: "flipselector/default/text"; } desc { "disabled"; inherit: "default"; color_class: "flipselector/default/text_disabled"; } } image { "bg_bottom"; nomouse; scale; desc { "default"; rel.to: "base_bottom"; image.normal: "core_picker_bg_down.png"; color_class: "flipselector/default/bg_bottom"; map { on: 1; perspective_on: 1; perspective: "perspective"; smooth: 1; rotation { center: "divider"; x: 0; } } } desc { "shrinked"; inherit: "default"; map { on: 1; perspective_on: 1; perspective: "perspective"; smooth: 1; rotation { center: "divider"; x: 90; } } } } image { "stroke_bottom"; nomouse; scale; desc { "default"; rel.to: "base_bottom"; image.normal: "core_picker_stroke_down.png"; color_class: "flipselector/default/stroke"; map { on: 1; perspective_on: 1; perspective: "perspective"; smooth: 1; rotation { center: "divider"; x: 0; } } } desc { "shrinked"; inherit: "default"; map { on: 1; perspective_on: 1; perspective: "perspective"; smooth: 1; rotation { center: "divider"; x: 90; } } } } image { "arrow_bottom"; nomouse; scale; desc { "default"; fixed: 1 1; min: FLIPSELECTOR_ARROW_TOP_BOTTOM_SIZE_INC; max: FLIPSELECTOR_ARROW_TOP_BOTTOM_SIZE_INC; align: 0.5 1.0; rel.to: "padding_bottom_arrow"; rel2.relative: 1.0 0.0; image.normal: "core_picker_arrow_down.png"; color_class: "flipselector/default/arrow"; map { on: 1; perspective_on: 1; perspective: "perspective"; smooth: 1; rotation { center: "divider"; x: 0; } } } desc { "shrinked"; inherit: "default"; map { on: 1; perspective_on: 1; perspective: "perspective"; smooth: 1; rotation { center: "divider"; x: 90; } } } desc { "hidden"; inherit: "default"; hid; } } text { "elm.bottom"; nomouse; scale; clip: "clipper_bottom"; desc { "default"; fixed: 1 1; rel.to: "text_width"; rel2.relative: 1.0 0.0; text { font: "Tizen:weight=Light"; size: FLIPSELECTOR_TEXT_MAX_SIZE_INC; size_range: FLIPSELECTOR_TEXT_MIN_SIZE_INC FLIPSELECTOR_TEXT_MAX_SIZE_INC; fit: 1 0; ellipsis: -1; align: 0.5 0.5; text_class: "tizen"; } color_class: "flipselector/default/text"; map { on: 1; perspective_on: 1; perspective: "perspective"; smooth: 1; rotation { center: "divider"; x: 0; } } } desc { "shrinked"; inherit: "default"; map { on: 1; perspective_on: 1; perspective: "perspective"; smooth: 1; rotation { center: "divider"; x: 90; } } } desc { "disabled"; inherit: "default"; color_class: "flipselector/default/text_disabled"; } } rect { "clipper_bottom"; nomouse; scale; desc { "default"; rel.to: "base_bottom_fixed"; color: 255 255 255 255; } } rect { "divider"; nomouse; scale; desc { "default"; min: FLIPSELECTOR_DIVIDER_SIZE_INC; align: 0.5 0.0; rel1.to: "base_top"; rel1.relative: 0.0 1.0; rel2.to: "base_bottom"; rel2.relative: 1.0 0.0; fixed: 1 1; color_class: "flipselector/default/divider"; } } } inherit: "elm/flipselector/event/default"; parts { rect { "event_top"; mouse; desc { "default"; rel.to: "base_top"; } desc { "disabled"; rel.to: "base_top"; } } rect { "event_bottom"; mouse; desc { "default"; rel.to: "base_bottom_fixed"; } desc { "disabled"; rel.to: "base_bottom_fixed"; } } } //FIXME: quick successive clicks on, say, up, lead to nastiness script { public cur, prev, next, lock; flip_down(str[]) { new tmp[FLIP_PICKER_MAX_LEN]; if (get_int(lock) == 1) { replace_str(next, 0, str); return; } fetch_str(cur, 0, tmp, FLIP_PICKER_MAX_LEN); if (strncmp(tmp, "", FLIP_PICKER_MAX_LEN) == 0) get_text(PART:"elm.top", tmp, FLIP_PICKER_MAX_LEN); set_text(PART:"text_bottom_fixed", tmp); set_text(PART:"elm.top", tmp); replace_str(prev, 0, tmp); set_state(PART:"elm.bottom", "shrinked", 0.0); set_text(PART:"elm.bottom", str); set_text(PART:"text_top_fixed", str); set_state(PART:"bg_bottom", "shrinked", 0.0); set_state(PART:"stroke_bottom", "shrinked", 0.0); set_state(PART:"arrow_bottom", "shrinked", 0.0); replace_str(cur, 0, str); set_int(lock, 1); anim(0.2, "animator_top_down", 1); } flip_up(str[]) { new tmp[FLIP_PICKER_MAX_LEN]; if (get_int(lock) == 1) { replace_str(next, 0, str); return; } fetch_str(cur, 0, tmp, FLIP_PICKER_MAX_LEN); if (strncmp(tmp, "", FLIP_PICKER_MAX_LEN) == 0) get_text(PART:"elm.bottom", tmp, FLIP_PICKER_MAX_LEN); set_text(PART:"text_top_fixed", tmp); set_text(PART:"elm.bottom", tmp); replace_str(prev, 0, tmp); set_state(PART:"elm.top", "shrinked", 0.0); set_text(PART:"elm.top", str); set_text(PART:"text_bottom_fixed", str); set_state(PART:"bg_top", "shrinked", 0.0); set_state(PART:"stroke_top", "shrinked", 0.0); set_state(PART:"arrow_top", "shrinked", 0.0); replace_str(cur, 0, str); set_int(lock, 1); anim(0.2, "animator_bottom_up", 1); } public animator_top_down(val, Float:pos) { set_tween_state(PART:"elm.top", pos, "default", 0.0, "shrinked", 0.0); set_tween_state(PART:"bg_top", pos, "default", 0.0, "shrinked", 0.0); set_tween_state(PART:"stroke_top", pos, "default", 0.0, "shrinked", 0.0); set_tween_state(PART:"arrow_top", pos, "default", 0.0, "shrinked", 0.0); if (pos >= 1.0) { new tmp[FLIP_PICKER_MAX_LEN]; fetch_str(cur, 0, tmp, FLIP_PICKER_MAX_LEN); set_text(PART:"elm.top", tmp); set_state(PART:"elm.top", "default", 0.0); set_state(PART:"bg_top", "default", 0.0); set_state(PART:"stroke_top", "default", 0.0); set_state(PART:"arrow_top", "default", 0.0); anim(0.2, "animator_bottom_down", val); } } public animator_bottom_down(val, Float:pos) { new tmp[FLIP_PICKER_MAX_LEN]; set_tween_state(PART:"elm.bottom", pos, "shrinked", 0.0, "default", 0.0); set_tween_state(PART:"bg_bottom", pos, "shrinked", 0.0, "default", 0.0); set_tween_state(PART:"stroke_bottom", pos, "shrinked", 0.0, "default", 0.0); set_tween_state(PART:"arrow_bottom", pos, "shrinked", 0.0, "default", 0.0); if (pos >= 1.0) { set_state(PART:"bg_bottom", "default", 0.0); set_state(PART:"stroke_bottom", "default", 0.0); set_state(PART:"arrow_bottom", "default", 0.0); set_int(lock, 0); fetch_str(next, 0, tmp, FLIP_PICKER_MAX_LEN); if (strncmp(tmp, "", FLIP_PICKER_MAX_LEN) != 0) { replace_str(next, 0, ""); flip_down(tmp); } } } public animator_bottom_up(val, Float:pos) { set_tween_state(PART:"elm.bottom", pos, "default", 0.0, "shrinked", 0.0); set_tween_state(PART:"bg_bottom", pos, "default", 0.0, "shrinked", 0.0); set_tween_state(PART:"stroke_bottom", pos, "default", 0.0, "shrinked", 0.0); set_tween_state(PART:"arrow_bottom", pos, "default", 0.0, "shrinked", 0.0); if (pos >= 1.0) { new tmp[FLIP_PICKER_MAX_LEN]; fetch_str(cur, 0, tmp, FLIP_PICKER_MAX_LEN); set_text(PART:"elm.bottom", tmp); set_state(PART:"elm.bottom", "default", 0.0); set_state(PART:"bg_bottom", "default", 0.0); set_state(PART:"stroke_bottom", "default", 0.0); set_state(PART:"arrow_bottom", "default", 0.0); anim(0.2, "animator_top_up", val); } } public animator_top_up(val, Float:pos) { new tmp[FLIP_PICKER_MAX_LEN]; set_tween_state(PART:"elm.top", pos, "shrinked", 0.0, "default", 0.0); set_tween_state(PART:"bg_top", pos, "shrinked", 0.0, "default", 0.0); set_tween_state(PART:"stroke_top", pos, "shrinked", 0.0, "default", 0.0); set_tween_state(PART:"arrow_top", pos, "shrinked", 0.0, "default", 0.0); if (pos >= 1.0) { set_state(PART:"bg_top", "default", 0.0); set_state(PART:"stroke_top", "default", 0.0); set_state(PART:"arrow_top", "default", 0.0); set_int(lock, 0); fetch_str(next, 0, tmp, FLIP_PICKER_MAX_LEN); if (strncmp(tmp, "", FLIP_PICKER_MAX_LEN) != 0) { replace_str(next, 0, ""); flip_up(tmp); } } } public message(Msg_Type:type, id, ...) { if ((type == MSG_STRING) && (id == 1)) { new value[FLIP_PICKER_MAX_LEN]; snprintf(value, FLIP_PICKER_MAX_LEN, "%s", getarg(2)); flip_down(value); } else if ((type == MSG_STRING) && (id == 2)) { new value[FLIP_PICKER_MAX_LEN]; snprintf(value, FLIP_PICKER_MAX_LEN, "%s", getarg(2)); flip_up(value); } } } programs { program { signal: "load"; source: ""; script { append_str(cur, ""); append_str(prev, ""); append_str(next, ""); set_int(lock, 0); } } program { "on_hidden_button"; action: STATE_SET "hidden"; target: "arrow_top"; target: "arrow_top_fixed"; target: "arrow_bottom"; target: "arrow_bottom_fixed"; } program { "on_visible_button"; action: STATE_SET "default"; target: "arrow_top"; target: "arrow_top_fixed"; target: "arrow_bottom"; target: "arrow_bottom_fixed"; } program { "on_disabled"; action: STATE_SET "disabled"; target: "elm.bottom"; target: "elm.top"; target: "text_bottom_fixed"; target: "text_top_fixed"; } program { "on_enabled"; action: STATE_SET "default"; target: "elm.bottom"; target: "elm.top"; target: "text_bottom_fixed"; target: "text_top_fixed"; } } }