introduce ui_iface_overlay. 00/64300/3
authorHermet Park <hermet@hermet.pe.kr>
Thu, 31 Mar 2016 09:04:08 +0000 (18:04 +0900)
committerHermet Park <hermet@hermet.pe.kr>
Fri, 1 Apr 2016 05:15:47 +0000 (14:15 +0900)
this ui_iface_overlay is designed for overlaied object such as popup and menu...

Change-Id: I4aec2a3131cb208530677749bf2fed7716ce8c3c

src/include/efl/mobile/ui_menu.h
src/include/efl/ui_base_popup.h
src/include/efl/ui_base_view.h
src/include/efl/ui_base_viewmanager.h
src/include/interface/ui_iface_overlay.h [new file with mode: 0644]
src/include/interface/ui_iface_rotatable.h
src/include/interface/ui_iface_view.h
src/include/interface/ui_iface_viewmanager.h
src/include/interface/ui_iface_viewmgr.h
src/lib/efl/mobile/ui_menu.cpp
src/lib/efl/ui_base_popup.cpp

index ee01f46d06476d90227029bcd3b7fd9cd42153ac..613d2470812ce3f827381b7d137060f4f0c518f6 100644 (file)
@@ -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<Elm_Ctxpopup *>
 {
        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;
-       }
 };
 
 }
index 63d5d970136de654cdfb9cf4c1ead8dbe387e4e5..c1fba51e04ffb2d0b3369bbe4d18cc5e5c5bb6a0 100644 (file)
 
 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<Elm_Popup *>
 {
-       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;
-       }
 };
 
 }
index 7b6cadbddb39b697c2c1c739471188182d758327..ab1982268116461bcd8176898b6370323989e073 100644 (file)
@@ -20,9 +20,6 @@
 #include <Elementary.h>
 #include "../interface/ui_iface_viewmanager.h"
 
-#define CONVERT_TO_EO(T) static_cast<Evas_Object *>((T))
-#define CONVERT_TO_T(EO) static_cast<T>((EO))
-
 namespace efl_viewmgr
 {
 class ui_base_popup;
index 8a5a717c2e14ced463788a2837fc99ed5d289da0..71876b30682b193edca165287b143db955ebafd8 100644 (file)
 #endif
 #define LOG_TAG "UI_VIEWMGR"
 
+#define CONVERT_TO_EO(T) static_cast<Evas_Object *>((T))
+#define CONVERT_TO_T(EO) static_cast<T>((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 (file)
index 0000000..17aa7ad
--- /dev/null
@@ -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<typename T>
+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<typename T>
+ui_iface_overlay<T>::ui_iface_overlay(ui_iface_view *view)
+               : view(view), content(NULL)
+{
+}
+
+template<typename T>
+ui_iface_overlay<T>::~ui_iface_overlay()
+{
+}
+
+template<typename T>
+bool ui_iface_overlay<T>::set_content(T content)
+{
+       T prev = this->content;
+       this->content = content;
+       return true;
+}
+
+template<typename T>
+T ui_iface_overlay<T>::unset_content()
+{
+       T prev = this->content;
+       this->content = NULL;
+       return prev;
+}
+
+template<typename T>
+T ui_iface_overlay<T>::get_content()
+{
+       return this->content;
+}
+
+template<typename T>
+ui_iface_view *ui_iface_overlay<T>::get_view()
+{
+       return this->view;
+}
+
+template<typename T>
+void ui_iface_overlay<T>::on_back()
+{
+       this->deactivate();
+}
+
+}
+
+#endif /* UI_IFACE_OVERLAY_H */
index e5018df9923a3fca002d5463732b8ca1aa9130f1..f9f5dea22c73b30e5ee318394f4c26291d5b6352 100644 (file)
@@ -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_ */
index 2d67074120b5194957dae16e45eb1d6ad257f3d7..50012bc8a53d1f800c0c296b13f5a85f20a496fe 100644 (file)
  *  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 <string>
 
 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_ */
index 600134121457d3b716b5646590edbafefb2e4174..5175c27a2eaea1aff5b3762515b968e7f12c7ed1 100644 (file)
@@ -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 <app.h>
 #include <dlog.h>
@@ -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 */
index 4cfe687b5f8478c94aa96462a8a4b3f9546dc7c2..4fce48eb0791dba2a91131ee5078e9d4cec8dbee 100644 (file)
@@ -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 <list>
 
@@ -301,4 +301,4 @@ public:
 
 }
 
-#endif /* UI_VIEWMGR_INTERFACE_H_ */
+#endif /* UI_IFACE_VIEWMGR_H_ */
index 27853bfb8805464622fd26937222f1b62fb496b9..426ac2dc671809c5d3f93edc8097ba98406f283a 100644 (file)
@@ -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<ui_menu *>(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<ui_view *>(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<ui_view *>(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();
 }
index fc4db65f4b08ee91bbb0a274ef3bcb07ed90a402..e2bcc1e539fbe10cb3226662b2c79ebafbe0667a 100644 (file)
@@ -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<ui_base_view *>(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<ui_base_view*>(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<ui_base_view*>(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();
 }