From: Woochan Lee Date: Thu, 17 Mar 2016 05:04:10 +0000 (+0900) Subject: Add view inheritance example. X-Git-Tag: submit/tizen/20160617.075742~111 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d16eb360e85c9e89911a1f0e13745c9acddf2a6c;p=platform%2Fcore%2Fuifw%2Fui-viewmgr.git Add view inheritance example. Change-Id: If1bd0daf9de88c754bb267b4f32b1ee341333eb4 --- diff --git a/src/examples/efl/main.cpp b/src/examples/efl/main.cpp index 459d25d..5daf120 100644 --- a/src/examples/efl/main.cpp +++ b/src/examples/efl/main.cpp @@ -15,6 +15,8 @@ * */ #include "main.h" +#include "page9.h" +#include "page8.h" #include "page7.h" #include "page6.h" #include "page5.h" diff --git a/src/examples/efl/page7.h b/src/examples/efl/page7.h index 1d75204..a50ae14 100644 --- a/src/examples/efl/page7.h +++ b/src/examples/efl/page7.h @@ -44,10 +44,12 @@ public: [](void *data, Evas_Object *obj, void *event_info) -> void { appdata_s *ad = static_cast(data); - ad->viewmgr->deactivate(); + create_page8(ad); }, this->ad); + //Don't delete view's content when this view poped. + view->set_removable_content(false); view->set_content(content, "Title with toolbar"); Evas_Object *toolbar = create_toolbar(view->get_base(), "navigationbar"); view->set_toolbar(toolbar); diff --git a/src/examples/efl/page8.h b/src/examples/efl/page8.h new file mode 100644 index 0000000..61bdafc --- /dev/null +++ b/src/examples/efl/page8.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +class page8: public ui_basic_view +{ +private: + appdata_s *ad; + +protected: + virtual void load() + { + //Create a main content. + Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Page 8
(View inheritance lazy load)", + //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_page9(ad); + }, + this->ad); + + this->set_content(content, "Title"); + } + +public: + page8(const char *name, appdata_s *ad) + : ui_basic_view(name), ad(ad) + { + ad->viewmgr->push_view(this); + } + + ~page8() + { + } +}; + +void create_page8(appdata_s *ad) +{ + /* A example for view class extension instead of using controller class. */ + new page8("page8", ad); +} diff --git a/src/examples/efl/page9.h b/src/examples/efl/page9.h new file mode 100644 index 0000000..1c35d6d --- /dev/null +++ b/src/examples/efl/page9.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +class page9: public ui_basic_view +{ +private: + appdata_s *ad; + +public: + page9(const char *name, appdata_s *ad) + : ui_basic_view(name), ad(ad) + { + //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); + + //Create a main content. + Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Page 9
(View inheritance)", + //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); + + //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); + } + + ~page9() + { + } +}; + +void create_page9(appdata_s *ad) +{ + /* A example for view class extension instead of using controller class. */ + new page9("page9", ad); +} diff --git a/src/include/efl/mobile/ui_basic_view.h b/src/include/efl/mobile/ui_basic_view.h index 8b944bd..3835639 100644 --- a/src/include/efl/mobile/ui_basic_view.h +++ b/src/include/efl/mobile/ui_basic_view.h @@ -38,6 +38,7 @@ protected: public: ui_basic_view(ui_controller *controller, const char *name = NULL); + ui_basic_view(const char *name = NULL); virtual ~ui_basic_view(); Evas_Object *set_content(Evas_Object *content, const char *title = NULL); diff --git a/src/include/efl/ui_view.h b/src/include/efl/ui_view.h index f9349e7..2bcc286 100644 --- a/src/include/efl/ui_view.h +++ b/src/include/efl/ui_view.h @@ -46,6 +46,8 @@ class ui_view: public viewmgr::ui_iface_view public: ///Constructor. ui_view(ui_controller *controller, const char *name = NULL); + ///Constructor. + ui_view(const char *name = NULL); ///Destructor. virtual ~ui_view(); diff --git a/src/lib/efl/mobile/ui_basic_view.cpp b/src/lib/efl/mobile/ui_basic_view.cpp index 04c55fd..99de673 100644 --- a/src/lib/efl/mobile/ui_basic_view.cpp +++ b/src/lib/efl/mobile/ui_basic_view.cpp @@ -92,6 +92,11 @@ ui_basic_view::ui_basic_view(ui_controller *controller, const char *name) { } +ui_basic_view::ui_basic_view(const char *name) + : ui_basic_view(NULL, name) +{ +} + ui_basic_view::~ui_basic_view() { destroy_layout(); diff --git a/src/lib/efl/ui_view.cpp b/src/lib/efl/ui_view.cpp index a50329b..adfbae9 100644 --- a/src/lib/efl/ui_view.cpp +++ b/src/lib/efl/ui_view.cpp @@ -24,6 +24,11 @@ ui_view::ui_view(ui_controller *controller, const char *name) { } +ui_view::ui_view(const char *name) + : ui_view(NULL, name) +{ +} + ui_view::~ui_view() { } diff --git a/src/lib/interface/ui_iface_view.cpp b/src/lib/interface/ui_iface_view.cpp index 39a3dad..750ee0b 100644 --- a/src/lib/interface/ui_iface_view.cpp +++ b/src/lib/interface/ui_iface_view.cpp @@ -87,7 +87,9 @@ ui_iface_view::ui_iface_view(ui_iface_controller *controller, const char *name) indicator(UI_VIEW_INDICATOR_DEFAULT), event_block(false), removable_content(true) { this->state = UI_VIEW_STATE_UNLOAD; - controller->set_view(this); + + if (controller) + controller->set_view(this); } ui_iface_view::ui_iface_view(const char *name)