From: Woochan Lee Date: Wed, 16 Mar 2016 02:52:46 +0000 (+0900) Subject: Add zoom transition effect with effect change infra code. X-Git-Tag: submit/tizen/20160617.075742~110^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F06%2F62406%2F7;p=platform%2Fcore%2Fuifw%2Fui-viewmgr.git Add zoom transition effect with effect change infra code. Change-Id: I829915350cfbec285bc5b55908849190069749a9 --- diff --git a/data/edc/ui-viewmgr.edc b/data/edc/ui-viewmgr.edc index 64dd08b..6cea6c9 100644 --- a/data/edc/ui-viewmgr.edc +++ b/data/edc/ui-viewmgr.edc @@ -50,7 +50,7 @@ #define TIZEN_VIEW_TOOLBAR_TITLE_CLIPPER_HEIGHT_INC 80 #define TIZEN_VIEW_TOOLBAR_LIGHT_VIEW_HEIGHT_INC 86 #define TIZEN_VIEW_TOOLBAR_TOP_DIVIDER_HEIGHT_INC 0 -#define TRANSITION_TIME 0.25 +#define TRANSITION_TIME 0.2 collections { base_scale: 2.6; @@ -1168,4 +1168,102 @@ collections { } } } -} + /* Zoom Effect */ + group { "transition/zoom"; + parts { + rect { "opacity_content"; + desc { "default"; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 1.0; + color: 255 255 255 255; + } + desc { "appear_from"; + rel1.relative: 0.2 0.2; + rel2.relative: 0.8 0.8; + color: 255 255 255 0; + } + } + rect { "opacity_pcontent"; + desc { "default"; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 1.0; + color: 255 255 255 255; + } + desc { "appear_from"; + rel1.relative: 0.2 0.2; + rel2.relative: 0.8 0.8; + color: 255 255 255 0; + } + desc { "disappear_to"; + inherit: "appear_from"; + } + } + proxy { "content_proxy"; + desc { + source: "content"; + //FIXME: It has to added for zoom effect. + // Can't use below command right now. It will be added in upstream. + //source_visible: 0; + } + } + swallow { "pcontent"; + clip_to: opacity_pcontent; + desc { "default"; + rel1.to: "opacity_pcontent"; + rel2.to: "opacity_pcontent"; + } + } + swallow { "content"; + clip_to: opacity_content; + desc { "default"; + rel1.to: "opacity_content"; + rel2.to: "opacity_content"; + } + desc { "hidden"; + visible: 0; + } + } + } + programs { + program { "push_finished"; + action: SIGNAL_EMIT "push,finished" "viewmgr"; + } + program { "push_content"; + action: STATE_SET "default" 0.0; + target: "opacity_content"; + transition: DECELERATE TRANSITION_TIME; + after: "push_finished"; + } + program { "push"; + signal: "view,push"; + source: "viewmgr"; + script { + set_state(PART:"opacity_content", "appear_from", 0.0); + run_program(PROGRAM:"push_content"); + } + } + program { "pop_finished" + action: SIGNAL_EMIT "pop,finished" "viewmgr"; + } + program { "content_state_change"; + action: STATE_SET "default" 0.0; + target: "content"; + after: "pop_finished"; + } + program { "pop_content"; + action: STATE_SET "disappear_to" 0.0; + target: "opacity_pcontent"; + transition: DECELERATE TRANSITION_TIME; + after: "content_state_change"; + } + program { "pop"; + signal: "view,pop"; + source: "viewmgr"; + script { + set_state(PART:"opacity_pcontent", "default", 0.0); + set_state(PART:"content", "hidden", 0.0); + run_program(PROGRAM:"pop_content"); + } + } + } + } diff --git a/src/include/efl/ui_viewmgr.h b/src/include/efl/ui_viewmgr.h index 6ade0d2..b507711 100644 --- a/src/include/efl/ui_viewmgr.h +++ b/src/include/efl/ui_viewmgr.h @@ -20,6 +20,7 @@ #include #include "../interface/ui_viewmanager_interface.h" #include "ui_key_listener.h" +#include namespace efl_viewmgr { @@ -42,12 +43,13 @@ class ui_viewmgr: public viewmgr::ui_iface_viewmgr friend class ui_view; private: - Evas_Object *win; //This is acting like a base object of viewmgr. - Evas_Object *conform; //Conformant for viewmgr. - Evas_Object *layout; //Viewmgr's base layout. - ui_key_listener *key_listener; //HW Key Handler such as "BACK" key... - ui_view_indicator indicator; //Mode of indicator. - string transition_style; //Current transiton effect style name + Evas_Object *win; //This is acting like a base object of viewmgr. + Evas_Object *conform; //Conformant for viewmgr. + Evas_Object *layout; //Viewmgr's base layout. + ui_key_listener *key_listener; //HW Key Handler such as "BACK" key... + ui_view_indicator indicator; //Mode of indicator. + string transition_style; //Current transiton effect style name + map effect_map; //Map for effect layouts. Evas_Object *set_transition_layout(string transition_style); @@ -64,10 +66,11 @@ private: * @brief Create a base layout. * * @param conform viewmgr's conformant object. this will be parent of layout object. + * @param style view's transition effect style. * * @return @c true success or @c false not. */ - bool create_base_layout(Evas_Object *conform); + bool create_base_layout(Evas_Object *conform, const char *style); /** @brief Set the indicator mode. * diff --git a/src/lib/efl/ui_viewmgr.cpp b/src/lib/efl/ui_viewmgr.cpp index 11ff304..bfa12b3 100644 --- a/src/lib/efl/ui_viewmgr.cpp +++ b/src/lib/efl/ui_viewmgr.cpp @@ -22,21 +22,79 @@ using namespace viewmgr; //FIXME: is it correct to define here? #define EDJ_PATH "/usr/share/edje/ui-viewmgr/ui-viewmgr.edj" +bool ui_viewmgr::create_base_layout(Evas_Object *conform, const char *style) +{ + char buf[128]; + Evas_Object *layout = elm_layout_add(conform); + if (!layout) return false; + + //FIXME: Is it C programming style? need to change? + snprintf(buf, sizeof(buf), "transition/%s", style); + //default transition layout + elm_layout_file_set(layout, EDJ_PATH, buf); + elm_object_content_set(conform, layout); + + //Push Finished Event + elm_layout_signal_callback_add(layout, "push,finished", "viewmgr", + [](void *data, Evas_Object *obj, const char *emission, const char *source) -> void + { + ui_viewmgr *viewmgr = static_cast(data); + ui_view *pview = viewmgr->get_view(viewmgr->get_view_count() - 2); + ui_view *view = viewmgr->get_last_view(); + if (pview) viewmgr->push_view_finished(pview); + if (view) viewmgr->push_view_finished(view); + }, + this); + + //Pop Finished Event + elm_layout_signal_callback_add(layout, "pop,finished", "viewmgr", + [](void *data, Evas_Object *obj, const char *emission, const char *source) -> void + { + ui_viewmgr *viewmgr = static_cast(data); + ui_view *pview = viewmgr->get_view(viewmgr->get_view_count() - 2); + ui_view *view = viewmgr->get_last_view(); + if (pview) viewmgr->pop_view_finished(pview); + if (view) viewmgr->pop_view_finished(view); + }, + this); + + this->layout = layout; + + return true; +} + Evas_Object *ui_viewmgr::set_transition_layout(string transition_style) { + Evas_Object *effect_layout = NULL; + elm_object_part_content_unset(this->get_base(), "pcontent"); elm_object_part_content_unset(this->get_base(), "content"); - if (transition_style == this->transition_style) return this->layout; + if (transition_style.compare(this->transition_style) == 0) return this->layout; + + if (effect_map.size()) effect_layout = effect_map.find(transition_style)->second; + + //Conformant content change to current effect layout and change to hide prev layout. + Evas_Object *playout = elm_object_part_content_unset(this->conform, "elm.swallow.content"); + evas_object_hide(playout); + + if (!effect_layout) + { + //Create and add effect_layouts in map here. + //FIXME: If we have to support many effects, this logic should be changed. + effect_map.insert(pair("default", this->layout)); + + this->create_base_layout(this->get_conformant(), transition_style.c_str()); - //FIXME: 1. Find current style effect layout - Evas_Object *effect = this->get_base(); + effect_map.insert(pair(transition_style, this->layout)); + } + else + { + elm_object_part_content_set(this->conform, "elm.swallow.content", effect_layout); - //2. Switch effect layout to base layout - elm_object_part_content_unset(this->get_conformant(), "elm.swallow.content"); - elm_object_part_content_set(this->get_conformant(), "elm.swallow.content", effect); + this->layout = effect_layout; + } - this->layout = effect; this->transition_style = transition_style; return this->layout; @@ -113,46 +171,8 @@ bool ui_viewmgr::create_conformant(Evas_Object *win) return true; } -bool ui_viewmgr::create_base_layout(Evas_Object *conform) -{ - Evas_Object *layout = elm_layout_add(conform); - if (!layout) return false; - - //default transition layout - elm_layout_file_set(layout, EDJ_PATH, "transition/default"); - elm_object_content_set(conform, layout); - - //Push Finished Event - elm_layout_signal_callback_add(layout, "push,finished", "viewmgr", - [](void *data, Evas_Object *obj, const char *emission, const char *source) -> void - { - ui_viewmgr *viewmgr = static_cast(data); - ui_view *pview = viewmgr->get_view(viewmgr->get_view_count() - 2); - ui_view *view = viewmgr->get_last_view(); - if (pview) viewmgr->push_view_finished(pview); - if (view) viewmgr->push_view_finished(view); - }, - this); - - //Pop Finished Event - elm_layout_signal_callback_add(layout, "pop,finished", "viewmgr", - [](void *data, Evas_Object *obj, const char *emission, const char *source) -> void - { - ui_viewmgr *viewmgr = static_cast(data); - ui_view *pview = viewmgr->get_view(viewmgr->get_view_count() - 2); - ui_view *view = viewmgr->get_last_view(); - if (pview) viewmgr->pop_view_finished(pview); - if (view) viewmgr->pop_view_finished(view); - }, - this); - - this->layout = layout; - - return true; -} - ui_viewmgr::ui_viewmgr(const char *pkg, ui_key_listener *key_listener) - : ui_iface_viewmgr(), key_listener(key_listener), transition_style("") + : ui_iface_viewmgr(), key_listener(key_listener), transition_style("default") { if (!pkg) { @@ -194,7 +214,7 @@ ui_viewmgr::ui_viewmgr(const char *pkg, ui_key_listener *key_listener) return; } - if (!this->create_base_layout(this->conform)) + if (!this->create_base_layout(this->conform, "default")) { LOGE("Failed to create a base layout (%s)", pkg); return; diff --git a/src/lib/interface/ui_iface_view.cpp b/src/lib/interface/ui_iface_view.cpp index 39a3dad..f45a3c3 100644 --- a/src/lib/interface/ui_iface_view.cpp +++ b/src/lib/interface/ui_iface_view.cpp @@ -83,7 +83,7 @@ void ui_iface_view::destroy() } ui_iface_view::ui_iface_view(ui_iface_controller *controller, const char *name) - : content(NULL), controller(controller), name(string(name ? name : "")), transition_style(string("")), viewmgr(NULL), state(UI_VIEW_STATE_LOAD), + : content(NULL), controller(controller), name(string(name ? name : "")), transition_style(string("default")), viewmgr(NULL), state(UI_VIEW_STATE_LOAD), indicator(UI_VIEW_INDICATOR_DEFAULT), event_block(false), removable_content(true) { this->state = UI_VIEW_STATE_UNLOAD;