From: Woochan Lee Date: Tue, 15 Nov 2016 05:24:32 +0000 (+0900) Subject: Tabview implement. X-Git-Tag: submit/tizen_3.0/20161123.082748^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F98%2F97798%2F11;p=platform%2Fcore%2Fuifw%2Fui-viewmgr.git Tabview implement. Change-Id: I9ded922df300ad0306bcf41761aba18c51f1ba0f --- diff --git a/data/edc/ui-viewmgr.edc b/data/edc/ui-viewmgr.edc index 98af0fa..f3bb4fd 100644 --- a/data/edc/ui-viewmgr.edc +++ b/data/edc/ui-viewmgr.edc @@ -51,6 +51,8 @@ #define TIZEN_VIEW_TOOLBAR_LIGHT_VIEW_HEIGHT_INC 86 #define TIZEN_VIEW_TOOLBAR_TOP_DIVIDER_HEIGHT_INC 0 #define TRANSITION_TIME 0.2 +#define TIZEN_VIEW_TAB1_HEIGHT_INC 110 +#define TIZEN_VIEW_TAB2_HEIGHT_INC 144 collections { base_scale: 2.6; @@ -1115,6 +1117,181 @@ collections { } } } + + group { "tizen_view/tabbar/default"; + images { + image: "images/core_theme_bg_01.png" COMP; + image: "images/core_icon_badge_container.#.png" COMP; + } + script { + public landscape_mode = 0; + public tabbar_visible = 0; + } + parts{ + spacer { "base"; + desc { "default"; + } + } + image { "bg_img"; + scale: 1; + mouse_events: 0; + clip_to: "clipper"; + desc { "default"; + rel1.to: "base"; + rel2.to: "base"; + align: 0.5 0.0; + fixed: 0 1; + min: 0 TIZEN_VIEW_BG_PORTRAIT_HEIGHT_INC; + image.normal: "images/core_theme_bg_01.png"; + } + desc { "landscape"; + inherit: "default"; + min: 0 TIZEN_VIEW_BG_LANDSPACPE_HEIGHT_INC; + } + } + part { name: "clipper"; + type: RECT; + mouse_events: 0; + description { state: "default" 0.0; + visible: 1; + } + description { state: "hidden" 0.0; + visible: 0; + } + } + swallow { "tabbar"; + 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: "base"; relative: 0.0 0.0; } + rel2 { to: "base"; relative: 1.0 0.0; } + visible: 0; + } + description { state: "text_visible" 0.0; + inherit: "default" 0.0; + min: 0 TIZEN_VIEW_TAB1_HEIGHT_INC; + max: -1 TIZEN_VIEW_TAB1_HEIGHT_INC; + visible: 1; + } + description { state: "icon_visible" 0.0; + inherit: "default" 0.0; + min: 0 TIZEN_VIEW_TAB2_HEIGHT_INC; + max: -1 TIZEN_VIEW_TAB2_HEIGHT_INC; + visible: 1; + } + } + rect { "tabbar_clipper"; + mouse_events: 0; + clip_to: "clipper"; + description { state: "default" 0.0; + rel1.to_y: "tabbar"; + rel2.to_y: "tabbar"; + } + } + + swallow { "elm.swallow.content"; + 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: "base"; relative: 1.0 1.0; } + } + } + rect { name: "content_clipper"; + mouse_events: 0; + clip_to: "clipper"; + description { state: "default" 0.0; + rel1.to_y: "elm.swallow.content"; + rel2.to_y: "elm.swallow.content"; + } + } + } + programs { + program { name: "title_show"; + signal: "elm,state,title,show"; + source: "viewmgr"; + script { + if (get_int(tabbar_visible)) { + set_state(PART:"tabbar", "text_visible", 0.0); + } + } + } + program { name: "title_hide"; + signal: "elm,state,title,hide"; + source: "viewmgr"; + script { + set_state(PART:"tabbar", "default", 0.0); + } + } + program { name: "tabbar_show"; + signal: "elm,state,tabbar,show"; + source: "viewmgr"; + script { + set_state(PART:"tabbar", "text_visible", 0.0); + set_int(tabbar_visible, 1); + } + } + program { name: "tabbar_icon_show"; + signal: "elm,state,tabbar,icon,show"; + source: "viewmgr"; + script { + set_state(PART:"tabbar", "icon_visible", 0.0); + set_int(tabbar_visible, 1); + } + } + program { name: "tabbar_hide"; + signal: "elm,state,tabbar,hide"; + source: "viewmgr"; + script { + set_state(PART:"tabbar", "default", 0.0); + set_int(tabbar_visible, 0); + } + } + program { "change_to_landscape"; + script { + if (!get_int(landscape_mode)) { + set_int(landscape_mode, 1); + } + set_state(PART:"bg_img", "landscape", 0.0); + } + } + program { "change_to_portrait"; + script { + if (get_int(landscape_mode)) { + set_int(landscape_mode, 0); + } + set_state(PART:"bg_img", "default", 0.0); + } + } + program { "landscape_mode"; + source: "elm"; + signal: "elm,state,orient,90"; + after: "change_to_landscape"; + } + program { "landscape_mode2"; + source: "elm"; + signal: "elm,state,orient,270"; + after: "change_to_landscape"; + } + program { "portrait_mode"; + source: "elm"; + signal: "elm,state,orient,0"; + after: "change_to_portrait"; + } + program { "portrait_mode2"; + source: "elm"; + signal: "elm,state,orient,180"; + after: "change_to_portrait"; + } + } + } + /* Sliding Effect */ group { "transition/default"; alias: "transition/slide"; diff --git a/data/images/icon_alarm.png b/data/images/icon_alarm.png new file mode 100644 index 0000000..688b0cf Binary files /dev/null and b/data/images/icon_alarm.png differ diff --git a/data/images/icon_timer.png b/data/images/icon_timer.png new file mode 100644 index 0000000..fe2845d Binary files /dev/null and b/data/images/icon_timer.png differ diff --git a/data/images/icon_worldclock.png b/data/images/icon_worldclock.png new file mode 100644 index 0000000..b403ef5 Binary files /dev/null and b/data/images/icon_worldclock.png differ diff --git a/src/examples/efl/cpp/main.cpp b/src/examples/efl/cpp/main.cpp index 6d6e782..ab45133 100644 --- a/src/examples/efl/cpp/main.cpp +++ b/src/examples/efl/cpp/main.cpp @@ -15,6 +15,7 @@ * */ #include "main.h" +#include "page17.h" #include "page16.h" #include "page15.h" #include "page14.h" diff --git a/src/examples/efl/cpp/page16.h b/src/examples/efl/cpp/page16.h index 5bb2494..226a563 100644 --- a/src/examples/efl/cpp/page16.h +++ b/src/examples/efl/cpp/page16.h @@ -35,7 +35,7 @@ protected: //Next Button Callback [](void *data, Eo *obj, void *event_info) { - UI_VIEWMGR->deactivate(); + UI_VIEWMGR->pushView(new page17()); }, //Title Show Button Callback [](void *data, Eo *obj, void *event_info) diff --git a/src/examples/efl/cpp/page17.h b/src/examples/efl/cpp/page17.h new file mode 100644 index 0000000..3c9d611 --- /dev/null +++ b/src/examples/efl/cpp/page17.h @@ -0,0 +1,95 @@ +/* + * 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. + * + */ + +/** This example create a simple view which is inheritance of an UiTabView. + * Then push in viewmgr. + */ +class page17: public UiTabView +{ +protected: + //tabActivated() will be called when specific tab is selected. + void tabActivated(int id) + { + + } + + //tabDeactivated() will be called when another tab selected, otherwise tab view deactivated. + void tabDeactivated(int id) + { + + } + +public: + page17() : UiTabView("page17") { + + //Create a main content. + Eo *content1 = createContent(this->getBase(), "ViewMgr++ Demo
Alarm Tab", + //Prev Button Callback + [](void *data, Evas_Object *obj, void *event_info) + { + UI_VIEWMGR->popView(); + }, + //Next Button Callback + [](void *data, Evas_Object *obj, void *event_info) + { + UI_VIEWMGR->deactivate(); + }); + + Eo *content2 = createContent(this->getBase(), "ViewMgr++ Demo
Timer Tab", + //Prev Button Callback + [](void *data, Evas_Object *obj, void *event_info) + { + UI_VIEWMGR->popView(); + }, + //Next Button Callback + [](void *data, Evas_Object *obj, void *event_info) + { + UI_VIEWMGR->deactivate(); + }); + + Eo *content3 = createContent(this->getBase(), "ViewMgr++ Demo
World Clock Tab", + //Prev Button Callback + [](void *data, Evas_Object *obj, void *event_info) + { + UI_VIEWMGR->popView(); + }, + //Next Button Callback + [](void *data, Evas_Object *obj, void *event_info) + { + UI_VIEWMGR->deactivate(); + }); + + this->addTab(0); + this->addTab(1); + this->addTab(2); + + this->setTabLabel(0, "Alarm"); + this->setTabLabel(1, "Timer"); + this->setTabLabel(2, "World Clock"); + + this->setTabIcon(0, BINDIR"/data/images/icon_alarm.png"); + this->setTabIcon(1, BINDIR"/data/images/icon_timer.png"); + this->setTabIcon(2, BINDIR"/data/images/icon_worldclock.png"); + + this->setTabContent(0, content1); + this->setTabContent(1, content2); + this->setTabContent(2, content3); + + this->selectTab(2); + } + ~page17() {} +}; diff --git a/src/include/efl/mobile/UiMobileViewManager.h b/src/include/efl/mobile/UiMobileViewManager.h index 8ffeefe..db390bc 100644 --- a/src/include/efl/mobile/UiMobileViewManager.h +++ b/src/include/efl/mobile/UiMobileViewManager.h @@ -20,6 +20,7 @@ #include "../UiBaseViewManager.h" #include "UiView.h" #include "UiStandardView.h" +#include "UiTabView.h" #include "UiKeyListener.h" #include "UiViewmgr.h" #include "UiMenu.h" diff --git a/src/include/efl/mobile/UiTabView.h b/src/include/efl/mobile/UiTabView.h new file mode 100644 index 0000000..69b5f33 --- /dev/null +++ b/src/include/efl/mobile/UiTabView.h @@ -0,0 +1,121 @@ +/* + * 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. + * + */ +#ifndef _UI_TAB_VIEW_H_ +#define _UI_TAB_VIEW_H_ + +namespace efl_viewmanager +{ + +/** + * @class UiView + * + * @ingroup efl_viewmanager + * + * @brief This is a mobile tab view. This view extends UiView and implements tab view specific behaviors for EFL view in mobile profile. + * UiTabView implements tab view UI form for mobile application view. Each tab can has label, icon, content. The connected content will be shown + * when user select specific tab. It internally constructs a layout which builds a form that is consisted of tab part and content part. + * The tab part is located in top of the view and Elm_Toolbar widget used for this part. The each tab item matched with specific id that user gave + * in created time. user can handle tab item property and tab view option using id. If user never set select tab item, tab view will be give a selection + * to first added item internally. Lastly the tab part height size is decided by whether icon exist or not. + */ +class UiTabView: public efl_viewmanager::UiView +{ +public: + /** + * @brief A constructor for an UiStandardView. + * + * @param name view name. + */ + explicit UiTabView(const char *name = nullptr); + + ///Destructor. + virtual ~UiTabView(); + + bool addTab(int id); + + bool setTabIcon(int id, const char *icon); + + bool setTabLabel(int id, const char *label); + + bool setTabContent(int id, Eo *content); + + const char *getTabIcon(int id); + + const char *getTabLabel(int id); + + Eo *getTabContent(int id); + + const char *unsetTabIcon(int id); + + const char *unsetTabLabel(int id); + + Eo *unsetTabContent(int id); + + int getSelectedTab(); + + bool removeTab(int id); + + bool selectTab(int id); + + /** + * @brief Get a base layout of viewmgr. + * + * @return viewmgr's base layout object. + */ + virtual Eo *getBase() const override; + +protected: + + virtual void tabActivated(int id); + + virtual void tabDeactivated(int id); + + /** + * @brief view load state. + * + * @note this state will be triggered by UiIfaceViewmgr. + * + */ + virtual void onLoad() override; + + /** @brief view unload state. + * + * @note this state will be triggered by UiIfaceViewmgr. + * + */ + virtual void onUnload() override; + + /** @brief toggle event block. + * + * @note This interface is designed for toggling touch event on view transition. + * UiIfaceViewmgr will call this interface for notifying event blocking toggling on transition time. + * + * @param block @c true, blocking enable, otherwise @c false. + */ + virtual int setEventBlock(bool block) override; + +public: + _UI_DISABLE_DEFAULT_CTOR(UiTabView); + _UI_DISABLE_COPY_AND_ASSIGN(UiTabView); + +private: + _UI_DECLARE_PRIVATE_IMPL(UiTabView); +}; + +} + +#endif /* _UI_STANDARD_VIEW_H_ */ diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index d74f09a..55dc95c 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -14,6 +14,7 @@ SET(SRCS efl/mobile/UiPopup.cpp efl/mobile/UiView.cpp efl/mobile/UiStandardView.cpp + efl/mobile/UiTabView.cpp efl/mobile/UiKeyListener.cpp efl/mobile/UiViewmgr.cpp ) @@ -33,6 +34,7 @@ SET(SRCS efl/mobile/UiPopup.cpp efl/mobile/UiView.cpp efl/mobile/UiStandardView.cpp + efl/mobile/UiTabView.cpp efl/mobile/UiKeyListener.cpp efl/mobile/UiViewmgr.cpp efl/mobile/c/ui_application.cpp diff --git a/src/lib/efl/mobile/UiTabView.cpp b/src/lib/efl/mobile/UiTabView.cpp new file mode 100644 index 0000000..e337925 --- /dev/null +++ b/src/lib/efl/mobile/UiTabView.cpp @@ -0,0 +1,548 @@ +/* + * 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. + * + */ +#include +#include +#include +#include "../../../include/efl/mobile/UiMobileViewManager.h" + +using namespace std; +using namespace ui_viewmanager; +using namespace efl_viewmanager; + +/***********************************************************************************************/ +/* Internal class Implementation */ +/***********************************************************************************************/ + +namespace efl_viewmanager +{ + +class UiTabViewImpl +{ + friend class UiTabView; + +private: + UiTabView *_view = nullptr; + Elm_Layout *_layout = nullptr; //Base layout for view + Elm_Toolbar *_toolbar = nullptr; + bool _icon = false; + + struct _tabItem { + Elm_Object_Item *_item; + Eo *_itemContent; + int _itemId; + UiTabViewImpl *_tabView; + }; + + _tabItem *_selectedItem = nullptr; + list<_tabItem *> _itemList; //Tab item list. + + _tabItem *_getItem(int id) { + for (auto i : this->_itemList) { + if (i->_itemId == id) { + return i; + } + } + + LOGE("There is no id(%d) in the item list", id); + return nullptr; + } + + bool _createLayout(); + bool _destroyLayout(); + bool _createToolbar(); + +public: + explicit UiTabViewImpl(UiTabView *view); + ~UiTabViewImpl(); + + Eo *getBase() const; + Elm_Toolbar *getToolbar() { + return this->_toolbar; + } + + list<_tabItem *>& getItemList() { + return this->_itemList; + } + + _tabItem *getSelectedItem() { + return this->_selectedItem; + } + + bool addTab(int id); + + bool setTabIcon(int id, const char *icon); + + bool setTabLabel(int id, const char *label); + + bool setTabContent(int id, Eo *content); + + const char *getTabIcon(int id); + + const char *getTabLabel(int id); + + Eo *getTabContent(int id); + + const char *unsetTabIcon(int id); + + const char *unsetTabLabel(int id); + + Eo *unsetTabContent(int id); + + int getSelectedTab(); + + bool removeTab(int id); + + bool selectTab(int id); +}; + +} + +#define TABBAR_GROUP "tizen_view/tabbar/default" + +#define LAYOUT_VALIDATE() if (!layout) { \ + LOGE("Layout is invalid! UiTabView(%p)", this); \ + return false; \ + } + +bool UiTabViewImpl::_destroyLayout() +{ + if (!this->_layout) return false; + + evas_object_del(this->_layout); + evas_object_del(this->_toolbar); + this->_layout = NULL; + this->_toolbar = NULL; + this->_view->tabDeactivated(this->_selectedItem->_itemId); + this->_itemList.clear(); + + return true; +} + +bool UiTabViewImpl::_createLayout() +{ + if (this->_layout) return false; + + Elm_Layout *layout = elm_layout_add(this->_view->getParent()); + LAYOUT_VALIDATE(); + + char buf[PATH_MAX]; + snprintf(buf, sizeof(buf), "%s/ui-viewmgr.edj", EDJ_PATH); + + if (!elm_layout_file_set(layout, buf, TABBAR_GROUP)) { + LOGE("Failed to set file = UiTabView(%p), path(%s), group(%s)", this, buf, TABBAR_GROUP); + evas_object_del(layout); + return false; + } + + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + + this->_layout = layout; + + return true; +} + +bool UiTabViewImpl::_createToolbar() +{ + if (this->_toolbar) return false; + + Elm_Toolbar *toolbar = elm_toolbar_add(this->getBase()); + + elm_object_style_set(toolbar, "tabbar"); + elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_EXPAND); + elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE); + + elm_object_part_content_set(this->_layout, "tabbar", toolbar); + elm_object_signal_emit(this->_layout, "elm,state,tabbar,show", "viewmgr"); + + evas_object_event_callback_add(toolbar, EVAS_CALLBACK_SHOW, + [](void *data, Evas *e, Evas_Object *obj, void *event_info) -> void + { + auto *view = static_cast(data); + + elm_toolbar_item_selected_set(view->getSelectedItem()->_item, EINA_TRUE); + + view->_view->tabActivated(view->getSelectedItem()->_itemId); + + Eo *layout = view->getBase(); + Eo *content = view->getSelectedItem()->_itemContent; + if (content) elm_object_part_content_set(layout, "elm.swallow.content", content); + + elm_toolbar_select_mode_set(view->getToolbar(), ELM_OBJECT_SELECT_MODE_ALWAYS); + }, this); + + this->_toolbar = toolbar; + + return true; +} + +UiTabViewImpl::UiTabViewImpl(UiTabView *view) + : _view(view) +{ + _createToolbar(); +} + +UiTabViewImpl::~UiTabViewImpl() +{ + _destroyLayout(); +} + + +Eo *UiTabViewImpl::getBase() const +{ + if (!this->_layout) { + const_cast(this)->_createLayout(); + } + + return this->_layout; +} + +bool UiTabViewImpl::addTab(int id) +{ + for (auto i : this->_itemList) { + if (i->_itemId == id) { + LOGE("Given id(%d) is already reserved.", id); + return false; + } + } + + _tabItem *tabItem = new _tabItem; + + Elm_Object_Item *it = elm_toolbar_item_append(this->_toolbar, NULL, NULL, + [](void *data, Evas_Object *obj, void *event_info) + { + auto *tabItem = static_cast<_tabItem *>(data); + + if (tabItem == tabItem->_tabView->_selectedItem) return; + + Eo *layout = tabItem->_tabView->_view->getBase(); + Eo *content = tabItem->_itemContent; + + evas_object_hide(elm_object_part_content_unset(layout, "elm.swallow.content")); + tabItem->_tabView->_view->tabDeactivated(tabItem->_tabView->_selectedItem->_itemId); + + tabItem->_tabView->_view->tabActivated(tabItem->_itemId); + if (content) elm_object_part_content_set(layout, "elm.swallow.content", content); + + tabItem->_tabView->_selectedItem = tabItem; + }, tabItem); + + if (!it) { + LOGE("Failed to create tabbar item"); + return NULL; + } + + tabItem->_item = it; + tabItem->_itemId = id; + tabItem->_tabView = this; + elm_object_item_data_set(it, tabItem); + + this->_itemList.push_back(tabItem); + + if (this->_itemList.size() == 1) { + LOGE("WCC selcted it set!"); + this->_selectedItem = tabItem; + } + + return true; +} + +bool UiTabViewImpl::setTabIcon(int id, const char *icon) +{ + _tabItem *it = this->_getItem(id); + if (!it) return false; + + if (icon && !this->_icon) { + elm_object_signal_emit(this->_layout, "elm,state,tabbar,icon,show", "viewmgr"); + this->_icon = true; + } + else if (this->_icon) { + elm_object_signal_emit(this->_layout, "elm,state,tabbar,show", "viewmgr"); + this->_icon = false; + } + + elm_toolbar_item_icon_set(it->_item, icon); + + return true; +} + +bool UiTabViewImpl::setTabLabel(int id, const char *label) +{ + _tabItem *it = this->_getItem(id); + if (!it) return false; + + elm_object_item_text_set(it->_item, label); + + return true; +} + +bool UiTabViewImpl::setTabContent(int id, Eo *content) +{ + _tabItem *it = this->_getItem(id); + if (!it) return false; + + it->_itemContent = content; + evas_object_event_callback_add(content, EVAS_CALLBACK_DEL, + [](void *data, Evas *e, Evas_Object *obj, void *event_info) -> void + { + UiTabViewImpl *view = static_cast(data); + + for (auto i : view->getItemList()) { + if (i->_itemContent == obj) { + i->_itemContent = NULL; + break; + } + } + }, this); + + return true; +} + +const char *UiTabViewImpl::getTabIcon(int id) +{ + _tabItem *it = this->_getItem(id); + if (!it) return nullptr; + + return elm_toolbar_item_icon_get(it->_item); +} + +const char *UiTabViewImpl::getTabLabel(int id) +{ + _tabItem *it = this->_getItem(id); + if (!it) return nullptr; + + return elm_object_item_text_get(it->_item); +} + +Eo *UiTabViewImpl::getTabContent(int id) +{ + _tabItem *it = this->_getItem(id); + if (!it) return nullptr; + + return it->_item; +} + +const char *UiTabViewImpl::unsetTabIcon(int id) +{ + bool iconExist = false; + const char *icon; + _tabItem *it = this->_getItem(id); + if (!it) return nullptr; + + icon = elm_toolbar_item_icon_get(it->_item); + elm_toolbar_item_icon_set(it->_item, NULL); + + //Send a signal to change height size of toolbar, if there is a no item which has a icon. + if (this->_icon) { + for (auto i : this->_itemList) { + if (elm_toolbar_item_icon_get(i->_item)) { + iconExist = true; + break; + } + } + } + + if (!iconExist) { + elm_object_signal_emit(this->_layout, "elm,state,tabbar,show", "viewmgr"); + this->_icon = false; + } + + return icon; +} + +const char *UiTabViewImpl::unsetTabLabel(int id) +{ + const char *label; + _tabItem *it = this->_getItem(id); + if (!it) return nullptr; + + label = elm_object_item_text_get(it->_item); + elm_object_item_text_set(it->_item, NULL); + + return label; +} + +Eo *UiTabViewImpl::unsetTabContent(int id) +{ + Evas_Object *content; + _tabItem *it = this->_getItem(id); + if (!it) return nullptr; + + content = it->_itemContent; + evas_object_hide(content); + it->_itemContent = NULL; + + return content; +} + +int UiTabViewImpl::getSelectedTab() +{ + Elm_Object_Item* it = elm_toolbar_selected_item_get(this->_toolbar); + _tabItem* tabItem = static_cast<_tabItem *>(elm_object_item_data_get(it)); + + return tabItem->_itemId; +} + +bool UiTabViewImpl::removeTab(int id) +{ + _tabItem *it = this->_getItem(id); + if (!it) return false; + + elm_object_item_del(it->_item); + return true; +} + +bool UiTabViewImpl::selectTab(int id) +{ + _tabItem *it = this->_getItem(id); + if (!it) return false; + + if (evas_object_visible_get(this->_toolbar)) { + elm_toolbar_item_selected_set(it->_item, EINA_TRUE); + } + else { + this->_selectedItem = it; + } + + return true; +} + +/***********************************************************************************************/ +/* External class Implementation */ +/***********************************************************************************************/ + +UiTabView::UiTabView(const char *name) + : UiView(name) +{ + this->_impl = new UiTabViewImpl(this); +} + +UiTabView::~UiTabView() +{ + delete(this->_impl); +} + +void UiTabView::onLoad() +{ + UiView::onLoad(); + + Elm_Layout *layout = this->getBase(); + evas_object_show(layout); +} + +void UiTabView::onUnload() +{ + UiView::onUnload(); + + Elm_Layout *layout = this->getBase(); + evas_object_hide(layout); +} + +int UiTabView::setEventBlock(bool block) +{ + int ret = UiView::setEventBlock(block); + if (ret != UI_VIEWMGR_ERROR_NONE) return ret; + + evas_object_freeze_events_set(this->getBase(), block); + + return UI_VIEWMGR_ERROR_NONE; +} + +Eo *UiTabView::getBase() const +{ + return this->_impl->getBase(); +} + +bool UiTabView::addTab(int id) +{ + if (id < 0) { + LOGE("invalid index value. index value(%d) start since 0", id); + return NULL; + } + + return this->_impl->addTab(id); +} + +bool UiTabView::setTabIcon(int id, const char *icon) +{ + return this->_impl->setTabIcon(id, icon); +} + +bool UiTabView::setTabLabel(int id, const char *label) +{ + return this->_impl->setTabLabel(id, label); +} + +bool UiTabView::setTabContent(int id, Eo *content) +{ + return this->_impl->setTabContent(id, content); +} + +const char *UiTabView::getTabIcon(int id) +{ + return this->_impl->getTabIcon(id); +} + +const char *UiTabView::getTabLabel(int id) +{ + return this->_impl->getTabLabel(id); +} + +Eo *UiTabView::getTabContent(int id) +{ + return this->_impl->getTabContent(id); +} + +const char *UiTabView::unsetTabIcon(int id) +{ + return this->_impl->unsetTabIcon(id); +} + +const char *UiTabView::unsetTabLabel(int id) +{ + return this->_impl->unsetTabLabel(id); +} + +Eo *UiTabView::unsetTabContent(int id) +{ + return this->_impl->unsetTabContent(id); +} + +int UiTabView::getSelectedTab() +{ + return this->_impl->getSelectedTab(); +} + +bool UiTabView::removeTab(int id) +{ + return this->_impl->removeTab(id); +} + +bool UiTabView::selectTab(int id) +{ + return this->_impl->selectTab(id); +} + +void UiTabView::tabActivated(int id) +{ + +} + +void UiTabView::tabDeactivated(int id) +{ + +}