Refactoring examples, page 5,6,7,8 79/63779/4
authorWoochan Lee <wc0917.lee@samsung.com>
Sat, 26 Mar 2016 09:25:58 +0000 (18:25 +0900)
committerHermet Park <chuneon.park@samsung.com>
Sat, 26 Mar 2016 09:41:16 +0000 (02:41 -0700)
replace inheritance origin from ui_controller to ui_view.

Change-Id: Ib0a81606ae6d594872710ffa20a1a705400fb4fa

src/examples/efl/page5.h
src/examples/efl/page6.h
src/examples/efl/page7.h
src/examples/efl/page8.h

index 1527986..c30a8e5 100644 (file)
  *  limitations under the License.
  *
  */
-class page5: public ui_controller
+
+/** This page inherit ui_base_view to show how to create full view.
+ *  And set indicator state as hide.
+ */
+class page5: public ui_base_view
 {
 private:
        appdata_s *ad;
 
-public:
-       page5(appdata_s *ad)
-                       : ad(ad)
-       {
-               //No basic form.
-               /* ui_view(controller, identity name).
-                  Later, you could get the identity name using view->get_name(); */
-               ad->viewmgr->push_view(new ui_base_view(this, "page5"));
-       }
-
-       ~page5()
-       {
-       }
-
+protected:
        void on_load()
        {
-               //Initialize contents.
-
-               ui_base_view *view = dynamic_cast<ui_base_view *>(this->get_view());
-
                //Create a main content.
-               Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 5<br>(Full View)",
+               Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 5<br>(Full View)",
                                //Prev Button Callback
                                [](void *data, Evas_Object *obj, void *event_info) -> void
                                {
@@ -55,8 +42,18 @@ public:
                                },
                                this->ad);
 
-               view->set_content(content);
-               view->set_indicator(UI_VIEW_INDICATOR_HIDE);
+               this->set_content(content);
+               this->set_indicator(UI_VIEW_INDICATOR_HIDE);
+       }
+
+public:
+       page5(appdata_s *ad) : ui_base_view("page5"), ad(ad)
+       {
+               ad->viewmgr->push_view(this);
+       }
+
+       ~page5()
+       {
        }
 };
 
index 9d93864..a7faccd 100644 (file)
  *  limitations under the License.
  *
  */
-class page6: public ui_controller
+
+/** This page inherit ui_view to show title with toolbar sample.
+ */
+class page6: public ui_view
 {
 private:
        appdata_s *ad;
 
-public:
-       page6(appdata_s *ad)
-               : ad(ad)
-       {
-               /* ui_view(controller, identity name).
-                  Later, you could get the identity name using view->get_name(); */
-               ad->viewmgr->push_view(new ui_view(this, "page6"));
-       }
-
-       ~page6()
-       {
-       }
-
+protected:
        void on_load()
        {
-
-               //Initialize contents.
-
-               ui_view *view = dynamic_cast<ui_view *>(this->get_view());
-
                //Create a main content.
-               Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 6",
+               Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 6",
                                //Prev Button Callback
                                [](void *data, Evas_Object *obj, void *event_info) -> void
                                {
@@ -56,13 +42,24 @@ public:
                                this->ad);
 
                //Arguments: content, title
-               view->set_content(content, "Title with toolbar");
-               Elm_Toolbar *toolbar = create_toolbar(view->get_base(), "toolbar_with_title");
-               view->set_toolbar(toolbar);
+               this->set_content(content, "Title with toolbar");
+               Elm_Toolbar *toolbar = create_toolbar(this->get_base(), "toolbar_with_title");
+               this->set_toolbar(toolbar);
+       }
+
+public:
+       page6(appdata_s *ad) : ui_view("page6"), ad(ad)
+       {
+               ad->viewmgr->push_view(this);
+       }
+
+       ~page6()
+       {
        }
 };
 
 void create_page6(appdata_s *ad)
 {
+       /* A example for view class extension instead of using controller class. */
        new page6(ad);
 }
index 6012dfa..bdf013e 100644 (file)
  *  limitations under the License.
  *
  */
-class page7: public ui_controller
+
+/** This page inherit ui_view to show title with toolbar sample.
+ *  And this page make a content in page constructor time.
+ */
+class page7: public ui_view
 {
 private:
        appdata_s *ad;
 
 public:
-       page7(appdata_s *ad)
-               : ad(ad)
+       page7(appdata_s *ad) : ui_view("page7"), ad(ad)
        {
-               /* ui_view(controller, identity name, style name of view).
-                  Later, you could get the identity name using view->get_name();
-                  you could get the style name of view as well */
-               ui_view *view = new ui_view(this, "page7");
-
                //FIXME: It will be deleted or change to other way :(
                //       We don't have any way to support it now.
-               view->set_viewmgr(ad->viewmgr);
+               this->set_viewmgr(ad->viewmgr);
 
                //Create a main content.
-               Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 7<br>(Navigationbar style)",
+               Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 7<br>(Navigationbar style)",
                                //Prev Button Callback
                                [](void *data, Evas_Object *obj, void *event_info) -> void
                                {
@@ -49,11 +47,11 @@ public:
                                this->ad);
 
                //Don't delete view's content when this view poped.
-               view->set_removable_content(false);
-               view->set_content(content, "Title with toolbar");
-               Elm_Toolbar *toolbar = create_toolbar(view->get_base(), "navigationbar");
-               view->set_toolbar(toolbar);
-               ad->viewmgr->push_view(view);
+               this->set_removable_content(false);
+               this->set_content(content, "Title with toolbar");
+               Elm_Toolbar *toolbar = create_toolbar(this->get_base(), "navigationbar");
+               this->set_toolbar(toolbar);
+               ad->viewmgr->push_view(this);
        }
 
        ~page7()
index 5ca8d55..37e1d77 100644 (file)
  *
  */
 
-class page8: public ui_view
+/** This page inherit ui_controller to show view create in controller side.
+ */
+class page8: public ui_controller
 {
 private:
        appdata_s *ad;
 
-protected:
+public:
+       page8(appdata_s *ad)
+                       : ad(ad)
+       {
+               /* ui_view(controller, identity name).
+                  Later, you could get the identity name using view->get_name(); */
+               ad->viewmgr->push_view(new ui_view(this, "page8"));
+       }
+       ~page8()
+       {
+       }
+
        void on_load()
        {
+               //Initialize contents.
+               ui_view *view = dynamic_cast<ui_view *>(this->get_view());
+
                //Create a main content.
-               Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 8<br>(View inheritance)",
+               Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 8",
                                //Prev Button Callback
                                [](void *data, Evas_Object *obj, void *event_info) -> void
                                {
@@ -39,23 +55,11 @@ protected:
                                },
                                this->ad);
 
-               this->set_content(content, "Title");
-       }
-
-public:
-       page8(const char *name, appdata_s *ad)
-               : ui_view(name), ad(ad)
-       {
-               ad->viewmgr->push_view(this);
-       }
-
-       ~page8()
-       {
+               view->set_content(content, "Title");
        }
 };
 
 void create_page8(appdata_s *ad)
 {
-       /* A example for view class extension instead of using controller class. */
-       new page8("page8", ad);
+       new page8(ad);
 }