Tabview: C api wrapping, Define error code. 96/99896/1
authorWoochan Lee <wc0917.lee@samsung.com>
Thu, 24 Nov 2016 10:56:00 +0000 (19:56 +0900)
committerWoochan Lee <wc0917.lee@samsung.com>
Thu, 24 Nov 2016 10:56:34 +0000 (19:56 +0900)
Change-Id: I351b0deb63a87493a6721504699c0f95de28c60d

14 files changed:
src/examples/efl/c/CMakeLists.txt
src/examples/efl/c/main.h
src/examples/efl/c/page16.cpp
src/examples/efl/c/page17.cpp [new file with mode: 0644]
src/include/efl/mobile/UiTabView.h
src/include/efl/mobile/c/_ui_private.h
src/include/efl/mobile/c/ui_mobile_viewmanager.h
src/include/efl/mobile/c/ui_tab_view.h [new file with mode: 0644]
src/include/interface/_UiIfacePrivate.h
src/lib/CMakeLists.txt
src/lib/efl/UiBaseViewmgr.cpp
src/lib/efl/mobile/UiTabView.cpp
src/lib/efl/mobile/c/ui_standard_view.cpp
src/lib/efl/mobile/c/ui_tab_view.cpp [new file with mode: 0644]

index 8051a9a83e9ab298cb3ce88856a604153dee4667..b8a8e9c83ebdeb5f062c5792f1df4b72f093397e 100644 (file)
@@ -17,6 +17,7 @@ SET(SRCS
       page14.cpp
       page15.cpp
       page16.cpp
+      page17.cpp
    )
 
 ADD_EXECUTABLE(${BINNAME} ${SRCS})
index 9f41b12b7f92984eede08b4b232a32ae10dbcfaf..9480a797d6780c99c13d630cfc84c6bb02bf0f88 100644 (file)
@@ -55,3 +55,4 @@ void create_page13();
 void create_page14();
 void create_page15();
 void create_page16();
+void create_page17();
index c4c3bf787966f07bfd76701441cd8d881529bca4..e7bba944ddfa506b236d80235a70f3643f1887f1 100644 (file)
@@ -30,11 +30,7 @@ prev_btn_clicked_cb(void *data, Eo *obj, void *event_info)
 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
diff --git a/src/examples/efl/c/page17.cpp b/src/examples/efl/c/page17.cpp
new file mode 100644 (file)
index 0000000..5c30bcd
--- /dev/null
@@ -0,0 +1,205 @@
+/*
+ * 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);
+       }
+}
+
index 69b5f333e84b3b4b0f2e525905d216449ee0cf0e..7688db7f3a9006702b0706bbff9e621dc35f1bd8 100644 (file)
@@ -45,13 +45,13 @@ public:
        ///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);
 
@@ -67,9 +67,9 @@ public:
 
        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.
index 520011771b4778c50d03a955023d1beece5524d5..036aa63677e1e82ff681961f854a8cac7e5cec3c 100644 (file)
@@ -25,6 +25,7 @@ using namespace efl_viewmanager;
 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;
 
index d57cd602830152ec496df1453472f34257874dbb..855829c54acfed518d0d5ecb30bf2c99ce136309 100644 (file)
@@ -40,6 +40,7 @@
 
 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;
 
@@ -53,5 +54,6 @@ 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 */
diff --git a/src/include/efl/mobile/c/ui_tab_view.h b/src/include/efl/mobile/c/ui_tab_view.h
new file mode 100644 (file)
index 0000000..c7f1568
--- /dev/null
@@ -0,0 +1,50 @@
+#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_ */
index b468104e22988ba32ae6b76173e7c3370dd627f3..6d2bed1c929c82380def8e90d2591d6a3302fa79 100644 (file)
@@ -6,5 +6,6 @@
 #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_ */
index 55dc95c4ed01508e4385c3c19828e21cacaad9fb..c424fd51f71c91d307573e36884279b7bbe7497c 100644 (file)
@@ -42,6 +42,7 @@ SET(SRCS
      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()
index 797f11d8466c1a751816146870f268bc145629c1..754123a033628218e1a2ec4c7086615c5250238f 100644 (file)
@@ -547,5 +547,5 @@ void UiBaseViewmgr::setIndicator(UiViewIndicator indicator)
 
 int UiBaseViewmgr::activateTopView()
 {
-       this->_impl->activateTopView();
+       return this->_impl->activateTopView();
 }
index e33792534aca73dfdab1141408b735ce24920053..79877796a55f884384683b65e22d3c0976eaa82e 100644 (file)
@@ -53,11 +53,13 @@ private:
        _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;
        }
 
@@ -82,13 +84,13 @@ public:
                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);
 
@@ -104,9 +106,9 @@ public:
 
        int getSelectedTab();
 
-       bool removeTab(int id);
+       int removeTab(int id);
 
-       bool selectTab(int id);
+       int selectTab(int id);
 };
 
 }
@@ -173,6 +175,7 @@ bool UiTabViewImpl::_createToolbar()
                        [](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);
 
@@ -211,12 +214,12 @@ Eo *UiTabViewImpl::getBase() const
        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;
                }
        }
 
@@ -243,28 +246,26 @@ bool UiTabViewImpl::addTab(int id)
 
        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");
@@ -277,23 +278,23 @@ bool UiTabViewImpl::setTabIcon(int id, const char *icon)
 
        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,
@@ -309,7 +310,7 @@ bool UiTabViewImpl::setTabContent(int id, Eo *content)
                                }
                        }, this);
 
-       return true;
+       return UI_VIEWMGR_ERROR_NONE;;
 }
 
 const char *UiTabViewImpl::getTabIcon(int id)
@@ -392,24 +393,30 @@ Eo *UiTabViewImpl::unsetTabContent(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);
@@ -418,7 +425,7 @@ bool UiTabViewImpl::selectTab(int id)
                this->_selectedItem = it;
        }
 
-       return true;
+       return UI_VIEWMGR_ERROR_NONE;;
 }
 
 /***********************************************************************************************/
@@ -467,27 +474,27 @@ Eo *UiTabView::getBase() const
        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);
 }
@@ -527,12 +534,12 @@ int UiTabView::getSelectedTab()
        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);
 }
index cd171af2becba7b07cd6c0a71b8084423a7c8895..205a6664bdf08a15300a5a48f01a3559345a1af4 100644 (file)
@@ -215,7 +215,7 @@ static ui_standard_view_capi *validate_view(const ui_standard_view *view)
        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;
        }
 
diff --git a/src/lib/efl/mobile/c/ui_tab_view.cpp b/src/lib/efl/mobile/c/ui_tab_view.cpp
new file mode 100644 (file)
index 0000000..5016227
--- /dev/null
@@ -0,0 +1,382 @@
+#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);
+}