updated implementation. 85/59785/1
authorHermet Park <hermet@hermet.pe.kr>
Thu, 18 Feb 2016 11:36:51 +0000 (20:36 +0900)
committerHermet Park <hermet@hermet.pe.kr>
Thu, 18 Feb 2016 11:36:51 +0000 (20:36 +0900)
Change-Id: I617363138a9c191f0365e49397ab0679c4df7b72

13 files changed:
src/efl/mobile/ui_basic_view.cpp
src/efl/mobile/ui_basic_view.h
src/efl/ui_view.cpp
src/efl/ui_view.h
src/efl/ui_viewmgr.cpp
src/efl/ui_viewmgr.h
src/interface/ui_view_base.cpp
src/interface/ui_view_base.h
src/interface/ui_viewmgr_base.h
src/page1_controller.h
src/page2_controller.h
src/page3_controller.h
src/page4_controller.h

index 7187d5e..64b32d5 100644 (file)
@@ -5,21 +5,20 @@ using namespace efl;
 bool ui_basic_view::destroy_layout()
 {
        if (!this->layout) return false;
-       if (this->get_content())
-       {
-               elm_object_part_content_unset(this->layout, "elm.swallow.content");
-       }
        evas_object_del(this->layout);
+       this->layout = NULL;
 
        return true;
 }
 
 bool ui_basic_view::create_layout()
 {
+       if (this->layout) return false;
+
        ui_viewmgr *viewmgr = dynamic_cast<ui_viewmgr *>(ui_view_base::get_viewmgr());
-       Evas_Object *parent = viewmgr->get_window();
 
-       Evas_Object *layout = elm_layout_add(parent);
+       Evas_Object *layout = elm_layout_add(viewmgr->get_base());
+
        if (!layout)
        {
                LOGE("Failed to create a layout = ui_basic_view(%p)", this);
@@ -63,7 +62,6 @@ void ui_basic_view::load()
 
 void ui_basic_view::unload()
 {
-       this->destroy_layout();
        ui_view::unload();
 }
 
@@ -197,3 +195,8 @@ Evas_Object *ui_basic_view::set_content(Evas_Object *content, const char *title,
        return pcontent;
 }
 
+void ui_basic_view::unload_content()
+{
+       ui_view::set_content(NULL);
+       this->destroy_layout();
+}
index 85f55cb..9104886 100644 (file)
@@ -18,8 +18,9 @@ private:
        bool destroy_layout();
 
 protected:
-       void load();
-       void unload();
+       virtual void load();
+       virtual void unload();
+       virtual void unload_content();
 
 public:
        ui_basic_view(ui_controller *controller, const char *name = NULL);
index c319203..4f0dda0 100644 (file)
@@ -2,8 +2,8 @@
 
 using namespace efl;
 
-ui_view::ui_view(ui_controller *controller, const char *name) :
-               ui_view_base(controller, name)
+ui_view::ui_view(ui_controller *controller, const char *name)
+               ui_view_base(controller, name)
 {
 }
 
@@ -11,25 +11,34 @@ ui_view::~ui_view()
 {
 }
 
-Evas_Object *
-ui_view::set_content(Evas_Object *content)
+Evas_Object *ui_view::set_content(Evas_Object *content)
 {
        T pcontent = ui_view_base::set_content(CONVERT_TO_T(content));
        return static_cast<Evas_Object *>(pcontent);
 }
 
-Evas_Object *
-ui_view::get_base()
+Evas_Object *ui_view::get_base()
 {
        ui_viewmgr *viewmgr = dynamic_cast<ui_viewmgr *>(ui_view_base::get_viewmgr());
        if (!viewmgr)
        {
                return NULL;
        }
-       return viewmgr->get_base_layout();
+       return viewmgr->get_base();
 }
 
 void ui_view::load()
 {
        ui_view_base::load();
 }
+
+void ui_view::unload()
+{
+       ui_view_base::unload();
+}
+
+void ui_view::unload_content()
+{
+       Evas_Object *pcontent = this->set_content(NULL);
+       if (pcontent) evas_object_del(pcontent);
+}
index dfd825a..51ffd62 100644 (file)
@@ -22,6 +22,8 @@ public:
 
 protected:
        virtual void load();
+       virtual void unload();
+       virtual void unload_content();
 };
 
 }
index 998b8a6..8e0bc2d 100644 (file)
@@ -9,30 +9,34 @@ win_delete_request_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info
        delete(viewmgr);
 }
 
-Evas_Object *
+bool
 ui_viewmgr::create_conformant(Evas_Object *win)
 {
        Evas_Object *conform = elm_conformant_add(win);
-       if (!conform) return NULL;
+       if (!conform) return false;
 
        evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        elm_win_resize_object_add(win, conform);
        elm_win_conformant_set(win, EINA_TRUE);
        evas_object_show(conform);
 
-       return conform;
+       this->conform = conform;
+
+       return true;
 }
 
-Evas_Object *
+bool
 ui_viewmgr::create_base_layout(Evas_Object *conform)
 {
        Evas_Object *layout = elm_layout_add(conform);
-       if (!layout) return NULL;
+       if (!layout) return false;
 
        elm_layout_theme_set(layout, "layout", "application", "default");
        elm_object_content_set(conform, layout);
 
-       return layout;
+       this->layout = layout;
+
+       return true;
 }
 
 ui_viewmgr::ui_viewmgr(const char *pkg)
@@ -73,17 +77,13 @@ ui_viewmgr::ui_viewmgr(const char *pkg)
                        this);
 
        //Conformant: Make this configurable.
-       this->conform = this->create_conformant(this->win);
-
-       if (!this->conform)
+       if (!this->create_conformant(this->win))
        {
                LOGE("Failed to create a conformant (%s)", pkg);
                return;
        }
 
-       this->base_layout = this->create_base_layout(this->conform);
-
-       if (!this->base_layout)
+       if (!this->create_base_layout(this->conform))
        {
                LOGE("Failed to create a base layout (%s)", pkg);
                return;
@@ -103,19 +103,19 @@ bool ui_viewmgr::activate()
 {
        ui_viewmgr_base :: activate();
 
-       elm_object_part_content_unset(this->base_layout, "elm.swallow.content");
+       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->base_layout)
+       if (content == this->get_base())
        {
-               elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_content()));
+               elm_object_part_content_set(this->get_base(), "elm.swallow.content", CONVERT_TO_EO(view->get_content()));
        }
        else
        {
-               elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_base()));
+               elm_object_part_content_set(this->get_base(), "elm.swallow.content", CONVERT_TO_EO(view->get_base()));
        }
 
        evas_object_show(this->win);
@@ -152,13 +152,13 @@ bool ui_viewmgr::pop_view()
 
        //TODO: get parent?
        Evas_Object *content = view->get_base();
-       if (content == this->base_layout)
+       if (content == this->get_base())
        {
-               elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_content()));
+               elm_object_part_content_set(this->get_base(), "elm.swallow.content", CONVERT_TO_EO(view->get_content()));
        }
        else
        {
-               elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_base()));
+               elm_object_part_content_set(this->get_base(), "elm.swallow.content", CONVERT_TO_EO(view->get_base()));
        }
 
        return true;
@@ -172,18 +172,18 @@ ui_viewmgr::push_view(ui_view *view)
        //Don't prepare yet if viewmgr is not activated.
        if (!this->is_activated()) return view;
 
-       elm_object_part_content_unset(this->base_layout, "elm.swallow.content");
+       elm_object_part_content_unset(this->get_base(), "elm.swallow.content");
 
        Evas_Object *content = view->get_base();
 
-       if (content == this->base_layout)
+       if (content == this->get_base())
        {
-               elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_content()));
+               elm_object_part_content_set(this->get_base(), "elm.swallow.content", CONVERT_TO_EO(view->get_content()));
        }
        else
        {
                LOGE("view->base = %p", view->get_base());
-               elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_base()));
+               elm_object_part_content_set(this->get_base(), "elm.swallow.content", CONVERT_TO_EO(view->get_base()));
        }
 
        return view;
index bbb8258..c76a2ce 100644 (file)
@@ -14,10 +14,10 @@ class ui_viewmgr: public ui_viewmgr_base
 private:
        Evas_Object *win;
        Evas_Object *conform;
-       Evas_Object *base_layout;
+       Evas_Object *layout;
 
-       Evas_Object *create_conformant(Evas_Object *win);
-       Evas_Object *create_base_layout(Evas_Object *conform);
+       bool create_conformant(Evas_Object *win);
+       bool create_base_layout(Evas_Object *conform);
 
 public:
        ui_viewmgr(const char *pkg);
@@ -29,9 +29,9 @@ public:
        bool pop_view();
 
        //FIXME: Make this private
-       Evas_Object *get_base_layout()
+       Evas_Object *get_base()
        {
-               return this->base_layout;
+               return this->layout;
        }
 
        Evas_Object *get_window()
index 50a3357..4c6e4dd 100644 (file)
@@ -16,6 +16,11 @@ void ui_view_base::load()
 void ui_view_base::unload()
 {
        this->state = UI_VIEW_STATE_UNLOAD;
+       if (this->get_removable_content())
+       {
+               this->unload_content();
+               return;
+       }
        if (!this->content) return;
        if (!this->controller) return;
        this->controller->unload();
@@ -60,8 +65,8 @@ 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)
+               : content(content), controller(controller), name(string(name ? name : "")), style(string("")), viewmgr(NULL), state(UI_VIEW_STATE_LOAD),
+                 event_block(false), removable_content(true)
 {
        if (!content) this->state = UI_VIEW_STATE_UNLOAD;
        else this->state = UI_VIEW_STATE_LOAD;
@@ -86,8 +91,7 @@ ui_view_base::~ui_view_base()
        if (this->controller) delete (this->controller);
 }
 
-ui_controller_base*
-ui_view_base::set_controller(ui_controller_base *controller)
+ui_controller_base* ui_view_base::set_controller(ui_controller_base *controller)
 {
        ui_controller_base *prev_controller = this->controller;
        this->controller = controller;
@@ -108,3 +112,10 @@ bool ui_view_base::set_style(const char *style)
        this->style.assign(style);
        return true;
 }
+
+void ui_view_base::set_removable_content(bool removable)
+{
+       this->removable_content = removable;
+
+       //FIXME: If this api is called on unload state? should we remove content right now?
+}
index 2ca3545..5280e7d 100644 (file)
@@ -46,20 +46,15 @@ private:
        };
 
        T content;                              ///< A content instance for a screen as a view.
-       ui_controller_base *controller;         ///< view life-cycle controller interface.
-       std::string name;                       ///< view name
-       std::string style;                      ///< view style name.
-       ui_viewmgr_base *viewmgr;               ///< viewmgr which this view belongs to.
-       ui_view_state state;                    ///< view state
-       bool event_block;                       ///< state of event block.
-
-       //Need to check.
+       ui_controller_base *controller;         ///< View life-cycle controller interface.
+       std::string name;                       ///< View name
+       std::string style;                      ///< View style name.
+       ui_viewmgr_base *viewmgr;               ///< Viewmgr which this view belongs to.
+       ui_view_state state;                    ///< View state
+       bool event_block;                       ///< State of event block.
+       bool removable_content;                 ///< When this value is true, view removes it's content internally on unload state.
+
        friend class ui_viewmgr_base;
-       //friend bool ui_viewmgr_base ::_connect_view(ui_view_base *view);
-       //friend bool ui_viewmgr_base ::_disconnect_view(ui_view_base<T> *view);
-       //friend void ui_viewmgr_base ::_set_event_block(ui_view_base<T> *view);
-       //friend bool ui_viewmgr_base ::_push_view_finished(ui_view_base<T> *view);
-       //friend bool ui_viewmgr_base ::_pop_view_finished(ui_view_base<T> *view);
 
 protected:
 
@@ -129,6 +124,9 @@ protected:
         */
        virtual void destroy();
 
+
+       virtual void unload_content() = 0;
+
        /// Return the state of event block.
        bool get_event_block()
        {
@@ -145,8 +143,6 @@ public:
         *  @warning Be aware the deletion of controller passed here will be covered by ui_view_base.
         *           If you want to keep it for any reasons, please unset it using set_controller() before ui_view_base is deleted.
         */
-
-       //Constructor
        ui_view_base(T content, ui_controller_base *controller, const char *name);
        ///Constructor for initializing with controller.
        ui_view_base(ui_controller_base *controller, const char *name = NULL);
@@ -168,7 +164,7 @@ public:
 
        /** @brief This is for replacing or setting a content of the view.
         *
-        *  @note @c content is a logical object that represents a view in your framework. The actual type of the content could be translated to any certain types.
+        *  @note @p content is a logical object that represents a view in your framework. The actual type of the content could be translated to any certain types.
         *        For instance, the type could be Evas_Object * in EFL and Layer * in Dali.
         *
         *  @param content a new content. It allows @c NULL for canceling the previous content.
@@ -190,6 +186,15 @@ public:
         */
        virtual bool set_style(const char *style);
 
+       /** @brief set content removable
+        *
+        *  @param removable if @p removable is @c true, content of this view will be removed on unload state. @c false otherwise.
+        *
+        *  @warning You should not remove a view content manually on unload status if removable content is set.
+        *
+        */
+       void set_removable_content(bool removable);
+
        /// Return a controller of this view.
        const ui_controller_base* get_controller()
        {
@@ -215,6 +220,11 @@ public:
        {
                return this->state;
        }
+       /// Return a state of removeable content.
+       bool get_removable_content()
+       {
+               return this->removable_content;
+       }
 };
 
 #endif /* UI_VIEW_BASE_H_ */
index 25bd39d..1b3d676 100644 (file)
@@ -173,11 +173,11 @@ public:
         */
        ui_view_base *get_view(const char *name)
        {
-               //TODO: ...
+               //FIXME: ...
                return NULL;
        }
 
-       //TODO: Doc.
+       //FIXME: Doc.
        ui_view_base *get_last_view();
 
        /**
index 650a9ce..2cc33a0 100644 (file)
@@ -36,12 +36,4 @@ public:
 
                view->set_content(content, "Title");
        }
-
-       void unload()
-       {
-               //You could destroy the content here for save memory.
-               ui_view *view = this->get_view();
-               Evas_Object *content = view->set_content(NULL);
-               evas_object_del(content);
-       }
 };
index ee63057..64c2eac 100644 (file)
@@ -45,12 +45,4 @@ public:
                //Arguments: content, title, subtitle, icon, title left button, title right button
                view->set_content(content, "Title Buttons", NULL, NULL, left_title_btn, right_title_btn);
        }
-
-       void unload()
-       {
-               //You could destroy the content here for save memory.
-               ui_view *view = this->get_view();
-               Evas_Object *content = view->set_content(NULL);
-               evas_object_del(content);
-       }
 };
index 56d7631..3726c18 100644 (file)
@@ -38,12 +38,4 @@ public:
                //Arguments: content, title, subtitle, icon, title left button, title right button
                view->set_content(content, "Title", "Subtitle", NULL, NULL, NULL);
        }
-
-       void unload()
-       {
-               //You could destroy the content here for save memory.
-               ui_view *view = this->get_view();
-               Evas_Object *content = view->set_content(NULL);
-               evas_object_del(content);
-       }
 };
index b612583..268ec63 100644 (file)
@@ -39,13 +39,4 @@ public:
                view->set_content(content, "TitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitle");
                view->set_title_badge("999+");
        }
-
-       void unload()
-       {
-               //You could destroy the content here for save memory.
-               ui_view *view = this->get_view();
-               Evas_Object *content = view->set_content(NULL);
-               evas_object_del(content);
-       }
-
 };