From: Hermet Park Date: Thu, 31 Mar 2016 09:04:08 +0000 (+0900) Subject: introduce ui_iface_overlay. X-Git-Tag: submit/tizen/20160617.075742~72 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F00%2F64300%2F3;p=platform%2Fcore%2Fuifw%2Fui-viewmgr.git introduce ui_iface_overlay. this ui_iface_overlay is designed for overlaied object such as popup and menu... Change-Id: I4aec2a3131cb208530677749bf2fed7716ce8c3c --- diff --git a/src/include/efl/mobile/ui_menu.h b/src/include/efl/mobile/ui_menu.h index ee01f46..613d247 100644 --- a/src/include/efl/mobile/ui_menu.h +++ b/src/include/efl/mobile/ui_menu.h @@ -24,13 +24,10 @@ namespace efl_viewmgr { class ui_view; -class ui_menu: public viewmgr::ui_iface_rotatable +class ui_menu: public viewmgr::ui_iface_overlay { friend class ui_view; private: - ui_view *view; - Elm_Ctxpopup *ctxpopup; - ui_menu(ui_view *view); virtual ~ui_menu(); @@ -41,15 +38,10 @@ public: virtual bool deactivate(); virtual bool set_content(Elm_Ctxpopup* ctxpopup); virtual Elm_Ctxpopup *unset_content(); - virtual void on_back(); virtual bool is_activated(); virtual Evas_Object *get_base(); virtual int get_degree(); - virtual Elm_Ctxpopup *get_content() - { - return this->ctxpopup; - } }; } diff --git a/src/include/efl/ui_base_popup.h b/src/include/efl/ui_base_popup.h index 63d5d97..c1fba51 100644 --- a/src/include/efl/ui_base_popup.h +++ b/src/include/efl/ui_base_popup.h @@ -21,15 +21,9 @@ namespace efl_viewmgr { -class ui_base_view; - -class ui_base_popup : public viewmgr::ui_iface_rotatable +class ui_base_popup : public viewmgr::ui_iface_overlay { - friend class ui_base_view; private: - ui_base_view *view; - Elm_Popup *popup; - Elm_Win *get_window(); public: @@ -38,17 +32,12 @@ public: virtual bool activate(); virtual bool deactivate(); - virtual bool set_content(Elm_Ctxpopup* ctxpopup); + virtual bool set_content(Elm_Popup* ctxpopup); virtual Elm_Popup *unset_content(); - virtual void on_back(); virtual bool is_activated(); virtual Evas_Object *get_base(); virtual int get_degree(); - virtual Elm_Popup *get_content() - { - return this->popup; - } }; } diff --git a/src/include/efl/ui_base_view.h b/src/include/efl/ui_base_view.h index 7b6cadb..ab19822 100644 --- a/src/include/efl/ui_base_view.h +++ b/src/include/efl/ui_base_view.h @@ -20,9 +20,6 @@ #include #include "../interface/ui_iface_viewmanager.h" -#define CONVERT_TO_EO(T) static_cast((T)) -#define CONVERT_TO_T(EO) static_cast((EO)) - namespace efl_viewmgr { class ui_base_popup; diff --git a/src/include/efl/ui_base_viewmanager.h b/src/include/efl/ui_base_viewmanager.h index 8a5a717..71876b3 100644 --- a/src/include/efl/ui_base_viewmanager.h +++ b/src/include/efl/ui_base_viewmanager.h @@ -21,11 +21,12 @@ #endif #define LOG_TAG "UI_VIEWMGR" +#define CONVERT_TO_EO(T) static_cast((T)) +#define CONVERT_TO_T(EO) static_cast((EO)) +#define UI_BASE_VIEWMGR efl_viewmgr::ui_base_viewmgr::get_instance() + #include "ui_base_singleton.h" #include "ui_base_viewmgr.h" #include "ui_base_view.h" #include "ui_base_key_listener.h" #include "ui_base_popup.h" - - -#define UI_BASE_VIEWMGR efl_viewmgr::ui_base_viewmgr::get_instance() diff --git a/src/include/interface/ui_iface_overlay.h b/src/include/interface/ui_iface_overlay.h new file mode 100644 index 0000000..17aa7ad --- /dev/null +++ b/src/include/interface/ui_iface_overlay.h @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef UI_IFACE_OVERLAY_H +#define UI_IFACE_OVERLAY_H + +namespace viewmgr +{ + +class ui_iface_view; + +template +class ui_iface_overlay: public ui_iface_rotatable +{ +private: + ui_iface_view *view; + T content; + +protected: + ui_iface_overlay(ui_iface_view *view); + virtual ~ui_iface_overlay(); + virtual bool set_content(T content); + virtual T unset_content(); + +public: + ui_iface_view *get_view(); + virtual T get_content(); + virtual void on_back(); + virtual bool activate() = 0; + virtual bool deactivate() = 0; + virtual bool is_activated() = 0; +}; + + +template +ui_iface_overlay::ui_iface_overlay(ui_iface_view *view) + : view(view), content(NULL) +{ +} + +template +ui_iface_overlay::~ui_iface_overlay() +{ +} + +template +bool ui_iface_overlay::set_content(T content) +{ + T prev = this->content; + this->content = content; + return true; +} + +template +T ui_iface_overlay::unset_content() +{ + T prev = this->content; + this->content = NULL; + return prev; +} + +template +T ui_iface_overlay::get_content() +{ + return this->content; +} + +template +ui_iface_view *ui_iface_overlay::get_view() +{ + return this->view; +} + +template +void ui_iface_overlay::on_back() +{ + this->deactivate(); +} + +} + +#endif /* UI_IFACE_OVERLAY_H */ diff --git a/src/include/interface/ui_iface_rotatable.h b/src/include/interface/ui_iface_rotatable.h index e5018df..f9f5dea 100644 --- a/src/include/interface/ui_iface_rotatable.h +++ b/src/include/interface/ui_iface_rotatable.h @@ -14,8 +14,8 @@ * limitations under the License. * */ -#ifndef UI_ROTATABLE_INTERFACE_H_ -#define UI_ROTATABLE_INTERFACE_H_ +#ifndef UI_IFACE_ROTATABLE_H_ +#define UI_IFACE_ROTATABLE_H_ namespace viewmgr { @@ -36,4 +36,4 @@ public: } -#endif /* UI_ROTATABLE_INTERFACE_H_ */ +#endif /* UI_IFACE_ROTATABLE_H_ */ diff --git a/src/include/interface/ui_iface_view.h b/src/include/interface/ui_iface_view.h index 2d67074..50012bc 100644 --- a/src/include/interface/ui_iface_view.h +++ b/src/include/interface/ui_iface_view.h @@ -14,15 +14,13 @@ * limitations under the License. * */ -#ifndef UI_VIEW_INTERFACE_H_ -#define UI_VIEW_INTERFACE_H_ +#ifndef UI_IFACE_VIEW_H_ +#define UI_IFACE_VIEW_H_ #include using namespace std; -typedef void* T; - namespace viewmgr { class ui_iface_viewmgr; @@ -265,8 +263,13 @@ public: { return this->indicator; } + + virtual int get_degree() + { + return 0; + } }; } -#endif /* UI_VIEW_INTERFACE_H_ */ +#endif /* UI_IFACE_VIEW_H_ */ diff --git a/src/include/interface/ui_iface_viewmanager.h b/src/include/interface/ui_iface_viewmanager.h index 6001341..5175c27 100644 --- a/src/include/interface/ui_iface_viewmanager.h +++ b/src/include/interface/ui_iface_viewmanager.h @@ -14,8 +14,8 @@ * limitations under the License. * */ -#ifndef UI_VIEWMANAGER_INTERFACE_H_ -#define UI_VIEWMANAGER_INTERFACE_H_ +#ifndef UI_IFACE_VIEWMANAGER_H_ +#define UI_IFACE_VIEWMANAGER_H_ #include #include @@ -35,8 +35,11 @@ enum ui_view_indicator UI_VIEW_INDICATOR_LAST }; +typedef void* T; + #include "ui_iface_rotatable.h" +#include "ui_iface_overlay.h" #include "ui_iface_viewmgr.h" #include "ui_iface_view.h" -#endif /* UI_VIEWMANAGER_INTERFACE_H */ +#endif /* UI_IFACE_VIEWMANAGER_H */ diff --git a/src/include/interface/ui_iface_viewmgr.h b/src/include/interface/ui_iface_viewmgr.h index 4cfe687..4fce48e 100644 --- a/src/include/interface/ui_iface_viewmgr.h +++ b/src/include/interface/ui_iface_viewmgr.h @@ -14,8 +14,8 @@ * limitations under the License. * */ -#ifndef UI_VIEWMGR_INTERFACE_H_ -#define UI_VIEWMGR_INTERFACE_H_ +#ifndef UI_IFACE_VIEWMGR_H_ +#define UI_IFACE_VIEWMGR_H_ #include @@ -301,4 +301,4 @@ public: } -#endif /* UI_VIEWMGR_INTERFACE_H_ */ +#endif /* UI_IFACE_VIEWMGR_H_ */ diff --git a/src/lib/efl/mobile/ui_menu.cpp b/src/lib/efl/mobile/ui_menu.cpp index 27853bf..426ac2d 100644 --- a/src/lib/efl/mobile/ui_menu.cpp +++ b/src/lib/efl/mobile/ui_menu.cpp @@ -62,14 +62,12 @@ static bool update_menu(ui_menu *menu) static void win_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) { ui_menu *menu = static_cast(data); - Elm_Ctxpopup *ctxpopup = menu->get_content(); - if (!ctxpopup) return; - if (!evas_object_visible_get(ctxpopup)) return; + if (!menu->is_activated()) return; update_menu(menu); } ui_menu::ui_menu(ui_view *view) - : view(view), ctxpopup(NULL) + : ui_iface_overlay(view) { Elm_Win *win = this->get_window(); evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, win_resize_cb, this); @@ -79,7 +77,8 @@ ui_menu::~ui_menu() { Elm_Win *win = this->get_window(); if (win) evas_object_event_callback_del(win, EVAS_CALLBACK_RESIZE, win_resize_cb); - evas_object_del(this->ctxpopup); + Elm_Ctxpopup *ctxpopup = this->unset_content(); + evas_object_del(ctxpopup); } Elm_Win *ui_menu::get_window() @@ -96,17 +95,15 @@ Elm_Win *ui_menu::get_window() bool ui_menu::deactivate() { - if (this->ctxpopup) - { - elm_ctxpopup_dismiss(this->ctxpopup); - } - else + Elm_Ctxpopup *ctxpopup = this->get_content(); + if (!ctxpopup) { LOGE("Content is not set! = ui_menu(%p)", this); return false; } - this->view->on_resume(); + elm_ctxpopup_dismiss(ctxpopup); + dynamic_cast(this->get_view())->on_resume(); return true; } @@ -114,13 +111,16 @@ bool ui_menu::deactivate() bool ui_menu::activate() { bool ret = update_menu(this); - if (ret) this->view->on_pause(); + if (ret) dynamic_cast(this->get_view())->on_pause(); return ret; } bool ui_menu::set_content(Elm_Ctxpopup *ctxpopup) { - evas_object_del(this->ctxpopup); + Elm_Ctxpopup *prev = this->unset_content(); + evas_object_del(prev); + + if (!ctxpopup) return true; //validation! //FIXME: isa ? @@ -136,45 +136,35 @@ bool ui_menu::set_content(Elm_Ctxpopup *ctxpopup) evas_object_smart_callback_add(ctxpopup, "dismissed", ctxpopup_dismissed_cb, NULL); evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_DEL, ctxpopup_del_cb, this); - this->ctxpopup = ctxpopup; + ui_iface_overlay::set_content(ctxpopup); return true; } bool ui_menu::is_activated() { - if (!this->ctxpopup) return false; - return evas_object_visible_get(this->ctxpopup); + Elm_Ctxpopup *ctxpopup = this->get_content(); + if (!ctxpopup) return false; + return evas_object_visible_get(ctxpopup); } Elm_Ctxpopup *ui_menu::unset_content() { - if (!this->ctxpopup) return NULL; + Elm_Ctxpopup *ctxpopup = ui_iface_overlay::unset_content(); + if (!ctxpopup) return NULL; + + evas_object_smart_callback_del(ctxpopup, "dismissed", ctxpopup_dismissed_cb); + evas_object_event_callback_del(ctxpopup, EVAS_CALLBACK_DEL, ctxpopup_del_cb); - Elm_Ctxpopup *prev = this->ctxpopup; - this->ctxpopup = NULL; - evas_object_smart_callback_del(prev, "dismissed", ctxpopup_dismissed_cb); - evas_object_event_callback_del(prev, EVAS_CALLBACK_DEL, ctxpopup_del_cb); - return prev; + return ctxpopup; } Evas_Object *ui_menu::get_base() { - if (!this->view) - { - LOGE("View is null?? menu(%p)", this); - return NULL; - } - return this->get_window(); } -void ui_menu::on_back() -{ - this->deactivate(); -} - int ui_menu::get_degree() { - return this->view->get_degree(); + return this->get_view()->get_degree(); } diff --git a/src/lib/efl/ui_base_popup.cpp b/src/lib/efl/ui_base_popup.cpp index fc4db65..e2bcc1e 100644 --- a/src/lib/efl/ui_base_popup.cpp +++ b/src/lib/efl/ui_base_popup.cpp @@ -43,16 +43,16 @@ static void popup_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info } ui_base_popup::ui_base_popup(ui_base_view *view) - : view(view), popup(NULL) + : ui_iface_overlay(view) { view->connect_popup(this); } ui_base_popup::~ui_base_popup() { - this->view->disconnect_popup(this); - this->unset_content(); - evas_object_del(this->popup); + dynamic_cast(this->get_view())->disconnect_popup(this); + Elm_Popup *popup = this->unset_content(); + evas_object_del(popup); } Elm_Win *ui_base_popup::get_window() @@ -68,14 +68,15 @@ Elm_Win *ui_base_popup::get_window() bool ui_base_popup::deactivate() { - if (!this->popup) + Elm_Popup *popup = this->get_content(); + if (!popup) { LOGE("Content is not set! = ui_base_popup(%p)", this); return false; } - elm_popup_dismiss(this->popup); - this->view->on_resume(); + elm_popup_dismiss(popup); + dynamic_cast(this->get_view())->on_resume(); return true; } @@ -83,13 +84,16 @@ bool ui_base_popup::deactivate() bool ui_base_popup::activate() { bool ret = update_popup(this); - if (ret) this->view->on_pause(); + if (ret) dynamic_cast(this->get_view())->on_pause(); return ret; } bool ui_base_popup::set_content(Elm_Popup *popup) { - evas_object_del(this->popup); + Elm_Popup *prev = this->unset_content(); + evas_object_del(prev); + + if (!popup) return true; //validation! //FIXME: isa ? @@ -105,45 +109,35 @@ bool ui_base_popup::set_content(Elm_Popup *popup) evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, popup_del_cb, this); evas_object_smart_callback_add(popup, "dismissed", popup_dismissed_cb, this); - this->popup = popup; + ui_iface_overlay::set_content(popup); return true; } bool ui_base_popup::is_activated() { - if (!this->popup) return false; - return evas_object_visible_get(this->popup); + Elm_Popup *popup = this->get_content(); + if (!popup) return false; + return evas_object_visible_get(popup); } Elm_Popup *ui_base_popup::unset_content() { - if (!this->popup) return NULL; + Elm_Popup *popup = ui_iface_overlay::unset_content(); + if (!popup) return NULL; + + evas_object_event_callback_del(popup, EVAS_CALLBACK_DEL, popup_del_cb); + evas_object_smart_callback_del(popup, "dismissed", popup_dismissed_cb); - Elm_Popup *prev = this->popup; - this->popup = NULL; - evas_object_event_callback_del(prev, EVAS_CALLBACK_DEL, popup_del_cb); - evas_object_smart_callback_del(prev, "dismissed", popup_dismissed_cb); - return prev; + return popup; } Evas_Object *ui_base_popup::get_base() { - if (!this->view) - { - LOGE("View is null?? menu(%p)", this); - return NULL; - } - return this->get_window(); } -void ui_base_popup::on_back() -{ - this->deactivate(); -} - int ui_base_popup::get_degree() { - return this->view->get_degree(); + return this->get_view()->get_degree(); }