From: Woochan Lee Date: Sat, 26 Mar 2016 08:18:49 +0000 (+0900) Subject: Refactoring examples, page1,2,3,4 X-Git-Tag: submit/tizen/20160617.075742~86 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=63bd3588dd66bf914be39c3558015ac1c4e09451;p=platform%2Fcore%2Fuifw%2Fui-viewmgr.git Refactoring examples, page1,2,3,4 Change examples for view class extension instead of using controller class. Change-Id: I7edad76b8b9f50fb6d4f702c366796ee237ec9d7 --- diff --git a/src/examples/efl/page1.h b/src/examples/efl/page1.h index c352516..5ce77b3 100644 --- a/src/examples/efl/page1.h +++ b/src/examples/efl/page1.h @@ -14,30 +14,20 @@ * 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(this->get_view()); - //Create a main content. - Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo
Page 1", + Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
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() + { } }; diff --git a/src/examples/efl/page2.h b/src/examples/efl/page2.h index fba154b..d5def0d 100644 --- a/src/examples/efl/page2.h +++ b/src/examples/efl/page2.h @@ -14,55 +14,55 @@ * 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(this->get_view()); - //Create a main content. - Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo
Page 2", + Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Page 2", //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_page3(ad); - }, - this->ad); + [](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_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() + { } }; diff --git a/src/examples/efl/page3.h b/src/examples/efl/page3.h index e261b06..87401d0 100644 --- a/src/examples/efl/page3.h +++ b/src/examples/efl/page3.h @@ -14,32 +14,20 @@ * 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(this->get_view()); - //Create a main content. - Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo
Page 3", + Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
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() + { } }; diff --git a/src/examples/efl/page4.h b/src/examples/efl/page4.h index cd9e31b..21ad5ff 100644 --- a/src/examples/efl/page4.h +++ b/src/examples/efl/page4.h @@ -14,32 +14,21 @@ * 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(this->get_view()); - //Create a main content. - Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo
Page 4", + Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
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() + { } };