Refactoring examples, page 9,10,11,12,13 85/63785/1
authorWoochan Lee <wc0917.lee@samsung.com>
Sat, 26 Mar 2016 11:08:35 +0000 (20:08 +0900)
committerWoochan Lee <wc0917.lee@samsung.com>
Sat, 26 Mar 2016 11:09:06 +0000 (20:09 +0900)
Change-Id: I7cbbe690c3e78216b4f434f41eeb6bd7b543c268

src/examples/efl/page10.h
src/examples/efl/page11.h
src/examples/efl/page12.h
src/examples/efl/page13.h
src/examples/efl/page9.h

index edcef26..e3be5ed 100644 (file)
  *  limitations under the License.
  *
  */
-class page10: public ui_controller
+
+/** This page inherit ui_view.
+ *  And implement on_portait(), on_landscape() method to create portarit, landscape content.
+ *  This page will be created suitable content in on_portrait(), on_landscape() method.
+ */
+class page10: public ui_view
 {
 private:
        appdata_s *ad;
 
-public:
-       page10(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, "page10"));
-       }
-
-       ~page10()
-       {
-       }
-
+protected:
        void on_load()
        {
-               //Initialize contents.
-               ui_view *view = dynamic_cast<ui_view *>(this->get_view());
-
                //FIXME: Change below code to more convenient and clear way.
-               if (view->get_degree() == 90 || view->get_degree() == 270)
+               if (this->get_degree() == 90 || this->get_degree() == 270)
                        this->on_landscape();
                else
                        this->on_portrait();
@@ -46,29 +36,27 @@ public:
 
        void on_portrait()
        {
-               ui_view *view = dynamic_cast<ui_view *>(this->get_view());
-               Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 10<br>(Portrait + Landscape)",
-                                                               //Prev Button Callback
-                                                       [](void *data, Evas_Object *obj, void *event_info) -> void
-                                                       {
-                                                               appdata_s *ad = static_cast<appdata_s *>(data);
-                                                               ad->viewmgr->pop_view();
-                                                       },
-                                                       //Next Button Callback
-                                                       [](void *data, Evas_Object *obj, void *event_info) -> void
-                                                       {
-                                                               appdata_s *ad = static_cast<appdata_s *>(data);
-                                                               create_page11(ad);
-                                                       },
-                                                       this->ad);
-               view->set_content(content, "Title");
-               view->set_indicator(UI_VIEW_INDICATOR_DEFAULT);
+               Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 10<br>(Portrait + Landscape)",
+                       //Prev Button Callback
+                       [](void *data, Evas_Object *obj, void *event_info) -> void
+                       {
+                       appdata_s *ad = static_cast<appdata_s *>(data);
+                       ad->viewmgr->pop_view();
+                       },
+                       //Next Button Callback
+                       [](void *data, Evas_Object *obj, void *event_info) -> void
+                       {
+                       appdata_s *ad = static_cast<appdata_s *>(data);
+                       create_page11(ad);
+                       },
+                       this->ad);
+               this->set_content(content, "Title");
+               this->set_indicator(UI_VIEW_INDICATOR_DEFAULT);
        }
 
        void on_landscape()
        {
-               ui_view *view = dynamic_cast<ui_view *>(this->get_view());
-               Evas_Object *content = create_landscape_content(view->get_base(), "ViewMgr Demo<br>Page 10<br>(Portrait + Landscape)",
+               Evas_Object *content = create_landscape_content(this->get_base(), "ViewMgr Demo<br>Page 10<br>(Portrait + Landscape)",
                                //Prev Button Callback
                        [](void *data, Evas_Object *obj, void *event_info) -> void
                        {
@@ -82,10 +70,19 @@ public:
                                create_page11(ad);
                        },
                        this->ad);
-               view->set_content(content, "Title");
-               view->set_indicator(UI_VIEW_INDICATOR_OPTIMAL);
+               this->set_content(content, "Title");
+               this->set_indicator(UI_VIEW_INDICATOR_OPTIMAL);
        }
 
+public:
+       page10(appdata_s *ad) : ui_view("page10"), ad(ad)
+       {
+               ad->viewmgr->push_view(this);
+       }
+
+       ~page10()
+       {
+       }
 };
 
 void create_page10(appdata_s *ad)
index ff0dd57..9a5ed79 100644 (file)
  *
  */
 
-class page11: public ui_view
+/** This page inherit ui_controller
+ *  And implement on_rotate() method to create portarit, landscape content.
+ *  This page will be created suitable content in on_rotate() method.
+ */
+class page11: public ui_controller
 {
 private:
        appdata_s *ad;
 
-protected:
+public:
+       page11(appdata_s *ad)
+                       : ad(ad)
+       {
+               ad->viewmgr->push_view(new ui_view(this, "page11"));
+       }
+
+       ~page11()
+       {
+       }
+
        void on_load()
        {
-               this->on_rotate(this->get_degree());
+               ui_view *view = dynamic_cast<ui_view *>(this->get_view());
+
+               this->on_rotate(view->get_degree());
        }
 
        void on_rotate(int degree)
        {
+               ui_view *view = dynamic_cast<ui_view *>(this->get_view());
+
                //Portrait
-               if (this->get_degree() == 0 || this->get_degree() == 180)
+               if (view->get_degree() == 0 || view->get_degree() == 180)
                {
-                       Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 11<br>(Rotate)",
+                       Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 11<br>(Rotate)",
                                        //Prev Button Callback
                                [](void *data, Evas_Object *obj, void *event_info) -> void
                                {
@@ -45,13 +63,13 @@ protected:
                                        create_page12(ad);
                                },
                                this->ad);
-                       this->set_content(content, "Title");
-                       this->set_indicator(UI_VIEW_INDICATOR_DEFAULT);
+                       view->set_content(content, "Title");
+                       view->set_indicator(UI_VIEW_INDICATOR_DEFAULT);
                }
                //Landscape
                else
                {
-                       Evas_Object *content = create_landscape_content(this->get_base(), "ViewMgr Demo<br>Page 11<br>(Rotate)",
+                       Evas_Object *content = create_landscape_content(view->get_base(), "ViewMgr Demo<br>Page 11<br>(Rotate)",
                                        //Prev Button Callback
                                [](void *data, Evas_Object *obj, void *event_info) -> void
                                {
@@ -65,25 +83,14 @@ protected:
                                        create_page12(ad);
                                },
                                this->ad);
-                       this->set_content(content, "Title");
-                       this->set_indicator(UI_VIEW_INDICATOR_OPTIMAL);
+                       view->set_content(content, "Title");
+                       view->set_indicator(UI_VIEW_INDICATOR_OPTIMAL);
                }
        }
 
-public:
-       page11(const char *name, appdata_s *ad)
-               : ui_view(name), ad(ad)
-       {
-               ad->viewmgr->push_view(this);
-       }
-
-       ~page11()
-       {
-       }
 };
 
 void create_page11(appdata_s *ad)
 {
-       /* A example for view class extension instead of using controller class. */
-       new page11("page11", ad);
+       new page11(ad);
 }
index 4708084..2f8fff3 100644 (file)
  *
  */
 
+
+/** This page inherit ui_controller
+ *  And implement on_menu() method to create ctxpopup when menu HW key clicked.
+ *  This page will be created menu(ctxpopup)items in on_menu() method.
+ */
 static void ctxpopup_item_select_cb(void *data, Evas_Object *obj, void *event_info)
 {
        ui_view *view = static_cast<ui_view *>(data);
@@ -83,6 +88,5 @@ public:
 
 void create_page12(appdata_s *ad)
 {
-       /* A example for view class extension instead of using controller class. */
        new page12(ad);
 }
index e61abc6..f2e387d 100644 (file)
  *
  */
 
+/** This page inherit ui_ui_view
+ *  And make a button on right top side of title area to activate popup.
+ *  The created popup has view and it will be managed by viewmgr.
+ */
 class page13: public ui_view
 {
 private:
index 530591f..ae9e4c3 100644 (file)
  *  limitations under the License.
  *
  */
-class page9: public ui_view
+
+/** This page inherit ui_controller to show view create in controller side.
+ *  And this page create content in controller constructor time.
+ */
+class page9: public ui_controller
 {
 private:
        appdata_s *ad;
 
 public:
-       page9(const char *name, appdata_s *ad)
-               : ui_view(name), ad(ad)
+       page9(appdata_s *ad)
+                       : ad(ad)
        {
+               ui_view *view = new ui_view(this, "page9");
+
                //FIXME: It will be deleted or change to other way :(
                //       We don't have any way to support it now.
-               this->set_viewmgr(ad->viewmgr);
+               view->set_viewmgr(ad->viewmgr);
 
                //Create a main content.
-               Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 9<br>(Content Preloading)",
+               Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 9<br>(Content Preloading)",
                        //Prev Button Callback
                        [](void *data, Evas_Object *obj, void *event_info) -> void
                        {
@@ -44,11 +50,10 @@ public:
                        this->ad);
 
                //Don't delete view's content when this view poped.
-               this->set_removable_content(false);
-               this->set_content(content, "Title");
-               ad->viewmgr->push_view(this);
+               view->set_removable_content(false);
+               view->set_content(content, "Title");
+               ad->viewmgr->push_view(view);
        }
-
        ~page9()
        {
        }
@@ -56,6 +61,5 @@ public:
 
 void create_page9(appdata_s *ad)
 {
-       /* A example for view class extension instead of using controller class. */
-       new page9("page9", ad);
+       new page9(ad);
 }