refactoring page10, page11 52/63752/2
authorHermet Park <hermet@hermet.pe.kr>
Fri, 25 Mar 2016 13:04:22 +0000 (22:04 +0900)
committerHermet Park <hermet@hermet.pe.kr>
Fri, 25 Mar 2016 13:06:12 +0000 (22:06 +0900)
rewrite for clean & nice code

Change-Id: Ifd073bac2421c321d2ca197848b68599da72908d

src/examples/efl/page10.h
src/examples/efl/page11.h

index 844a9e9..fbf48f1 100644 (file)
@@ -32,56 +32,8 @@ public:
        {
        }
 
-       Evas_Object *create_page10_content(ui_view *view, bool is_portrait)
-       {
-               Evas_Object *content;
-
-               if (is_portrait)
-               {
-                       //Create portrait content.
-                       content = create_content(view->get_base(),
-                                       "ViewMgr Demo<br>Page 10 With<br>on_portrait(), on_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);
-               }
-               else
-               {
-                       //Create landscape content.
-                       content = create_landscape_content(view->get_base(),
-                                       "ViewMgr Demo<br>Page 10 With<br>on_portrait(), on_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);
-               }
-
-               return content;
-       }
-
        void on_load()
        {
-               Evas_Object *content;
-
                //Initialize contents.
                ui_view *view = dynamic_cast<ui_view *>(this->get_view());
 
@@ -94,21 +46,41 @@ public:
 
        void on_portrait()
        {
-               Evas_Object *content;
-
                ui_view *view = dynamic_cast<ui_view *>(this->get_view());
-
-               content = this->create_page10_content(view, true);
+               Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 10 With<br>on_portrait(), on_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 Portrait");
        }
 
        void on_landscape()
        {
-               Evas_Object *content;
-
                ui_view *view = dynamic_cast<ui_view *>(this->get_view());
-
-               content = this->create_page10_content(view, false);
+               Evas_Object *content = create_landscape_content(view->get_base(), "ViewMgr Demo<br>Page 10 With<br>on_portrait(), on_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 Landscape");
        }
 
index 115cf68..c0a1873 100644 (file)
@@ -21,50 +21,6 @@ private:
        appdata_s *ad;
 
 protected:
-       Evas_Object *create_page11_content(bool is_portrait)
-       {
-               Evas_Object *content;
-
-               if (is_portrait)
-               {
-                       //Create portrait content.
-                       content = create_content(this->get_base(), "ViewMgr Demo<br>Page 11 (View inheritance)<br>With on_rotate()",
-                                       //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);
-                                               ad->viewmgr->deactivate();
-                                       },
-                                       this->ad);
-               }
-               else
-               {
-                       //Create landscape content.
-                       content = create_landscape_content(this->get_base(), "ViewMgr Demo<br>Page 11 (View inheritance)<br>With on_rotate()",
-                                       //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);
-                                               ad->viewmgr->deactivate();
-                                       },
-                                       this->ad);
-               }
-
-               return content;
-       }
-
        virtual void on_load()
        {
                this->on_rotate(this->get_degree());
@@ -72,16 +28,42 @@ protected:
 
        virtual void on_rotate(int degree)
        {
-               Evas_Object *content;
-
+               //Portrait
                if (this->get_degree() == 0 || this->get_degree() == 180)
                {
-                       content = this->create_page11_content(true);
+                       Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 11 (View inheritance)<br>With on_rotate()",
+                                       //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);
+                                               ad->viewmgr->deactivate();
+                               },
+                               this->ad);
                        this->set_content(content, "Title Portrait");
                }
+               //Landscape
                else
                {
-                       content = this->create_page11_content(false);
+                       Evas_Object *content = create_landscape_content(this->get_base(), "ViewMgr Demo<br>Page 11 (View inheritance)<br>With on_rotate()",
+                                       //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);
+                                               ad->viewmgr->deactivate();
+                               },
+                               this->ad);
                        this->set_content(content, "Title Landscape");
                }
        }