From: Woochan Lee Date: Mon, 22 Feb 2016 02:02:37 +0000 (+0900) Subject: viewmgr: Add tabbar style view. X-Git-Tag: submit/tizen/20160617.075742~128 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ec71441779fe408efc74414adf2a8e99d8596fbd;p=platform%2Fcore%2Fuifw%2Fui-viewmgr.git viewmgr: Add tabbar style view. Change-Id: If6c124a76a7383d086a825e16515afd139811dd7 --- diff --git a/inc/main.h b/inc/main.h index 7de920e..fcc523d 100644 --- a/inc/main.h +++ b/inc/main.h @@ -40,3 +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_tabbar(Evas_Object *parent); diff --git a/res/ui-viewmgr.edc b/res/ui-viewmgr.edc index 4ab56ec..21299ce 100644 --- a/res/ui-viewmgr.edc +++ b/res/ui-viewmgr.edc @@ -50,6 +50,12 @@ #define TIZEN_VIEW_BACK_BUTTON_TITLE_RIGHT_PADDING_WIDTH_INC 90 #define BUTTON_TIZEN_VIEW_BACK_BUTTON_SIZE_INC 80 80 #define TIZEN_VIEW_TITLE_RIGHT_PADDING_WIDTH_INC 32 +#define TIZEN_VIEW_TABBAR_TITLE_TOP_PADDING_HEIGHT_INC 80 +#define TIZEN_VIEW_TABBAR_TITLE_HEIGHT_INC 100 +#define TIZEN_VIEW_TABBAR_TITLE_CLIPPER_HEIGHT_INC 80 +#define TIZEN_VIEW_TABBAR_LIGHT_VIEW_HEIGHT_INC 86 +#define TIZEN_VIEW_TABBAR2_HEIGHT_INC 144 +#define TIZEN_VIEW_TABBAR_TOP_DIVIDER_HEIGHT_INC 0 collections { base_scale: 2.6; @@ -889,4 +895,154 @@ collections { } } } + group { name: "elm/layout/tizen_view/tabbar"; + inherit: "elm/layout/tizen_view/default"; + parts { + part { name: "tabbar_top_padding"; + type: SPACER; + scale: 1; + repeat_events: 1; + description { state: "default" 0.0; + min: 0 TIZEN_VIEW_TABBAR_TITLE_TOP_PADDING_HEIGHT_INC; + max: -1 TIZEN_VIEW_TABBAR_TITLE_TOP_PADDING_HEIGHT_INC; + fixed: 0 1; + align: 0.5 0.0; + rel1 { to: "title_bg"; relative: 0.0 0.0; } + rel2 { to: "title_bg"; relative: 1.0 0.0; } + } + } + part { name: "tabbar"; + type: SWALLOW; + scale: 1; + clip_to: "tabbar_clipper"; + description { state: "default" 0.0; + min: 0 0; + max: -1 0; + fixed: 0 1; + align: 0.5 0.0; + rel1 { to: "tabbar_top_padding"; relative: 0.0 1.0; } + rel2 { to: "tabbar_top_padding"; relative: 1.0 1.0; } + visible: 0; + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + min: 0 TIZEN_VIEW_TABBAR_TITLE_HEIGHT_INC; + max: -1 TIZEN_VIEW_TABBAR_TITLE_HEIGHT_INC; + visible: 1; + } + } + part { name: "tabbar_top_divider"; + type: RECT; + scale: 1; + mouse_events: 0; + clip_to: "tabbar_clipper"; + description { state: "default" 0.0; + min: 0 0; + max: -1 0; + fixed: 0 1; + align: 0.5 0.0; + rel1 { to: "tabbar_clipper"; relative: 0.0 0.0; } + rel2 { to: "tabbar_clipper"; relative: 1.0 0.0; } + color: 244 244 244 25; + visible: 0; + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + min: 0 TIZEN_VIEW_TABBAR_TOP_DIVIDER_HEIGHT_INC; + max: -1 TIZEN_VIEW_TABBAR_TOP_DIVIDER_HEIGHT_INC; + visible: 1; + } + } + part { name: "tabbar_clipper"; + type: RECT; + scale: 1; + mouse_events: 0; + clip_to: "clipper"; + description { state: "default" 0.0; + min: 0 TIZEN_VIEW_TABBAR_TITLE_CLIPPER_HEIGHT_INC; + max: -1 TIZEN_VIEW_TABBAR_TITLE_CLIPPER_HEIGHT_INC; + fixed: 0 1; + align: 0.5 1.0; + rel1 { to: "tabbar"; relative: 0.0 1.0; } + rel2 { to: "tabbar"; relative: 1.0 1.0; } + } + } + part { name: "elm.swallow.content"; + type: SWALLOW; + scale: 1; + repeat_events: 0; + clip_to: "content_clipper"; + description { state: "default" 0.0; + align: 0.0 0.0; + rel1 { to_x: "base"; to_y: "tabbar"; relative: 0.0 1.0; } + rel2 { to_x: "base"; to_y: "toolbar"; relative: 1.0 0.0; } + } + } + } + programs { + program { name: "title_show"; + signal: "elm,state,title,show"; + source: "elm"; + script { + set_state(PART:"title_bg", "default", 0.0); + set_state(PART:"title_clipper", "default", 0.0); + if (get_int(title_left_btn_visible)) { + set_state(PART:"title_left_btn_bg", "visible", 0.0); + set_state(PART:"title_left_padding", "hidden", 0.0); + set_state(PART:"title_left_btn", "visible", 0.0); + set_state(PART:"title_right_btn_bg", "visible", 0.0); + set_state(PART:"title_right_padding", "hidden", 0.0); + } + else if (get_int(prev_btn_visible)) + set_state(PART:"elm.swallow.prev_btn", "default", 0.0); + if (get_int(title_right_btn_visible)) { + set_state(PART:"title_right_btn_bg", "visible", 0.0); + set_state(PART:"title_right_padding", "hidden", 0.0); + set_state(PART:"title_right_btn", "visible", 0.0); + set_state(PART:"title_left_btn_bg", "visible", 0.0); + set_state(PART:"title_left_padding", "hidden", 0.0); + } + if (get_int(tabbar_visible)) { + set_state(PART:"tabbar", "visible", 0.0); + set_state(PART:"tabbar_top_divider", "visible", 0.0); + } + } + } + program { name: "title_hide"; + signal: "elm,state,title,hide"; + source: "elm"; + script { + set_state(PART:"title_bg", "hidden", 0.0); + set_state(PART:"title_clipper", "hidden", 0.0); + set_state(PART:"title_left_btn_bg", "default", 0.0); + set_state(PART:"title_left_padding", "default", 0.0); + set_state(PART:"title_left_btn", "default", 0.0); + set_state(PART:"title_right_btn_bg", "default", 0.0); + set_state(PART:"title_right_padding", "default", 0.0); + set_state(PART:"title_right_btn", "default", 0.0); + set_state(PART:"tabbar", "default", 0.0); + set_state(PART:"tabbar_top_divider", "default", 0.0); + set_state(PART:"elm.swallow.prev_btn", "hidden", 0.0); + } + } + program { name: "tabbar_show"; + signal: "elm,state,tabbar,show"; + source: "elm"; + script { + set_state(PART:"tabbar", "visible", 0.0); + set_state(PART:"tabbar_top_divider", "visible", 0.0); + set_int(tabbar_visible, 1); + } + } + program { name: "tabbar_hide"; + signal: "elm,state,tabbar,hide"; + source: "elm"; + script { + set_state(PART:"tabbar", "default", 0.0); + set_state(PART:"tabbar_top_divider", "default", 0.0); + set_int(tabbar_visible, 0); + } + } + } + } } diff --git a/src/efl/example/main.cpp b/src/efl/example/main.cpp index ff20a0d..4b38950 100644 --- a/src/efl/example/main.cpp +++ b/src/efl/example/main.cpp @@ -15,12 +15,32 @@ * */ #include "main.h" +#include "page6.h" #include "page5.h" #include "page4.h" #include "page3.h" #include "page2.h" #include "page1.h" + +Evas_Object* +create_tabbar(Evas_Object *parent) +{ + Evas_Object *toolbar; + + toolbar = elm_toolbar_add(parent); + + elm_object_style_set(toolbar, "tabbar_with_title"); + 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); + + return toolbar; +} 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) { diff --git a/src/efl/example/page5.h b/src/efl/example/page5.h index 85f861a..202ce7b 100644 --- a/src/efl/example/page5.h +++ b/src/efl/example/page5.h @@ -26,7 +26,7 @@ public: //No basic form. /* ui_view(controller, identity name). Later, you could get the identity name using view->get_name(); */ - ui_view *view = ad->viewmgr->push_view(new ui_view(this, "page5")); + ad->viewmgr->push_view(new ui_view(this, "page5")); } ~page5() @@ -51,7 +51,7 @@ public: [](void *data, Evas_Object *obj, void *event_info) -> void { appdata_s *ad = static_cast(data); - ad->viewmgr->deactivate(); + create_page6(ad); }, this->ad); diff --git a/src/efl/example/page6.h b/src/efl/example/page6.h new file mode 100644 index 0000000..aa15024 --- /dev/null +++ b/src/efl/example/page6.h @@ -0,0 +1,68 @@ +/* + * 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 page6: public ui_controller +{ +private: + appdata_s *ad; + +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 */ + ad->viewmgr->push_view(new ui_basic_view(this, "page6", "tabbar")); + } + + ~page6() + { + } + + void load() + { + //Initialize contents. + + 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", + //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); + + //Arguments: content, title + view->set_content(content, "Title with tabbar"); + Evas_Object *toolbar = create_tabbar(view->get_base()); + view->set_tabbar(toolbar); + } +}; + +void create_page6(appdata_s *ad) +{ + new page6(ad); +} diff --git a/src/efl/mobile/ui_basic_view.cpp b/src/efl/mobile/ui_basic_view.cpp index 78cfb96..83886f9 100644 --- a/src/efl/mobile/ui_basic_view.cpp +++ b/src/efl/mobile/ui_basic_view.cpp @@ -19,6 +19,7 @@ //FIXME: is it correct to define here? #define EDJ_PATH "/opt/usr/apps/org.tizen.ui-viewmgr/res/ui-viewmgr.edj" #define GROUP "elm/layout/tizen_view/default" +#define TABBAR "elm/layout/tizen_view/tabbar" using namespace efl_viewmgr; using namespace viewmgr; @@ -44,7 +45,16 @@ bool ui_basic_view::create_layout() return false; } - if (!elm_layout_file_set(layout, EDJ_PATH, GROUP)) + if (!strcmp(this->get_style(), "tabbar")) + { + if (!elm_layout_file_set(layout, EDJ_PATH, TABBAR)) + { + LOGE("Failed to set tabbar style = ui_basic_view(%p)", this); + evas_object_del(layout); + return false; + } + } + else if (!elm_layout_file_set(layout, EDJ_PATH, GROUP)) { LOGE("Failed to set file = ui_basic_view(%p), path(%s), group(%s)", this, EDJ_PATH, GROUP); evas_object_del(layout); @@ -87,8 +97,8 @@ bool ui_basic_view::create_layout() return true; } -ui_basic_view::ui_basic_view(ui_controller *controller, const char *name) - : ui_view(controller, name), layout(NULL) +ui_basic_view::ui_basic_view(ui_controller *controller, const char *name, const char *style) + : ui_view(controller, name, style), layout(NULL) { } @@ -220,6 +230,18 @@ Evas_Object *ui_basic_view::set_content(Evas_Object *content, const char *title, return pcontent; } +bool ui_basic_view::set_tabbar(Evas_Object *toolbar) +{ + if (this->layout) + { + elm_object_part_content_set(this->layout, "tabbar", toolbar); + if (toolbar) elm_object_signal_emit(this->layout, "elm,state,tabbar,show", "elm"); + return true; + } + LOGE("Layout is not exist!"); + return false; +} + void ui_basic_view::unload_content() { ui_view::set_content(NULL); diff --git a/src/efl/mobile/ui_basic_view.h b/src/efl/mobile/ui_basic_view.h index 06268a6..8e37f2a 100644 --- a/src/efl/mobile/ui_basic_view.h +++ b/src/efl/mobile/ui_basic_view.h @@ -36,7 +36,7 @@ protected: virtual void unload_content(); public: - ui_basic_view(ui_controller *controller, const char *name = NULL); + ui_basic_view(ui_controller *controller, const char *name = NULL, const char *style = NULL); virtual ~ui_basic_view(); Evas_Object *set_content(Evas_Object *content, const char *title = NULL); @@ -46,6 +46,7 @@ public: bool set_title_left_btn(Evas_Object *title_left_btn); bool set_title_right_btn(Evas_Object *title_right_btn); bool set_title(const char *text); + bool set_tabbar(Evas_Object *toolbar); virtual Evas_Object *get_base() { diff --git a/src/efl/ui_view.cpp b/src/efl/ui_view.cpp index 22c395e..d4a4ec1 100644 --- a/src/efl/ui_view.cpp +++ b/src/efl/ui_view.cpp @@ -19,8 +19,8 @@ using namespace efl_viewmgr; using namespace viewmgr; -ui_view::ui_view(ui_controller *controller, const char *name) - : ui_view_interface(controller, name) +ui_view::ui_view(ui_controller *controller, const char *name, const char *style) + : ui_view_interface(controller, name, style) { } diff --git a/src/efl/ui_view.h b/src/efl/ui_view.h index 5b6c0eb..09171aa 100644 --- a/src/efl/ui_view.h +++ b/src/efl/ui_view.h @@ -32,7 +32,7 @@ class ui_view: public viewmgr::ui_view_interface friend class ui_viewmgr; public: - ui_view(ui_controller *controller, const char *name = NULL); + ui_view(ui_controller *controller, const char *name = NULL, const char *style = NULL); virtual ~ui_view(); virtual Evas_Object *set_content(Evas_Object *content); diff --git a/src/interface/ui_view_interface.cpp b/src/interface/ui_view_interface.cpp index 66f5348..f411ce6 100644 --- a/src/interface/ui_view_interface.cpp +++ b/src/interface/ui_view_interface.cpp @@ -82,8 +82,8 @@ void ui_view_interface::destroy() this->controller->destroy(); } -ui_view_interface::ui_view_interface(T content, ui_controller_interface *controller, const char *name) - : content(content), controller(controller), name(string(name ? name : "")), style(string("")), viewmgr(NULL), state(UI_VIEW_STATE_LOAD), +ui_view_interface::ui_view_interface(T content, ui_controller_interface *controller, const char *name, const char *style) + : content(content), controller(controller), name(string(name ? name : "")), style(string(style ? style : "")), 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; @@ -91,8 +91,8 @@ ui_view_interface::ui_view_interface(T content, ui_controller_interface *control controller->set_view(this); } -ui_view_interface::ui_view_interface(ui_controller_interface *controller, const char *name) - : ui_view_interface(NULL, controller, name) +ui_view_interface::ui_view_interface(ui_controller_interface *controller, const char *name, const char *style) + : ui_view_interface(NULL, controller, name, style) { this->state = UI_VIEW_STATE_UNLOAD; } diff --git a/src/interface/ui_view_interface.h b/src/interface/ui_view_interface.h index faed8b8..ef4327f 100644 --- a/src/interface/ui_view_interface.h +++ b/src/interface/ui_view_interface.h @@ -175,9 +175,9 @@ public: * @warning Be aware the deletion of controller passed here will be covered by ui_view_interface. * If you want to keep it for any reasons, please unset it using set_controller() before ui_view_interface is deleted. */ - ui_view_interface(T content, ui_controller_interface *controller, const char *name); + ui_view_interface(T content, ui_controller_interface *controller, const char *name, const char *style = NULL); ///Constructor for initializing with controller. - ui_view_interface(ui_controller_interface *controller, const char *name = NULL); + ui_view_interface(ui_controller_interface *controller, const char *name = NULL, const char *style = NULL); ///Constructor for initializing with name. ui_view_interface(const char *name = NULL);