From 4fb5ce180d515b964b2027090dbf6fd8a72bd45e Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Wed, 30 Mar 2016 20:36:41 +0900 Subject: [PATCH] intensive code change. Still viewmgr is too unstable. We need to implement bodies intensively. This means this commit includes a lot of improvements at once. Change-Id: Id95d05ea9db2c134d7cfbb11bfa0221a5c9feeaf --- src/examples/efl/page1.h | 2 + src/examples/efl/page10.h | 3 + src/examples/efl/page11.h | 4 + src/examples/efl/page12.h | 2 + src/examples/efl/page13.h | 2 + src/examples/efl/page14.h | 2 + src/examples/efl/page2.h | 2 + src/examples/efl/page3.h | 2 + src/examples/efl/page4.h | 2 + src/examples/efl/page5.h | 2 + src/examples/efl/page6.h | 2 + src/examples/efl/page7.h | 8 +- src/examples/efl/page9.h | 6 + src/include/efl/mobile/ui_key_listener.h | 2 +- src/include/efl/mobile/ui_menu.h | 4 +- src/include/efl/mobile/ui_view.h | 4 +- src/include/efl/mobile/ui_viewmgr.h | 2 +- src/include/efl/ui_base_key_listener.h | 2 +- src/include/efl/ui_base_popup.h | 2 +- src/include/efl/ui_base_view.h | 2 +- ...ui_viewmanager_base.h => ui_base_viewmanager.h} | 0 src/include/efl/ui_base_viewmgr.h | 2 +- ...wmanager_interface.h => ui_iface_viewmanager.h} | 0 src/lib/efl/mobile/ui_key_listener.cpp | 5 +- src/lib/efl/mobile/ui_view.cpp | 334 +++++++++++---------- src/lib/efl/ui_base_key_listener.cpp | 2 +- src/lib/efl/ui_base_popup.cpp | 2 +- src/lib/efl/ui_base_view.cpp | 31 +- src/lib/efl/ui_base_viewmgr.cpp | 5 +- src/lib/interface/ui_iface_view.cpp | 2 +- src/lib/interface/ui_iface_viewmgr.cpp | 2 +- 31 files changed, 254 insertions(+), 188 deletions(-) rename src/include/efl/{ui_viewmanager_base.h => ui_base_viewmanager.h} (100%) rename src/include/interface/{ui_viewmanager_interface.h => ui_iface_viewmanager.h} (100%) diff --git a/src/examples/efl/page1.h b/src/examples/efl/page1.h index 4263a41..4fb6128 100644 --- a/src/examples/efl/page1.h +++ b/src/examples/efl/page1.h @@ -23,6 +23,8 @@ class page1: public ui_view protected: void on_load() { + ui_view::on_load(); + //Create a main content. Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Basic View", //Prev Button Callback diff --git a/src/examples/efl/page10.h b/src/examples/efl/page10.h index fcc12c2..1bb2f83 100644 --- a/src/examples/efl/page10.h +++ b/src/examples/efl/page10.h @@ -23,11 +23,14 @@ class page10: public ui_view protected: void on_load() { + ui_view::on_load(); this->on_rotate(this->get_degree()); } void on_rotate(int degree) { + ui_view::on_rotate(degree); + //Portrait if (this->get_degree() == 0 || this->get_degree() == 180) { diff --git a/src/examples/efl/page11.h b/src/examples/efl/page11.h index 676fd0d..313d106 100644 --- a/src/examples/efl/page11.h +++ b/src/examples/efl/page11.h @@ -32,6 +32,8 @@ class page11: public ui_view protected: void on_load() { + ui_view::on_load(); + //Create a main content. Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Menu Popup", //Prev Button Callback @@ -50,6 +52,8 @@ protected: void on_menu(ui_menu *menu) { + ui_view::on_menu(menu); + Elm_Ctxpopup *ctxpopup = elm_ctxpopup_add(menu->get_base()); elm_ctxpopup_item_append(ctxpopup, "Phone calls", NULL, ctxpopup_item_select_cb, this); elm_ctxpopup_item_append(ctxpopup, "Favorites", NULL, ctxpopup_item_select_cb, this); diff --git a/src/examples/efl/page12.h b/src/examples/efl/page12.h index 51cee23..33fbc75 100644 --- a/src/examples/efl/page12.h +++ b/src/examples/efl/page12.h @@ -34,6 +34,8 @@ class page12: public ui_view protected: void on_load() { + ui_view::on_load(); + //Create a main content. Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Popup", //Prev Button Callback diff --git a/src/examples/efl/page13.h b/src/examples/efl/page13.h index 9fab450..8fbb665 100644 --- a/src/examples/efl/page13.h +++ b/src/examples/efl/page13.h @@ -23,6 +23,8 @@ class page13: public ui_view protected: void on_load() { + ui_view::on_load(); + //Create a main content. Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Fade Transition", //Prev Button Callback diff --git a/src/examples/efl/page14.h b/src/examples/efl/page14.h index f875de4..c67a4cb 100644 --- a/src/examples/efl/page14.h +++ b/src/examples/efl/page14.h @@ -23,6 +23,8 @@ class page14: public ui_view protected: void on_load() { + ui_view::on_load(); + //Create a main content. Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
None Transition", //Prev Button Callback diff --git a/src/examples/efl/page2.h b/src/examples/efl/page2.h index ba3c38d..e04a90a 100644 --- a/src/examples/efl/page2.h +++ b/src/examples/efl/page2.h @@ -23,6 +23,8 @@ class page2: public ui_view protected: void on_load() { + ui_view::on_load(); + //Create a main content. Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Title Buttons", //Prev Button Callback diff --git a/src/examples/efl/page3.h b/src/examples/efl/page3.h index 99762d9..d4a460e 100644 --- a/src/examples/efl/page3.h +++ b/src/examples/efl/page3.h @@ -23,6 +23,8 @@ class page3: public ui_view protected: void on_load() { + ui_view::on_load(); + //Create a main content. Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Subtitle", //Prev Button Callback diff --git a/src/examples/efl/page4.h b/src/examples/efl/page4.h index 153fc20..d746392 100644 --- a/src/examples/efl/page4.h +++ b/src/examples/efl/page4.h @@ -24,6 +24,8 @@ class page4: public ui_view protected: void on_load() { + ui_view::on_load(); + //Create a main content. Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Title Badge", //Prev Button Callback diff --git a/src/examples/efl/page5.h b/src/examples/efl/page5.h index 1c19d06..43ffd28 100644 --- a/src/examples/efl/page5.h +++ b/src/examples/efl/page5.h @@ -23,6 +23,8 @@ class page5: public ui_base_view protected: void on_load() { + ui_base_view::on_load(); + //Create a main content. Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Full View", //Prev Button Callback diff --git a/src/examples/efl/page6.h b/src/examples/efl/page6.h index 540c277..d37c8c4 100644 --- a/src/examples/efl/page6.h +++ b/src/examples/efl/page6.h @@ -22,6 +22,8 @@ class page6: public ui_view protected: void on_load() { + ui_view::on_load(); + //Create a main content. Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Toolbar", //Prev Button Callback diff --git a/src/examples/efl/page7.h b/src/examples/efl/page7.h index debbfa3..6bca5c1 100644 --- a/src/examples/efl/page7.h +++ b/src/examples/efl/page7.h @@ -20,9 +20,11 @@ */ class page7: public ui_view { -public: - page7() : ui_view("page7") +protected: + void on_load() { + ui_view::on_load(); + //Create a main content. Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Navigationbar", //Prev Button Callback @@ -42,6 +44,8 @@ public: Elm_Toolbar *toolbar = create_toolbar(this->get_base(), "navigationbar"); this->set_toolbar(toolbar); } +public: + page7() : ui_view("page7") {} ~page7() {} }; diff --git a/src/examples/efl/page9.h b/src/examples/efl/page9.h index 6e4059c..2a8d63b 100644 --- a/src/examples/efl/page9.h +++ b/src/examples/efl/page9.h @@ -24,6 +24,8 @@ class page9: public ui_view protected: void on_load() { + ui_view::on_load(); + //FIXME: Change below code to more convenient and clear way. if (this->get_degree() == 90 || this->get_degree() == 270) this->on_landscape(); @@ -33,6 +35,8 @@ protected: void on_portrait() { + ui_view::on_portrait(); + Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo
Portrait/Landscape", //Prev Button Callback [](void *data, Evas_Object *obj, void *event_info) -> void @@ -50,6 +54,8 @@ protected: void on_landscape() { + ui_view::on_landscape(); + Evas_Object *content = create_landscape_content(this->get_base(), "ViewMgr Demo
Portrait/Landscape", //Prev Button Callback [](void *data, Evas_Object *obj, void *event_info) -> void diff --git a/src/include/efl/mobile/ui_key_listener.h b/src/include/efl/mobile/ui_key_listener.h index 927007e..9d96066 100644 --- a/src/include/efl/mobile/ui_key_listener.h +++ b/src/include/efl/mobile/ui_key_listener.h @@ -17,7 +17,7 @@ #ifndef UI_KEY_HANDLER_H #define UI_KEY_HANDLER_H -#include "../ui_viewmanager_base.h" +#include "../ui_base_viewmanager.h" namespace efl_viewmgr { diff --git a/src/include/efl/mobile/ui_menu.h b/src/include/efl/mobile/ui_menu.h index de0d942..ee01f46 100644 --- a/src/include/efl/mobile/ui_menu.h +++ b/src/include/efl/mobile/ui_menu.h @@ -17,8 +17,8 @@ #ifndef UI_MENU_H #define UI_MENU_H -#include "../ui_viewmanager_base.h" -#include "../../interface/ui_viewmanager_interface.h" +#include "../../interface/ui_iface_viewmanager.h" +#include "../ui_base_viewmanager.h" namespace efl_viewmgr { diff --git a/src/include/efl/mobile/ui_view.h b/src/include/efl/mobile/ui_view.h index 1df362c..bdc6899 100644 --- a/src/include/efl/mobile/ui_view.h +++ b/src/include/efl/mobile/ui_view.h @@ -17,7 +17,7 @@ #ifndef UI_VIEW #define UI_VIEW -#include "../ui_viewmanager_base.h" +#include "../ui_base_viewmanager.h" namespace efl_viewmgr { @@ -43,7 +43,7 @@ private: protected: virtual void on_load(); virtual void on_unload(); - bool on_menu_pre(); + ui_menu *on_menu_pre(); void on_menu_post(); virtual void on_menu(ui_menu *menu); virtual void unload_content(); diff --git a/src/include/efl/mobile/ui_viewmgr.h b/src/include/efl/mobile/ui_viewmgr.h index bb9d3db..41e04d4 100644 --- a/src/include/efl/mobile/ui_viewmgr.h +++ b/src/include/efl/mobile/ui_viewmgr.h @@ -18,7 +18,7 @@ #define UI_VIEWMGR_H #include -#include "../ui_viewmanager_base.h" +#include "../ui_base_viewmanager.h" namespace efl_viewmgr { diff --git a/src/include/efl/ui_base_key_listener.h b/src/include/efl/ui_base_key_listener.h index 3efd5b0..1ddd81c 100644 --- a/src/include/efl/ui_base_key_listener.h +++ b/src/include/efl/ui_base_key_listener.h @@ -18,7 +18,7 @@ #define UI_BASE_KEY_LISTENER_H #include -#include "../interface/ui_viewmanager_interface.h" +#include "../interface/ui_iface_viewmanager.h" namespace efl_viewmgr { diff --git a/src/include/efl/ui_base_popup.h b/src/include/efl/ui_base_popup.h index a6f690a..63d5d97 100644 --- a/src/include/efl/ui_base_popup.h +++ b/src/include/efl/ui_base_popup.h @@ -17,7 +17,7 @@ #ifndef UI_BASE_POPUP_H #define UI_BASE_POPUP_H -#include "../interface/ui_viewmanager_interface.h" +#include "../interface/ui_iface_viewmanager.h" namespace efl_viewmgr { diff --git a/src/include/efl/ui_base_view.h b/src/include/efl/ui_base_view.h index 1cbb01d..7b6cadb 100644 --- a/src/include/efl/ui_base_view.h +++ b/src/include/efl/ui_base_view.h @@ -18,7 +18,7 @@ #define UI_BASE_VIEW_H #include -#include "../interface/ui_viewmanager_interface.h" +#include "../interface/ui_iface_viewmanager.h" #define CONVERT_TO_EO(T) static_cast((T)) #define CONVERT_TO_T(EO) static_cast((EO)) diff --git a/src/include/efl/ui_viewmanager_base.h b/src/include/efl/ui_base_viewmanager.h similarity index 100% rename from src/include/efl/ui_viewmanager_base.h rename to src/include/efl/ui_base_viewmanager.h diff --git a/src/include/efl/ui_base_viewmgr.h b/src/include/efl/ui_base_viewmgr.h index 2c8b960..f80929c 100644 --- a/src/include/efl/ui_base_viewmgr.h +++ b/src/include/efl/ui_base_viewmgr.h @@ -18,7 +18,7 @@ #define UI_BASE_VIEWMGR_H #include -#include "../interface/ui_viewmanager_interface.h" +#include "../interface/ui_iface_viewmanager.h" #include "ui_base_key_listener.h" #include diff --git a/src/include/interface/ui_viewmanager_interface.h b/src/include/interface/ui_iface_viewmanager.h similarity index 100% rename from src/include/interface/ui_viewmanager_interface.h rename to src/include/interface/ui_iface_viewmanager.h diff --git a/src/lib/efl/mobile/ui_key_listener.cpp b/src/lib/efl/mobile/ui_key_listener.cpp index dcad91d..057cc2d 100644 --- a/src/lib/efl/mobile/ui_key_listener.cpp +++ b/src/lib/efl/mobile/ui_key_listener.cpp @@ -31,8 +31,9 @@ void ui_key_listener::extend_event_proc(ui_base_view *view, Evas_Event_Key_Down { if (strcmp(ev->keyname, KEY_MENU) && strcmp(ev->keyname, KEY_MENU2)) return; ui_view *v = dynamic_cast(view); - if (!v->on_menu_pre()) return; - v->on_menu((ui_menu*)(v->get_menu())); + ui_menu *menu = v->on_menu_pre(); + if (!menu) return; + v->on_menu(menu); v->on_menu_post(); } diff --git a/src/lib/efl/mobile/ui_view.cpp b/src/lib/efl/mobile/ui_view.cpp index d6c6288..a8cebd8 100644 --- a/src/lib/efl/mobile/ui_view.cpp +++ b/src/lib/efl/mobile/ui_view.cpp @@ -23,11 +23,11 @@ using namespace efl_viewmgr; using namespace viewmgr; -static void content_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) -{ - ui_view *view = static_cast(data); - view->unset_content(); -} +#define LAYOUT_VALIDATE() if (!layout) \ + { \ + LOGE("Layout is invalid! ui_view(%p)", this); \ + return false; \ + } static void title_left_btn_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) { @@ -61,12 +61,7 @@ bool ui_view::create_layout() if (this->layout) return false; Elm_Layout *layout = elm_layout_add(this->get_parent()); - - if (!layout) - { - LOGE("Failed to create a layout = ui_view(%p)", this); - return false; - } + LAYOUT_VALIDATE(); if (!elm_layout_file_set(layout, EDJ_PATH, GROUP)) { @@ -121,152 +116,144 @@ void ui_view::on_back() return; } } - ui_base_view ::on_back(); + ui_base_view::on_back(); } ui_view::ui_view(const char *name) - : ui_base_view(name), layout(NULL), menu(NULL) + : ui_base_view(name), layout(NULL), toolbar(NULL), title_left_btn(NULL), title_right_btn(NULL), menu(NULL) { } ui_view::~ui_view() { - if (menu) delete(this->menu); + if (menu) delete (this->menu); destroy_layout(); } void ui_view::on_load() { - if (!this->layout) this->create_layout(); ui_base_view::on_load(); + + Elm_Layout *layout = this->get_base(); + evas_object_show(layout); } void ui_view::on_unload() { ui_base_view::on_unload(); + + Elm_Layout *layout = this->get_base(); + evas_object_hide(layout); } bool ui_view::set_content(Evas_Object *content, const char *title) { ui_base_view::set_content(content); - if (this->layout) + Elm_Layout *layout = this->get_base(); + LAYOUT_VALIDATE(); + + elm_object_part_content_set(layout, "elm.swallow.content", content); + if (content) { - 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); + elm_object_signal_emit(layout, "elm.state,elm.swallow.content,show", "elm"); } else { - LOGE("Layout is not exist!"); - return false; + elm_object_signal_emit(layout, "elm.state,elm.swallow.content,hide", "elm"); } - evas_object_event_callback_add(this->layout, EVAS_CALLBACK_DEL, content_del_cb, this); + this->set_title(title); return true; } bool ui_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; + Elm_Layout *layout = this->get_base(); + LAYOUT_VALIDATE(); + + elm_object_part_text_set(layout, "elm.text.subtitle", text); + if (text) elm_object_signal_emit(layout, "elm,state,subtitle,show", "elm"); + else elm_object_signal_emit(layout, "elm,state,subtitle,hide", "elm"); + + return true; } bool ui_view::set_title_left_btn(Elm_Button *title_left_btn) { - if (this->layout) - { - if (title_left_btn) - { - 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"); + Elm_Layout *layout = this->get_base(); + LAYOUT_VALIDATE(); - this->title_left_btn = title_left_btn; + //FIXME: inside of the unset_title_left_btn, it will send a title_left_btn,hide signal. + //But right after it needs to send a show signal again if new title_left_btn is valid. + //We don't need to send a hide signal in this case. + Elm_Button *pbtn = this->unset_title_left_btn(); + evas_object_del(pbtn); - evas_object_event_callback_add(this->title_left_btn, EVAS_CALLBACK_DEL, title_left_btn_del_cb, this); + this->title_left_btn = title_left_btn; + if (!title_left_btn) return true; - return true; - } - LOGE("Layout is not exist!"); - return false; + elm_object_style_set(title_left_btn, "tizen_view/title_left"); + elm_object_part_content_set(layout, "title_left_btn", title_left_btn); + elm_object_signal_emit(layout, "elm,state,title_left_btn,show", "elm"); + evas_object_event_callback_add(title_left_btn, EVAS_CALLBACK_DEL, title_left_btn_del_cb, this); + + return true; } bool ui_view::set_title_right_btn(Elm_Button *title_right_btn) { - if (this->layout) - { - if (title_right_btn) - { - elm_object_style_set(title_right_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"); + Elm_Layout *layout = this->get_base(); + LAYOUT_VALIDATE(); - this->title_right_btn = title_right_btn; + //FIXME: inside of the unset_title_right_btn, it will send a title_right_btn,hide signal. + //But right after it needs to send a show signal again if new title_right_btn is valid. + //We don't need to send a hide signal in this case. + Elm_Button *pbtn = this->unset_title_right_btn(); + evas_object_del(pbtn); - evas_object_event_callback_add(this->title_right_btn, EVAS_CALLBACK_DEL, title_right_btn_del_cb, this); + this->title_right_btn = title_right_btn; + if (!title_right_btn) return true; - return true; - } - LOGE("Layout is not exist!"); - return false; + elm_object_style_set(title_right_btn, "tizen_view/title_right"); + elm_object_part_content_set(layout, "title_right_btn", title_right_btn); + elm_object_signal_emit(layout, "elm,state,title_right_btn,show", "elm"); + evas_object_event_callback_add(title_right_btn, EVAS_CALLBACK_DEL, title_right_btn_del_cb, this); + + return true; } bool ui_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; + Elm_Layout *layout = this->get_base(); + LAYOUT_VALIDATE(); + + elm_object_part_text_set(layout, "title_badge", text); + if (text) elm_object_signal_emit(layout, "elm,state,title_badge,show", "elm"); + else elm_object_signal_emit(layout, "elm,state,title_badge,hide", "elm"); + + return true; } bool ui_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; + Elm_Layout *layout = this->get_base(); + LAYOUT_VALIDATE(); + + elm_object_part_text_set(layout, "elm.text.title", text); + if (text) elm_object_signal_emit(layout, "elm,state,title,show", "elm"); + else elm_object_signal_emit(layout, "elm,state,title,hide", "elm"); + + return true; } -bool ui_view::set_content(Evas_Object *content, const char *title, const char *subtitle, Elm_Button *title_left_btn, - Elm_Button *title_right_btn) +bool ui_view::set_content(Evas_Object *content, const char *title, const char *subtitle, Elm_Button *title_left_btn, Elm_Button *title_right_btn) { - if (!this->set_content(content)) return false; - - if (this->layout) - { - this->set_title(title); - this->set_subtitle(subtitle); - this->set_title_left_btn(title_left_btn); - this->set_title_right_btn(title_right_btn); - } - else - { - LOGE("Layout is not exist!"); - return false; - } + if (!this->set_content(content, title)) return false; + if (!this->set_subtitle(subtitle)) return false; + if (!this->set_title_left_btn(title_left_btn)) return false; + if (!this->set_title_right_btn(title_right_btn)) return false; return true; } @@ -274,18 +261,22 @@ bool ui_view::set_content(Evas_Object *content, const char *title, const char *s bool ui_view::set_toolbar(Elm_Toolbar *toolbar) { Elm_Layout *layout = this->get_base(); + LAYOUT_VALIDATE(); - //FIXME: Keep this toolbar inside of this view then set up when layout is created after. - if (!layout) - { - LOGE("Layout is not exist!"); - return false; - } + //FIXME: inside of the unset_toolbar, it will send a toolbar,hide signal. + //But right after it needs to send a show signal again if new toolbar is valid. + //We don't need to send a hide signal in this case. + Elm_Toolbar *ptoolbar = this->unset_toolbar(); + evas_object_del(ptoolbar); + + this->toolbar = toolbar; + if (!toolbar) return true; + //FIXME: eeeek. check style?? :( if (!strcmp(elm_object_style_get(toolbar), "navigationbar")) { - if (elm_toolbar_shrink_mode_get(toolbar) != ELM_TOOLBAR_SHRINK_SCROLL) elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_SCROLL); - elm_toolbar_align_set(toolbar, 0.0); + elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_SCROLL); + elm_toolbar_align_set(toolbar, 0); } else { @@ -298,35 +289,31 @@ bool ui_view::set_toolbar(Elm_Toolbar *toolbar) elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS); elm_object_part_content_set(layout, "toolbar", toolbar); - if (toolbar) elm_object_signal_emit(layout, "elm,state,toolbar,show", "elm"); - else elm_object_signal_emit(layout, "elm,state,toolbar,hide", "elm"); - - this->toolbar= toolbar; - - evas_object_event_callback_add(this->toolbar, EVAS_CALLBACK_DEL, toolbar_del_cb, this); - + elm_object_signal_emit(layout, "elm,state,toolbar,show", "elm"); + evas_object_event_callback_add(toolbar, EVAS_CALLBACK_DEL, toolbar_del_cb, this); return true; } void ui_view::unload_content() { - ui_base_view::set_content(NULL); - this->destroy_layout(); + ui_base_view::set_content (NULL); } -bool ui_view::on_menu_pre() +ui_menu *ui_view::on_menu_pre() { - if (this->menu && this->menu->is_activated()) - { - this->menu->deactivate(); - return false; - } if (!this->menu) { this->menu = new ui_menu(this); } - return true; + + if (this->menu->is_activated()) + { + this->menu->deactivate(); + return NULL; + } + + return this->menu; } void ui_view::on_menu(ui_menu *menu) @@ -335,10 +322,8 @@ void ui_view::on_menu(ui_menu *menu) void ui_view::on_menu_post() { - if (this->menu && this->menu->get_content()) - { - this->menu->activate(); - } + if (!this->menu) return; + this->menu->activate(); } void ui_view::set_event_block(bool block) @@ -350,90 +335,115 @@ void ui_view::set_event_block(bool block) Evas_Object *ui_view::unset_content() { Evas_Object *pcontent = ui_base_view::unset_content(); + if (!pcontent) return NULL; - if (!this->get_base()) return pcontent; - - elm_object_part_content_unset(this->get_base(), "elm.swallow.content"); - evas_object_event_callback_del(pcontent, EVAS_CALLBACK_DEL, content_del_cb); - evas_object_hide(pcontent); + Elm_Layout *layout = this->get_base(); + if (!layout) + { + LOGE("Layout is invalid! ui_view(%p)", this); + return pcontent; + } + elm_object_part_content_unset(layout, "elm.swallow.content"); + elm_object_signal_emit(layout, "elm.state,elm.swallow.content,hide", "elm"); return pcontent; } Elm_Button *ui_view::unset_title_left_btn() { - Elm_Button *title_left_btn; + Elm_Button *btn = this->title_left_btn; + if (!btn) return NULL; - if (!this->get_base()) return NULL; + Elm_Layout *layout = this->get_base(); + if (!layout) + { + LOGE("Layout is invalid! ui_view(%p)", this); + return btn; + } - title_left_btn = elm_object_part_content_unset(this->get_base(), "title_left_btn"); - if (title_left_btn) - elm_object_signal_emit(this->get_base(), "elm,state,title_left_btn,hide", "elm"); - evas_object_event_callback_del(title_left_btn, EVAS_CALLBACK_DEL, title_left_btn_del_cb); - evas_object_hide(title_left_btn); + elm_object_part_content_unset(layout, "title_left_btn"); + elm_object_signal_emit(layout, "elm,state,title_left_btn,hide", "elm"); + evas_object_event_callback_del(btn, EVAS_CALLBACK_DEL, title_left_btn_del_cb); + evas_object_hide(btn); + this->title_left_btn = NULL; - return title_left_btn; + return btn; } Elm_Button *ui_view::unset_title_right_btn() { - Elm_Button *title_right_btn; + Elm_Button *btn = this->title_right_btn; + if (!btn) return NULL; - if (!this->get_base()) return NULL; + Elm_Layout *layout = this->get_base(); + if (!layout) + { + LOGE("Layout is invalid! ui_view(%p)", this); + return btn; + } - title_right_btn = elm_object_part_content_unset(this->get_base(), "title_right_btn"); - if (title_right_btn) - elm_object_signal_emit(this->get_base(), "elm,state,title_right_btn,hide", "elm"); - evas_object_event_callback_del(title_right_btn, EVAS_CALLBACK_DEL, title_right_btn_del_cb); - evas_object_hide(title_right_btn); + elm_object_part_content_unset(layout, "title_right_btn"); + elm_object_signal_emit(layout, "elm,state,title_right_btn,hide", "elm"); + evas_object_event_callback_del(btn, EVAS_CALLBACK_DEL, title_right_btn_del_cb); + evas_object_hide(btn); + this->title_right_btn = NULL; - return title_right_btn; + return btn; } Elm_Toolbar *ui_view::unset_toolbar() { - Elm_Toolbar *toolbar; + Elm_Toolbar *toolbar = this->toolbar; + if (!toolbar) return NULL; - if (!this->get_base()) return NULL; + Elm_Layout *layout = this->get_base(); + if (!layout) + { + LOGE("Layout is invalid! ui_view(%p)", this); + return toolbar; + } - toolbar = elm_object_part_content_unset(this->get_base(), "toolbar"); - if (toolbar) - elm_object_signal_emit(this->get_base(), "elm,state,toolbar,hide", "elm"); + elm_object_part_content_unset(layout, "toolbar"); + elm_object_signal_emit(layout, "elm,state,toolbar,hide", "elm"); evas_object_event_callback_del(toolbar, EVAS_CALLBACK_DEL, toolbar_del_cb); evas_object_hide(toolbar); + this->toolbar = NULL; return toolbar; } void ui_view::on_rotate(int degree) { + //FIXME: see how to handle on_menu() ui_base_view::on_rotate(degree); - if (this->menu && this->menu->is_activated()) - { - this->menu->on_rotate(degree); - } + if (!this->menu) return; + if (!this->menu->is_activated()) return; + this->menu->on_rotate(degree); } void ui_view::on_portrait() { + //FIXME: see how to handle on_menu() ui_base_view::on_portrait(); - if (this->menu && this->menu->is_activated()) - { - this->menu->on_portrait(); - } + if (!this->menu) return; + if (!this->menu->is_activated()) return; + this->menu->on_portrait(); } void ui_view::on_landscape() { + //FIXME: see how to handle on_menu() ui_base_view::on_landscape(); - if (this->menu && this->menu->is_activated()) - { - this->menu->on_landscape(); - } + if (!this->menu) return; + if (!this->menu->is_activated()) return; + this->menu->on_landscape(); } Evas_Object *ui_view::get_base() { - if (!this->layout) this->create_layout(); + if (!this->layout) + { + this->create_layout(); + } return this->layout; } diff --git a/src/lib/efl/ui_base_key_listener.cpp b/src/lib/efl/ui_base_key_listener.cpp index 3a2bd92..68fe958 100644 --- a/src/lib/efl/ui_base_key_listener.cpp +++ b/src/lib/efl/ui_base_key_listener.cpp @@ -14,7 +14,7 @@ * limitations under the License. * */ -#include "../../include/efl/ui_viewmanager_base.h" +#include "../../include/efl/ui_base_viewmanager.h" using namespace efl_viewmgr; using namespace viewmgr; diff --git a/src/lib/efl/ui_base_popup.cpp b/src/lib/efl/ui_base_popup.cpp index 0a56bb8..fc4db65 100644 --- a/src/lib/efl/ui_base_popup.cpp +++ b/src/lib/efl/ui_base_popup.cpp @@ -14,7 +14,7 @@ * limitations under the License. * */ -#include "../../include/efl/ui_viewmanager_base.h" +#include "../../include/efl/ui_base_viewmanager.h" using namespace efl_viewmgr; diff --git a/src/lib/efl/ui_base_view.cpp b/src/lib/efl/ui_base_view.cpp index 3cbc695..e8d70ec 100644 --- a/src/lib/efl/ui_base_view.cpp +++ b/src/lib/efl/ui_base_view.cpp @@ -14,13 +14,19 @@ * limitations under the License. * */ -#include "../../include/efl/ui_viewmanager_base.h" +#include "../../include/efl/ui_base_viewmanager.h" using namespace efl_viewmgr; using namespace viewmgr; typedef list::reverse_iterator popup_ritr; +static void content_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + ui_base_view *view = static_cast(data); + view->unset_content(); +} + void ui_base_view::connect_popup(ui_base_popup *popup) { this->popup_list.push_back(popup); @@ -42,17 +48,30 @@ ui_base_view::~ui_base_view() bool ui_base_view::set_content(Evas_Object *content) { - T pcontent = this->get_content(); - if (pcontent) evas_object_del(CONVERT_TO_EO(pcontent)); - if (content) ui_iface_view::set_content(CONVERT_TO_T(content)); - else ui_iface_view::set_content(NULL); + Evas_Object *pcontent = this->unset_content(); + if (pcontent) + { + evas_object_del(pcontent); + } + if (content) + { + evas_object_event_callback_add(content, EVAS_CALLBACK_DEL, content_del_cb, this); + ui_iface_view::set_content(CONVERT_TO_T(content)); + } return true; } Evas_Object *ui_base_view::unset_content() { T pcontent = ui_iface_view::unset_content(); - return CONVERT_TO_EO(pcontent); + if (pcontent) + { + Evas_Object *obj = CONVERT_TO_EO(pcontent); + evas_object_event_callback_del(obj, EVAS_CALLBACK_DEL, content_del_cb); + evas_object_hide(obj); + return obj; + } + return NULL; } Evas_Object *ui_base_view::get_base() diff --git a/src/lib/efl/ui_base_viewmgr.cpp b/src/lib/efl/ui_base_viewmgr.cpp index 970b802..542902b 100644 --- a/src/lib/efl/ui_base_viewmgr.cpp +++ b/src/lib/efl/ui_base_viewmgr.cpp @@ -14,7 +14,7 @@ * limitations under the License. * */ -#include "../../include/efl/ui_viewmanager_base.h" +#include "../../include/efl/ui_base_viewmanager.h" using namespace efl_viewmgr; using namespace viewmgr; @@ -100,7 +100,8 @@ Elm_Layout *ui_base_viewmgr::set_transition_layout(string transition_style) void ui_base_viewmgr::activate_top_view() { - elm_object_part_content_unset(this->get_base(), "content"); + Evas_Object *pcontent = elm_object_part_content_unset(this->get_base(), "content"); + evas_object_hide(pcontent); ui_base_view *view = this->get_last_view(); diff --git a/src/lib/interface/ui_iface_view.cpp b/src/lib/interface/ui_iface_view.cpp index 76945d9..4cef532 100644 --- a/src/lib/interface/ui_iface_view.cpp +++ b/src/lib/interface/ui_iface_view.cpp @@ -14,7 +14,7 @@ * limitations under the License. * */ -#include "../../include/interface/ui_viewmanager_interface.h" +#include "../../include/interface/ui_iface_viewmanager.h" using namespace viewmgr; diff --git a/src/lib/interface/ui_iface_viewmgr.cpp b/src/lib/interface/ui_iface_viewmgr.cpp index a77951a..8b2a78e 100644 --- a/src/lib/interface/ui_iface_viewmgr.cpp +++ b/src/lib/interface/ui_iface_viewmgr.cpp @@ -14,7 +14,7 @@ * limitations under the License. * */ -#include "../../include/interface/ui_viewmanager_interface.h" +#include "../../include/interface/ui_iface_viewmanager.h" using namespace viewmgr; -- 2.7.4