page14.cpp
page15.cpp
page16.cpp
+ page17.cpp
)
ADD_EXECUTABLE(${BINNAME} ${SRCS})
void create_page14();
void create_page15();
void create_page16();
+void create_page17();
static void
next_btn_clicked_cb(void *data, Eo *obj, void *event_info)
{
- int ret = ui_viewmgr_deactivate();
- if (ret != UI_VIEWMGR_ERROR_NONE)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "ui_viewmgr_deactivate() is failed. err = %d", ret);
- }
+ create_page17();
}
static void
--- /dev/null
+/*
+ * 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 "main.h"
+
+static void
+prev_btn_clicked_cb(void *data, Eo *obj, void *event_info)
+{
+ int ret = ui_viewmgr_pop_view();
+ if (ret != UI_VIEWMGR_ERROR_NONE)
+ {
+ dlog_print(DLOG_ERROR, LOG_TAG, "ui_viewmgr_pop_view() is failed. err = %d", ret);
+ }
+}
+
+static void
+next_btn_clicked_cb(void *data, Eo *obj, void *event_info)
+{
+ int ret = ui_viewmgr_deactivate();
+ if (ret != UI_VIEWMGR_ERROR_NONE)
+ {
+ dlog_print(DLOG_ERROR, LOG_TAG, "ui_viewmgr_deactivate() is failed. err = %d", ret);
+ }
+}
+
+static void
+tab_activated(ui_tab_view *view, int id, void *user_data)
+{
+ printf("%d is activated. \n", id);
+}
+
+static void
+tab_deactivated(ui_tab_view *view, int id, void *user_data)
+{
+ printf("%d is deactivated. \n", id);
+}
+
+static bool
+view17_load_cb(ui_tab_view *view, void *user_data)
+{
+ Eo *base = NULL;
+ Eo *content1, *content2, *content3 = NULL;
+ int ret;
+
+ //Get a base object from view.
+ base = ui_view_get_base(view);
+ if (!base)
+ {
+ dlog_print(DLOG_ERROR, LOG_TAG, "failed to get a view base object");
+ return false;
+ }
+
+ //Create tab item content.
+ content1 = create_content(base, "ViewMgr Demo<br>Alarm Tab", prev_btn_clicked_cb, next_btn_clicked_cb);
+ if (!content1) return false;
+
+ content2 = create_content(base, "ViewMgr Demo<br>Timer Tab", prev_btn_clicked_cb, next_btn_clicked_cb);
+ if (!content2) return false;
+
+ content3 = create_content(base, "ViewMgr Demo<br>World Clock Tab", prev_btn_clicked_cb, next_btn_clicked_cb);
+ if (!content3) return false;
+
+ //Add tab items.
+ ret = ui_tab_view_add_tab(view, 0);
+ if (ret != UI_VIEWMGR_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "failed to add tab item");
+ return false;
+ }
+ ret = ui_tab_view_add_tab(view, 1);
+ if (ret != UI_VIEWMGR_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "failed to add tab item");
+ return false;
+ }
+ ret = ui_tab_view_add_tab(view, 2);
+ if (ret != UI_VIEWMGR_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "failed to add tab item");
+ return false;
+ }
+
+ ret = ui_tab_view_set_tab_label(view, 0, "Alarm");
+ if (ret != UI_VIEWMGR_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "failed to set tab label");
+ return false;
+ }
+
+ ret = ui_tab_view_set_tab_label(view, 1, "Timer");
+ if (ret != UI_VIEWMGR_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "failed to set tab label");
+ return false;
+ }
+
+ ret = ui_tab_view_set_tab_label(view, 2, "World Clock");
+ if (ret != UI_VIEWMGR_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "failed to set tab label");
+ return false;
+ }
+
+ ret = ui_tab_view_set_tab_icon(view, 0, BINDIR"/data/images/icon_alarm.png");
+ if (ret != UI_VIEWMGR_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "failed to set tab icon");
+ return false;
+ }
+
+ ret = ui_tab_view_set_tab_icon(view, 1, BINDIR"/data/images/icon_timer.png");
+ if (ret != UI_VIEWMGR_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "failed to set tab icon");
+ return false;
+ }
+
+ ret = ui_tab_view_set_tab_icon(view, 2, BINDIR"/data/images/icon_worldclock.png");
+ if (ret != UI_VIEWMGR_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "failed to set tab icon");
+ return false;
+ }
+
+ ret = ui_tab_view_set_tab_content(view, 0, content1);
+ if (ret != UI_VIEWMGR_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "failed to set tab content");
+ return false;
+ }
+
+ ret = ui_tab_view_set_tab_content(view, 1, content2);
+ if (ret != UI_VIEWMGR_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "failed to set tab content");
+ return false;
+ }
+
+ ret = ui_tab_view_set_tab_content(view, 2, content3);
+ if (ret != UI_VIEWMGR_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "failed to set tab content");
+ return false;
+ }
+
+ ret = ui_tab_view_select_tab(view, 2);
+ if (ret != UI_VIEWMGR_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "failed to set tab content");
+ return false;
+ }
+
+ return true;
+}
+
+void
+create_page17()
+{
+ int ret = 0;
+ ui_tab_view *view = NULL;
+
+ view = ui_tab_view_create("page17");
+ if (!view)
+ {
+ dlog_print(DLOG_ERROR, LOG_TAG, "failed to create a view");
+ return;
+ }
+
+ //Set View Load callback.
+ ret = ui_tab_view_set_event_cb(view, UI_TAB_ACTIVATED, tab_activated, NULL);
+ if (ret != UI_VIEWMGR_ERROR_NONE)
+ {
+ dlog_print(DLOG_ERROR, LOG_TAG, "ui_tab_view_set_event_cb() is failed. err = %d", ret);
+ ui_view_destroy(view);
+ return;
+ }
+
+ //Set View Load callback.
+ ret = ui_tab_view_set_event_cb(view, UI_TAB_DEACTIVATED, tab_deactivated, NULL);
+ if (ret != UI_VIEWMGR_ERROR_NONE)
+ {
+ dlog_print(DLOG_ERROR, LOG_TAG, "ui_tab_view_set_event_cb() is failed. err = %d", ret);
+ ui_view_destroy(view);
+ return;
+ }
+
+ //Set View Load callback.
+ ret = ui_view_set_event_cb(view, UI_VIEW_EVENT_LOAD, view17_load_cb, NULL);
+ if (ret != UI_VIEWMGR_ERROR_NONE)
+ {
+ dlog_print(DLOG_ERROR, LOG_TAG, "ui_view_set_event_cb() is failed. err = %d", ret);
+ ui_view_destroy(view);
+ return;
+ }
+
+ //Push view.
+ ret = ui_viewmgr_push_view(view);
+ if (ret != UI_VIEWMGR_ERROR_NONE)
+ {
+ dlog_print(DLOG_ERROR, LOG_TAG, "ui_viewmgr_push_view() is failed. err = %d", ret);
+ ui_view_destroy(view);
+ }
+}
+
///Destructor.
virtual ~UiTabView();
- bool addTab(int id);
+ int addTab(int id);
- bool setTabIcon(int id, const char *icon);
+ int setTabIcon(int id, const char *icon);
- bool setTabLabel(int id, const char *label);
+ int setTabLabel(int id, const char *label);
- bool setTabContent(int id, Eo *content);
+ int setTabContent(int id, Eo *content);
const char *getTabIcon(int id);
int getSelectedTab();
- bool removeTab(int id);
+ int removeTab(int id);
- bool selectTab(int id);
+ int selectTab(int id);
/**
* @brief Get a base layout of viewmgr.
using ui_viewmgr = UiViewmgr;
using ui_view = UiView;
using ui_standard_view = UiStandardView;
+using ui_tab_view = UiTabView;
using ui_menu = UiMenu;
using ui_popup = UiPopup;
typedef struct ui_view_s ui_view;
typedef ui_view ui_standard_view;
+typedef ui_view ui_tab_view;
typedef struct ui_menu_s ui_menu;
typedef struct ui_popup_s ui_popup;
#include "ui_viewmgr.h"
#include "ui_view.h"
#include "ui_standard_view.h"
+#include "ui_tab_view.h"
#endif /* UI_MOBILE_VIEWMANAGER_CAPI_H */
--- /dev/null
+#ifndef _UI_TAB_VIEW_CAPI_H_
+#define _UI_TAB_VIEW_CAPI_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void (*ui_tab_view_event_cb)(ui_tab_view *view, int id, void *user_data);
+
+typedef enum
+{
+ UI_TAB_ACTIVATED = 0,
+ UI_TAB_DEACTIVATED
+} ui_tab_view_event_type_e;
+
+EAPI ui_tab_view *ui_tab_view_create(const char *name);
+
+EAPI int ui_tab_view_set_event_cb(ui_tab_view *view, ui_tab_view_event_type_e event_type, ui_tab_view_event_cb event_cb, void *user_data);
+
+EAPI int ui_tab_view_add_tab(ui_tab_view *view, int id);
+
+EAPI int ui_tab_view_set_tab_icon(ui_tab_view *view, int id, const char *icon);
+
+EAPI int ui_tab_view_set_tab_label(ui_tab_view *view, int id, const char *label);
+
+EAPI int ui_tab_view_set_tab_content(ui_tab_view *view, int id, Eo *content);
+
+EAPI const char *ui_tab_view_get_tab_icon(ui_tab_view *view, int id);
+
+EAPI const char *ui_tab_view_get_tab_label(ui_tab_view *view,int id);
+
+EAPI Eo *ui_tab_view_get_tab_content(ui_tab_view *view, int id);
+
+EAPI const char *ui_tab_view_unset_tab_icon(ui_tab_view *view, int id);
+
+EAPI const char *ui_tab_view_unset_tab_label(ui_tab_view *view, int id);
+
+EAPI Eo *ui_tab_view_unset_tab_content(ui_tab_view *view, int id);
+
+EAPI int ui_tab_view_get_selected_tab(ui_tab_view *view);
+
+EAPI int ui_tab_view_remove_tab(ui_tab_view *view, int id);
+
+EAPI int ui_tab_view_select_tab(ui_tab_view *view, int id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _UI_TAB_VIEW_CAPI_H_ */
#define _NUM_OF_UI_VIEW_INDICATOR 6
#define _NUM_OF_UI_VIEW_STATE 6
#define _NUM_OF_UI_VIEW_ORIENTATION_MODE 3
+#define _NUM_OF_UI_TAB_VIEW_EVENT_TYPE 2
#endif /* _UI_IFACE_PRIVATE_H_ */
efl/mobile/c/ui_popup.cpp
efl/mobile/c/ui_view.cpp
efl/mobile/c/ui_standard_view.cpp
+ efl/mobile/c/ui_tab_view.cpp
efl/mobile/c/ui_viewmgr.cpp
)
ENDIF()
int UiBaseViewmgr::activateTopView()
{
- this->_impl->activateTopView();
+ return this->_impl->activateTopView();
}
_tabItem *_getItem(int id) {
for (auto i : this->_itemList) {
if (i->_itemId == id) {
+ set_last_result(UI_VIEWMGR_ERROR_NONE);
return i;
}
}
LOGE("There is no id(%d) in the item list", id);
+ set_last_result(UI_VIEWMGR_ERROR_INVALID_PARAMETER);
return nullptr;
}
return this->_selectedItem;
}
- bool addTab(int id);
+ int addTab(int id);
- bool setTabIcon(int id, const char *icon);
+ int setTabIcon(int id, const char *icon);
- bool setTabLabel(int id, const char *label);
+ int setTabLabel(int id, const char *label);
- bool setTabContent(int id, Eo *content);
+ int setTabContent(int id, Eo *content);
const char *getTabIcon(int id);
int getSelectedTab();
- bool removeTab(int id);
+ int removeTab(int id);
- bool selectTab(int id);
+ int selectTab(int id);
};
}
[](void *data, Evas *e, Evas_Object *obj, void *event_info) -> void
{
auto *view = static_cast<UiTabViewImpl *>(data);
+ if (!view->getSelectedItem()) return;
elm_toolbar_item_selected_set(view->getSelectedItem()->_item, EINA_TRUE);
return this->_layout;
}
-bool UiTabViewImpl::addTab(int id)
+int UiTabViewImpl::addTab(int id)
{
for (auto i : this->_itemList) {
if (i->_itemId == id) {
LOGE("Given id(%d) is already reserved.", id);
- return false;
+ return UI_VIEWMGR_ERROR_INVALID_PARAMETER;
}
}
if (!it) {
LOGE("Failed to create tabbar item");
- return NULL;
+ return UI_VIEWMGR_ERROR_OUT_OF_MEMORY;
}
tabItem->_item = it;
+ tabItem->_itemContent = nullptr;
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;
- }
+ if (this->_itemList.size() == 1) this->_selectedItem = tabItem;
- return true;
+ return UI_VIEWMGR_ERROR_NONE;
}
-bool UiTabViewImpl::setTabIcon(int id, const char *icon)
+int UiTabViewImpl::setTabIcon(int id, const char *icon)
{
_tabItem *it = this->_getItem(id);
- if (!it) return false;
+ if (!it) return UI_VIEWMGR_ERROR_INVALID_PARAMETER;
if (icon && !this->_icon) {
elm_object_signal_emit(this->_layout, "elm,state,tabbar,icon,show", "viewmgr");
elm_toolbar_item_icon_set(it->_item, icon);
- return true;
+ return UI_VIEWMGR_ERROR_NONE;
}
-bool UiTabViewImpl::setTabLabel(int id, const char *label)
+int UiTabViewImpl::setTabLabel(int id, const char *label)
{
_tabItem *it = this->_getItem(id);
- if (!it) return false;
+ if (!it) return UI_VIEWMGR_ERROR_INVALID_PARAMETER;
elm_object_item_text_set(it->_item, label);
- return true;
+ return UI_VIEWMGR_ERROR_NONE;;
}
-bool UiTabViewImpl::setTabContent(int id, Eo *content)
+int UiTabViewImpl::setTabContent(int id, Eo *content)
{
_tabItem *it = this->_getItem(id);
- if (!it) return false;
+ if (!it) return UI_VIEWMGR_ERROR_INVALID_PARAMETER;
it->_itemContent = content;
evas_object_event_callback_add(content, EVAS_CALLBACK_DEL,
}
}, this);
- return true;
+ return UI_VIEWMGR_ERROR_NONE;;
}
const char *UiTabViewImpl::getTabIcon(int id)
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));
+ if (it) {
+ _tabItem* tabItem = static_cast<_tabItem *>(elm_object_item_data_get(it));
+
+ set_last_result(UI_VIEWMGR_ERROR_NONE);
+ return tabItem->_itemId;
+ }
- return tabItem->_itemId;
+ set_last_result(UI_VIEWMGR_ERROR_NOT_PERMITTED);
+ return -1;
}
-bool UiTabViewImpl::removeTab(int id)
+int UiTabViewImpl::removeTab(int id)
{
_tabItem *it = this->_getItem(id);
- if (!it) return false;
+ if (!it) return UI_VIEWMGR_ERROR_INVALID_PARAMETER;
elm_object_item_del(it->_item);
- return true;
+ return UI_VIEWMGR_ERROR_NONE;;
}
-bool UiTabViewImpl::selectTab(int id)
+int UiTabViewImpl::selectTab(int id)
{
_tabItem *it = this->_getItem(id);
- if (!it) return false;
+ if (!it) return UI_VIEWMGR_ERROR_INVALID_PARAMETER;
if (evas_object_visible_get(this->_toolbar)) {
elm_toolbar_item_selected_set(it->_item, EINA_TRUE);
this->_selectedItem = it;
}
- return true;
+ return UI_VIEWMGR_ERROR_NONE;;
}
/***********************************************************************************************/
return this->_impl->getBase();
}
-bool UiTabView::addTab(int id)
+int UiTabView::addTab(int id)
{
if (id < 0) {
LOGE("invalid index value. index value(%d) start since 0", id);
- return NULL;
+ return UI_VIEWMGR_ERROR_INVALID_PARAMETER;;
}
return this->_impl->addTab(id);
}
-bool UiTabView::setTabIcon(int id, const char *icon)
+int UiTabView::setTabIcon(int id, const char *icon)
{
return this->_impl->setTabIcon(id, icon);
}
-bool UiTabView::setTabLabel(int id, const char *label)
+int UiTabView::setTabLabel(int id, const char *label)
{
return this->_impl->setTabLabel(id, label);
}
-bool UiTabView::setTabContent(int id, Eo *content)
+int UiTabView::setTabContent(int id, Eo *content)
{
return this->_impl->setTabContent(id, content);
}
return this->_impl->getSelectedTab();
}
-bool UiTabView::removeTab(int id)
+int UiTabView::removeTab(int id)
{
return this->_impl->removeTab(id);
}
-bool UiTabView::selectTab(int id)
+int UiTabView::selectTab(int id)
{
return this->_impl->selectTab(id);
}
auto capi_view = dynamic_cast<ui_standard_view_capi *>(const_cast<ui_standard_view*>(view));
if (!capi_view)
{
- LOGE("Invalid ui_standard_view = %p. Probably, you passed ui_view, not ui_standard_view.", view);
+ LOGE("Invalid ui_standard_view = %p. Probably, you passed other type of view, not ui_tab_view.", view);
return nullptr;
}
--- /dev/null
+#include "../../../../include/efl/mobile/c/_ui_private.h"
+#include "../../../../include/efl/mobile/c/ui_view.h"
+#include "../../../../include/efl/mobile/c/ui_tab_view.h"
+#include "../../../../include/efl/mobile/c/_ui_common_view_capi.h"
+
+static const char *_this_type = "ui_tab_view";
+
+class ui_tab_view_capi: public ui_tab_view, public ui_common_view_capi
+{
+public:
+ ui_tab_view_event_cb tab_event_cb[_NUM_OF_UI_TAB_VIEW_EVENT_TYPE] = {nullptr, };
+ void *tab_event_data[_NUM_OF_UI_TAB_VIEW_EVENT_TYPE] = {nullptr, };
+
+ void onLoad() override
+ {
+ if (this->event_cb[UI_VIEW_EVENT_LOAD])
+ {
+ if (!this->event_cb[UI_VIEW_EVENT_LOAD](this, this->event_data[UI_VIEW_EVENT_LOAD])) return;
+ }
+
+ ui_tab_view::onLoad();
+
+ if (this->event_cb[UI_VIEW_EVENT_LOAD_POST])
+ {
+ if (!this->event_cb[UI_VIEW_EVENT_LOAD_POST](this, this->event_data[UI_VIEW_EVENT_LOAD_POST])) return;
+ }
+ }
+
+ void onUnload() override
+ {
+ if (this->event_cb[UI_VIEW_EVENT_UNLOAD])
+ {
+ if (!this->event_cb[UI_VIEW_EVENT_UNLOAD](this, this->event_data[UI_VIEW_EVENT_UNLOAD])) return;
+ }
+
+ ui_tab_view::onUnload();
+
+ if (this->event_cb[UI_VIEW_EVENT_UNLOAD_POST])
+ {
+ if (!this->event_cb[UI_VIEW_EVENT_UNLOAD_POST](this, this->event_data[UI_VIEW_EVENT_UNLOAD_POST])) return;
+ }
+ }
+
+ void onPause() override
+ {
+ if (this->event_cb[UI_VIEW_EVENT_PAUSE])
+ {
+ if (!this->event_cb[UI_VIEW_EVENT_PAUSE](this, this->event_data[UI_VIEW_EVENT_PAUSE])) return;
+ }
+
+ ui_tab_view::onPause();
+
+ if (this->event_cb[UI_VIEW_EVENT_PAUSE_POST])
+ {
+ if (!this->event_cb[UI_VIEW_EVENT_PAUSE_POST](this, this->event_data[UI_VIEW_EVENT_PAUSE_POST])) return;
+ }
+ }
+
+ void onResume() override
+ {
+ if (this->event_cb[UI_VIEW_EVENT_RESUME])
+ {
+ if (!this->event_cb[UI_VIEW_EVENT_RESUME](this, this->event_data[UI_VIEW_EVENT_RESUME])) return;
+ }
+
+ ui_tab_view::onResume();
+
+ if (this->event_cb[UI_VIEW_EVENT_RESUME_POST])
+ {
+ if (!this->event_cb[UI_VIEW_EVENT_RESUME_POST](this, this->event_data[UI_VIEW_EVENT_RESUME_POST])) return;
+ }
+ }
+
+ void onActivate() override
+ {
+ if (this->event_cb[UI_VIEW_EVENT_ACTIVATE])
+ {
+ if (!this->event_cb[UI_VIEW_EVENT_ACTIVATE](this, this->event_data[UI_VIEW_EVENT_ACTIVATE])) return;
+ }
+
+ ui_tab_view::onActivate();
+
+ if (this->event_cb[UI_VIEW_EVENT_ACTIVATE_POST])
+ {
+ if (!this->event_cb[UI_VIEW_EVENT_ACTIVATE_POST](this, this->event_data[UI_VIEW_EVENT_ACTIVATE_POST])) return;
+ }
+ }
+
+ void onDeactivate() override
+ {
+ if (this->event_cb[UI_VIEW_EVENT_DEACTIVATE])
+ {
+ if (!this->event_cb[UI_VIEW_EVENT_DEACTIVATE](this, this->event_data[UI_VIEW_EVENT_DEACTIVATE])) return;
+ }
+
+ ui_tab_view::onDeactivate();
+
+ if (this->event_cb[UI_VIEW_EVENT_DEACTIVATE_POST])
+ {
+ if (!this->event_cb[UI_VIEW_EVENT_DEACTIVATE_POST](this, this->event_data[UI_VIEW_EVENT_DEACTIVATE_POST])) return;
+ }
+ }
+
+ void onDestroy() override
+ {
+ if (this->event_cb[UI_VIEW_EVENT_DESTROY])
+ {
+ if (!this->event_cb[UI_VIEW_EVENT_DESTROY](this, this->event_data[UI_VIEW_EVENT_DESTROY])) return;
+ }
+
+ ui_tab_view::onDestroy();
+
+ if (this->event_cb[UI_VIEW_EVENT_DESTROY_POST])
+ {
+ if (!this->event_cb[UI_VIEW_EVENT_DESTROY_POST](this, this->event_data[UI_VIEW_EVENT_DESTROY_POST])) return;
+ }
+ }
+
+ void onPortrait() override
+ {
+ if (this->event_cb[UI_VIEW_EVENT_PORTRAIT])
+ {
+ if (!(*this->event_cb[UI_VIEW_EVENT_PORTRAIT])(this, this->event_data[UI_VIEW_EVENT_PORTRAIT])) return;
+ }
+
+ ui_tab_view::onPortrait();
+
+ if (this->event_cb[UI_VIEW_EVENT_PORTRAIT_POST])
+ {
+ if (!(*this->event_cb[UI_VIEW_EVENT_PORTRAIT_POST])(this, this->event_data[UI_VIEW_EVENT_PORTRAIT_POST])) return;
+ }
+ }
+
+ void onLandscape() override
+ {
+ if (this->event_cb[UI_VIEW_EVENT_LANDSCAPE])
+ {
+ if (!(*this->event_cb[UI_VIEW_EVENT_LANDSCAPE])(this, this->event_data[UI_VIEW_EVENT_LANDSCAPE])) return;
+ }
+
+ ui_tab_view::onLandscape();
+
+ if (this->event_cb[UI_VIEW_EVENT_LANDSCAPE_POST])
+ {
+ if (!(*this->event_cb[UI_VIEW_EVENT_LANDSCAPE_POST])(this, this->event_data[UI_VIEW_EVENT_LANDSCAPE_POST])) return;
+ }
+ }
+
+ void onRotate(int degree) override
+ {
+ if (this->event_cb[UI_VIEW_EVENT_ROTATE])
+ {
+ if (!(*this->event_cb[UI_VIEW_EVENT_ROTATE])(this, this->event_data[UI_VIEW_EVENT_ROTATE])) return;
+ }
+
+ ui_tab_view::onRotate(degree);
+
+ if (this->event_cb[UI_VIEW_EVENT_ROTATE_POST])
+ {
+ if (!(*this->event_cb[UI_VIEW_EVENT_ROTATE_POST])(this, this->event_data[UI_VIEW_EVENT_ROTATE_POST])) return;
+ }
+ }
+
+ void onBack() override
+ {
+ if (this->event_cb[UI_VIEW_EVENT_BACK])
+ {
+ if (!(*this->event_cb[UI_VIEW_EVENT_BACK])(this, this->event_data[UI_VIEW_EVENT_BACK])) return;
+ }
+
+ ui_tab_view::onBack();
+
+ if (this->event_cb[UI_VIEW_EVENT_BACK_POST])
+ {
+ if (!(*this->event_cb[UI_VIEW_EVENT_BACK_POST])(this, this->event_data[UI_VIEW_EVENT_BACK_POST])) return;
+ }
+ }
+
+ void onMenu(ui_menu *menu) override
+ {
+ if (this->event_cb[UI_VIEW_EVENT_MENU])
+ {
+ if (!(*this->event_cb[UI_VIEW_EVENT_MENU])(this, this->event_data[UI_VIEW_EVENT_MENU])) return;
+ }
+
+ ui_tab_view::onMenu(menu);
+
+ if (this->event_cb[UI_VIEW_EVENT_MENU_POST])
+ {
+ if (!(*this->event_cb[UI_VIEW_EVENT_MENU_POST])(this, this->event_data[UI_VIEW_EVENT_MENU_POST])) return;
+ }
+ }
+
+ ui_tab_view_capi(const char *name)
+ : ui_tab_view(name), ui_common_view_capi(_this_type)
+ {
+ }
+
+ ~ui_tab_view_capi()
+ {
+ }
+
+protected:
+ void tabActivated(int id)
+ {
+ if (this->tab_event_cb[UI_TAB_ACTIVATED])
+ {
+ (*this->tab_event_cb[UI_TAB_ACTIVATED])(this, id, this->tab_event_data[UI_TAB_ACTIVATED]);
+ }
+ }
+
+ void tabDeactivated(int id)
+ {
+ if (this->tab_event_cb[UI_TAB_DEACTIVATED])
+ {
+ (*this->tab_event_cb[UI_TAB_DEACTIVATED])(this, id, this->tab_event_data[UI_TAB_DEACTIVATED]);
+ }
+ }
+
+};
+
+struct ui_tab_view_s
+{
+ ui_tab_view_capi *p;
+};
+
+static ui_tab_view_capi *validate_view(const ui_tab_view *view)
+{
+ if (!view)
+ {
+ LOGE("Invalid ui_tab_view = nullptr");
+ set_last_result(UI_VIEWMGR_ERROR_INVALID_PARAMETER);
+ return nullptr;
+ }
+
+ auto capi_view = dynamic_cast<ui_tab_view_capi *>(const_cast<ui_tab_view*>(view));
+ if (!capi_view)
+ {
+ LOGE("Invalid ui_tab_view = %p. Probably, you passed other type of view, not ui_tab_view.", view);
+ return nullptr;
+ }
+
+ return capi_view;
+}
+
+EAPI int ui_tab_view_set_event_cb(ui_tab_view *view, ui_tab_view_event_type_e event_type, ui_tab_view_event_cb event_cb, void *user_data)
+{
+ ui_tab_view_capi *capi_view = validate_view(view);
+ if (!capi_view) return UI_VIEWMGR_ERROR_INVALID_PARAMETER;
+
+ if (event_type < UI_TAB_ACTIVATED || event_type >= _NUM_OF_UI_TAB_VIEW_EVENT_TYPE)
+ {
+ LOGE("This view(%p) event_type is invalid(%d)", view, event_type);
+ return UI_VIEWMGR_ERROR_INVALID_PARAMETER;
+ }
+
+ capi_view->tab_event_cb[event_type] = event_cb;
+ capi_view->tab_event_data[event_type] = user_data;
+
+ return UI_VIEWMGR_ERROR_NONE;
+}
+
+
+EAPI ui_tab_view *ui_tab_view_create(const char *name)
+{
+ ui_tab_view *view = new ui_tab_view_capi(name);
+
+ if (!view)
+ {
+ LOGE("Failed to create new ui_tab_view instance");
+ set_last_result(UI_VIEWMGR_ERROR_OUT_OF_MEMORY);
+ return nullptr;
+ }
+
+ set_last_result(UI_VIEWMGR_ERROR_NONE);
+ return new ui_tab_view_capi(name);
+}
+
+EAPI int ui_tab_view_add_tab(ui_tab_view *view, int id)
+{
+ ui_tab_view_capi *capi_view = validate_view(view);
+ if (!capi_view) return UI_VIEWMGR_ERROR_INVALID_PARAMETER;
+
+ return capi_view->addTab(id);
+}
+
+EAPI int ui_tab_view_set_tab_icon(ui_tab_view *view, int id, const char *icon)
+{
+ ui_tab_view_capi *capi_view = validate_view(view);
+ if (!capi_view) return UI_VIEWMGR_ERROR_INVALID_PARAMETER;
+
+ return capi_view->setTabIcon(id, icon);
+}
+
+EAPI int ui_tab_view_set_tab_label(ui_tab_view *view, int id, const char *label)
+{
+ ui_tab_view_capi *capi_view = validate_view(view);
+ if (!capi_view) return UI_VIEWMGR_ERROR_INVALID_PARAMETER;
+
+ return capi_view->setTabLabel(id, label);
+}
+
+EAPI int ui_tab_view_set_tab_content(ui_tab_view *view, int id, Eo *content)
+{
+ ui_tab_view_capi *capi_view = validate_view(view);
+ if (!capi_view) return UI_VIEWMGR_ERROR_INVALID_PARAMETER;
+
+ return capi_view->setTabContent(id, content);
+}
+
+EAPI const char *ui_tab_view_get_tab_icon(ui_tab_view *view, int id)
+{
+ ui_tab_view_capi *capi_view = validate_view(view);
+ if (!capi_view) return NULL;
+
+ return capi_view->getTabIcon(id);
+}
+
+EAPI const char *ui_tab_view_get_tab_label(ui_tab_view *view,int id)
+{
+ ui_tab_view_capi *capi_view = validate_view(view);
+ if (!capi_view) return NULL;
+
+ return capi_view->getTabLabel(id);
+}
+
+EAPI Eo *ui_tab_view_get_tab_content(ui_tab_view *view, int id)
+{
+ ui_tab_view_capi *capi_view = validate_view(view);
+ if (!capi_view) return NULL;
+
+ return capi_view->getTabContent(id);
+}
+
+EAPI const char *ui_tab_view_unset_tab_icon(ui_tab_view *view, int id)
+{
+ ui_tab_view_capi *capi_view = validate_view(view);
+ if (!capi_view) return NULL;
+
+ return capi_view->unsetTabIcon(id);
+}
+
+EAPI const char *ui_tab_view_unset_tab_label(ui_tab_view *view, int id)
+{
+ ui_tab_view_capi *capi_view = validate_view(view);
+ if (!capi_view) return NULL;
+
+ return capi_view->unsetTabLabel(id);
+}
+
+EAPI Eo *ui_tab_view_unset_tab_content(ui_tab_view *view, int id)
+{
+ ui_tab_view_capi *capi_view = validate_view(view);
+ if (!capi_view) return NULL;
+
+ return capi_view->unsetTabContent(id);
+}
+
+
+EAPI int ui_tab_view_select_tab(ui_tab_view *view, int id)
+{
+ ui_tab_view_capi *capi_view = validate_view(view);
+ if (!capi_view) return UI_VIEWMGR_ERROR_INVALID_PARAMETER;
+
+ return capi_view->selectTab(id);
+}
+
+EAPI int ui_tab_view_get_selected_tab(ui_tab_view *view)
+{
+ ui_tab_view_capi *capi_view = validate_view(view);
+ if (!capi_view) return UI_VIEWMGR_ERROR_INVALID_PARAMETER;
+
+ return capi_view->getSelectedTab();
+}
+
+EAPI int ui_tab_view_remove_tab(ui_tab_view *view, int id)
+{
+ ui_tab_view_capi *capi_view = validate_view(view);
+ if (!capi_view) return UI_VIEWMGR_ERROR_INVALID_PARAMETER;
+
+ return capi_view->removeTab(id);
+}