From: Woochan Lee Date: Sat, 26 Mar 2016 11:08:35 +0000 (+0900) Subject: Refactoring examples, page 9,10,11,12,13 X-Git-Tag: submit/tizen/20160617.075742~84 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2e1eef1c14887017b05488296f0b0a2b09638ae1;p=platform%2Fcore%2Fuifw%2Fui-viewmgr.git Refactoring examples, page 9,10,11,12,13 Change-Id: I7cbbe690c3e78216b4f434f41eeb6bd7b543c268 --- diff --git a/src/examples/efl/page10.h b/src/examples/efl/page10.h index edcef26..e3be5ed 100644 --- a/src/examples/efl/page10.h +++ b/src/examples/efl/page10.h @@ -14,31 +14,21 @@ * 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(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(this->get_view()); - Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo
Page 10
(Portrait + 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"); - view->set_indicator(UI_VIEW_INDICATOR_DEFAULT); + Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Page 10
(Portrait + 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); + this->set_content(content, "Title"); + this->set_indicator(UI_VIEW_INDICATOR_DEFAULT); } void on_landscape() { - ui_view *view = dynamic_cast(this->get_view()); - Evas_Object *content = create_landscape_content(view->get_base(), "ViewMgr Demo
Page 10
(Portrait + Landscape)", + Evas_Object *content = create_landscape_content(this->get_base(), "ViewMgr Demo
Page 10
(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) diff --git a/src/examples/efl/page11.h b/src/examples/efl/page11.h index ff0dd57..9a5ed79 100644 --- a/src/examples/efl/page11.h +++ b/src/examples/efl/page11.h @@ -15,23 +15,41 @@ * */ -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(this->get_view()); + + this->on_rotate(view->get_degree()); } void on_rotate(int degree) { + ui_view *view = dynamic_cast(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
Page 11
(Rotate)", + Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo
Page 11
(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
Page 11
(Rotate)", + Evas_Object *content = create_landscape_content(view->get_base(), "ViewMgr Demo
Page 11
(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); } diff --git a/src/examples/efl/page12.h b/src/examples/efl/page12.h index 4708084..2f8fff3 100644 --- a/src/examples/efl/page12.h +++ b/src/examples/efl/page12.h @@ -15,6 +15,11 @@ * */ + +/** 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(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); } diff --git a/src/examples/efl/page13.h b/src/examples/efl/page13.h index e61abc6..f2e387d 100644 --- a/src/examples/efl/page13.h +++ b/src/examples/efl/page13.h @@ -15,6 +15,10 @@ * */ +/** 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: diff --git a/src/examples/efl/page9.h b/src/examples/efl/page9.h index 530591f..ae9e4c3 100644 --- a/src/examples/efl/page9.h +++ b/src/examples/efl/page9.h @@ -14,21 +14,27 @@ * 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
Page 9
(Content Preloading)", + Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo
Page 9
(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); }