From 156c790ac6bb4d91f9d57dbc2f1a233f5c9ddf0b Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Fri, 25 Mar 2016 22:04:22 +0900 Subject: [PATCH] refactoring page10, page11 rewrite for clean & nice code Change-Id: Ifd073bac2421c321d2ca197848b68599da72908d --- src/examples/efl/page10.h | 84 ++++++++++++++++------------------------------- src/examples/efl/page11.h | 78 +++++++++++++++++-------------------------- 2 files changed, 58 insertions(+), 104 deletions(-) diff --git a/src/examples/efl/page10.h b/src/examples/efl/page10.h index 844a9e9..fbf48f1 100644 --- a/src/examples/efl/page10.h +++ b/src/examples/efl/page10.h @@ -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
Page 10 With
on_portrait(), on_landscape()", - //Prev Button Callback - [](void *data, Evas_Object *obj, void *event_info) -> void - { - appdata_s *ad = static_cast(data); - ad->viewmgr->pop_view(); - }, - //Next Button Callback - [](void *data, Evas_Object *obj, void *event_info) -> void - { - appdata_s *ad = static_cast(data); - create_page11(ad); - }, - this->ad); - } - else - { - //Create landscape content. - content = create_landscape_content(view->get_base(), - "ViewMgr Demo
Page 10 With
on_portrait(), on_landscape()", - //Prev Button Callback - [](void *data, Evas_Object *obj, void *event_info) -> void - { - appdata_s *ad = static_cast(data); - ad->viewmgr->pop_view(); - }, - //Next Button Callback - [](void *data, Evas_Object *obj, void *event_info) -> void - { - appdata_s *ad = static_cast(data); - create_page11(ad); - }, - this->ad); - } - - return content; - } - void on_load() { - Evas_Object *content; - //Initialize contents. ui_view *view = dynamic_cast(this->get_view()); @@ -94,21 +46,41 @@ public: void on_portrait() { - Evas_Object *content; - ui_view *view = dynamic_cast(this->get_view()); - - content = this->create_page10_content(view, true); + Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo
Page 10 With
on_portrait(), on_landscape()", + //Prev Button Callback + [](void *data, Evas_Object *obj, void *event_info) -> void + { + appdata_s *ad = static_cast(data); + ad->viewmgr->pop_view(); + }, + //Next Button Callback + [](void *data, Evas_Object *obj, void *event_info) -> void + { + appdata_s *ad = static_cast(data); + create_page11(ad); + }, + this->ad); view->set_content(content, "Title Portrait"); } void on_landscape() { - Evas_Object *content; - ui_view *view = dynamic_cast(this->get_view()); - - content = this->create_page10_content(view, false); + Evas_Object *content = create_landscape_content(view->get_base(), "ViewMgr Demo
Page 10 With
on_portrait(), on_landscape()", + //Prev Button Callback + [](void *data, Evas_Object *obj, void *event_info) -> void + { + appdata_s *ad = static_cast(data); + ad->viewmgr->pop_view(); + }, + //Next Button Callback + [](void *data, Evas_Object *obj, void *event_info) -> void + { + appdata_s *ad = static_cast(data); + create_page11(ad); + }, + this->ad); view->set_content(content, "Title Landscape"); } diff --git a/src/examples/efl/page11.h b/src/examples/efl/page11.h index 115cf68..c0a1873 100644 --- a/src/examples/efl/page11.h +++ b/src/examples/efl/page11.h @@ -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
Page 11 (View inheritance)
With on_rotate()", - //Prev Button Callback - [](void *data, Evas_Object *obj, void *event_info) -> void - { - appdata_s *ad = static_cast(data); - ad->viewmgr->pop_view(); - }, - //Next Button Callback - [](void *data, Evas_Object *obj, void *event_info) -> void - { - appdata_s *ad = static_cast(data); - ad->viewmgr->deactivate(); - }, - this->ad); - } - else - { - //Create landscape content. - content = create_landscape_content(this->get_base(), "ViewMgr Demo
Page 11 (View inheritance)
With on_rotate()", - //Prev Button Callback - [](void *data, Evas_Object *obj, void *event_info) -> void - { - appdata_s *ad = static_cast(data); - ad->viewmgr->pop_view(); - }, - //Next Button Callback - [](void *data, Evas_Object *obj, void *event_info) -> void - { - appdata_s *ad = static_cast(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
Page 11 (View inheritance)
With on_rotate()", + //Prev Button Callback + [](void *data, Evas_Object *obj, void *event_info) -> void + { + appdata_s *ad = static_cast(data); + ad->viewmgr->pop_view(); + }, + //Next Button Callback + [](void *data, Evas_Object *obj, void *event_info) -> void + { + appdata_s *ad = static_cast(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
Page 11 (View inheritance)
With on_rotate()", + //Prev Button Callback + [](void *data, Evas_Object *obj, void *event_info) -> void + { + appdata_s *ad = static_cast(data); + ad->viewmgr->pop_view(); + }, + //Next Button Callback + [](void *data, Evas_Object *obj, void *event_info) -> void + { + appdata_s *ad = static_cast(data); + ad->viewmgr->deactivate(); + }, + this->ad); this->set_content(content, "Title Landscape"); } } -- 2.7.4