From 604b435653aee78f2a5a8689b39a7b36e4e41941 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Thu, 18 Feb 2016 19:37:42 +0900 Subject: [PATCH] updated implementation. reorganize folder hierarchy for view manager. Change-Id: I1b1a88f6a71c4262eea4fc97f88d4e1d826732fb --- CMakeLists.txt | 18 +- inc/main.h | 9 +- src/app_controller.h | 253 ----------------------------- src/efl/efl_viewmgr.h | 3 + src/efl/mobile/efl_viewmgr.h | 1 + src/{ => efl/mobile}/ui_basic_view.cpp | 13 +- src/{ => efl/mobile}/ui_basic_view.h | 2 +- src/{ => efl}/ui_controller.cpp | 4 +- src/efl/ui_controller.h | 27 +++ src/{ => efl}/ui_view.cpp | 4 +- src/{ => efl}/ui_view.h | 2 +- src/{ => efl}/ui_viewmgr.cpp | 7 +- src/{ => efl}/ui_viewmgr.h | 22 ++- src/efl_viewmgr.h | 8 - src/{ => interface}/ui_controller_base.cpp | 4 +- src/{ => interface}/ui_controller_base.h | 5 - src/{ => interface}/ui_view_base.cpp | 5 - src/{ => interface}/ui_view_base.h | 5 - src/interface/ui_viewmgr.h | 11 ++ src/{ => interface}/ui_viewmgr_base.cpp | 7 +- src/{ => interface}/ui_viewmgr_base.h | 5 - src/main.cpp | 74 ++++++--- src/page1_controller.h | 47 ++++++ src/page2_controller.h | 56 +++++++ src/page3_controller.h | 49 ++++++ src/page4_controller.h | 51 ++++++ src/ui_controller.h | 50 ------ 27 files changed, 330 insertions(+), 412 deletions(-) delete mode 100644 src/app_controller.h create mode 100644 src/efl/efl_viewmgr.h create mode 100644 src/efl/mobile/efl_viewmgr.h rename src/{ => efl/mobile}/ui_basic_view.cpp (93%) rename src/{ => efl/mobile}/ui_basic_view.h (97%) rename src/{ => efl}/ui_controller.cpp (73%) create mode 100644 src/efl/ui_controller.h rename src/{ => efl}/ui_view.cpp (88%) rename src/{ => efl}/ui_view.h (92%) rename src/{ => efl}/ui_viewmgr.cpp (96%) rename src/{ => efl}/ui_viewmgr.h (66%) delete mode 100644 src/efl_viewmgr.h rename src/{ => interface}/ui_controller_base.cpp (60%) rename src/{ => interface}/ui_controller_base.h (98%) rename src/{ => interface}/ui_view_base.cpp (96%) rename src/{ => interface}/ui_view_base.h (99%) create mode 100644 src/interface/ui_viewmgr.h rename src/{ => interface}/ui_viewmgr_base.cpp (96%) rename src/{ => interface}/ui_viewmgr_base.h (98%) create mode 100644 src/page1_controller.h create mode 100644 src/page2_controller.h create mode 100644 src/page3_controller.h create mode 100644 src/page4_controller.h delete mode 100644 src/ui_controller.h 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/ui_basic_view.cpp b/src/efl/mobile/ui_basic_view.cpp similarity index 93% rename from src/ui_basic_view.cpp rename to src/efl/mobile/ui_basic_view.cpp index f1dbb36..db2414c 100644 --- a/src/ui_basic_view.cpp +++ b/src/efl/mobile/ui_basic_view.cpp @@ -1,6 +1,4 @@ -#include -#include "ui_basic_view.h" -#include "ui_viewmgr.h" +#include "efl_viewmgr.h" using namespace efl; @@ -133,8 +131,7 @@ bool ui_basic_view::set_title_left_btn(Evas_Object *title_left_btn) return false; } -bool -ui_basic_view::set_title_right_btn(Evas_Object *title_right_btn) +bool ui_basic_view::set_title_right_btn(Evas_Object *title_right_btn) { if (this->layout) { @@ -166,8 +163,7 @@ bool ui_basic_view::set_title_badge(const char *text) return false; } -bool -ui_basic_view::set_title(const char *text) +bool ui_basic_view::set_title(const char *text) { if (this->layout) { @@ -180,8 +176,7 @@ ui_basic_view::set_title(const char *text) 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 *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); diff --git a/src/ui_basic_view.h b/src/efl/mobile/ui_basic_view.h similarity index 97% rename from src/ui_basic_view.h rename to src/efl/mobile/ui_basic_view.h index d942190..f99674f 100644 --- a/src/ui_basic_view.h +++ b/src/efl/mobile/ui_basic_view.h @@ -1,7 +1,7 @@ #ifndef UI_BASIC_VIEW #define UI_BASIC_VIEW -#include "ui_view.h" +#include "../efl_viewmgr.h" namespace efl { diff --git a/src/ui_controller.cpp b/src/efl/ui_controller.cpp similarity index 73% rename from src/ui_controller.cpp rename to src/efl/ui_controller.cpp index e312012..d195cc0 100644 --- a/src/ui_controller.cpp +++ b/src/efl/ui_controller.cpp @@ -1,6 +1,4 @@ -#include -#include "ui_view.h" -#include "ui_controller.h" +#include "efl_viewmgr.h" using namespace efl; 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/ui_view.cpp b/src/efl/ui_view.cpp similarity index 88% rename from src/ui_view.cpp rename to src/efl/ui_view.cpp index 36d7bf3..c319203 100644 --- a/src/ui_view.cpp +++ b/src/efl/ui_view.cpp @@ -1,6 +1,4 @@ -#include "ui_view.h" -#include "ui_controller.h" -#include "ui_viewmgr.h" +#include "efl_viewmgr.h" using namespace efl; diff --git a/src/ui_view.h b/src/efl/ui_view.h similarity index 92% rename from src/ui_view.h rename to src/efl/ui_view.h index edf4d59..dfd825a 100644 --- a/src/ui_view.h +++ b/src/efl/ui_view.h @@ -2,7 +2,7 @@ #define UI_VIEW #include -#include "ui_view_base.h" +#include "../interface/ui_viewmgr.h" #define CONVERT_TO_EO(T) static_cast((T)) #define CONVERT_TO_T(EO) static_cast((EO)) diff --git a/src/ui_viewmgr.cpp b/src/efl/ui_viewmgr.cpp similarity index 96% rename from src/ui_viewmgr.cpp rename to src/efl/ui_viewmgr.cpp index 5845eb7..998b8a6 100644 --- a/src/ui_viewmgr.cpp +++ b/src/efl/ui_viewmgr.cpp @@ -1,6 +1,4 @@ -#include -#include "ui_view.h" -#include "ui_viewmgr.h" +#include "efl_viewmgr.h" using namespace efl; @@ -9,9 +7,6 @@ win_delete_request_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info { ui_viewmgr *viewmgr = static_cast(data); delete(viewmgr); - - //FIXME: Window is destroyed. Terminate Application! - //ui_app_exit(); } Evas_Object * diff --git a/src/ui_viewmgr.h b/src/efl/ui_viewmgr.h similarity index 66% rename from src/ui_viewmgr.h rename to src/efl/ui_viewmgr.h index 409c550..bbb8258 100644 --- a/src/ui_viewmgr.h +++ b/src/efl/ui_viewmgr.h @@ -2,7 +2,7 @@ #define UI_VIEWMGR #include -#include "ui_viewmgr_base.h" +#include "../interface/ui_viewmgr.h" namespace efl { @@ -12,34 +12,32 @@ 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); + 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 + //FIXME: Make this private Evas_Object *get_base_layout() { return this->base_layout; } + + Evas_Object *get_window() + { + return this->win; + } }; } 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/ui_controller_base.cpp b/src/interface/ui_controller_base.cpp similarity index 60% rename from src/ui_controller_base.cpp rename to src/interface/ui_controller_base.cpp index 53d1cb9..b751a22 100644 --- a/src/ui_controller_base.cpp +++ b/src/interface/ui_controller_base.cpp @@ -1,6 +1,4 @@ -#include -#include "ui_view_base.h" -#include "ui_controller_base.h" +#include "ui_viewmgr.h" void ui_controller_base::set_view(ui_view_base *view) { diff --git a/src/ui_controller_base.h b/src/interface/ui_controller_base.h similarity index 98% rename from src/ui_controller_base.h rename to src/interface/ui_controller_base.h index 352dd31..e5bfd47 100644 --- a/src/ui_controller_base.h +++ b/src/interface/ui_controller_base.h @@ -8,11 +8,6 @@ #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; /** diff --git a/src/ui_view_base.cpp b/src/interface/ui_view_base.cpp similarity index 96% rename from src/ui_view_base.cpp rename to src/interface/ui_view_base.cpp index 637ffda..50a3357 100644 --- a/src/ui_view_base.cpp +++ b/src/interface/ui_view_base.cpp @@ -1,9 +1,4 @@ -#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) { diff --git a/src/ui_view_base.h b/src/interface/ui_view_base.h similarity index 99% rename from src/ui_view_base.h rename to src/interface/ui_view_base.h index fbcc30b..dabaf10 100644 --- a/src/ui_view_base.h +++ b/src/interface/ui_view_base.h @@ -10,11 +10,6 @@ #include -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "VIEWMGR" - typedef void* T; class ui_viewmgr_base; 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/ui_viewmgr_base.cpp b/src/interface/ui_viewmgr_base.cpp similarity index 96% rename from src/ui_viewmgr_base.cpp rename to src/interface/ui_viewmgr_base.cpp index d7f100b..34ef0a0 100644 --- a/src/ui_viewmgr_base.cpp +++ b/src/interface/ui_viewmgr_base.cpp @@ -1,7 +1,4 @@ -#include -#include -#include "ui_view_base.h" -#include "ui_viewmgr_base.h" +#include "ui_viewmgr.h" bool ui_viewmgr_base::_connect_view(ui_view_base *view) { @@ -85,7 +82,7 @@ ui_viewmgr_base::~ui_viewmgr_base() delete (view); } - //Terminate applicationn when viewmgr is destroyed. + //FIXME: Window is destroyed. Terminate Application! ui_app_exit(); } diff --git a/src/ui_viewmgr_base.h b/src/interface/ui_viewmgr_base.h similarity index 98% rename from src/ui_viewmgr_base.h rename to src/interface/ui_viewmgr_base.h index eefb05e..01abae5 100644 --- a/src/ui_viewmgr_base.h +++ b/src/interface/ui_viewmgr_base.h @@ -10,11 +10,6 @@ #include -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "VIEWMGR" - using namespace std; class ui_view_base; 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_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 */ -- 2.7.4