Refactoring examples, page1,2,3,4 78/63778/4
authorWoochan Lee <wc0917.lee@samsung.com>
Sat, 26 Mar 2016 08:18:49 +0000 (17:18 +0900)
committerWoochan Lee <wc0917.lee@samsung.com>
Sat, 26 Mar 2016 09:01:01 +0000 (18:01 +0900)
Change examples for view class extension instead of using controller class.

Change-Id: I7edad76b8b9f50fb6d4f702c366796ee237ec9d7

src/examples/efl/page1.h
src/examples/efl/page2.h
src/examples/efl/page3.h
src/examples/efl/page4.h

index c352516e00a0af5131096bdb299aae45b54ce286..5ce77b3f62fe82101d2e9fa7d2072c0ae87b10ed 100644 (file)
  *  limitations under the License.
  *
  */
-class page1: public ui_controller
+
+/** This example create a simple view which is inheritance ui_view.
+ *  Then push in viewmgr.
+ */
+class page1: public ui_view
 {
 private:
        appdata_s *ad;
 
-public:
-       page1(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, "page1"));
-       }
-       ~page1()
-       {
-       }
-
+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 1",
+               Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 1",
                                //Prev Button Callback
                                [](void *data, Evas_Object *obj, void *event_info) -> void
                                {
@@ -52,7 +42,17 @@ public:
                                },
                                this->ad);
 
-               view->set_content(content, "Title");
+               this->set_content(content, "Title");
+       }
+
+public:
+       page1(appdata_s *ad) : ui_view("page1"), ad(ad)
+       {
+               ad->viewmgr->push_view(this);
+       }
+
+       ~page1()
+       {
        }
 };
 
index fba154b7a0a97e69bb3c6b7673a1129b2da13501..d5def0d63b010978553cbaf218db49795cad0990 100644 (file)
  *  limitations under the License.
  *
  */
-class page2: public ui_controller
+
+/** This example create a simple view which is inheritance ui_view.
+ *  And add two buttons in view title area. hen push in viewmgr.
+ */
+class page2: public ui_view
 {
 private:
        appdata_s *ad;
 
-public:
-       page2(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, "page2"));
-       }
-
-       ~page2()
-       {
-       }
-
+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 2",
+               Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 2",
                                //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_page3(ad);
-                       },
-                       this->ad);
+                               [](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_page3(ad);
+                               },
+                               this->ad);
 
                //Title left button
-               Elm_Button *left_title_btn = elm_button_add(view->get_base());
+               Elm_Button *left_title_btn = elm_button_add(this->get_base());
                elm_object_text_set(left_title_btn, "Cancel");
 
                //Title right button
-               Elm_Button *right_title_btn = elm_button_add(view->get_base());
+               Elm_Button *right_title_btn = elm_button_add(this->get_base());
                elm_object_text_set(right_title_btn, "Done");
 
                //Arguments: content, title, subtitle, title left button, title right button
-               view->set_content(content, "Title Buttons", NULL, left_title_btn, right_title_btn);
+               this->set_content(content, "Title Buttons", NULL, left_title_btn, right_title_btn);
+       }
+
+public:
+       page2(appdata_s *ad) : ui_view("page2"), ad(ad)
+       {
+               //Push this view in viewmgr.
+               ad->viewmgr->push_view(this);
+       }
+
+       ~page2()
+       {
        }
 };
 
index e261b061a40ee464d8678ea83cacfbedac290d7d..87401d082e708c8166450827c99b489fc747dc29 100644 (file)
  *  limitations under the License.
  *
  */
-class page3: public ui_controller
+
+/** This example create a simple view which is inheritance ui_view.
+ *  And set text in view subtitle. then push in viewmgr.
+ */
+class page3: public ui_view
 {
 private:
        appdata_s *ad;
 
-public:
-       page3(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, "page3"));
-       }
-
-       ~page3()
-       {
-       }
-
+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 3",
+               Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 3",
                                //Prev Button Callback
                                [](void *data, Evas_Object *obj, void *event_info) -> void
                                {
@@ -55,7 +43,17 @@ public:
                                this->ad);
 
                //Arguments: content, title, subtitle, title left button, title right button
-               view->set_content(content, "Title", "Subtitle", NULL, NULL);
+               this->set_content(content, "Title", "Subtitle", NULL, NULL);
+       }
+
+public:
+       page3(appdata_s *ad) : ui_view("page3"), ad(ad)
+       {
+               ad->viewmgr->push_view(this);
+       }
+
+       ~page3()
+       {
        }
 };
 
index cd9e31bf87ba31b1cadc865087f4857ac28c815f..21ad5ffd9cbb2f08bb18a92f1b3af60b033d68b4 100644 (file)
  *  limitations under the License.
  *
  */
-class page4: public ui_controller
+
+/** This example create a simple view which is inheritance ui_view.
+ *  And set long text to title, set badge text in view title area.
+ *  Then push in viewmgr.
+ */
+class page4: public ui_view
 {
 private:
        appdata_s *ad;
 
-public:
-       page4(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, "page4"));
-       }
-
-       ~page4()
-       {
-       }
-
+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 4",
+               Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 4",
                                //Prev Button Callback
                                [](void *data, Evas_Object *obj, void *event_info) -> void
                                {
@@ -55,8 +44,18 @@ public:
                                this->ad);
 
                //Arguments: content, title
-               view->set_content(content, "TitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitle");
-               view->set_title_badge("999+");
+               this->set_content(content, "TitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitle");
+               this->set_title_badge("999+");
+       }
+
+public:
+       page4(appdata_s *ad) : ui_view("page4"), ad(ad)
+       {
+               ad->viewmgr->push_view(this);
+       }
+
+       ~page4()
+       {
        }
 };