From: Hermet Park Date: Thu, 18 Feb 2016 10:37:42 +0000 (+0900) Subject: updated implementation. X-Git-Tag: submit/tizen/20160617.075742~144 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=604b435653aee78f2a5a8689b39a7b36e4e41941;p=platform%2Fcore%2Fuifw%2Fui-viewmgr.git updated implementation. reorganize folder hierarchy for view manager. Change-Id: I1b1a88f6a71c4262eea4fc97f88d4e1d826732fb --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 985d7ae..f25fd7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,15 +3,15 @@ PROJECT(ui-viewmgr) SET(PACKAGE org.tizen.ui-viewmgr) SET(SRCS - src/ui_controller.cpp - src/ui_view.cpp - src/ui_viewmgr.cpp - src/ui_controller_base.cpp - src/ui_view_base.cpp - src/ui_viewmgr_base.cpp - src/ui_basic_view.cpp - src/main.cpp - ) + src/efl/ui_controller.cpp + src/efl/ui_view.cpp + src/efl/ui_viewmgr.cpp + src/interface/ui_controller_base.cpp + src/interface/ui_view_base.cpp + src/interface/ui_viewmgr_base.cpp + src/efl/mobile/ui_basic_view.cpp + src/main.cpp + ) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/inc) diff --git a/inc/main.h b/inc/main.h index 6052e48..4cf5095 100644 --- a/inc/main.h +++ b/inc/main.h @@ -18,7 +18,7 @@ #include #include #include -#include "../src/efl_viewmgr.h" +#include "../src/efl/mobile/efl_viewmgr.h" //uncomment if you want debug #ifndef TIZEN_ENGINEER_MODE @@ -30,17 +30,14 @@ #endif #define LOG_TAG "VIEWMGR" - #if !defined(PACKAGE) #define PACKAGE "org.tizen.ui-viewmgr" #endif - -#define ELM_DEMO_EDJ "/opt/usr/apps/org.tizen.ui-viewmgr/res/ui-viewmgr.edj" - +using namespace efl; typedef struct appdata { ui_viewmgr *viewmgr; } appdata_s; -void view_cb(void *data, Evas_Object *obj, void *event_info); +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/app_controller.h b/src/app_controller.h deleted file mode 100644 index 80c8d44..0000000 --- a/src/app_controller.h +++ /dev/null @@ -1,253 +0,0 @@ -#include "ui_controller.h" - -static 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 *grid, *box, *layout, *scroller, *btn, *button_layout; - - /* Scroller */ - scroller = elm_scroller_add(parent); - elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE); - elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO); - - /* Grid */ - grid = elm_grid_add(scroller); - evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_show(grid); - - /* NoContent Layout */ - layout = elm_layout_add(grid); - elm_layout_theme_set(layout, "layout", "nocontents", "default"); - elm_object_part_text_set(layout, "elm.text", text); - evas_object_show(layout); - elm_grid_pack(grid, layout, 0, 0, 100, 100); - - /* Previous Page Button */ - btn = elm_button_add(grid); - elm_object_text_set(btn, "Prev"); - evas_object_smart_callback_add(btn, "clicked", prev_btn_clicked_cb, ad); - evas_object_show(btn); - elm_grid_pack(grid, btn, 10, 90, 30, 8); - - /* Next Page Button */ - btn = elm_button_add(grid); - elm_object_text_set(btn, "Next"); - evas_object_smart_callback_add(btn, "clicked", next_btn_clicked_cb, ad); - evas_object_show(btn); - elm_grid_pack(grid, btn, 60, 90, 30, 8); - - elm_object_content_set(scroller, grid); - - return scroller; -} - - -class app_controller4: public ui_controller -{ -private: - appdata_s *ad; - -public: - app_controller4(appdata_s *ad) - : ad(ad) - { - } - - ~app_controller4() - { - } - - 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 4", - //Prev Button - [](void *data, Evas_Object *obj, void *event_info) -> void - { - appdata_s *ad = static_cast(data); - ad->viewmgr->pop_view(); - }, - //Next Button - [](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, "TitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitle"); - view->set_title_badge("999+"); - } - - void unload() - { - //You could destroy the content here for save memory. - ui_view *view = this->get_view(); - Evas_Object *content = view->set_content(NULL); - evas_object_del(content); - } - -}; - - -class app_controller3: public ui_controller -{ -private: - appdata_s *ad; - -public: - app_controller3(appdata_s *ad) - : ad(ad) - { - } - - ~app_controller3() - { - } - - 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 3", - //Prev Button - [](void *data, Evas_Object *obj, void *event_info) -> void - { - appdata_s *ad = static_cast(data); - ad->viewmgr->pop_view(); - }, - //Next Button - [](void *data, Evas_Object *obj, void *event_info) -> void - { - appdata_s *ad = static_cast(data); - app_controller4 *controller = new app_controller4(ad); - ad->viewmgr->push_view(new ui_basic_view(controller)); - }, this->ad); - - //Arguments: content, title, subtitle, icon, title left button, title right button - view->set_content(content, "Title", "Subtitle", NULL, NULL, NULL); - } - - void unload() - { - //You could destroy the content here for save memory. - ui_view *view = this->get_view(); - Evas_Object *content = view->set_content(NULL); - evas_object_del(content); - } -}; - - -class app_controller2: public ui_controller -{ -private: - appdata_s *ad; - -public: - app_controller2(appdata_s *ad) - : ad(ad) - { - } - ~app_controller2() - { - } - - void load() - { - //Initialize contents. - - ui_basic_view *view = dynamic_cast(ui_controller::get_view()); - - //Create a main content. - Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo
Page 2", - //Prev Button - [](void *data, Evas_Object *obj, void *event_info) -> void - { - appdata_s *ad = static_cast(data); - ad->viewmgr->pop_view(); - }, - //Next Button - [](void *data, Evas_Object *obj, void *event_info) -> void - { - appdata_s *ad = static_cast(data); - app_controller3 *controller = new app_controller3(ad); - ad->viewmgr->push_view(new ui_basic_view(controller)); - }, this->ad); - - //Title left button - Evas_Object *left_title_btn = elm_button_add(view->get_base()); - elm_object_text_set(left_title_btn, "Cancel"); - - //Title right button - Evas_Object *right_title_btn = elm_button_add(view->get_base()); - elm_object_text_set(right_title_btn, "Done"); - - //Arguments: content, title, subtitle, icon, title left button, title right button - view->set_content(content, "Title Buttons", NULL, NULL, left_title_btn, right_title_btn); - } - - void unload() - { - //You could destroy the content here for save memory. - ui_view *view = this->get_view(); - Evas_Object *content = view->set_content(NULL); - evas_object_del(content); - } -}; - -class app_controller1: public ui_controller -{ -private: - appdata_s *ad; - -public: - app_controller1(appdata_s *ad) - : ad(ad) - { - } - ~app_controller1() - { - } - - void load() - { - //Initialize contents. - - ui_basic_view *view = dynamic_cast(ui_controller::get_view()); - - //Create a main content. - Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo
Page 1", - //Prev Button - [](void *data, Evas_Object *obj, void *event_info) -> void - { - appdata_s *ad = static_cast(data); - ad->viewmgr->deactivate(); - }, - //Next Button - [](void *data, Evas_Object *obj, void *event_info) -> void - { - appdata_s *ad = static_cast(data); - app_controller2 *controller = new app_controller2(ad); - ui_basic_view *view = new ui_basic_view(controller, "page2"); - ad->viewmgr->push_view(view); - }, this->ad); - - view->set_content(content, "Title"); - } - - void unload() - { - //You could destroy the content here for save memory. - ui_view *view = this->get_view(); - Evas_Object *content = view->set_content(NULL); - evas_object_del(content); - } -}; diff --git a/src/efl/efl_viewmgr.h b/src/efl/efl_viewmgr.h new file mode 100644 index 0000000..7dc04b2 --- /dev/null +++ b/src/efl/efl_viewmgr.h @@ -0,0 +1,3 @@ +#include "ui_viewmgr.h" +#include "ui_controller.h" +#include "ui_view.h" diff --git a/src/efl/mobile/efl_viewmgr.h b/src/efl/mobile/efl_viewmgr.h new file mode 100644 index 0000000..b2389bd --- /dev/null +++ b/src/efl/mobile/efl_viewmgr.h @@ -0,0 +1 @@ +#include "ui_basic_view.h" diff --git a/src/efl/mobile/ui_basic_view.cpp b/src/efl/mobile/ui_basic_view.cpp new file mode 100644 index 0000000..db2414c --- /dev/null +++ b/src/efl/mobile/ui_basic_view.cpp @@ -0,0 +1,199 @@ +#include "efl_viewmgr.h" + +using namespace efl; + +bool ui_basic_view::destroy_layout() +{ + if (!this->layout) return false; + if (this->get_content()) + { + elm_object_part_content_unset(this->layout, "elm.swallow.content"); + } + evas_object_del(this->layout); + + return true; +} + +bool ui_basic_view::create_layout() +{ + ui_viewmgr *viewmgr = dynamic_cast(ui_view_base::get_viewmgr()); + Evas_Object *parent = viewmgr->get_window(); + + Evas_Object *layout = elm_layout_add(parent); + if (!layout) + { + LOGE("Failed to create a layout = ui_basic_view(%p)", this); + return false; + } + + if (!elm_layout_theme_set(layout, "layout", "tizen_view", "default")) + { + LOGE("Failed to set theme = ui_basic_view(%p)", this); + 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); + + if (this->get_content()) + { + elm_object_part_content_set(layout, "elm.swallow.content", CONVERT_TO_EO(this->get_content())); + } + + this->layout = 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() +{ + destroy_layout(); +} + +void ui_basic_view::load() +{ + this->create_layout(); + ui_view::load(); +} + +void ui_basic_view::unload() +{ + this->destroy_layout(); + ui_view::unload(); +} + +Evas_Object * +ui_basic_view::set_content(Evas_Object *content, const char *title) +{ + Evas_Object *pcontent = ui_view::set_content(content); + + if (this->layout) + { + elm_object_part_content_unset(this->layout, "elm.swallow.content"); + elm_object_part_content_set(this->layout, "elm.swallow.content", content); + elm_object_part_text_set(this->layout, "elm.text.title", title); + } + else + { + LOGE("Layout is not exist!"); + } + + return pcontent; +} + +bool ui_basic_view::set_subtitle(const char *text) +{ + if (this->layout) + { + elm_object_part_text_set(this->layout, "elm.text.subtitle", text); + if (text) elm_object_signal_emit(this->layout, "elm,state,subtitle,show", "elm"); + else elm_object_signal_emit(this->layout, "elm,state,subtitle,hide", "elm"); + return true; + } + LOGE("Layout is not exist!"); + return false; +} + +bool ui_basic_view::set_icon(Evas_Object *icon) +{ + if (this->layout) + { + elm_object_part_content_set(this->layout, "elm.swallow.icon", icon); + if (icon) elm_object_signal_emit(this->layout, "elm,state,icon,show", "elm"); + else elm_object_signal_emit(this->layout, "elm,state,icon,hide", "elm"); + return true; + } + LOGE("Layout is not exist!"); + return false; +} + +bool ui_basic_view::set_title_left_btn(Evas_Object *title_left_btn) +{ + if (this->layout) + { + if (title_left_btn) + { + elm_object_style_set(title_left_btn, "naviframe/title_left"); + //FIXME: naviframe/title_left -> tizen_view/title_left + //elm_object_style_set(title_left_btn, "tizen_view/title_left"); + } + elm_object_part_content_set(this->layout, "title_left_btn", title_left_btn); + if (title_left_btn) elm_object_signal_emit(this->layout, "elm,state,title_left_btn,show", "elm"); + else elm_object_signal_emit(this->layout, "elm,state,title_left_btn,hide", "elm"); + return true; + } + LOGE("Layout is not exist!"); + return false; +} + +bool ui_basic_view::set_title_right_btn(Evas_Object *title_right_btn) +{ + if (this->layout) + { + if (title_right_btn) + { + elm_object_style_set(title_right_btn, "naviframe/title_right"); + //FIXME: naviframe/title_right -> tizen_view/title_right + //elm_object_style_set(title_left_btn, "tizen_view/title_right"); + } + elm_object_part_content_set(this->layout, "title_right_btn", title_right_btn); + if (title_right_btn) elm_object_signal_emit(this->layout, "elm,state,title_right_btn,show", "elm"); + else elm_object_signal_emit(this->layout, "elm,state,title_right_btn,hide", "elm"); + return true; + } + LOGE("Layout is not exist!"); + return false; +} + +bool ui_basic_view::set_title_badge(const char *text) +{ + if (this->layout) + { + elm_object_part_text_set(this->layout, "title_badge", text); + if (text) elm_object_signal_emit(this->layout, "elm,state,title_badge,show", "elm"); + else elm_object_signal_emit(this->layout, "elm,state,title_badge,hide", "elm"); + return true; + } + LOGE("Layout is not exist!"); + return false; +} + +bool ui_basic_view::set_title(const char *text) +{ + if (this->layout) + { + elm_object_part_text_set(this->layout, "elm.text.title", text); + if (text) elm_object_signal_emit(this->layout, "elm,state,title,show", "elm"); + else elm_object_signal_emit(this->layout, "elm,state,title,hide", "elm"); + return true; + } + LOGE("Layout is not exist!"); + return false; +} + +Evas_Object *ui_basic_view::set_content(Evas_Object *content, const char *title, const char *subtitle, Evas_Object *icon, Evas_Object *title_left_btn, + Evas_Object *title_right_btn) +{ + Evas_Object *pcontent = this->set_content(content); + + if (this->layout) + { + this->set_title(title); + this->set_subtitle(subtitle); + this->set_icon(icon); + this->set_title_left_btn(title_left_btn); + this->set_title_right_btn(title_right_btn); + } + else + { + LOGE("Layout is not exist!"); + } + + return pcontent; +} + diff --git a/src/efl/mobile/ui_basic_view.h b/src/efl/mobile/ui_basic_view.h new file mode 100644 index 0000000..f99674f --- /dev/null +++ b/src/efl/mobile/ui_basic_view.h @@ -0,0 +1,41 @@ +#ifndef UI_BASIC_VIEW +#define UI_BASIC_VIEW + +#include "../efl_viewmgr.h" + +namespace efl +{ + +class ui_basic_view: public ui_view +{ +private: + Evas_Object *layout; //Base layout for view + bool create_layout(); + bool destroy_layout(); + +protected: + void load(); + void unload(); + +public: + ui_basic_view(ui_controller *controller, const char *name = NULL); + virtual ~ui_basic_view(); + + Evas_Object *get_base() + { + return this->layout; + } + + Evas_Object *set_content(Evas_Object *content, const char *title = NULL); + Evas_Object *set_content(Evas_Object *content, const char *title, const char *subtitle, Evas_Object *icon, Evas_Object *title_left_btn, Evas_Object *title_right_btn); + bool set_title_badge(const char *text); + bool set_subtitle(const char *text); + bool set_icon(Evas_Object *icon); + 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); +}; + +} + +#endif /* UI_BASIC_VIEW */ diff --git a/src/efl/ui_controller.cpp b/src/efl/ui_controller.cpp new file mode 100644 index 0000000..d195cc0 --- /dev/null +++ b/src/efl/ui_controller.cpp @@ -0,0 +1,11 @@ +#include "efl_viewmgr.h" + +using namespace efl; + +ui_view * +ui_controller::get_view() +{ + ui_view_base *view = ui_controller_base::get_view(); + if (!view) return NULL; + return dynamic_cast(view); +} diff --git a/src/efl/ui_controller.h b/src/efl/ui_controller.h new file mode 100644 index 0000000..d9de73e --- /dev/null +++ b/src/efl/ui_controller.h @@ -0,0 +1,27 @@ +#ifndef UI_CONTROLLER +#define UI_CONTROLLER + +#include +#include "../interface/ui_viewmgr.h" + +namespace efl +{ +class ui_controller: public ui_controller_base +{ +public: + virtual ~ui_controller() + { + } + ui_view *get_view(); + + virtual void load() {} + virtual void unload() {} + virtual void active() {} + virtual void inactive() {} + virtual void pause() {} + virtual void resume() {} + virtual void destroy() {} +}; +} + +#endif /* UI_CONTROLLER_H */ diff --git a/src/efl/ui_view.cpp b/src/efl/ui_view.cpp new file mode 100644 index 0000000..c319203 --- /dev/null +++ b/src/efl/ui_view.cpp @@ -0,0 +1,35 @@ +#include "efl_viewmgr.h" + +using namespace efl; + +ui_view::ui_view(ui_controller *controller, const char *name) : + ui_view_base(controller, name) +{ +} + +ui_view::~ui_view() +{ +} + +Evas_Object * +ui_view::set_content(Evas_Object *content) +{ + T pcontent = ui_view_base::set_content(CONVERT_TO_T(content)); + return static_cast(pcontent); +} + +Evas_Object * +ui_view::get_base() +{ + ui_viewmgr *viewmgr = dynamic_cast(ui_view_base::get_viewmgr()); + if (!viewmgr) + { + return NULL; + } + return viewmgr->get_base_layout(); +} + +void ui_view::load() +{ + ui_view_base::load(); +} diff --git a/src/efl/ui_view.h b/src/efl/ui_view.h new file mode 100644 index 0000000..dfd825a --- /dev/null +++ b/src/efl/ui_view.h @@ -0,0 +1,29 @@ +#ifndef UI_VIEW +#define UI_VIEW + +#include +#include "../interface/ui_viewmgr.h" + +#define CONVERT_TO_EO(T) static_cast((T)) +#define CONVERT_TO_T(EO) static_cast((EO)) + +namespace efl +{ +class ui_controller; + +class ui_view: public ui_view_base +{ +public: + ui_view(ui_controller *controller, const char *name = NULL); + virtual ~ui_view(); + + virtual Evas_Object *set_content(Evas_Object *content); + virtual Evas_Object *get_base(); + +protected: + virtual void load(); +}; + +} + +#endif /* UI_VIEW */ diff --git a/src/efl/ui_viewmgr.cpp b/src/efl/ui_viewmgr.cpp new file mode 100644 index 0000000..998b8a6 --- /dev/null +++ b/src/efl/ui_viewmgr.cpp @@ -0,0 +1,190 @@ +#include "efl_viewmgr.h" + +using namespace efl; + +void +win_delete_request_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + ui_viewmgr *viewmgr = static_cast(data); + delete(viewmgr); +} + +Evas_Object * +ui_viewmgr::create_conformant(Evas_Object *win) +{ + Evas_Object *conform = elm_conformant_add(win); + if (!conform) return NULL; + + evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(win, conform); + elm_win_conformant_set(win, EINA_TRUE); + evas_object_show(conform); + + return conform; +} + +Evas_Object * +ui_viewmgr::create_base_layout(Evas_Object *conform) +{ + Evas_Object *layout = elm_layout_add(conform); + if (!layout) return NULL; + + elm_layout_theme_set(layout, "layout", "application", "default"); + elm_object_content_set(conform, layout); + + return layout; +} + +ui_viewmgr::ui_viewmgr(const char *pkg) + : ui_viewmgr_base() +{ + if (!pkg) + { + LOGE("Invalid package name"); + return; + } + //Window + this->win = elm_win_util_standard_add(pkg, pkg); + + if (!this->win) + { + LOGE("Failed to create a window (%s)", pkg); + return; + } + + //Set window rotation + if (elm_win_wm_rotation_supported_get(this->win)) + { + int rots[4] = + { 0, 90, 180, 270 }; + elm_win_wm_rotation_available_rotations_set(this->win, (const int *) (&rots), 4); + } + + //Window is requested to delete. + evas_object_smart_callback_add(this->win, "delete,request", + [](void *data, Evas_Object *obj, void *event_info) -> void + { + ui_viewmgr *viewmgr = static_cast(data); + delete(viewmgr); + + //FIXME: Window is destroyed. Terminate Application! + //ui_app_exit(); + }, + this); + + //Conformant: Make this configurable. + this->conform = this->create_conformant(this->win); + + if (!this->conform) + { + LOGE("Failed to create a conformant (%s)", pkg); + return; + } + + this->base_layout = this->create_base_layout(this->conform); + + if (!this->base_layout) + { + LOGE("Failed to create a base layout (%s)", pkg); + return; + } + + //Set Indicator properties + elm_win_indicator_mode_set(this->win, ELM_WIN_INDICATOR_SHOW); + elm_win_indicator_opacity_set(this->win, ELM_WIN_INDICATOR_TRANSPARENT); + elm_win_autodel_set(this->win, EINA_TRUE); +} + +ui_viewmgr::~ui_viewmgr() +{ +} + +bool ui_viewmgr::activate() +{ + ui_viewmgr_base :: activate(); + + elm_object_part_content_unset(this->base_layout, "elm.swallow.content"); + + ui_view *view = dynamic_cast(this->get_last_view()); + + //TODO: get parent? + Evas_Object *content = view->get_base(); + if (content == this->base_layout) + { + elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_content())); + } + else + { + elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_base())); + } + + evas_object_show(this->win); + + return true; +} + +bool ui_viewmgr::deactivate() +{ + ui_viewmgr_base ::deactivate(); + + //FIXME: based on the profile, we should app to go behind or terminate. + if (true) + { + evas_object_lower(this->win); + } + else + { + //FIXME: exit app + //ui_app_exit(); + } + + return true; +} + +bool ui_viewmgr::pop_view() +{ + if (!ui_viewmgr_base::pop_view()) + { + return false; + } + + ui_view *view = dynamic_cast(this->get_last_view()); + + //TODO: get parent? + Evas_Object *content = view->get_base(); + if (content == this->base_layout) + { + elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_content())); + } + else + { + elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_base())); + } + + return true; +} + +ui_view * +ui_viewmgr::push_view(ui_view *view) +{ + ui_viewmgr_base::push_view(view); + + //Don't prepare yet if viewmgr is not activated. + if (!this->is_activated()) return view; + + elm_object_part_content_unset(this->base_layout, "elm.swallow.content"); + + Evas_Object *content = view->get_base(); + + if (content == this->base_layout) + { + elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_content())); + } + else + { + LOGE("view->base = %p", view->get_base()); + elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_base())); + } + + return view; +} diff --git a/src/efl/ui_viewmgr.h b/src/efl/ui_viewmgr.h new file mode 100644 index 0000000..bbb8258 --- /dev/null +++ b/src/efl/ui_viewmgr.h @@ -0,0 +1,44 @@ +#ifndef UI_VIEWMGR +#define UI_VIEWMGR + +#include +#include "../interface/ui_viewmgr.h" + +namespace efl +{ + +class ui_view; + +class ui_viewmgr: public ui_viewmgr_base +{ +private: + Evas_Object *win; + Evas_Object *conform; + Evas_Object *base_layout; + + Evas_Object *create_conformant(Evas_Object *win); + Evas_Object *create_base_layout(Evas_Object *conform); + +public: + ui_viewmgr(const char *pkg); + ~ui_viewmgr(); + + bool activate(); + bool deactivate(); + ui_view *push_view(ui_view *view); + bool pop_view(); + + //FIXME: Make this private + Evas_Object *get_base_layout() + { + return this->base_layout; + } + + Evas_Object *get_window() + { + return this->win; + } +}; +} + +#endif /* UI_VIEWMGR */ diff --git a/src/efl_viewmgr.h b/src/efl_viewmgr.h deleted file mode 100644 index a426a2a..0000000 --- a/src/efl_viewmgr.h +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include "ui_viewmgr.h" -#include "ui_controller.h" -#include "ui_basic_view.h" -#include "ui_view.h" - - -using namespace efl; diff --git a/src/interface/ui_controller_base.cpp b/src/interface/ui_controller_base.cpp new file mode 100644 index 0000000..b751a22 --- /dev/null +++ b/src/interface/ui_controller_base.cpp @@ -0,0 +1,10 @@ +#include "ui_viewmgr.h" + +void ui_controller_base::set_view(ui_view_base *view) +{ + if (this->view) + { + //TODO: ? + } + this->view = view; +} diff --git a/src/interface/ui_controller_base.h b/src/interface/ui_controller_base.h new file mode 100644 index 0000000..e5bfd47 --- /dev/null +++ b/src/interface/ui_controller_base.h @@ -0,0 +1,101 @@ +/* + * ui_controller_base.h + * + * Created on: Jan 15, 2016 + * Author: Hermet Park + */ + +#ifndef UI_CONTROLLER_BASE_H_ +#define UI_CONTROLLER_BASE_H_ + +class ui_view_base; + +/** + * @class ui_controller_base + * + * @ingroup ui_viewmgr + * + * @brief UI Controller Interface. This interface is designed for handling of life-cycle events from user side. + * + * @date 2016/01/15 + * @author Hermet Park + * + */ +class ui_controller_base +{ +private: + ui_view_base *view; + +public: + ui_controller_base() : + view(NULL) + { + } + virtual ~ui_controller_base() + { + } + + /** @brief load callback + * + * @note Now, this view is moving onto the screen. Get ready for this view. If this view content is alive, load callback won't be called. + * In the most cases, this callback will be triggered with this step load -> inactive -> active. + */ + virtual void load() = 0; + + /** @brief unload callback + * + * @note Remove resources with regards to this view for saving memory or keep the content for performance. It's up to your scenario. + * Unload will be called just right before when the view is going to be deleted by popping or it's piled under the more than one view. + * If the view content is not alive, the unload won't be called. + * In the most cases, this callback will be triggered with this step. inactive -> unload -> destroy + */ + virtual void unload() = 0; + + /** @brief active callback + * + * @note View is on active state after show transition is finished. + * From whatever the state, if the view is on the screen, the active callback will be called. + * In the most cases, this callback will be triggered with this step. load -> inactive -> active + */ + virtual void active() = 0; + + /** @brief inactive callback + * + * @note View is on inactive state. Get ready for unload. Hide transition may be triggered at this point. + * Inactive state is triggered on this scenario that the view is still visible but it's not interactive with users. + * In the most cases, when view is going to be popped or destroyed or pushed one more depth, the inactive state will be triggered. + * Some UI controls such as a center popup or a menu popup blocks the view, this view may be inactive but still visible in someway (with transparency) + */ + virtual void inactive() = 0; + + /** @brief pause callback + * + * @note When the system blocks the application running in cases such as phone call, system notification, switching applications ... + * When Window turns to deactivate. (@see ui_viewmgr_base :: deactivate()) + * If the view were inactive or unload state, the pause won't be called. + */ + virtual void pause() = 0; + + /** @brief resume callback + * + * @note View is turning back to the active state again from pause. + * When the system allows the application turns to activate. + * When the Window turns to activate. (@see ui_viewmgr_base :: activate()) + */ + virtual void resume() = 0; + + /** @brief destroy callback + * + * @note When this view is on destroying by popping or deleting. + */ + virtual void destroy() = 0; + + void set_view(ui_view_base *view); + + ui_view_base *get_view() + { + return this->view; + } +}; + +#endif /* UI_CONTROLLER_BASE_H_ */ diff --git a/src/interface/ui_view_base.cpp b/src/interface/ui_view_base.cpp new file mode 100644 index 0000000..50a3357 --- /dev/null +++ b/src/interface/ui_view_base.cpp @@ -0,0 +1,110 @@ +#include "ui_viewmgr.h" + +void ui_view_base::set_event_block(bool block) +{ + this->event_block = block; +} + +void ui_view_base::load() +{ + this->state = UI_VIEW_STATE_LOAD; + if (this->content) return; + if (!this->controller) return; + this->controller->load(); +} + +void ui_view_base::unload() +{ + this->state = UI_VIEW_STATE_UNLOAD; + if (!this->content) return; + if (!this->controller) return; + this->controller->unload(); +} + +void ui_view_base::active() +{ + this->state = UI_VIEW_STATE_ACTIVE; + if (!this->controller) return; + this->controller->active(); +} + +void ui_view_base::inactive() +{ + this->state = UI_VIEW_STATE_INACTIVE; + if (!this->controller) return; + this->controller->inactive(); +} + +void ui_view_base::pause() +{ + this->state = UI_VIEW_STATE_PAUSE; + if (!this->content) return; + if (state != UI_VIEW_STATE_ACTIVE) return; + if (!this->controller) return; + this->controller->pause(); +} + +void ui_view_base::resume() +{ + this->state = UI_VIEW_STATE_ACTIVE; + if (state != UI_VIEW_STATE_PAUSE) return; + if (!this->content) return; + if (!this->controller) return; + this->controller->resume(); +} + +void ui_view_base::destroy() +{ + if (!this->controller) return; + this->controller->destroy(); +} + +ui_view_base::ui_view_base(T content, ui_controller_base *controller, const char *name) + : content(content), controller(controller), name(string(name ? name : "")), style(string()), viewmgr(NULL), state(UI_VIEW_STATE_LOAD), event_block( + false) +{ + if (!content) this->state = UI_VIEW_STATE_UNLOAD; + else this->state = UI_VIEW_STATE_LOAD; + controller->set_view(this); +} + +ui_view_base::ui_view_base(ui_controller_base *controller, const char *name) + : ui_view_base(NULL, controller, name) +{ + this->state = UI_VIEW_STATE_UNLOAD; +} + +ui_view_base::ui_view_base(const char *name) + : ui_view_base(NULL, name) +{ + +} + +ui_view_base::~ui_view_base() +{ + this->viewmgr->remove_view(this); + if (this->controller) delete (this->controller); +} + +ui_controller_base* +ui_view_base::set_controller(ui_controller_base *controller) +{ + ui_controller_base *prev_controller = this->controller; + this->controller = controller; + controller->set_view(this); + prev_controller->set_view(NULL); + return prev_controller; +} + +T ui_view_base::set_content(T content) +{ + T prev = this->content; + this->content = content; + return prev; +} + +bool ui_view_base::set_style(const char *style) +{ + this->style.assign(style); + return true; +} diff --git a/src/interface/ui_view_base.h b/src/interface/ui_view_base.h new file mode 100644 index 0000000..dabaf10 --- /dev/null +++ b/src/interface/ui_view_base.h @@ -0,0 +1,219 @@ +/* + * ui_view_base.h + * + * Created on: Jan 15, 2016 + * Author: hermet + */ + +#ifndef UI_VIEW_BASE_H_ +#define UI_VIEW_BASE_H_ + +#include + +typedef void* T; + +class ui_viewmgr_base; +class ui_controller_base; + +/** + * @class ui_view_base + * + * @ingroup ui_viewmgr + * + * @brief UI View Base Class. This is the base class of view. A view must have one content instance which represents a view for a current screen. + * UI View may have it's own show/hide transition styles. That means, it's available that views have different show/hide effects on demands. + * It's not mandatory but view should describe the transitions in this class. + * + * @warning When the transitions are finished, the view must to call ui_viewmgr_base :: _push_finished(), ui_viewmgr_base :: _pop_finished() in order that + * The ui_viewmgr_base keeps the view states exactly. + * + * @date 2016/01/15 + * @author Hermet Park + */ +class ui_view_base +{ +private: + /// View state definition + enum ui_view_state + { + UI_VIEW_STATE_LOAD = 0, ///< Load state + UI_VIEW_STATE_UNLOAD, ///< Unload state + UI_VIEW_STATE_ACTIVE, ///< Active state + UI_VIEW_STATE_INACTIVE, ///< Inactive state + UI_VIEW_STATE_PAUSE, ///< Pause state + UI_VIEW_STATE_LAST + }; + + T content; ///< A content instance for a screen as a view. + ui_controller_base *controller; ///< view life-cycle controller interface. + std::string name; ///< view name + std::string style; ///< view style name. + ui_viewmgr_base *viewmgr; ///< viewmgr which this view belongs to. + ui_view_state state; ///< view state + bool event_block; ///< state of event block. + + //Need to check. + friend class ui_viewmgr_base; + //friend bool ui_viewmgr_base ::_connect_view(ui_view_base *view); + //friend bool ui_viewmgr_base ::_disconnect_view(ui_view_base *view); + //friend void ui_viewmgr_base ::_set_event_block(ui_view_base *view); + //friend bool ui_viewmgr_base ::_push_view_finished(ui_view_base *view); + //friend bool ui_viewmgr_base ::_pop_view_finished(ui_view_base *view); + +protected: + + /** @brief toggle event block + * + * @note This interface is designed for toggling touch event on view transition. + * ui_viewmgr_base will call this interface for notifying event blocking toggling on transition time. + * + * @param block @c true, when blocking is enabled, otherwise @c false. + * + */ + virtual void set_event_block(bool block); + + /** @brief view load state + * + * @note this state will be triggered by ui_viewmgr_base + * + * @see ui_controller_base for this state in detail. + */ + virtual void load(); + + /** @brief view unload state + * + * @note this state will be triggered by ui_viewmgr_base + * + * @see ui_controller_base for this state in detail. + */ + virtual void unload(); + + /** @brief view active state + * + * @note this state will be triggered by ui_viewmgr_base + * + * @see ui_controller_base for this state in detail. + */ + virtual void active(); + + /** @brief view inactive state + * + * @note this state will be triggered by ui_viewmgr_base + * + * @see ui_controller_base for this state in detail. + */ + virtual void inactive(); + + /** @brief view pause state + * + * @note this state will be triggered by ui_viewmgr_base + * + * @see ui_controller_base for this state in detail. + */ + virtual void pause(); + + /** @brief view resume state + * + * @note this state will be triggered by ui_viewmgr_base + * + * @see ui_controller_base for this state in detail. + */ + virtual void resume(); + + /** @brief view destroy state + * + * @note this state will be triggered by ui_viewmgr_base + * + * @see ui_controller_base for this state in detail. + */ + virtual void destroy(); + + /// Return the state of event block. + bool get_event_block() + { + return this->event_block; + } + +public: + /** @brief This is a constructor for initializing this view resources. + * + * @param content A content instance for a screen as a view. + * @param controller view life-cycle controller interface. + * @param name view name. + * + * @warning Be aware the deletion of controller passed here will be covered by ui_view_base. + * If you want to keep it for any reasons, please unset it using set_controller() before ui_view_base is deleted. + */ + + //Constructor + ui_view_base(T content, ui_controller_base *controller, const char *name); + ///Constructor for initializing with controller. + ui_view_base(ui_controller_base *controller, const char *name = NULL); + ///Constructor for initializing with name. + ui_view_base(const char *name = NULL); + + ///Destructor for terminating view. + virtual ~ui_view_base(); + + /** @brief This is for replacing or setting a controller of the view. + * + * @param controller a new controller. It allows @c NULL for canceling the previous controller. + * @return A previous controller. If it wasn't, the return value will be @c NULL + * + * @warning Be aware deletion of controller passed here will be taken cover by ui_view_base. + * If you want to keep the controller for any reasons, please unset it using set_controller() before ui_view_base is deleted. + */ + ui_controller_base* set_controller(ui_controller_base *controller); + + /** @brief This is for replacing or setting a content of the view. + * + * @note @c content is a logical object that represents a view in your framework. The actual type of the content could be translated to any certain types. + * For instance, the type could be Evas_Object * in EFL and Layer * in Dali. + * + * @param content a new content. It allows @c NULL for canceling the previous content. + * @return A previous content. If it wasn't, return value will be @c NULL + */ + virtual T set_content(T content); + + /** @brief set style of the view. + * + * @note style is reserved for supporting various kinds of view as well as it's transition effects. + * The actual behaviors with this style is up to your frameworks. Default value of the style is NULL. + * + * @param style a new style name. + * @return true if the given @c style is available, otherwise false. + * + * @warning When you override this member function, you should implement the logic to check the given style name is available or not. + * If your framework doesn't support any styles then just allow a @c NULL argument and return true. Otherwise return false. + * + */ + virtual bool set_style(const char *style); + + /// Return a controller of this view. + const ui_controller_base* get_controller() + { + return this->controller; + } + /// Return a style name of this view. + const char *get_style() + { + return this->style.c_str(); + } + /// Return a content instance of this view. + T get_content() + { + return this->content; + } + /// Return a viewmgr which this view is belonging to + ui_viewmgr_base *get_viewmgr() + { + return this->viewmgr; + } + /// Return a state of this view. + ui_view_state get_state() + { + return this->state; + } +}; + +#endif /* UI_VIEW_BASE_H_ */ diff --git a/src/interface/ui_viewmgr.h b/src/interface/ui_viewmgr.h new file mode 100644 index 0000000..3a96621 --- /dev/null +++ b/src/interface/ui_viewmgr.h @@ -0,0 +1,11 @@ +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "VIEWMGR" + +#include "ui_viewmgr_base.h" +#include "ui_view_base.h" +#include "ui_controller_base.h" diff --git a/src/interface/ui_viewmgr_base.cpp b/src/interface/ui_viewmgr_base.cpp new file mode 100644 index 0000000..34ef0a0 --- /dev/null +++ b/src/interface/ui_viewmgr_base.cpp @@ -0,0 +1,239 @@ +#include "ui_viewmgr.h" + +bool ui_viewmgr_base::_connect_view(ui_view_base *view) +{ + if (view->viewmgr) + { + LOGE("view(%p) has already connected to viewmgr(%p)", view, this); + return false; + } + + view->viewmgr = this; + return true; +} + +bool ui_viewmgr_base::_disconnect_view(ui_view_base *view) +{ + if (!view->viewmgr) return false; + view->viewmgr = NULL; + return true; +} + +void ui_viewmgr_base::_set_event_block(ui_view_base *view, bool block) +{ + + if (!this->event_block) return; + view->set_event_block(block); +} + +bool ui_viewmgr_base::_push_view_finished(ui_view_base *view) +{ + ui_view_base *last = this->view_list.back(); + + //The previous view has been pushed. This should be unload. + if (last != view) + { + view->unload(); + return true; + } + + //A new view has been pushed. This should be active. + view->active(); + this->_set_event_block(view, true); + + return true; +} + +bool ui_viewmgr_base::_pop_view_finished(ui_view_base *view) +{ + ui_view_base *last = this->view_list.back(); + + //This view has been popped. It should be destroyed. + if (last == view) + { + view->unload(); + view->destroy(); + delete (view); + return true; + } + + //The previous view has been popped. It should become active. + view->active(); + this->_set_event_block(view, true); + + return true; +} + +ui_viewmgr_base::ui_viewmgr_base() + : event_block(true), activated(false) +{ + //TODO: Initialize ? +} + +ui_viewmgr_base::~ui_viewmgr_base() +{ + //Terminate views + for (typename std::list::reverse_iterator it = this->view_list.rbegin(); it != this->view_list.rend(); it++) + { + ui_view_base *view = *it; + view->inactive(); + view->unload(); + view->destroy(); + delete (view); + } + + //FIXME: Window is destroyed. Terminate Application! + ui_app_exit(); +} + +ui_view_base * +ui_viewmgr_base::push_view(ui_view_base *view) +{ + if (!view) + { + LOGE("invalid view argument. view(NULL)"); + return NULL; + } + + if (!this->_connect_view(view)) + { + LOGE("connect view failed"); + return NULL; + } + + ui_view_base *pview; + + //Previous view + if (this->view_list.size()) + { + pview = this->view_list.back(); + pview->inactive(); + this->_set_event_block(pview, true); + + //FIXME: Since we have no transition + pview->unload(); + } + + view_list.push_back(view); + + if (!view->get_content()) + { + view->load(); + } + + view->inactive(); + this->_set_event_block(view, true); + + return view; +} + +bool ui_viewmgr_base::pop_view() +{ + //No more view? destroy viewmgr? + if (this->get_view_count() == 0) + { + return false; + } + + //This is the last page. destroy viewmgr? + if (this->get_view_count() == 1) + { + //destroy viewmgr? + ui_view_base *view = this->view_list.back(); + view->inactive(); + view->unload(); + view->destroy(); + return true; + } + + //last page to be popped. + ui_view_base *view = this->view_list.back(); + view->inactive(); + this->_set_event_block(view, true); + + //Below object has to be used in child class... + //Make this getter method? or define instance? + //previous page to be current active. + auto nx = std::prev(this->view_list.end(), 2); + ui_view_base *pview = *nx; + pview->load(); + pview->inactive(); + this->_set_event_block(pview, true); + + //FIXME: since we have no transition effect + pview->active(); + view->inactive(); + view->unload(); + view->destroy(); + delete (view); + + return true; +} + +bool ui_viewmgr_base::insert_view_before(ui_view_base *view, ui_view_base *before) +{ + //TODO: ... + return true; +} + +bool ui_viewmgr_base::insert_view_after(ui_view_base *view, ui_view_base *after) +{ + //TODO: ... + return true; +} + +bool ui_viewmgr_base::remove_view(ui_view_base *view) +{ + this->view_list.remove(view); + this->_disconnect_view(view); + + //TODO: If this view is the top on the stack ? + return true; +} + +ui_view_base* +ui_viewmgr_base::get_view(unsigned int idx) +{ + if (idx < 0 || idx >= this->view_list.size()) + { + LOGE("Invalid idx(%d)! =? (idx range: %d ~ %d)", idx, 0, this->view_list.size() - 1); + return NULL; + } + typename std::list::iterator it = this->view_list.begin(); + std::advance(it, idx); + return *it; +} + +int ui_viewmgr_base::get_view_index(const ui_view_base *view) +{ + int idx = 0; + + for (typename std::list::iterator it = this->view_list.begin(); it != this->view_list.end(); it++) + { + if (view == *it) return idx; + ++idx; + } + + return -1; +} + +ui_view_base * +ui_viewmgr_base::get_last_view() +{ + int cnt = this->get_view_count(); + return this->get_view(cnt - 1); +} + +bool ui_viewmgr_base::activate() +{ + if (this->activated) return false; + this->activated = true; + return true; +} + +bool ui_viewmgr_base::deactivate() +{ + if (!this->activated) return false; + this->activated = false; + return true; +} diff --git a/src/interface/ui_viewmgr_base.h b/src/interface/ui_viewmgr_base.h new file mode 100644 index 0000000..01abae5 --- /dev/null +++ b/src/interface/ui_viewmgr_base.h @@ -0,0 +1,227 @@ +/* + * ui_viewmgr_base.h + * + * Created on: Jan 15, 2016 + * Author: hermet + */ + +#ifndef UI_WINDOW_BASE_H_ +#define UI_WINDOW_BASE_H_ + +#include + +using namespace std; + +class ui_view_base; + +/** + * @class ui_viewmgr_base + * + * @ingroup ui_viewmgr + * + * @brief This is a base class of viewmgr. One viewmgr represents a window which contains multiple views. + * A viewmgr manages not only views life-cycle but constructs some basic infrastructure. It's up to derived classes. + * + * @warning viewmgr will remove all containing views when it's destroyed. + * @date 2016/01/29 + * @author Hermet Park + */ +class ui_viewmgr_base +{ +private: + //TODO: change name to view_stack + std::list view_list; //view list. + bool event_block; //event block on view transition. This value should be configurable by system. + bool activated; //activated status of this viewmgr. + + /** + * @brief link a given view to this viewmgr. + * + * @param view a view to connect to this viewmgr. + * @return success or not. + * + * @note This is s a friend function of ui_view_base + */ + bool _connect_view(ui_view_base *view); + + /** + * @brief unlink a given view from this viewmgr. + * + * @param view a view to disconnect from this viewmgr. + * @return @c true success or @c false not. + * + * @note This is s a friend function of ui_view_base + */ + bool _disconnect_view(ui_view_base *view); + + /** + * @brief toggle event blocking to the given view. + * + * @param view a view to toggle event blocking + * @param block @c true is block event, otherwise @c false. + * + * @note This is s a friend function of ui_view_base + */ + void _set_event_block(ui_view_base *view, bool block); + +protected: + + /** + * @brief This function is designed for end of push transition. + * + * @param view view which is finished pushing. + * @return @c true success or @c false not. + * + * @warning This function must be called definitely when push transition is finished. + * @note This is s a friend function of ui_view_base + */ + virtual bool _push_view_finished(ui_view_base *view); + + /** + * @brief This function is designed for end of pop transition. + * + * @param view view which is finished popping. + * @return @c true success or @c false not. + * + * @warning This function must be called definitely when push transition is finished. + * @note This is s a friend function of ui_view_base + */ + virtual bool _pop_view_finished(ui_view_base *view); + +public: + ///Constructor. + ui_viewmgr_base(); + + ///Destructor. Delete all contained views. + virtual ~ui_viewmgr_base(); + + //Activate a viewmgr. + virtual bool activate(); + + //Deactivate a viewmgr. + virtual bool deactivate(); + + /** + * @brief Push a new view into the viewmgr stack. + * This function is used for application switches the current view to a new one. + * + * @note Normally, the current view will be hidden by a new view. + * @return @c true on success, @c false otherwise. + */ + virtual ui_view_base *push_view(ui_view_base *view); + + /** + * @brief Pop the top view from the viewmgr stack. + * This function is used for application switches the current view back to the previous view. + * The top view will be removed from the view stack and then it will be deleted by the viewmgr. + * + * @note If the view is just one left, then viewmgr would be destroyed since the application might be terminated. + * But this behavior is optional. + * + * @return A view pointer which was popped. If it's failed to pop, @c NULL will be returned. + */ + bool pop_view(); + + /** + * @brief Insert a view into this viewmgr stack. Specially, right before of the given view, @before + * + * @param view a view to push into the viewmgr stack + * @param before a view that will be just after the @c view. + * If you pass @c NULL, @c view will be inserted at the front of the view stack. + * @return @c true success or @c false not. + */ + virtual bool insert_view_before(ui_view_base *view, ui_view_base *before); + + /** + * @brief Insert a view into this viewmgr stack. Specially, right after of the given view, @after + * + * @param view a view to push into the viewmgr stack + * @param after a view that will be just before the @c view. + * If you pass @c NULL, @c view will be inserted at the end of the view stack. + * @return @c true success or @c false not. + */ + virtual bool insert_view_after(ui_view_base *view, ui_view_base *after); + + /** + * @brief Remove the given view from this viewmgr stack. + * + * @return @c true on success or @c false if not. + * + */ + virtual bool remove_view(ui_view_base *view); + + /** + * @brief Return a stack index number of the given view. + * You could use this function to query the given view stack order. + * + * @param idx a view to query the index. + * @return an index of the give view. + * If there were no views on the idx, @c NULL will be returned. + * + * @warning the index number is variable since the view stack size is also variable. + */ + ui_view_base* get_view(unsigned int idx); + + /** + * @brief Return a view which is matched with the @c name. + * + * @param name the name of the view which you find. + * @return the view which name is matched with @c name. + * If there were no views name matched, @c NULL will be returned. + * + */ + ui_view_base *get_view(const char *name) + { + //TODO: ... + return NULL; + } + + //TODO: Doc. + ui_view_base *get_last_view(); + + /** + * @brief Return a stack index number of the given view. + * You could use this function to query the given view stack order. + * + * @param a view to query the index. + * @return an index of the give view on success, otherwise, -1. + * + * @warning the index number is variable since the view stack size is also variable. + */ + int get_view_index(const ui_view_base *view); + + /** + * @brief Return the number of views which this viewmgr has. + * + * @return the number of view + * + */ + unsigned int get_view_count() + { + return this->view_list.size(); + } + + /** + * @brief Return the active status of viewmgr. + * + * @return active status + * + */ + bool is_activated() + { + return this->activated; + } + + /** + * @brief Return a list of views which this viewmgr has. + * + * @return a pointer of list of views. + * + */ + const list* const get_view_list() + { + return &this->view_list; + } +}; + +#endif /* UI_WINDOW_BASE_H_ */ diff --git a/src/main.cpp b/src/main.cpp index b8a8653..2288b7b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -16,34 +16,60 @@ */ #include "main.h" -#include "app_controller.h" +#include "page4_controller.h" +#include "page3_controller.h" +#include "page2_controller.h" +#include "page1_controller.h" + +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 *grid, *box, *layout, *scroller, *btn, *button_layout; + + /* Scroller */ + scroller = elm_scroller_add(parent); + elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE); + elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO); + + /* Grid */ + grid = elm_grid_add(scroller); + evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(grid); + + /* NoContent Layout */ + layout = elm_layout_add(grid); + elm_layout_theme_set(layout, "layout", "nocontents", "default"); + elm_object_part_text_set(layout, "elm.text", text); + evas_object_show(layout); + elm_grid_pack(grid, layout, 0, 0, 100, 100); + + /* Previous Page Button */ + btn = elm_button_add(grid); + elm_object_text_set(btn, "Prev"); + evas_object_smart_callback_add(btn, "clicked", prev_btn_clicked_cb, ad); + evas_object_show(btn); + elm_grid_pack(grid, btn, 10, 90, 30, 8); + + /* Next Page Button */ + btn = elm_button_add(grid); + elm_object_text_set(btn, "Next"); + evas_object_smart_callback_add(btn, "clicked", next_btn_clicked_cb, ad); + evas_object_show(btn); + elm_grid_pack(grid, btn, 60, 90, 30, 8); + + elm_object_content_set(scroller, grid); + + return scroller; +} static void create_base_gui(appdata_s *ad) { + //FIXME: Hide this creation. ad->viewmgr = new ui_viewmgr(PACKAGE); - //View 1 - { - app_controller1 *controller = new app_controller1(ad); - ad->viewmgr->push_view(new ui_basic_view(controller, "page1")); - } -/* - //View 2 - { - app_controller2 *controller = new app_controller2(ad); - ad->viewmgr->push_view(new ui_basic_view(controller, "page2")); - } - //View 3 - { - app_controller3 *controller = new app_controller3(ad); - ad->viewmgr->push_view(new ui_view(controller)); - } - //View 4 - { - app_controller4 *controller = new app_controller4(); - ui_basic_view *view = ad->viewmgr->push_view(new ui_basic_view(controller)); - } -*/ + page1_controller *page1 = new page1_controller(ad); + ad->viewmgr->activate(); } @@ -77,6 +103,8 @@ static void app_pause(void *data) static void app_resume(void *data) { + appdata_s *ad = (appdata_s *) data; + ad->viewmgr->activate(); } static void app_terminate(void *data) diff --git a/src/page1_controller.h b/src/page1_controller.h new file mode 100644 index 0000000..650a9ce --- /dev/null +++ b/src/page1_controller.h @@ -0,0 +1,47 @@ +class page1_controller: public ui_controller +{ +private: + appdata_s *ad; + +public: + page1_controller(appdata_s *ad) + : ad(ad) + { + ad->viewmgr->push_view(new ui_basic_view(this, "page1")); + } + ~page1_controller() + { + } + + void load() + { + //Initialize contents. + + ui_basic_view *view = dynamic_cast(ui_controller::get_view()); + + //Create a main content. + Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo
Page 1", + //Prev Button + [](void *data, Evas_Object *obj, void *event_info) -> void + { + appdata_s *ad = static_cast(data); + ad->viewmgr->deactivate(); + }, + //Next Button + [](void *data, Evas_Object *obj, void *event_info) -> void + { + appdata_s *ad = static_cast(data); + page2_controller *controller = new page2_controller(ad); + }, this->ad); + + view->set_content(content, "Title"); + } + + void unload() + { + //You could destroy the content here for save memory. + ui_view *view = this->get_view(); + Evas_Object *content = view->set_content(NULL); + evas_object_del(content); + } +}; diff --git a/src/page2_controller.h b/src/page2_controller.h new file mode 100644 index 0000000..ee63057 --- /dev/null +++ b/src/page2_controller.h @@ -0,0 +1,56 @@ +class page2_controller: public ui_controller +{ +private: + appdata_s *ad; + +public: + page2_controller(appdata_s *ad) + : ad(ad) + { + ad->viewmgr->push_view(new ui_basic_view(this, "page2")); + } + ~page2_controller() + { + } + + void load() + { + //Initialize contents. + + ui_basic_view *view = dynamic_cast(ui_controller::get_view()); + + //Create a main content. + Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo
Page 2", + //Prev Button + [](void *data, Evas_Object *obj, void *event_info) -> void + { + appdata_s *ad = static_cast(data); + ad->viewmgr->pop_view(); + }, + //Next Button + [](void *data, Evas_Object *obj, void *event_info) -> void + { + appdata_s *ad = static_cast(data); + page3_controller *controller = new page3_controller(ad); + }, this->ad); + + //Title left button + Evas_Object *left_title_btn = elm_button_add(view->get_base()); + elm_object_text_set(left_title_btn, "Cancel"); + + //Title right button + Evas_Object *right_title_btn = elm_button_add(view->get_base()); + elm_object_text_set(right_title_btn, "Done"); + + //Arguments: content, title, subtitle, icon, title left button, title right button + view->set_content(content, "Title Buttons", NULL, NULL, left_title_btn, right_title_btn); + } + + void unload() + { + //You could destroy the content here for save memory. + ui_view *view = this->get_view(); + Evas_Object *content = view->set_content(NULL); + evas_object_del(content); + } +}; diff --git a/src/page3_controller.h b/src/page3_controller.h new file mode 100644 index 0000000..56d7631 --- /dev/null +++ b/src/page3_controller.h @@ -0,0 +1,49 @@ +class page3_controller: public ui_controller +{ +private: + appdata_s *ad; + +public: + page3_controller(appdata_s *ad) + : ad(ad) + { + ad->viewmgr->push_view(new ui_basic_view(this, "page3")); + } + + ~page3_controller() + { + } + + 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 3", + //Prev Button + [](void *data, Evas_Object *obj, void *event_info) -> void + { + appdata_s *ad = static_cast(data); + ad->viewmgr->pop_view(); + }, + //Next Button + [](void *data, Evas_Object *obj, void *event_info) -> void + { + appdata_s *ad = static_cast(data); + page4_controller *controller = new page4_controller(ad); + }, this->ad); + + //Arguments: content, title, subtitle, icon, title left button, title right button + view->set_content(content, "Title", "Subtitle", NULL, NULL, NULL); + } + + void unload() + { + //You could destroy the content here for save memory. + ui_view *view = this->get_view(); + Evas_Object *content = view->set_content(NULL); + evas_object_del(content); + } +}; diff --git a/src/page4_controller.h b/src/page4_controller.h new file mode 100644 index 0000000..b612583 --- /dev/null +++ b/src/page4_controller.h @@ -0,0 +1,51 @@ +class page4_controller: public ui_controller +{ +private: + appdata_s *ad; + +public: + page4_controller(appdata_s *ad) + : ad(ad) + { + ad->viewmgr->push_view(new ui_basic_view(this, "page4")); + } + + ~page4_controller() + { + } + + 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 4", + //Prev Button + [](void *data, Evas_Object *obj, void *event_info) -> void + { + appdata_s *ad = static_cast(data); + ad->viewmgr->pop_view(); + }, + //Next Button + [](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, "TitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitle"); + view->set_title_badge("999+"); + } + + void unload() + { + //You could destroy the content here for save memory. + ui_view *view = this->get_view(); + Evas_Object *content = view->set_content(NULL); + evas_object_del(content); + } + +}; diff --git a/src/ui_basic_view.cpp b/src/ui_basic_view.cpp deleted file mode 100644 index f1dbb36..0000000 --- a/src/ui_basic_view.cpp +++ /dev/null @@ -1,204 +0,0 @@ -#include -#include "ui_basic_view.h" -#include "ui_viewmgr.h" - -using namespace efl; - -bool ui_basic_view::destroy_layout() -{ - if (!this->layout) return false; - if (this->get_content()) - { - elm_object_part_content_unset(this->layout, "elm.swallow.content"); - } - evas_object_del(this->layout); - - return true; -} - -bool ui_basic_view::create_layout() -{ - ui_viewmgr *viewmgr = dynamic_cast(ui_view_base::get_viewmgr()); - Evas_Object *parent = viewmgr->get_window(); - - Evas_Object *layout = elm_layout_add(parent); - if (!layout) - { - LOGE("Failed to create a layout = ui_basic_view(%p)", this); - return false; - } - - if (!elm_layout_theme_set(layout, "layout", "tizen_view", "default")) - { - LOGE("Failed to set theme = ui_basic_view(%p)", this); - 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); - - if (this->get_content()) - { - elm_object_part_content_set(layout, "elm.swallow.content", CONVERT_TO_EO(this->get_content())); - } - - this->layout = 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() -{ - destroy_layout(); -} - -void ui_basic_view::load() -{ - this->create_layout(); - ui_view::load(); -} - -void ui_basic_view::unload() -{ - this->destroy_layout(); - ui_view::unload(); -} - -Evas_Object * -ui_basic_view::set_content(Evas_Object *content, const char *title) -{ - Evas_Object *pcontent = ui_view::set_content(content); - - if (this->layout) - { - elm_object_part_content_unset(this->layout, "elm.swallow.content"); - elm_object_part_content_set(this->layout, "elm.swallow.content", content); - elm_object_part_text_set(this->layout, "elm.text.title", title); - } - else - { - LOGE("Layout is not exist!"); - } - - return pcontent; -} - -bool ui_basic_view::set_subtitle(const char *text) -{ - if (this->layout) - { - elm_object_part_text_set(this->layout, "elm.text.subtitle", text); - if (text) elm_object_signal_emit(this->layout, "elm,state,subtitle,show", "elm"); - else elm_object_signal_emit(this->layout, "elm,state,subtitle,hide", "elm"); - return true; - } - LOGE("Layout is not exist!"); - return false; -} - -bool ui_basic_view::set_icon(Evas_Object *icon) -{ - if (this->layout) - { - elm_object_part_content_set(this->layout, "elm.swallow.icon", icon); - if (icon) elm_object_signal_emit(this->layout, "elm,state,icon,show", "elm"); - else elm_object_signal_emit(this->layout, "elm,state,icon,hide", "elm"); - return true; - } - LOGE("Layout is not exist!"); - return false; -} - -bool ui_basic_view::set_title_left_btn(Evas_Object *title_left_btn) -{ - if (this->layout) - { - if (title_left_btn) - { - elm_object_style_set(title_left_btn, "naviframe/title_left"); - //FIXME: naviframe/title_left -> tizen_view/title_left - //elm_object_style_set(title_left_btn, "tizen_view/title_left"); - } - elm_object_part_content_set(this->layout, "title_left_btn", title_left_btn); - if (title_left_btn) elm_object_signal_emit(this->layout, "elm,state,title_left_btn,show", "elm"); - else elm_object_signal_emit(this->layout, "elm,state,title_left_btn,hide", "elm"); - return true; - } - LOGE("Layout is not exist!"); - return false; -} - -bool -ui_basic_view::set_title_right_btn(Evas_Object *title_right_btn) -{ - if (this->layout) - { - if (title_right_btn) - { - elm_object_style_set(title_right_btn, "naviframe/title_right"); - //FIXME: naviframe/title_right -> tizen_view/title_right - //elm_object_style_set(title_left_btn, "tizen_view/title_right"); - } - elm_object_part_content_set(this->layout, "title_right_btn", title_right_btn); - if (title_right_btn) elm_object_signal_emit(this->layout, "elm,state,title_right_btn,show", "elm"); - else elm_object_signal_emit(this->layout, "elm,state,title_right_btn,hide", "elm"); - return true; - } - LOGE("Layout is not exist!"); - return false; -} - -bool ui_basic_view::set_title_badge(const char *text) -{ - if (this->layout) - { - elm_object_part_text_set(this->layout, "title_badge", text); - if (text) elm_object_signal_emit(this->layout, "elm,state,title_badge,show", "elm"); - else elm_object_signal_emit(this->layout, "elm,state,title_badge,hide", "elm"); - return true; - } - LOGE("Layout is not exist!"); - return false; -} - -bool -ui_basic_view::set_title(const char *text) -{ - if (this->layout) - { - elm_object_part_text_set(this->layout, "elm.text.title", text); - if (text) elm_object_signal_emit(this->layout, "elm,state,title,show", "elm"); - else elm_object_signal_emit(this->layout, "elm,state,title,hide", "elm"); - return true; - } - LOGE("Layout is not exist!"); - return false; -} - -Evas_Object * -ui_basic_view::set_content(Evas_Object *content, const char *title, const char *subtitle, Evas_Object *icon, Evas_Object *title_left_btn, - Evas_Object *title_right_btn) -{ - Evas_Object *pcontent = this->set_content(content); - - if (this->layout) - { - this->set_title(title); - this->set_subtitle(subtitle); - this->set_icon(icon); - this->set_title_left_btn(title_left_btn); - this->set_title_right_btn(title_right_btn); - } - else - { - LOGE("Layout is not exist!"); - } - - return pcontent; -} - diff --git a/src/ui_basic_view.h b/src/ui_basic_view.h deleted file mode 100644 index d942190..0000000 --- a/src/ui_basic_view.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef UI_BASIC_VIEW -#define UI_BASIC_VIEW - -#include "ui_view.h" - -namespace efl -{ - -class ui_basic_view: public ui_view -{ -private: - Evas_Object *layout; //Base layout for view - bool create_layout(); - bool destroy_layout(); - -protected: - void load(); - void unload(); - -public: - ui_basic_view(ui_controller *controller, const char *name = NULL); - virtual ~ui_basic_view(); - - Evas_Object *get_base() - { - return this->layout; - } - - Evas_Object *set_content(Evas_Object *content, const char *title = NULL); - Evas_Object *set_content(Evas_Object *content, const char *title, const char *subtitle, Evas_Object *icon, Evas_Object *title_left_btn, Evas_Object *title_right_btn); - bool set_title_badge(const char *text); - bool set_subtitle(const char *text); - bool set_icon(Evas_Object *icon); - 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); -}; - -} - -#endif /* UI_BASIC_VIEW */ diff --git a/src/ui_controller.cpp b/src/ui_controller.cpp deleted file mode 100644 index e312012..0000000 --- a/src/ui_controller.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include "ui_view.h" -#include "ui_controller.h" - -using namespace efl; - -ui_view * -ui_controller::get_view() -{ - ui_view_base *view = ui_controller_base::get_view(); - if (!view) return NULL; - return dynamic_cast(view); -} diff --git a/src/ui_controller.h b/src/ui_controller.h deleted file mode 100644 index ecc1324..0000000 --- a/src/ui_controller.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef UI_CONTROLLER -#define UI_CONTROLLER - -#include -#include -#include "ui_controller_base.h" -#include "ui_view.h" - -namespace efl -{ -class ui_controller: public ui_controller_base -{ -public: - virtual ~ui_controller() - { - } - - virtual void load() - { - } - - virtual void unload() - { - } - - virtual void active() - { - } - - virtual void inactive() - { - } - - virtual void pause() - { - } - - virtual void resume() - { - } - - virtual void destroy() - { - } - - ui_view *get_view(); -}; -} - -#endif /* UI_CONTROLLER_H */ diff --git a/src/ui_controller_base.cpp b/src/ui_controller_base.cpp deleted file mode 100644 index 53d1cb9..0000000 --- a/src/ui_controller_base.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include "ui_view_base.h" -#include "ui_controller_base.h" - -void ui_controller_base::set_view(ui_view_base *view) -{ - if (this->view) - { - //TODO: ? - } - this->view = view; -} diff --git a/src/ui_controller_base.h b/src/ui_controller_base.h deleted file mode 100644 index 352dd31..0000000 --- a/src/ui_controller_base.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * ui_controller_base.h - * - * Created on: Jan 15, 2016 - * Author: Hermet Park - */ - -#ifndef UI_CONTROLLER_BASE_H_ -#define UI_CONTROLLER_BASE_H_ - -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "VIEWMGR" - -class ui_view_base; - -/** - * @class ui_controller_base - * - * @ingroup ui_viewmgr - * - * @brief UI Controller Interface. This interface is designed for handling of life-cycle events from user side. - * - * @date 2016/01/15 - * @author Hermet Park - * - */ -class ui_controller_base -{ -private: - ui_view_base *view; - -public: - ui_controller_base() : - view(NULL) - { - } - virtual ~ui_controller_base() - { - } - - /** @brief load callback - * - * @note Now, this view is moving onto the screen. Get ready for this view. If this view content is alive, load callback won't be called. - * In the most cases, this callback will be triggered with this step load -> inactive -> active. - */ - virtual void load() = 0; - - /** @brief unload callback - * - * @note Remove resources with regards to this view for saving memory or keep the content for performance. It's up to your scenario. - * Unload will be called just right before when the view is going to be deleted by popping or it's piled under the more than one view. - * If the view content is not alive, the unload won't be called. - * In the most cases, this callback will be triggered with this step. inactive -> unload -> destroy - */ - virtual void unload() = 0; - - /** @brief active callback - * - * @note View is on active state after show transition is finished. - * From whatever the state, if the view is on the screen, the active callback will be called. - * In the most cases, this callback will be triggered with this step. load -> inactive -> active - */ - virtual void active() = 0; - - /** @brief inactive callback - * - * @note View is on inactive state. Get ready for unload. Hide transition may be triggered at this point. - * Inactive state is triggered on this scenario that the view is still visible but it's not interactive with users. - * In the most cases, when view is going to be popped or destroyed or pushed one more depth, the inactive state will be triggered. - * Some UI controls such as a center popup or a menu popup blocks the view, this view may be inactive but still visible in someway (with transparency) - */ - virtual void inactive() = 0; - - /** @brief pause callback - * - * @note When the system blocks the application running in cases such as phone call, system notification, switching applications ... - * When Window turns to deactivate. (@see ui_viewmgr_base :: deactivate()) - * If the view were inactive or unload state, the pause won't be called. - */ - virtual void pause() = 0; - - /** @brief resume callback - * - * @note View is turning back to the active state again from pause. - * When the system allows the application turns to activate. - * When the Window turns to activate. (@see ui_viewmgr_base :: activate()) - */ - virtual void resume() = 0; - - /** @brief destroy callback - * - * @note When this view is on destroying by popping or deleting. - */ - virtual void destroy() = 0; - - void set_view(ui_view_base *view); - - ui_view_base *get_view() - { - return this->view; - } -}; - -#endif /* UI_CONTROLLER_BASE_H_ */ diff --git a/src/ui_view.cpp b/src/ui_view.cpp deleted file mode 100644 index 36d7bf3..0000000 --- a/src/ui_view.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "ui_view.h" -#include "ui_controller.h" -#include "ui_viewmgr.h" - -using namespace efl; - -ui_view::ui_view(ui_controller *controller, const char *name) : - ui_view_base(controller, name) -{ -} - -ui_view::~ui_view() -{ -} - -Evas_Object * -ui_view::set_content(Evas_Object *content) -{ - T pcontent = ui_view_base::set_content(CONVERT_TO_T(content)); - return static_cast(pcontent); -} - -Evas_Object * -ui_view::get_base() -{ - ui_viewmgr *viewmgr = dynamic_cast(ui_view_base::get_viewmgr()); - if (!viewmgr) - { - return NULL; - } - return viewmgr->get_base_layout(); -} - -void ui_view::load() -{ - ui_view_base::load(); -} diff --git a/src/ui_view.h b/src/ui_view.h deleted file mode 100644 index edf4d59..0000000 --- a/src/ui_view.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef UI_VIEW -#define UI_VIEW - -#include -#include "ui_view_base.h" - -#define CONVERT_TO_EO(T) static_cast((T)) -#define CONVERT_TO_T(EO) static_cast((EO)) - -namespace efl -{ -class ui_controller; - -class ui_view: public ui_view_base -{ -public: - ui_view(ui_controller *controller, const char *name = NULL); - virtual ~ui_view(); - - virtual Evas_Object *set_content(Evas_Object *content); - virtual Evas_Object *get_base(); - -protected: - virtual void load(); -}; - -} - -#endif /* UI_VIEW */ diff --git a/src/ui_view_base.cpp b/src/ui_view_base.cpp deleted file mode 100644 index 637ffda..0000000 --- a/src/ui_view_base.cpp +++ /dev/null @@ -1,115 +0,0 @@ -#include -#include "ui_controller.h" -#include "ui_viewmgr.h" -#include "ui_view_base.h" - -using namespace efl; - -void ui_view_base::set_event_block(bool block) -{ - this->event_block = block; -} - -void ui_view_base::load() -{ - this->state = UI_VIEW_STATE_LOAD; - if (this->content) return; - if (!this->controller) return; - this->controller->load(); -} - -void ui_view_base::unload() -{ - this->state = UI_VIEW_STATE_UNLOAD; - if (!this->content) return; - if (!this->controller) return; - this->controller->unload(); -} - -void ui_view_base::active() -{ - this->state = UI_VIEW_STATE_ACTIVE; - if (!this->controller) return; - this->controller->active(); -} - -void ui_view_base::inactive() -{ - this->state = UI_VIEW_STATE_INACTIVE; - if (!this->controller) return; - this->controller->inactive(); -} - -void ui_view_base::pause() -{ - this->state = UI_VIEW_STATE_PAUSE; - if (!this->content) return; - if (state != UI_VIEW_STATE_ACTIVE) return; - if (!this->controller) return; - this->controller->pause(); -} - -void ui_view_base::resume() -{ - this->state = UI_VIEW_STATE_ACTIVE; - if (state != UI_VIEW_STATE_PAUSE) return; - if (!this->content) return; - if (!this->controller) return; - this->controller->resume(); -} - -void ui_view_base::destroy() -{ - if (!this->controller) return; - this->controller->destroy(); -} - -ui_view_base::ui_view_base(T content, ui_controller_base *controller, const char *name) - : content(content), controller(controller), name(string(name ? name : "")), style(string()), viewmgr(NULL), state(UI_VIEW_STATE_LOAD), event_block( - false) -{ - if (!content) this->state = UI_VIEW_STATE_UNLOAD; - else this->state = UI_VIEW_STATE_LOAD; - controller->set_view(this); -} - -ui_view_base::ui_view_base(ui_controller_base *controller, const char *name) - : ui_view_base(NULL, controller, name) -{ - this->state = UI_VIEW_STATE_UNLOAD; -} - -ui_view_base::ui_view_base(const char *name) - : ui_view_base(NULL, name) -{ - -} - -ui_view_base::~ui_view_base() -{ - this->viewmgr->remove_view(this); - if (this->controller) delete (this->controller); -} - -ui_controller_base* -ui_view_base::set_controller(ui_controller_base *controller) -{ - ui_controller_base *prev_controller = this->controller; - this->controller = controller; - controller->set_view(this); - prev_controller->set_view(NULL); - return prev_controller; -} - -T ui_view_base::set_content(T content) -{ - T prev = this->content; - this->content = content; - return prev; -} - -bool ui_view_base::set_style(const char *style) -{ - this->style.assign(style); - return true; -} diff --git a/src/ui_view_base.h b/src/ui_view_base.h deleted file mode 100644 index fbcc30b..0000000 --- a/src/ui_view_base.h +++ /dev/null @@ -1,224 +0,0 @@ -/* - * ui_view_base.h - * - * Created on: Jan 15, 2016 - * Author: hermet - */ - -#ifndef UI_VIEW_BASE_H_ -#define UI_VIEW_BASE_H_ - -#include - -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "VIEWMGR" - -typedef void* T; - -class ui_viewmgr_base; -class ui_controller_base; - -/** - * @class ui_view_base - * - * @ingroup ui_viewmgr - * - * @brief UI View Base Class. This is the base class of view. A view must have one content instance which represents a view for a current screen. - * UI View may have it's own show/hide transition styles. That means, it's available that views have different show/hide effects on demands. - * It's not mandatory but view should describe the transitions in this class. - * - * @warning When the transitions are finished, the view must to call ui_viewmgr_base :: _push_finished(), ui_viewmgr_base :: _pop_finished() in order that - * The ui_viewmgr_base keeps the view states exactly. - * - * @date 2016/01/15 - * @author Hermet Park - */ -class ui_view_base -{ -private: - /// View state definition - enum ui_view_state - { - UI_VIEW_STATE_LOAD = 0, ///< Load state - UI_VIEW_STATE_UNLOAD, ///< Unload state - UI_VIEW_STATE_ACTIVE, ///< Active state - UI_VIEW_STATE_INACTIVE, ///< Inactive state - UI_VIEW_STATE_PAUSE, ///< Pause state - UI_VIEW_STATE_LAST - }; - - T content; ///< A content instance for a screen as a view. - ui_controller_base *controller; ///< view life-cycle controller interface. - std::string name; ///< view name - std::string style; ///< view style name. - ui_viewmgr_base *viewmgr; ///< viewmgr which this view belongs to. - ui_view_state state; ///< view state - bool event_block; ///< state of event block. - - //Need to check. - friend class ui_viewmgr_base; - //friend bool ui_viewmgr_base ::_connect_view(ui_view_base *view); - //friend bool ui_viewmgr_base ::_disconnect_view(ui_view_base *view); - //friend void ui_viewmgr_base ::_set_event_block(ui_view_base *view); - //friend bool ui_viewmgr_base ::_push_view_finished(ui_view_base *view); - //friend bool ui_viewmgr_base ::_pop_view_finished(ui_view_base *view); - -protected: - - /** @brief toggle event block - * - * @note This interface is designed for toggling touch event on view transition. - * ui_viewmgr_base will call this interface for notifying event blocking toggling on transition time. - * - * @param block @c true, when blocking is enabled, otherwise @c false. - * - */ - virtual void set_event_block(bool block); - - /** @brief view load state - * - * @note this state will be triggered by ui_viewmgr_base - * - * @see ui_controller_base for this state in detail. - */ - virtual void load(); - - /** @brief view unload state - * - * @note this state will be triggered by ui_viewmgr_base - * - * @see ui_controller_base for this state in detail. - */ - virtual void unload(); - - /** @brief view active state - * - * @note this state will be triggered by ui_viewmgr_base - * - * @see ui_controller_base for this state in detail. - */ - virtual void active(); - - /** @brief view inactive state - * - * @note this state will be triggered by ui_viewmgr_base - * - * @see ui_controller_base for this state in detail. - */ - virtual void inactive(); - - /** @brief view pause state - * - * @note this state will be triggered by ui_viewmgr_base - * - * @see ui_controller_base for this state in detail. - */ - virtual void pause(); - - /** @brief view resume state - * - * @note this state will be triggered by ui_viewmgr_base - * - * @see ui_controller_base for this state in detail. - */ - virtual void resume(); - - /** @brief view destroy state - * - * @note this state will be triggered by ui_viewmgr_base - * - * @see ui_controller_base for this state in detail. - */ - virtual void destroy(); - - /// Return the state of event block. - bool get_event_block() - { - return this->event_block; - } - -public: - /** @brief This is a constructor for initializing this view resources. - * - * @param content A content instance for a screen as a view. - * @param controller view life-cycle controller interface. - * @param name view name. - * - * @warning Be aware the deletion of controller passed here will be covered by ui_view_base. - * If you want to keep it for any reasons, please unset it using set_controller() before ui_view_base is deleted. - */ - - //Constructor - ui_view_base(T content, ui_controller_base *controller, const char *name); - ///Constructor for initializing with controller. - ui_view_base(ui_controller_base *controller, const char *name = NULL); - ///Constructor for initializing with name. - ui_view_base(const char *name = NULL); - - ///Destructor for terminating view. - virtual ~ui_view_base(); - - /** @brief This is for replacing or setting a controller of the view. - * - * @param controller a new controller. It allows @c NULL for canceling the previous controller. - * @return A previous controller. If it wasn't, the return value will be @c NULL - * - * @warning Be aware deletion of controller passed here will be taken cover by ui_view_base. - * If you want to keep the controller for any reasons, please unset it using set_controller() before ui_view_base is deleted. - */ - ui_controller_base* set_controller(ui_controller_base *controller); - - /** @brief This is for replacing or setting a content of the view. - * - * @note @c content is a logical object that represents a view in your framework. The actual type of the content could be translated to any certain types. - * For instance, the type could be Evas_Object * in EFL and Layer * in Dali. - * - * @param content a new content. It allows @c NULL for canceling the previous content. - * @return A previous content. If it wasn't, return value will be @c NULL - */ - virtual T set_content(T content); - - /** @brief set style of the view. - * - * @note style is reserved for supporting various kinds of view as well as it's transition effects. - * The actual behaviors with this style is up to your frameworks. Default value of the style is NULL. - * - * @param style a new style name. - * @return true if the given @c style is available, otherwise false. - * - * @warning When you override this member function, you should implement the logic to check the given style name is available or not. - * If your framework doesn't support any styles then just allow a @c NULL argument and return true. Otherwise return false. - * - */ - virtual bool set_style(const char *style); - - /// Return a controller of this view. - const ui_controller_base* get_controller() - { - return this->controller; - } - /// Return a style name of this view. - const char *get_style() - { - return this->style.c_str(); - } - /// Return a content instance of this view. - T get_content() - { - return this->content; - } - /// Return a viewmgr which this view is belonging to - ui_viewmgr_base *get_viewmgr() - { - return this->viewmgr; - } - /// Return a state of this view. - ui_view_state get_state() - { - return this->state; - } -}; - -#endif /* UI_VIEW_BASE_H_ */ diff --git a/src/ui_viewmgr.cpp b/src/ui_viewmgr.cpp deleted file mode 100644 index 5845eb7..0000000 --- a/src/ui_viewmgr.cpp +++ /dev/null @@ -1,195 +0,0 @@ -#include -#include "ui_view.h" -#include "ui_viewmgr.h" - -using namespace efl; - -void -win_delete_request_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ - ui_viewmgr *viewmgr = static_cast(data); - delete(viewmgr); - - //FIXME: Window is destroyed. Terminate Application! - //ui_app_exit(); -} - -Evas_Object * -ui_viewmgr::create_conformant(Evas_Object *win) -{ - Evas_Object *conform = elm_conformant_add(win); - if (!conform) return NULL; - - evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_win_resize_object_add(win, conform); - elm_win_conformant_set(win, EINA_TRUE); - evas_object_show(conform); - - return conform; -} - -Evas_Object * -ui_viewmgr::create_base_layout(Evas_Object *conform) -{ - Evas_Object *layout = elm_layout_add(conform); - if (!layout) return NULL; - - elm_layout_theme_set(layout, "layout", "application", "default"); - elm_object_content_set(conform, layout); - - return layout; -} - -ui_viewmgr::ui_viewmgr(const char *pkg) - : ui_viewmgr_base() -{ - if (!pkg) - { - LOGE("Invalid package name"); - return; - } - //Window - this->win = elm_win_util_standard_add(pkg, pkg); - - if (!this->win) - { - LOGE("Failed to create a window (%s)", pkg); - return; - } - - //Set window rotation - if (elm_win_wm_rotation_supported_get(this->win)) - { - int rots[4] = - { 0, 90, 180, 270 }; - elm_win_wm_rotation_available_rotations_set(this->win, (const int *) (&rots), 4); - } - - //Window is requested to delete. - evas_object_smart_callback_add(this->win, "delete,request", - [](void *data, Evas_Object *obj, void *event_info) -> void - { - ui_viewmgr *viewmgr = static_cast(data); - delete(viewmgr); - - //FIXME: Window is destroyed. Terminate Application! - //ui_app_exit(); - }, - this); - - //Conformant: Make this configurable. - this->conform = this->create_conformant(this->win); - - if (!this->conform) - { - LOGE("Failed to create a conformant (%s)", pkg); - return; - } - - this->base_layout = this->create_base_layout(this->conform); - - if (!this->base_layout) - { - LOGE("Failed to create a base layout (%s)", pkg); - return; - } - - //Set Indicator properties - elm_win_indicator_mode_set(this->win, ELM_WIN_INDICATOR_SHOW); - elm_win_indicator_opacity_set(this->win, ELM_WIN_INDICATOR_TRANSPARENT); - elm_win_autodel_set(this->win, EINA_TRUE); -} - -ui_viewmgr::~ui_viewmgr() -{ -} - -bool ui_viewmgr::activate() -{ - ui_viewmgr_base :: activate(); - - elm_object_part_content_unset(this->base_layout, "elm.swallow.content"); - - ui_view *view = dynamic_cast(this->get_last_view()); - - //TODO: get parent? - Evas_Object *content = view->get_base(); - if (content == this->base_layout) - { - elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_content())); - } - else - { - elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_base())); - } - - evas_object_show(this->win); - - return true; -} - -bool ui_viewmgr::deactivate() -{ - ui_viewmgr_base ::deactivate(); - - //FIXME: based on the profile, we should app to go behind or terminate. - if (true) - { - evas_object_lower(this->win); - } - else - { - //FIXME: exit app - //ui_app_exit(); - } - - return true; -} - -bool ui_viewmgr::pop_view() -{ - if (!ui_viewmgr_base::pop_view()) - { - return false; - } - - ui_view *view = dynamic_cast(this->get_last_view()); - - //TODO: get parent? - Evas_Object *content = view->get_base(); - if (content == this->base_layout) - { - elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_content())); - } - else - { - elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_base())); - } - - return true; -} - -ui_view * -ui_viewmgr::push_view(ui_view *view) -{ - ui_viewmgr_base::push_view(view); - - //Don't prepare yet if viewmgr is not activated. - if (!this->is_activated()) return view; - - elm_object_part_content_unset(this->base_layout, "elm.swallow.content"); - - Evas_Object *content = view->get_base(); - - if (content == this->base_layout) - { - elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_content())); - } - else - { - LOGE("view->base = %p", view->get_base()); - elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_base())); - } - - return view; -} diff --git a/src/ui_viewmgr.h b/src/ui_viewmgr.h deleted file mode 100644 index 409c550..0000000 --- a/src/ui_viewmgr.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef UI_VIEWMGR -#define UI_VIEWMGR - -#include -#include "ui_viewmgr_base.h" - -namespace efl -{ - -class ui_view; - -class ui_viewmgr: public ui_viewmgr_base -{ -private: - Ecore_Job *animation_job; - bool animation_ongoing; - //CHECK is it really needed? - bool to_show; - Evas_Object *win; - Evas_Object *conform; - Evas_Object *base_layout; - - Evas_Object * create_conformant(Evas_Object *win); - Evas_Object * create_base_layout(Evas_Object *conform); - -public: - ui_viewmgr(const char *pkg); - ~ui_viewmgr(); - bool activate(); - bool deactivate(); - Evas_Object *get_window() - { - return this->win; - } - ui_view *push_view(ui_view *view); - bool pop_view(); - - //TODO: Make this private - Evas_Object *get_base_layout() - { - return this->base_layout; - } -}; -} - -#endif /* UI_VIEWMGR */ diff --git a/src/ui_viewmgr_base.cpp b/src/ui_viewmgr_base.cpp deleted file mode 100644 index d7f100b..0000000 --- a/src/ui_viewmgr_base.cpp +++ /dev/null @@ -1,242 +0,0 @@ -#include -#include -#include "ui_view_base.h" -#include "ui_viewmgr_base.h" - -bool ui_viewmgr_base::_connect_view(ui_view_base *view) -{ - if (view->viewmgr) - { - LOGE("view(%p) has already connected to viewmgr(%p)", view, this); - return false; - } - - view->viewmgr = this; - return true; -} - -bool ui_viewmgr_base::_disconnect_view(ui_view_base *view) -{ - if (!view->viewmgr) return false; - view->viewmgr = NULL; - return true; -} - -void ui_viewmgr_base::_set_event_block(ui_view_base *view, bool block) -{ - - if (!this->event_block) return; - view->set_event_block(block); -} - -bool ui_viewmgr_base::_push_view_finished(ui_view_base *view) -{ - ui_view_base *last = this->view_list.back(); - - //The previous view has been pushed. This should be unload. - if (last != view) - { - view->unload(); - return true; - } - - //A new view has been pushed. This should be active. - view->active(); - this->_set_event_block(view, true); - - return true; -} - -bool ui_viewmgr_base::_pop_view_finished(ui_view_base *view) -{ - ui_view_base *last = this->view_list.back(); - - //This view has been popped. It should be destroyed. - if (last == view) - { - view->unload(); - view->destroy(); - delete (view); - return true; - } - - //The previous view has been popped. It should become active. - view->active(); - this->_set_event_block(view, true); - - return true; -} - -ui_viewmgr_base::ui_viewmgr_base() - : event_block(true), activated(false) -{ - //TODO: Initialize ? -} - -ui_viewmgr_base::~ui_viewmgr_base() -{ - //Terminate views - for (typename std::list::reverse_iterator it = this->view_list.rbegin(); it != this->view_list.rend(); it++) - { - ui_view_base *view = *it; - view->inactive(); - view->unload(); - view->destroy(); - delete (view); - } - - //Terminate applicationn when viewmgr is destroyed. - ui_app_exit(); -} - -ui_view_base * -ui_viewmgr_base::push_view(ui_view_base *view) -{ - if (!view) - { - LOGE("invalid view argument. view(NULL)"); - return NULL; - } - - if (!this->_connect_view(view)) - { - LOGE("connect view failed"); - return NULL; - } - - ui_view_base *pview; - - //Previous view - if (this->view_list.size()) - { - pview = this->view_list.back(); - pview->inactive(); - this->_set_event_block(pview, true); - - //FIXME: Since we have no transition - pview->unload(); - } - - view_list.push_back(view); - - if (!view->get_content()) - { - view->load(); - } - - view->inactive(); - this->_set_event_block(view, true); - - return view; -} - -bool ui_viewmgr_base::pop_view() -{ - //No more view? destroy viewmgr? - if (this->get_view_count() == 0) - { - return false; - } - - //This is the last page. destroy viewmgr? - if (this->get_view_count() == 1) - { - //destroy viewmgr? - ui_view_base *view = this->view_list.back(); - view->inactive(); - view->unload(); - view->destroy(); - return true; - } - - //last page to be popped. - ui_view_base *view = this->view_list.back(); - view->inactive(); - this->_set_event_block(view, true); - - //Below object has to be used in child class... - //Make this getter method? or define instance? - //previous page to be current active. - auto nx = std::prev(this->view_list.end(), 2); - ui_view_base *pview = *nx; - pview->load(); - pview->inactive(); - this->_set_event_block(pview, true); - - //FIXME: since we have no transition effect - pview->active(); - view->inactive(); - view->unload(); - view->destroy(); - delete (view); - - return true; -} - -bool ui_viewmgr_base::insert_view_before(ui_view_base *view, ui_view_base *before) -{ - //TODO: ... - return true; -} - -bool ui_viewmgr_base::insert_view_after(ui_view_base *view, ui_view_base *after) -{ - //TODO: ... - return true; -} - -bool ui_viewmgr_base::remove_view(ui_view_base *view) -{ - this->view_list.remove(view); - this->_disconnect_view(view); - - //TODO: If this view is the top on the stack ? - return true; -} - -ui_view_base* -ui_viewmgr_base::get_view(unsigned int idx) -{ - if (idx < 0 || idx >= this->view_list.size()) - { - LOGE("Invalid idx(%d)! =? (idx range: %d ~ %d)", idx, 0, this->view_list.size() - 1); - return NULL; - } - typename std::list::iterator it = this->view_list.begin(); - std::advance(it, idx); - return *it; -} - -int ui_viewmgr_base::get_view_index(const ui_view_base *view) -{ - int idx = 0; - - for (typename std::list::iterator it = this->view_list.begin(); it != this->view_list.end(); it++) - { - if (view == *it) return idx; - ++idx; - } - - return -1; -} - -ui_view_base * -ui_viewmgr_base::get_last_view() -{ - int cnt = this->get_view_count(); - return this->get_view(cnt - 1); -} - -bool ui_viewmgr_base::activate() -{ - if (this->activated) return false; - this->activated = true; - return true; -} - -bool ui_viewmgr_base::deactivate() -{ - if (!this->activated) return false; - this->activated = false; - return true; -} diff --git a/src/ui_viewmgr_base.h b/src/ui_viewmgr_base.h deleted file mode 100644 index eefb05e..0000000 --- a/src/ui_viewmgr_base.h +++ /dev/null @@ -1,232 +0,0 @@ -/* - * ui_viewmgr_base.h - * - * Created on: Jan 15, 2016 - * Author: hermet - */ - -#ifndef UI_WINDOW_BASE_H_ -#define UI_WINDOW_BASE_H_ - -#include - -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "VIEWMGR" - -using namespace std; - -class ui_view_base; - -/** - * @class ui_viewmgr_base - * - * @ingroup ui_viewmgr - * - * @brief This is a base class of viewmgr. One viewmgr represents a window which contains multiple views. - * A viewmgr manages not only views life-cycle but constructs some basic infrastructure. It's up to derived classes. - * - * @warning viewmgr will remove all containing views when it's destroyed. - * @date 2016/01/29 - * @author Hermet Park - */ -class ui_viewmgr_base -{ -private: - //TODO: change name to view_stack - std::list view_list; //view list. - bool event_block; //event block on view transition. This value should be configurable by system. - bool activated; //activated status of this viewmgr. - - /** - * @brief link a given view to this viewmgr. - * - * @param view a view to connect to this viewmgr. - * @return success or not. - * - * @note This is s a friend function of ui_view_base - */ - bool _connect_view(ui_view_base *view); - - /** - * @brief unlink a given view from this viewmgr. - * - * @param view a view to disconnect from this viewmgr. - * @return @c true success or @c false not. - * - * @note This is s a friend function of ui_view_base - */ - bool _disconnect_view(ui_view_base *view); - - /** - * @brief toggle event blocking to the given view. - * - * @param view a view to toggle event blocking - * @param block @c true is block event, otherwise @c false. - * - * @note This is s a friend function of ui_view_base - */ - void _set_event_block(ui_view_base *view, bool block); - -protected: - - /** - * @brief This function is designed for end of push transition. - * - * @param view view which is finished pushing. - * @return @c true success or @c false not. - * - * @warning This function must be called definitely when push transition is finished. - * @note This is s a friend function of ui_view_base - */ - virtual bool _push_view_finished(ui_view_base *view); - - /** - * @brief This function is designed for end of pop transition. - * - * @param view view which is finished popping. - * @return @c true success or @c false not. - * - * @warning This function must be called definitely when push transition is finished. - * @note This is s a friend function of ui_view_base - */ - virtual bool _pop_view_finished(ui_view_base *view); - -public: - ///Constructor. - ui_viewmgr_base(); - - ///Destructor. Delete all contained views. - virtual ~ui_viewmgr_base(); - - //Activate a viewmgr. - virtual bool activate(); - - //Deactivate a viewmgr. - virtual bool deactivate(); - - /** - * @brief Push a new view into the viewmgr stack. - * This function is used for application switches the current view to a new one. - * - * @note Normally, the current view will be hidden by a new view. - * @return @c true on success, @c false otherwise. - */ - virtual ui_view_base *push_view(ui_view_base *view); - - /** - * @brief Pop the top view from the viewmgr stack. - * This function is used for application switches the current view back to the previous view. - * The top view will be removed from the view stack and then it will be deleted by the viewmgr. - * - * @note If the view is just one left, then viewmgr would be destroyed since the application might be terminated. - * But this behavior is optional. - * - * @return A view pointer which was popped. If it's failed to pop, @c NULL will be returned. - */ - bool pop_view(); - - /** - * @brief Insert a view into this viewmgr stack. Specially, right before of the given view, @before - * - * @param view a view to push into the viewmgr stack - * @param before a view that will be just after the @c view. - * If you pass @c NULL, @c view will be inserted at the front of the view stack. - * @return @c true success or @c false not. - */ - virtual bool insert_view_before(ui_view_base *view, ui_view_base *before); - - /** - * @brief Insert a view into this viewmgr stack. Specially, right after of the given view, @after - * - * @param view a view to push into the viewmgr stack - * @param after a view that will be just before the @c view. - * If you pass @c NULL, @c view will be inserted at the end of the view stack. - * @return @c true success or @c false not. - */ - virtual bool insert_view_after(ui_view_base *view, ui_view_base *after); - - /** - * @brief Remove the given view from this viewmgr stack. - * - * @return @c true on success or @c false if not. - * - */ - virtual bool remove_view(ui_view_base *view); - - /** - * @brief Return a stack index number of the given view. - * You could use this function to query the given view stack order. - * - * @param idx a view to query the index. - * @return an index of the give view. - * If there were no views on the idx, @c NULL will be returned. - * - * @warning the index number is variable since the view stack size is also variable. - */ - ui_view_base* get_view(unsigned int idx); - - /** - * @brief Return a view which is matched with the @c name. - * - * @param name the name of the view which you find. - * @return the view which name is matched with @c name. - * If there were no views name matched, @c NULL will be returned. - * - */ - ui_view_base *get_view(const char *name) - { - //TODO: ... - return NULL; - } - - //TODO: Doc. - ui_view_base *get_last_view(); - - /** - * @brief Return a stack index number of the given view. - * You could use this function to query the given view stack order. - * - * @param a view to query the index. - * @return an index of the give view on success, otherwise, -1. - * - * @warning the index number is variable since the view stack size is also variable. - */ - int get_view_index(const ui_view_base *view); - - /** - * @brief Return the number of views which this viewmgr has. - * - * @return the number of view - * - */ - unsigned int get_view_count() - { - return this->view_list.size(); - } - - /** - * @brief Return the active status of viewmgr. - * - * @return active status - * - */ - bool is_activated() - { - return this->activated; - } - - /** - * @brief Return a list of views which this viewmgr has. - * - * @return a pointer of list of views. - * - */ - const list* const get_view_list() - { - return &this->view_list; - } -}; - -#endif /* UI_WINDOW_BASE_H_ */