From: Woochan Lee Date: Thu, 10 Mar 2016 11:41:50 +0000 (+0900) Subject: viewmgr: Add page7 example. X-Git-Tag: submit/tizen/20160617.075742~117 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F78%2F61778%2F5;p=platform%2Fcore%2Fuifw%2Fui-viewmgr.git viewmgr: Add page7 example. Directly make a view and content in the same function. Change-Id: Id470c7af4cbcc116b0ad304424c0119de85518ae --- diff --git a/src/examples/efl/main.cpp b/src/examples/efl/main.cpp index e10e8c0..459d25d 100644 --- a/src/examples/efl/main.cpp +++ b/src/examples/efl/main.cpp @@ -15,6 +15,7 @@ * */ #include "main.h" +#include "page7.h" #include "page6.h" #include "page5.h" #include "page4.h" @@ -23,21 +24,23 @@ #include "page1.h" Evas_Object* -create_toolbar(Evas_Object *parent) +create_toolbar(Evas_Object *parent, const char *style) { Evas_Object *toolbar; toolbar = elm_toolbar_add(parent); //FIXME: :( UI_View can set this style instead. - elm_object_style_set(toolbar, "toolbar_with_title"); + elm_object_style_set(toolbar, style); + + //FIXME: If not call below API, toolbar items create with min size. + // It looks toolbar bug. elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_EXPAND); - elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE); elm_toolbar_item_append(toolbar, NULL, "Tab1", NULL, NULL); elm_toolbar_item_append(toolbar, NULL, "Tab2", NULL, NULL); - - elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS); + elm_toolbar_item_append(toolbar, NULL, "Tab3", NULL, NULL); + elm_toolbar_item_append(toolbar, NULL, "Tab4", NULL, NULL); return toolbar; } diff --git a/src/examples/efl/main.h b/src/examples/efl/main.h index f508a1a..0535e7e 100644 --- a/src/examples/efl/main.h +++ b/src/examples/efl/main.h @@ -40,4 +40,4 @@ typedef struct appdata { } appdata_s; Evas_Object *create_content(Evas_Object *parent, const char *text, Evas_Smart_Cb prev_btn_clicked_cb, Evas_Smart_Cb next_btn_clicked_cb, appdata_s *ad); -Evas_Object *create_toolbar(Evas_Object *parent); +Evas_Object *create_toolbar(Evas_Object *parent, const char *style); diff --git a/src/examples/efl/page6.h b/src/examples/efl/page6.h index 9fad923..a7ad601 100644 --- a/src/examples/efl/page6.h +++ b/src/examples/efl/page6.h @@ -23,9 +23,8 @@ public: page6(appdata_s *ad) : ad(ad) { - /* ui_basic_view(controller, identity name, style name of view). - Later, you could get the identity name using view->get_name(); - you could get the style name of view as well */ + /* ui_basic_view(controller, identity name). + Later, you could get the identity name using view->get_name(); */ ad->viewmgr->push_view(new ui_basic_view(this, "page6")); } @@ -41,7 +40,7 @@ public: ui_basic_view *view = dynamic_cast(this->get_view()); //Create a main content. - Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo
Page 6
With Tabar", + Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo
Page 6
With Toolbar
(tabbar style)", //Prev Button Callback [](void *data, Evas_Object *obj, void *event_info) -> void { @@ -52,13 +51,13 @@ public: [](void *data, Evas_Object *obj, void *event_info) -> void { appdata_s *ad = static_cast(data); - ad->viewmgr->deactivate(); + create_page7(ad); }, this->ad); //Arguments: content, title view->set_content(content, "Title with toolbar"); - Evas_Object *toolbar = create_toolbar(view->get_base()); + Evas_Object *toolbar = create_toolbar(view->get_base(), "toolbar_with_title"); view->set_toolbar(toolbar); } }; diff --git a/src/examples/efl/page7.h b/src/examples/efl/page7.h new file mode 100644 index 0000000..a6bafb5 --- /dev/null +++ b/src/examples/efl/page7.h @@ -0,0 +1,65 @@ +/* + * 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 page7: public ui_basic_controller +{ +private: + appdata_s *ad; + +public: + page7(appdata_s *ad) + : ad(ad) + { + /* ui_basic_view(controller, identity name, style name of view). + Later, you could get the identity name using view->get_name(); + you could get the style name of view as well */ + ui_basic_view *view = new ui_basic_view(this, "page7"); + + //FIXME: It will be deleted or change to other way :( + // We don't have any way to support it now. + view->set_viewmgr(ad->viewmgr); + + //Create a main content. + Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo
Page 7
With Toolbar
(Navigationbar style)", + //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); + + view->set_content(content, "Title with toolbar"); + Evas_Object *toolbar = create_toolbar(view->get_base(), "navigationbar"); + view->set_toolbar(toolbar); + ad->viewmgr->push_view(view); + } + + ~page7() + { + } +}; + +void create_page7(appdata_s *ad) +{ + new page7(ad); +} diff --git a/src/include/efl/mobile/ui_basic_view.h b/src/include/efl/mobile/ui_basic_view.h index e6bda73..297efb1 100644 --- a/src/include/efl/mobile/ui_basic_view.h +++ b/src/include/efl/mobile/ui_basic_view.h @@ -52,6 +52,7 @@ public: virtual Evas_Object *get_base() { + if (!this->layout)this->create_layout(); return this->layout; } }; diff --git a/src/include/interface/ui_iface_view.h b/src/include/interface/ui_iface_view.h index 5ceeb8a..597ce37 100644 --- a/src/include/interface/ui_iface_view.h +++ b/src/include/interface/ui_iface_view.h @@ -172,16 +172,20 @@ protected: ui_iface_controller* set_controller(ui_iface_controller *controller); public: + //FIXME: This method for support a use case that user make content, view same time. + void set_viewmgr(ui_iface_viewmgr *viewmgr) + { + this->viewmgr = viewmgr; + } + /** @brief This is a constructor for initializing this view resources. * - * @param content A content instance for a screen as a view. * @param controller view life-cycle controller interface. * @param name view name. * * @warning Be aware the deletion of controller passed here will be covered by ui_iface_view. * If you want to keep it for any reasons, please unset it using set_controller() before ui_iface_view is deleted. */ - ui_iface_view(T content, ui_iface_controller *controller, const char *name); ///Constructor for initializing with controller. ui_iface_view(ui_iface_controller *controller, const char *name = NULL); ///Constructor for initializing with name. diff --git a/src/lib/efl/mobile/ui_basic_view.cpp b/src/lib/efl/mobile/ui_basic_view.cpp index ef15fee..f7f68d0 100644 --- a/src/lib/efl/mobile/ui_basic_view.cpp +++ b/src/lib/efl/mobile/ui_basic_view.cpp @@ -101,7 +101,7 @@ ui_basic_view::~ui_basic_view() void ui_basic_view::load() { - this->create_layout(); + if (!this->layout) this->create_layout(); ui_view::load(); } @@ -228,6 +228,24 @@ bool ui_basic_view::set_toolbar(Evas_Object *toolbar) if (layout) { + + if ((!strcmp(elm_object_style_get(toolbar), "toolbar_with_title")) && + ((elm_toolbar_shrink_mode_get(toolbar) != ELM_TOOLBAR_SHRINK_EXPAND))) + { + elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_EXPAND); + } + else if (!strcmp(elm_object_style_get(toolbar), "navigationbar")) + { + if (elm_toolbar_shrink_mode_get(toolbar) != ELM_TOOLBAR_SHRINK_SCROLL) + elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_SCROLL); + elm_toolbar_align_set(toolbar, 0.0); + } + elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE); + + //FIXME: It can be deleted when the application want to handle this property. + // Some of application may want to select one of toolbar item when view activated. + elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS); + elm_object_part_content_set(layout, "toolbar", toolbar); if (toolbar) elm_object_signal_emit(layout, "elm,state,toolbar,show", "elm"); else elm_object_signal_emit(layout, "elm,state,toolbar,hide", "elm"); diff --git a/src/lib/efl/ui_view.cpp b/src/lib/efl/ui_view.cpp index dfa66f4..a50329b 100644 --- a/src/lib/efl/ui_view.cpp +++ b/src/lib/efl/ui_view.cpp @@ -53,6 +53,11 @@ void ui_view::unload_content() Evas_Object *ui_view ::get_parent() { ui_viewmgr *viewmgr = dynamic_cast(this->get_viewmgr()); + if (!viewmgr) + { + LOGE("Failed to get a viewmgr"); + return NULL; + } return viewmgr->get_base(); } diff --git a/src/lib/interface/ui_iface_view.cpp b/src/lib/interface/ui_iface_view.cpp index 8348563..ca9b444 100644 --- a/src/lib/interface/ui_iface_view.cpp +++ b/src/lib/interface/ui_iface_view.cpp @@ -82,19 +82,12 @@ void ui_iface_view::destroy() this->controller->destroy(); } -ui_iface_view::ui_iface_view(T content, ui_iface_controller *controller, const char *name) - : content(content), controller(controller), name(string(name ? name : "")), style(string("")), viewmgr(NULL), state(UI_VIEW_STATE_LOAD), - indicator(UI_VIEW_INDICATOR_DEFAULT), event_block(false), removable_content(true) -{ - if (!content) this->state = UI_VIEW_STATE_UNLOAD; - else this->state = UI_VIEW_STATE_LOAD; - controller->set_view(this); -} - ui_iface_view::ui_iface_view(ui_iface_controller *controller, const char *name) - : ui_iface_view(NULL, controller, name) + : content(NULL), controller(controller), name(string(name ? name : "")), style(string("")), viewmgr(NULL), state(UI_VIEW_STATE_LOAD), + indicator(UI_VIEW_INDICATOR_DEFAULT), event_block(false), removable_content(true) { this->state = UI_VIEW_STATE_UNLOAD; + controller->set_view(this); } ui_iface_view::ui_iface_view(const char *name) diff --git a/src/lib/interface/ui_iface_viewmgr.cpp b/src/lib/interface/ui_iface_viewmgr.cpp index 164f987..5f19c90 100644 --- a/src/lib/interface/ui_iface_viewmgr.cpp +++ b/src/lib/interface/ui_iface_viewmgr.cpp @@ -30,11 +30,14 @@ bool ui_iface_viewmgr::need_soft_key() bool ui_iface_viewmgr::connect_view(ui_iface_view *view) { + //FIXME: If user call a set_viewmgr() before, It should not return false. + /* if (view->viewmgr) { LOGE("view(%p) has already connected to viewmgr(%p)", view, this); return false; } + */ view->viewmgr = this; return true;