move the domain of the popup. 18/64418/1
authorHermet Park <hermet@hermet.pe.kr>
Fri, 1 Apr 2016 05:30:16 +0000 (14:30 +0900)
committerHermet Park <hermet@hermet.pe.kr>
Fri, 1 Apr 2016 05:30:16 +0000 (14:30 +0900)
ui_base_popup -> ui_popup

Current popup behaviors are depending on mobile domain.
So changed it.

Change-Id: I3fd9493418ade8ecdfbeda281ce53174c3ca7147

14 files changed:
src/examples/efl/CMakeLists.txt
src/examples/efl/page12.h
src/include/efl/mobile/ui_menu.h
src/include/efl/mobile/ui_popup.h [new file with mode: 0644]
src/include/efl/mobile/ui_view.h
src/include/efl/mobile/ui_viewmanager.h
src/include/efl/ui_base_popup.h [deleted file]
src/include/efl/ui_base_view.h
src/include/efl/ui_base_viewmanager.h
src/lib/CMakeLists.txt
src/lib/efl/mobile/ui_popup.cpp [new file with mode: 0644]
src/lib/efl/mobile/ui_view.cpp
src/lib/efl/ui_base_popup.cpp [deleted file]
src/lib/efl/ui_base_view.cpp

index 99b4f7ff2d8ee7fc1d7787547799d1409cfa2b2a..b5e528db0394e0bdeb87dba9e5c395185a2946a2 100644 (file)
@@ -2,11 +2,11 @@ SET(EXAM_NAME viewmgr_demo)
 SET(EXAM_SRCS
          ../../lib/interface/ui_iface_view.cpp
          ../../lib/interface/ui_iface_viewmgr.cpp
-         ../../lib/efl/ui_base_popup.cpp
          ../../lib/efl/ui_base_view.cpp
          ../../lib/efl/ui_base_viewmgr.cpp
          ../../lib/efl/ui_base_key_listener.cpp
          ../../lib/efl/mobile/ui_menu.cpp
+         ../../lib/efl/mobile/ui_popup.cpp
          ../../lib/efl/mobile/ui_view.cpp
          ../../lib/efl/mobile/ui_key_listener.cpp
          ../../lib/efl/mobile/ui_viewmgr.cpp
index 33fbc759079a67a6743858b657cbd03fa01eb46d..f81d00e5d4ae5331a1f2731a101e3b35854d6b5c 100644 (file)
@@ -25,8 +25,8 @@ static void popup_dismissed_cb(void *data, Evas_Object *obj, void *event_info)
        //FIXME: remove dismissed callback because this callback is called twice.
        //It seems this is an efl or popup error, not this ui_popup nor example.
        evas_object_smart_callback_del(obj, "dismissed", popup_dismissed_cb);
-       ui_base_popup *overlay = static_cast<ui_base_popup *>(data);
-       delete (overlay);
+       ui_popup *popup = static_cast<ui_popup *>(data);
+       delete (popup);
 }
 
 class page12: public ui_view
@@ -71,26 +71,26 @@ public:
        void create_popup()
        {
                //FIXME: is overlay a proper name?
-               ui_base_popup *overlay = new ui_base_popup(this);
+               ui_popup *popup = new ui_popup(this);
 
-               Elm_Popup *popup = elm_popup_add(overlay->get_base());
-               elm_object_text_set(popup, "This popup has only text which is set via desc set function, (This popup gets hidden when user clicks outside) here timeout of 3 sec is set.");
-               elm_popup_timeout_set(popup, 3.0);
-               evas_object_smart_callback_add(popup, "dismissed", popup_dismissed_cb, overlay);
-               evas_object_smart_callback_add(popup, "block,clicked",
+               Elm_Popup *obj = elm_popup_add(popup->get_base());
+               elm_object_text_set(obj, "This popup has only text which is set via desc set function, (This popup gets hidden when user clicks outside) here timeout of 3 sec is set.");
+               elm_popup_timeout_set(obj, 3.0);
+               evas_object_smart_callback_add(obj, "dismissed", popup_dismissed_cb, popup);
+               evas_object_smart_callback_add(obj, "block,clicked",
                                [](void *data, Evas_Object *obj, void *event_info) -> void
                                {
                                        elm_popup_dismiss(obj);
                                },
                                NULL);
-               evas_object_smart_callback_add(popup, "timeout",
+               evas_object_smart_callback_add(obj, "timeout",
                                [](void *data, Evas_Object *obj, void *event_info) -> void
                                {
                                        elm_popup_dismiss(obj);
                                },
                                NULL);
-               overlay->set_content(popup);
-               overlay->activate();
+               popup->set_content(obj);
+               popup->activate();
        }
 };
 
index 613d2470812ce3f827381b7d137060f4f0c518f6..437ed29d59cf6787fb6a5ab39f4639158c4deaf5 100644 (file)
@@ -18,7 +18,6 @@
 #define UI_MENU_H
 
 #include "../../interface/ui_iface_viewmanager.h"
-#include "../ui_base_viewmanager.h"
 
 namespace efl_viewmgr
 {
diff --git a/src/include/efl/mobile/ui_popup.h b/src/include/efl/mobile/ui_popup.h
new file mode 100644 (file)
index 0000000..6eb6374
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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_POPUP_H
+#define UI_POPUP_H
+
+#include "../../interface/ui_iface_viewmanager.h"
+
+namespace efl_viewmgr
+{
+class ui_popup : public viewmgr::ui_iface_overlay<Elm_Popup *>
+{
+private:
+       Elm_Win *get_window();
+
+public:
+       ui_popup(ui_view *view);
+       virtual ~ui_popup();
+
+       virtual bool activate();
+       virtual bool deactivate();
+       virtual bool set_content(Elm_Popup* ctxpopup);
+       virtual Elm_Popup *unset_content();
+       virtual bool is_activated();
+
+       virtual Evas_Object *get_base();
+       virtual int get_degree();
+};
+
+}
+
+#endif /* UI_POPUP_H */
index bdc689975232c3c340404afb31598da4ee8b783e..070129b4c2a0fbe99b2ec0db74a418437d7da4b8 100644 (file)
@@ -23,11 +23,13 @@ namespace efl_viewmgr
 {
 
 class ui_menu;
+class ui_popup;
 class ui_key_listener;
 
 class ui_view: public ui_base_view
 {
        friend class ui_menu;
+       friend class ui_popup;
        friend class ui_key_listener;
 
 private:
@@ -36,6 +38,11 @@ private:
        Elm_Button *title_left_btn;        //Title left button
        Elm_Button *title_right_btn;       //Title right button
        ui_menu *menu;                     //Menu
+       list<ui_popup *> popup_list;
+
+       void connect_popup(ui_popup *popup);
+       void disconnect_popup(ui_popup *popup);
+       bool deactivate_popup(bool top_one);
 
        bool create_layout();
        bool destroy_layout();
@@ -53,6 +60,14 @@ protected:
        virtual void on_portrait();
        virtual void on_landscape();
 
+       /** @brief view deactivate state.
+        *
+        *  @note this state will be triggered by ui_iface_viewmgr.
+        *
+        */
+       virtual void on_deactivate();
+
+
 public:
        ui_view(const char *name = NULL);
        virtual ~ui_view();
index 797581f3accf318bd1f20e5741e59d9102612f6e..bebbadc23fc543a5a5bbbfd6889a557a31946c35 100644 (file)
@@ -25,5 +25,6 @@
 #include "ui_key_listener.h"
 #include "ui_viewmgr.h"
 #include "ui_menu.h"
+#include "ui_popup.h"
 
 #define UI_VIEWMGR dynamic_cast<ui_viewmgr *>(efl_viewmgr::ui_base_viewmgr::get_instance())
diff --git a/src/include/efl/ui_base_popup.h b/src/include/efl/ui_base_popup.h
deleted file mode 100644 (file)
index c1fba51..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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_BASE_POPUP_H
-#define UI_BASE_POPUP_H
-
-#include "../interface/ui_iface_viewmanager.h"
-
-namespace efl_viewmgr
-{
-class ui_base_popup : public viewmgr::ui_iface_overlay<Elm_Popup *>
-{
-private:
-       Elm_Win *get_window();
-
-public:
-       ui_base_popup(ui_base_view *view);
-       virtual ~ui_base_popup();
-
-       virtual bool activate();
-       virtual bool deactivate();
-       virtual bool set_content(Elm_Popup* ctxpopup);
-       virtual Elm_Popup *unset_content();
-       virtual bool is_activated();
-
-       virtual Evas_Object *get_base();
-       virtual int get_degree();
-};
-
-}
-
-#endif /* UI_BASE_POPUP_H */
index ab1982268116461bcd8176898b6370323989e073..71dc9f549e19c51f84019ecc727949d3801c6a84 100644 (file)
@@ -22,7 +22,6 @@
 
 namespace efl_viewmgr
 {
-class ui_base_popup;
 
 /**
  *  @class ui_base_view
@@ -39,14 +38,6 @@ class ui_base_popup;
 class ui_base_view: public viewmgr::ui_iface_view, public viewmgr::ui_iface_rotatable
 {
        friend class ui_base_viewmgr;
-       friend class ui_base_popup;
-
-private:
-       list<ui_base_popup *> popup_list;
-
-       void connect_popup(ui_base_popup *popup);
-       void disconnect_popup(ui_base_popup *popup);
-       bool deactivate_popup(bool top_one);
 
 protected:
        /** @brief Unload current view's content
@@ -75,13 +66,6 @@ protected:
        virtual void on_portrait();
        virtual void on_landscape();
 
-       /** @brief view deactivate state.
-        *
-        *  @note this state will be triggered by ui_iface_viewmgr.
-        *
-        */
-       virtual void on_deactivate();
-
 public:
        ///Constructor.
        ui_base_view(const char *name = NULL);
index 71876b30682b193edca165287b143db955ebafd8..82fa69fafaf3eac4dde317ea8ae33ee81ca91d12 100644 (file)
@@ -29,4 +29,3 @@
 #include "ui_base_viewmgr.h"
 #include "ui_base_view.h"
 #include "ui_base_key_listener.h"
-#include "ui_base_popup.h"
index 4a1e3b4f10b1db14322c51a5845442bbabec1c64..173841dcc9e6f8d499ba5e77670ab57cf99f3d27 100644 (file)
@@ -1,11 +1,11 @@
 SET(LIB_SRCS
      interface/ui_iface_view.cpp
      interface/ui_iface_viewmgr.cpp
-     efl/ui_base_popup.cpp
      efl/ui_base_view.cpp
      efl/ui_base_viewmgr.cpp
      efl/ui_base_key_listener.cpp
      efl/mobile/ui_menu.cpp
+     efl/mobile/ui_popup.cpp
      efl/mobile/ui_view.cpp
      efl/mobile/ui_key_listener.cpp
      efl/mobile/ui_viewmgr.cpp
diff --git a/src/lib/efl/mobile/ui_popup.cpp b/src/lib/efl/mobile/ui_popup.cpp
new file mode 100644 (file)
index 0000000..15b55a3
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * 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.
+ *
+ */
+#include "../../../include/efl/mobile/ui_viewmanager.h"
+
+using namespace efl_viewmgr;
+
+static bool update_popup(ui_popup *popup)
+{
+       Elm_Win *win = popup->get_base();
+       if (!win) return false;
+
+       Elm_Popup *_popup = popup->get_content();
+       if (!_popup) return false;
+
+       evas_object_show(_popup);
+
+       return true;
+}
+
+static void popup_dismissed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       evas_object_hide(obj);
+}
+
+static void popup_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+       ui_popup *popup = static_cast<ui_popup *>(data);
+       popup->unset_content();
+}
+
+ui_popup::ui_popup(ui_view *view)
+               : ui_iface_overlay(view)
+{
+       view->connect_popup(this);
+}
+
+ui_popup::~ui_popup()
+{
+       dynamic_cast<ui_view *>(this->get_view())->disconnect_popup(this);
+       Elm_Popup *popup = this->unset_content();
+       evas_object_del(popup);
+}
+
+Elm_Win *ui_popup::get_window()
+{
+       ui_viewmgr *viewmgr = UI_VIEWMGR;
+       if (!viewmgr)
+       {
+               LOGE("Viewmgr is null?? menu(%p)", this);
+               return NULL;
+       }
+       return viewmgr->get_window();
+}
+
+bool ui_popup::deactivate()
+{
+       Elm_Popup *popup = this->get_content();
+       if (!popup)
+       {
+               LOGE("Content is not set! = ui_popup(%p)", this);
+               return false;
+       }
+
+       elm_popup_dismiss(popup);
+       dynamic_cast<ui_view*>(this->get_view())->on_resume();
+
+       return true;
+}
+
+bool ui_popup::activate()
+{
+       bool ret = update_popup(this);
+       if (ret) dynamic_cast<ui_view*>(this->get_view())->on_pause();
+       return ret;
+}
+
+bool ui_popup::set_content(Elm_Popup *popup)
+{
+       Elm_Popup *prev = this->unset_content();
+       evas_object_del(prev);
+
+       if (!popup) return true;
+
+       //validation!
+       //FIXME: isa ?
+       if (strcmp(evas_object_type_get(popup), "elm_popup"))
+       {
+               LOGE("Menu widget is not a popup!");
+               return false;
+       }
+
+       elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
+
+       //FIXME: rename style.
+       evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, popup_del_cb, this);
+       evas_object_smart_callback_add(popup, "dismissed", popup_dismissed_cb, this);
+
+       ui_iface_overlay::set_content(popup);
+
+       return true;
+}
+
+bool ui_popup::is_activated()
+{
+       Elm_Popup *popup = this->get_content();
+       if (!popup) return false;
+       return evas_object_visible_get(popup);
+}
+
+Elm_Popup *ui_popup::unset_content()
+{
+       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);
+
+       return popup;
+}
+
+Evas_Object *ui_popup::get_base()
+{
+       return this->get_window();
+}
+
+int ui_popup::get_degree()
+{
+       return this->get_view()->get_degree();
+}
index a8cebd8efe65890355dd1f9802376eb766704984..5766f61e37f2888df276fee67a38daa689aec972 100644 (file)
@@ -23,6 +23,8 @@
 using namespace efl_viewmgr;
 using namespace viewmgr;
 
+typedef list<ui_popup*>::reverse_iterator popup_ritr;
+
 #define LAYOUT_VALIDATE() if (!layout) \
                                                        { \
                                                                LOGE("Layout is invalid! ui_view(%p)", this); \
@@ -47,6 +49,29 @@ static void toolbar_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_in
        view->unset_toolbar();
 }
 
+void ui_view::connect_popup(ui_popup *popup)
+{
+       this->popup_list.push_back(popup);
+}
+
+void ui_view::disconnect_popup(ui_popup *popup)
+{
+       this->popup_list.remove(popup);
+}
+
+bool ui_view::deactivate_popup(bool top_one)
+{
+       for (popup_ritr it = this->popup_list.rbegin(); it != this->popup_list.rend(); it++)
+       {
+               ui_popup *popup = *it;
+               if (!popup->is_activated()) continue;
+               popup->on_back();
+               //deactivate only one top one? or all popups?
+               if (top_one) return true;
+       }
+       return false;
+}
+
 bool ui_view::destroy_layout()
 {
        if (!this->layout) return false;
@@ -106,8 +131,17 @@ bool ui_view::create_layout()
        return true;
 }
 
+void ui_view::on_deactivate()
+{
+       deactivate_popup(false);
+       ui_base_view::on_deactivate();
+}
+
 void ui_view::on_back()
 {
+       //If any popup is activated, deactivate the popup first.
+       if (this->deactivate_popup(true)) return;
+
        if (this->menu)
        {
                if (this->menu->is_activated())
diff --git a/src/lib/efl/ui_base_popup.cpp b/src/lib/efl/ui_base_popup.cpp
deleted file mode 100644 (file)
index e2bcc1e..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * 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.
- *
- */
-#include "../../include/efl/ui_base_viewmanager.h"
-
-using namespace efl_viewmgr;
-
-static bool update_popup(ui_base_popup *popup)
-{
-       Elm_Win *win = popup->get_base();
-       if (!win) return false;
-
-       Elm_Popup *_popup = popup->get_content();
-       if (!_popup) return false;
-
-       evas_object_show(_popup);
-
-       return true;
-}
-
-static void popup_dismissed_cb(void *data, Evas_Object *obj, void *event_info)
-{
-       evas_object_hide(obj);
-}
-
-static void popup_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
-       ui_base_popup *popup = static_cast<ui_base_popup *>(data);
-       popup->unset_content();
-}
-
-ui_base_popup::ui_base_popup(ui_base_view *view)
-               : ui_iface_overlay(view)
-{
-       view->connect_popup(this);
-}
-
-ui_base_popup::~ui_base_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()
-{
-       ui_base_viewmgr *viewmgr = UI_BASE_VIEWMGR;
-       if (!viewmgr)
-       {
-               LOGE("Viewmgr is null?? menu(%p)", this);
-               return NULL;
-       }
-       return viewmgr->get_window();
-}
-
-bool ui_base_popup::deactivate()
-{
-       Elm_Popup *popup = this->get_content();
-       if (!popup)
-       {
-               LOGE("Content is not set! = ui_base_popup(%p)", this);
-               return false;
-       }
-
-       elm_popup_dismiss(popup);
-       dynamic_cast<ui_base_view*>(this->get_view())->on_resume();
-
-       return true;
-}
-
-bool ui_base_popup::activate()
-{
-       bool ret = update_popup(this);
-       if (ret) dynamic_cast<ui_base_view*>(this->get_view())->on_pause();
-       return ret;
-}
-
-bool ui_base_popup::set_content(Elm_Popup *popup)
-{
-       Elm_Popup *prev = this->unset_content();
-       evas_object_del(prev);
-
-       if (!popup) return true;
-
-       //validation!
-       //FIXME: isa ?
-       if (strcmp(evas_object_type_get(popup), "elm_popup"))
-       {
-               LOGE("Menu widget is not a popup!");
-               return false;
-       }
-
-       elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
-
-       //FIXME: rename style.
-       evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, popup_del_cb, this);
-       evas_object_smart_callback_add(popup, "dismissed", popup_dismissed_cb, this);
-
-       ui_iface_overlay::set_content(popup);
-
-       return true;
-}
-
-bool ui_base_popup::is_activated()
-{
-       Elm_Popup *popup = this->get_content();
-       if (!popup) return false;
-       return evas_object_visible_get(popup);
-}
-
-Elm_Popup *ui_base_popup::unset_content()
-{
-       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);
-
-       return popup;
-}
-
-Evas_Object *ui_base_popup::get_base()
-{
-       return this->get_window();
-}
-
-int ui_base_popup::get_degree()
-{
-       return this->get_view()->get_degree();
-}
index e8d70ece3062167b42bef6cbe1d6b5b3f752def2..f56212ec91b6352fc79288385dc31d24c37f43b9 100644 (file)
 using namespace efl_viewmgr;
 using namespace viewmgr;
 
-typedef list<ui_base_popup*>::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<ui_base_view *>(data);
        view->unset_content();
 }
 
-void ui_base_view::connect_popup(ui_base_popup *popup)
-{
-       this->popup_list.push_back(popup);
-}
-
-void ui_base_view::disconnect_popup(ui_base_popup *popup)
-{
-       this->popup_list.remove(popup);
-}
-
 ui_base_view::ui_base_view(const char *name)
                : ui_iface_view(name)
 {
@@ -123,30 +111,8 @@ void ui_base_view::set_indicator(ui_view_indicator indicator)
        viewmgr->set_indicator(indicator);
 }
 
-bool ui_base_view::deactivate_popup(bool top_one)
-{
-       for (popup_ritr it = this->popup_list.rbegin(); it != this->popup_list.rend(); it++)
-       {
-               ui_base_popup *popup = *it;
-               if (!popup->is_activated()) continue;
-               popup->on_back();
-               //deactivate only one top one? or all popups?
-               if (top_one) return true;
-       }
-       return false;
-}
-
-void ui_base_view::on_deactivate()
-{
-       deactivate_popup(false);
-       ui_iface_view::on_deactivate();
-}
-
 void ui_base_view::on_back()
 {
-       //If any popup is activated, deactivate the popup first.
-       if (this->deactivate_popup(true)) return;
-
        ui_base_viewmgr *viewmgr = UI_BASE_VIEWMGR;
        if (!viewmgr)
        {