From: Hermet Park Date: Thu, 18 Feb 2016 16:48:01 +0000 (+0900) Subject: support view indicator mode. X-Git-Tag: submit/tizen/20160617.075742~137 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4e9071c910d271f7d331cb1f74aeb652d77554cf;p=platform%2Fcore%2Fuifw%2Fui-viewmgr.git support view indicator mode. Change-Id: Ic64dd80103f9b3ca2d19b86a435251b46749f3e2 --- diff --git a/src/efl/ui_view.cpp b/src/efl/ui_view.cpp index 635e9fd..11b64fd 100644 --- a/src/efl/ui_view.cpp +++ b/src/efl/ui_view.cpp @@ -64,3 +64,18 @@ Evas_Object *ui_view ::get_parent() ui_viewmgr *viewmgr = dynamic_cast(this->get_viewmgr()); return viewmgr->get_base(); } + +void ui_view::set_indicator(ui_view_indicator indicator) +{ + if (this->get_indicator() == indicator) return; + + ui_view_base::set_indicator(indicator); + + ui_viewmgr *viewmgr = dynamic_cast(this->get_viewmgr()); + + if (!viewmgr->is_activated()) return; + + if (dynamic_cast(viewmgr->get_last_view()) != this) return; + + viewmgr->set_indicator(indicator); +} diff --git a/src/efl/ui_view.h b/src/efl/ui_view.h index 3a7c6ee..b3d87b4 100644 --- a/src/efl/ui_view.h +++ b/src/efl/ui_view.h @@ -36,6 +36,8 @@ public: virtual Evas_Object *set_content(Evas_Object *content); virtual Evas_Object *get_base(); + void set_indicator(ui_view_indicator indicator); + protected: virtual void load(); virtual void unload(); diff --git a/src/efl/ui_viewmgr.cpp b/src/efl/ui_viewmgr.cpp index e85f4fb..16598d9 100644 --- a/src/efl/ui_viewmgr.cpp +++ b/src/efl/ui_viewmgr.cpp @@ -18,15 +18,39 @@ using namespace efl; -void -win_delete_request_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +bool ui_viewmgr::set_indicator(ui_view_indicator indicator) { - ui_viewmgr *viewmgr = static_cast(data); - delete(viewmgr); + if (this->indicator == indicator) return false; + this->indicator = indicator; + + Evas_Object *window = this->get_window(); + Evas_Object *conform = this->get_conformant(); + + switch (indicator) + { + case UI_VIEW_INDICATOR_DEFAULT: + elm_win_indicator_opacity_set(window, ELM_WIN_INDICATOR_OPAQUE); + elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW); + /* Unset if you set the Indicator BG */ + evas_object_del(elm_object_part_content_get(conform, "elm.swallow.indicator_bg")); + elm_object_signal_emit(conform, "elm,state,indicator,nooverlap", "elm"); + break; + case UI_VIEW_INDICATOR_OPTIMAL: + elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW); + elm_win_indicator_opacity_set(window, ELM_WIN_INDICATOR_TRANSPARENT); + break; + case UI_VIEW_INDICATOR_OVERLAP: + elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW); + elm_object_signal_emit(conform, "elm,state,indicator,overlap", "elm"); + break; + default: + elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_HIDE); + break; + } + return true; } -bool -ui_viewmgr::create_conformant(Evas_Object *win) +bool ui_viewmgr::create_conformant(Evas_Object *win) { Evas_Object *conform = elm_conformant_add(win); if (!conform) return false; @@ -41,8 +65,7 @@ ui_viewmgr::create_conformant(Evas_Object *win) return true; } -bool -ui_viewmgr::create_base_layout(Evas_Object *conform) +bool ui_viewmgr::create_base_layout(Evas_Object *conform) { Evas_Object *layout = elm_layout_add(conform); if (!layout) return false; @@ -86,7 +109,6 @@ ui_viewmgr::ui_viewmgr(const char *pkg) { ui_viewmgr *viewmgr = static_cast(data); delete(viewmgr); - //FIXME: Window is destroyed. Terminate Application! //ui_app_exit(); }, @@ -108,6 +130,7 @@ ui_viewmgr::ui_viewmgr(const char *pkg) //Set Indicator properties elm_win_indicator_mode_set(this->win, ELM_WIN_INDICATOR_SHOW); elm_win_indicator_opacity_set(this->win, ELM_WIN_INDICATOR_OPAQUE); + elm_win_autodel_set(this->win, EINA_TRUE); } @@ -117,7 +140,7 @@ ui_viewmgr::~ui_viewmgr() bool ui_viewmgr::activate() { - ui_viewmgr_base :: activate(); + ui_viewmgr_base::activate(); elm_object_part_content_unset(this->get_base(), "elm.swallow.content"); @@ -134,6 +157,8 @@ bool ui_viewmgr::activate() elm_object_part_content_set(this->get_base(), "elm.swallow.content", CONVERT_TO_EO(view->get_base())); } + this->set_indicator(view->get_indicator()); + evas_object_show(this->win); return true; @@ -141,7 +166,7 @@ bool ui_viewmgr::activate() bool ui_viewmgr::deactivate() { - ui_viewmgr_base ::deactivate(); + ui_viewmgr_base::deactivate(); //FIXME: based on the profile, we should app to go behind or terminate. if (true) @@ -177,6 +202,8 @@ bool ui_viewmgr::pop_view() elm_object_part_content_set(this->get_base(), "elm.swallow.content", CONVERT_TO_EO(view->get_base())); } + this->set_indicator(view->get_indicator()); + return true; } @@ -198,9 +225,10 @@ ui_viewmgr::push_view(ui_view *view) } else { - LOGE("view->base = %p", view->get_base()); elm_object_part_content_set(this->get_base(), "elm.swallow.content", CONVERT_TO_EO(view->get_base())); } + this->set_indicator(view->get_indicator()); + return view; } diff --git a/src/efl/ui_viewmgr.h b/src/efl/ui_viewmgr.h index 06aa65b..5da92e8 100644 --- a/src/efl/ui_viewmgr.h +++ b/src/efl/ui_viewmgr.h @@ -33,9 +33,11 @@ private: Evas_Object *win; Evas_Object *conform; Evas_Object *layout; + ui_view_indicator indicator; bool create_conformant(Evas_Object *win); bool create_base_layout(Evas_Object *conform); + bool set_indicator(ui_view_indicator indicator); protected: Evas_Object *get_base() diff --git a/src/interface/ui_view_base.cpp b/src/interface/ui_view_base.cpp index c5a8df4..f708ec9 100644 --- a/src/interface/ui_view_base.cpp +++ b/src/interface/ui_view_base.cpp @@ -82,7 +82,7 @@ void ui_view_base::destroy() ui_view_base::ui_view_base(T content, ui_controller_base *controller, const char *name) : content(content), controller(controller), name(string(name ? name : "")), style(string("")), viewmgr(NULL), state(UI_VIEW_STATE_LOAD), - event_block(false), removable_content(true) + indicator(UI_VIEW_INDICATOR_DEFAULT), event_block(false), removable_content(true) { if (!content) this->state = UI_VIEW_STATE_UNLOAD; else this->state = UI_VIEW_STATE_LOAD; @@ -135,3 +135,8 @@ void ui_view_base::set_removable_content(bool removable) //FIXME: If this api is called on unload state? should we remove content right now? } + +void ui_view_base::set_indicator(ui_view_indicator indicator) +{ + this->indicator = indicator; +} diff --git a/src/interface/ui_view_base.h b/src/interface/ui_view_base.h index 8c9abfd..08caea0 100644 --- a/src/interface/ui_view_base.h +++ b/src/interface/ui_view_base.h @@ -62,6 +62,7 @@ private: std::string style; ///< View style name. ui_viewmgr_base *viewmgr; ///< Viewmgr which this view belongs to. ui_view_state state; ///< View state + ui_view_indicator indicator; ///< View indicator mode bool event_block; ///< State of event block. bool removable_content; ///< When this value is true, view removes it's content internally on unload state. @@ -215,28 +216,41 @@ public: */ void set_removable_content(bool removable); + void set_indicator(ui_view_indicator indicator); + /// Return a style name of this view. const char *get_style() { return this->style.c_str(); } - /// Return a content instance of this view. + const char *get_name() + { + return this->name.c_str(); + } + + /// Return the content instance of this view. T get_content() { return this->content; } - /// Return a state of this view. + /// Return the state of this view. ui_view_state get_state() { return this->state; } - /// Return a state of removeable content. + /// Return the state of removeable content. bool get_removable_content() { return this->removable_content; } + + /// Return the indicator mode of this view. + ui_view_indicator get_indicator() + { + return this->indicator; + } }; #endif /* UI_VIEW_BASE_H_ */ diff --git a/src/interface/ui_viewmgr.h b/src/interface/ui_viewmgr.h index 512525f..cc56ba2 100644 --- a/src/interface/ui_viewmgr.h +++ b/src/interface/ui_viewmgr.h @@ -14,6 +14,9 @@ * limitations under the License. * */ +#ifndef UI_VIEWMGR_H_ +#define UI_VIEWMGR_H_ + #include #include @@ -22,6 +25,18 @@ #endif #define LOG_TAG "VIEWMGR" +enum ui_view_indicator +{ + UI_VIEW_INDICATOR_DEFAULT = 0, + UI_VIEW_INDICATOR_OPTIMAL, + UI_VIEW_INDICATOR_OVERLAP, + UI_VIEW_INDICATOR_HIDE, + UI_VIEW_INDICATOR_LAST +}; + #include "ui_viewmgr_base.h" #include "ui_view_base.h" #include "ui_controller_base.h" + + +#endif /* UI_VIEWMGR_H */ diff --git a/src/page1_controller.h b/src/page1_controller.h index 031eed6..b34d122 100644 --- a/src/page1_controller.h +++ b/src/page1_controller.h @@ -23,6 +23,8 @@ public: page1_controller(appdata_s *ad) : ad(ad) { + /* ui_basic_view(controller, identity name). + Later, you could get the identity name using view->get_name(); */ ad->viewmgr->push_view(new ui_basic_view(this, "page1")); } ~page1_controller() @@ -33,23 +35,23 @@ public: { //Initialize contents. - ui_basic_view *view = dynamic_cast(ui_controller::get_view()); + ui_basic_view *view = dynamic_cast(this->get_view()); //Create a main content. Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo
Page 1", - //Prev Button - [](void *data, Evas_Object *obj, void *event_info) -> void - { - appdata_s *ad = static_cast(data); - ad->viewmgr->deactivate(); - }, - //Next Button - [](void *data, Evas_Object *obj, void *event_info) -> void - { - appdata_s *ad = static_cast(data); - page2(ad); - }, - this->ad); + //Prev Button Callback + [](void *data, Evas_Object *obj, void *event_info) -> void + { + appdata_s *ad = static_cast(data); + ad->viewmgr->deactivate(); + }, + //Next Button Callback + [](void *data, Evas_Object *obj, void *event_info) -> void + { + appdata_s *ad = static_cast(data); + page2(ad); + }, + this->ad); view->set_content(content, "Title"); } diff --git a/src/page2_controller.h b/src/page2_controller.h index 06e3f94..5e71b8d 100644 --- a/src/page2_controller.h +++ b/src/page2_controller.h @@ -23,8 +23,11 @@ public: page2_controller(appdata_s *ad) : ad(ad) { + /* ui_basic_view(controller, identity name). + Later, you could get the identity name using view->get_name(); */ ad->viewmgr->push_view(new ui_basic_view(this, "page2")); } + ~page2_controller() { } @@ -32,18 +35,17 @@ public: void load() { //Initialize contents. - - ui_basic_view *view = dynamic_cast(ui_controller::get_view()); + ui_basic_view *view = dynamic_cast(this->get_view()); //Create a main content. Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo
Page 2", - //Prev Button + //Prev Button Callback [](void *data, Evas_Object *obj, void *event_info) -> void { appdata_s *ad = static_cast(data); ad->viewmgr->pop_view(); }, - //Next Button + //Next Button Callback [](void *data, Evas_Object *obj, void *event_info) -> void { appdata_s *ad = static_cast(data); diff --git a/src/page3_controller.h b/src/page3_controller.h index 2d1dd0f..67a6070 100644 --- a/src/page3_controller.h +++ b/src/page3_controller.h @@ -23,6 +23,8 @@ public: page3_controller(appdata_s *ad) : ad(ad) { + /* ui_basic_view(controller, identity name). + Later, you could get the identity name using view->get_name(); */ ad->viewmgr->push_view(new ui_basic_view(this, "page3")); } @@ -38,19 +40,19 @@ public: //Create a main content. Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo
Page 3", - //Prev Button - [](void *data, Evas_Object *obj, void *event_info) -> void - { - appdata_s *ad = static_cast(data); - ad->viewmgr->pop_view(); - }, - //Next Button - [](void *data, Evas_Object *obj, void *event_info) -> void - { - appdata_s *ad = static_cast(data); - page4(ad); - }, - this->ad); + //Prev Button Callback + [](void *data, Evas_Object *obj, void *event_info) -> void + { + appdata_s *ad = static_cast(data); + ad->viewmgr->pop_view(); + }, + //Next Button Callback + [](void *data, Evas_Object *obj, void *event_info) -> void + { + appdata_s *ad = static_cast(data); + page4(ad); + }, + this->ad); //Arguments: content, title, subtitle, title left button, title right button view->set_content(content, "Title", "Subtitle", NULL, NULL); diff --git a/src/page4_controller.h b/src/page4_controller.h index 434b394..6e97a38 100644 --- a/src/page4_controller.h +++ b/src/page4_controller.h @@ -23,6 +23,8 @@ public: page4_controller(appdata_s *ad) : ad(ad) { + /* ui_basic_view(controller, identity name). + Later, you could get the identity name using view->get_name(); */ ad->viewmgr->push_view(new ui_basic_view(this, "page4")); } @@ -38,18 +40,19 @@ public: //Create a main content. Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo
Page 4", - //Prev Button - [](void *data, Evas_Object *obj, void *event_info) -> void - { - appdata_s *ad = static_cast(data); - ad->viewmgr->pop_view(); - }, - //Next Button - [](void *data, Evas_Object *obj, void *event_info) -> void - { - appdata_s *ad = static_cast(data); - page5(ad); - }, this->ad); + //Prev Button Callback + [](void *data, Evas_Object *obj, void *event_info) -> void + { + appdata_s *ad = static_cast(data); + ad->viewmgr->pop_view(); + }, + //Next Button Callback + [](void *data, Evas_Object *obj, void *event_info) -> void + { + appdata_s *ad = static_cast(data); + page5(ad); + }, + this->ad); //Arguments: content, title view->set_content(content, "TitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitle"); diff --git a/src/page5_controller.h b/src/page5_controller.h index a12ec14..744de44 100644 --- a/src/page5_controller.h +++ b/src/page5_controller.h @@ -24,7 +24,9 @@ public: : ad(ad) { //No basic form. - ad->viewmgr->push_view(new ui_view(this, "page5")); + /* ui_view(controller, identity name). + Later, you could get the identity name using view->get_name(); */ + ui_view *view = ad->viewmgr->push_view(new ui_view(this, "page5")); } ~page5_controller() @@ -38,21 +40,23 @@ public: ui_view *view = dynamic_cast(this->get_view()); //Create a main content. - Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo
Page 5
(No Title View)", - //Prev Button - [](void *data, Evas_Object *obj, void *event_info) -> void - { - appdata_s *ad = static_cast(data); - ad->viewmgr->pop_view(); - }, - //Next Button - [](void *data, Evas_Object *obj, void *event_info) -> void - { - appdata_s *ad = static_cast(data); - ad->viewmgr->deactivate(); - }, this->ad); + Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo
Page 5
(Full View)", + //Prev Button Callback + [](void *data, Evas_Object *obj, void *event_info) -> void + { + appdata_s *ad = static_cast(data); + ad->viewmgr->pop_view(); + }, + //Next Button Callback + [](void *data, Evas_Object *obj, void *event_info) -> void + { + appdata_s *ad = static_cast(data); + ad->viewmgr->deactivate(); + }, + this->ad); view->set_content(content); + view->set_indicator(UI_VIEW_INDICATOR_HIDE); } };