ui_viewmgr: refactoring code 49/61649/1
authorHermet Park <hermet@hermet.pe.kr>
Wed, 9 Mar 2016 10:28:50 +0000 (19:28 +0900)
committerHermet Park <hermet@hermet.pe.kr>
Wed, 9 Mar 2016 10:28:50 +0000 (19:28 +0900)
Change-Id: I2ec5d09da073f437a457bdcc7de4a079a5c8ec59

src/include/efl/ui_viewmgr.h
src/lib/efl/ui_viewmgr.cpp
src/lib/interface/ui_iface_viewmgr.cpp

index 61c7070fada88993623b6151068bc4217cb88ee8..9477f923e84e03fa1803f2dddc9bb520d404ee9a 100644 (file)
@@ -72,6 +72,8 @@ private:
         */
        bool set_indicator(ui_view_indicator indicator);
 
+       void active_top_view();
+
 protected:
        ui_viewmgr(const char *pkg, ui_key_listener *key_listener);
 
index b21172b3a42907c78837f0b63dc817be54c45ba7..a8e990231a1293a64af262751ece07da009f610b 100644 (file)
 using namespace efl_viewmgr;
 using namespace viewmgr;
 
+void ui_viewmgr::active_top_view()
+{
+       elm_object_part_content_unset(this->get_base(), "elm.swallow.content");
+
+       ui_view *view = dynamic_cast<ui_view *>(this->get_last_view());
+
+       //TODO: get parent?
+       Evas_Object *content = view->get_base();
+       if (content == this->get_base())
+       {
+               elm_object_part_content_set(this->get_base(), "elm.swallow.content", CONVERT_TO_EO(view->get_content()));
+       }
+       else
+       {
+               elm_object_part_content_set(this->get_base(), "elm.swallow.content", CONVERT_TO_EO(view->get_base()));
+       }
+
+       this->set_indicator(view->get_indicator());
+}
+
+//FIXME: How to deal with indicator in other UI framework? Dali? Volt?
+//Is it possible make this interface common?
 bool ui_viewmgr::set_indicator(ui_view_indicator indicator)
 {
        if (this->indicator == indicator) return false;
@@ -150,24 +172,12 @@ ui_viewmgr::~ui_viewmgr()
 
 bool ui_viewmgr::activate()
 {
-       ui_iface_viewmgr::activate();
+       if (!ui_iface_viewmgr::activate()) return false;
 
-       elm_object_part_content_unset(this->get_base(), "elm.swallow.content");
+       this->active_top_view();
 
+       //FIXME: Necessary??
        ui_view *view = dynamic_cast<ui_view *>(this->get_last_view());
-
-       //TODO: get parent?
-       Evas_Object *content = view->get_base();
-       if (content == this->get_base())
-       {
-               elm_object_part_content_set(this->get_base(), "elm.swallow.content", CONVERT_TO_EO(view->get_content()));
-       }
-       else
-       {
-               elm_object_part_content_set(this->get_base(), "elm.swallow.content", CONVERT_TO_EO(view->get_base()));
-       }
-
-       this->set_indicator(view->get_indicator());
        view->active();
 
        evas_object_show(this->win);
@@ -222,23 +232,7 @@ ui_view * ui_viewmgr::push_view(ui_view *view)
 {
        ui_iface_viewmgr::push_view(view);
 
-       //Don't prepare yet if viewmgr is not activated.
-       if (!this->is_activated()) return view;
-
-       elm_object_part_content_unset(this->get_base(), "elm.swallow.content");
-
-       Evas_Object *content = view->get_base();
-
-       if (content == this->get_base())
-       {
-               elm_object_part_content_set(this->get_base(), "elm.swallow.content", CONVERT_TO_EO(view->get_content()));
-       }
-       else
-       {
-               elm_object_part_content_set(this->get_base(), "elm.swallow.content", CONVERT_TO_EO(view->get_base()));
-       }
-
-       this->set_indicator(view->get_indicator());
+       this->active_top_view();
 
        return view;
 }
index d2cb2b08e5997c9dff3cd742174fc81e8e7f1296..164f987d2326675f82404641040721318488063f 100644 (file)
@@ -256,6 +256,7 @@ ui_iface_viewmgr::get_last_view()
 bool ui_iface_viewmgr::activate()
 {
        if (this->activated) return false;
+       if (this->get_view_count() == 0) return false;
        this->activated = true;
        return true;
 }