remove template code. 82/67982/2
authorHermet Park <hermet@hermet.pe.kr>
Fri, 29 Apr 2016 12:48:14 +0000 (21:48 +0900)
committerHermet Park <hermet@hermet.pe.kr>
Fri, 29 Apr 2016 12:53:52 +0000 (21:53 +0900)
let's simplify interface.

This is third step for sorting up public interfaces.

Change-Id: Id461b5f395ebfd35f431c70b6002e80abaa14166

13 files changed:
src/include/efl/ui_base_overlay.h
src/include/efl/ui_base_view.h
src/include/efl/ui_base_viewmanager.h
src/include/efl/ui_base_viewmgr.h
src/include/interface/ui_iface_overlay.h
src/include/interface/ui_iface_singleton.h
src/include/interface/ui_iface_view.h
src/include/interface/ui_iface_viewmanager.h
src/include/interface/ui_iface_viewmgr.h
src/lib/CMakeLists.txt
src/lib/interface/ui_iface_overlay.cpp [new file with mode: 0644]
src/lib/interface/ui_iface_view.cpp [new file with mode: 0644]
src/lib/interface/ui_iface_viewmgr.cpp [new file with mode: 0644]

index 849743dd12a709b5057002f31ac53b10d433516e..ee0fb750e79ae660d1ceabd7a98ee1f2b5f4e54c 100644 (file)
@@ -23,7 +23,7 @@ namespace efl_viewmanager
 class ui_base_viewmgr;
 class ui_base_view;
 
-class ui_base_overlay: public ui_iface_overlay<Evas_Object *>
+class ui_base_overlay: public ui_iface_overlay
 {
 protected:
        ui_base_overlay(ui_base_view *view);
index 58abebd5e77193c60a8c8c2165aa32895caf8aee..2f41438d802b0260b4ce00fbbce3b2f1d30a255d 100644 (file)
@@ -32,7 +32,7 @@ namespace efl_viewmanager
  *  @warning When the transitions are finished, the view must to call ui_iface_viewmgr :: _push_finished(), ui_iface_viewmgr :: _pop_finished() in order that
  *           The ui_iface_viewmgr keeps the view states exactly.
  */
-class ui_base_view: public ui_iface_view<Evas_Object *>
+class ui_base_view: public ui_iface_view
 {
        friend class ui_base_viewmgr;
 
index 0576ab553022c36965112d2e11f02b9724eadcd8..f03c71178f0f2580a3fbd6e97f8ab27eac49bf97 100644 (file)
 #ifndef _UI_BASE_VIEWMANAGER_H_
 #define _UI_BASE_VIEWMANAGER_H_
 
-#include <Elementary.h>
 #include "../interface/ui_iface_viewmanager.h"
 #include "ui_base_overlay.h"
 #include "ui_base_key_listener.h"
 #include "ui_base_viewmgr.h"
 #include "ui_base_view.h"
 
-#define UI_BASE_VIEWMGR dynamic_cast<ui_base_viewmgr *>(ui_iface_viewmgr<Evas_Object *>::get_instance())
+#define UI_BASE_VIEWMGR dynamic_cast<ui_base_viewmgr *>(ui_iface_viewmgr::get_instance())
 
 using namespace efl_viewmanager;
 
index e5052093e4431a3c1ee84c84e4fe30eac8eaa1b3..64b20f0f7d70671468f63150658632ff8f79ef1e 100644 (file)
@@ -40,7 +40,7 @@ class ui_base_view;
  *
  *  @warning viewmgr will remove all containing views when it's destroyed.
  */
-class ui_base_viewmgr: public ui_iface_viewmgr<Evas_Object *>
+class ui_base_viewmgr: public ui_iface_viewmgr
 {
        friend class ui_base_view;
 
@@ -51,7 +51,7 @@ private:
        Elm_Layout *layout;                        //Viewmgr's base layout.
        ui_base_key_listener *key_listener;        //HW Key Handler such as "BACK" key...
        ui_view_indicator indicator;               //Mode of indicator.
-       string transition_style;                   //Current transiton effect style name
+       string transition_style;                   //Current transition effect style name
        map<string, Elm_Layout *> effect_map;      //Map for effect layouts.
 
        Elm_Layout *set_transition_layout(string transition_style);
index 960ac22953a5d3cd2698bf59b8b1754034697e94..fcbaa4340f45f4e41176d7819289dd3b0fcc80c2 100644 (file)
 namespace ui_viewmanager
 {
 
-template<typename T>
 class ui_iface_view;
 
-template<typename T>
 class ui_iface_overlay: public ui_iface_rotatable
 {
 private:
-       ui_iface_view<T> *view;
+       ui_iface_view *view;
        T content;
 
 protected:
-       ui_iface_overlay(ui_iface_view<T> *view);
+       ui_iface_overlay(ui_iface_view *view);
        virtual ~ui_iface_overlay();
 
 public:
        virtual bool set_content(T content);
        virtual T unset_content();
-       ui_iface_view<T> *get_view();
+       ui_iface_view *get_view();
        virtual T get_content();
        virtual void on_back();
        virtual bool activate() = 0;
@@ -45,51 +43,6 @@ public:
        virtual bool is_activated() = 0;
 };
 
-
-template<typename T>
-ui_iface_overlay<T>::ui_iface_overlay(ui_iface_view<T> *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)
-{
-       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<T> *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 fe944ef6ae65f1ec9a4da4b818ee331f4fb122c5..d351ad20cab07ae593e658d12c1c3409f6ef4d68 100644 (file)
@@ -4,38 +4,38 @@
 namespace ui_viewmanager
 {
 
-template<typename T>
+template<typename XX>
 class singleton
 {
 private:
-       static T* inst;
+       static XX* inst;
 
 public:
        singleton();
        virtual ~singleton();
-       inline static T* get_instance();
+       inline static XX* get_instance();
 };
 
-template<typename T> T* singleton<T>::inst = NULL;
+template<typename XX> XX* singleton<XX>::inst = NULL;
 
-template<typename T>
-singleton<T>::singleton()
+template<typename XX>
+singleton<XX>::singleton()
 {
-       T* pT = reinterpret_cast<T*>(1);
+       XX* pT = reinterpret_cast<XX*>(1);
 
        //Derived Class - Singleton class
-       int offset = reinterpret_cast<int>(pT) - reinterpret_cast<int>(reinterpret_cast<singleton<T>*>(pT));
-       singleton::inst = reinterpret_cast<T*>((reinterpret_cast<int>(this) + offset));
+       int offset = reinterpret_cast<int>(pT) - reinterpret_cast<int>(reinterpret_cast<singleton<XX>*>(pT));
+       singleton::inst = reinterpret_cast<XX*>((reinterpret_cast<int>(this) + offset));
 }
 
-template<typename T>
-singleton<T>::~singleton()
+template<typename XX>
+singleton<XX>::~singleton()
 {
        singleton::inst = NULL;
 }
 
-template<typename T>
-T* singleton<T>::get_instance()
+template<typename XX>
+XX* singleton<XX>::get_instance()
 {
        return singleton::inst;
 }
index 754e549ea42ac4fbeb57a1f78e38f84ddbc67af2..2e7774e8380ba6e1c2b499fd5a712583ff0bfa28 100644 (file)
@@ -23,7 +23,6 @@ using namespace std;
 
 namespace ui_viewmanager {
 
-template<typename T>
 class ui_iface_viewmgr;
 
 /**
@@ -39,16 +38,15 @@ class ui_iface_viewmgr;
  *  @warning When the transitions are finished, the view must to call ui_iface_viewmgr :: _push_finished(), ui_iface_viewmgr :: _pop_finished() in order that
  *           The ui_iface_viewmgr keeps the view states exactly.
  */
-template<typename T>
 class ui_iface_view : public ui_iface_rotatable
 {
-       friend class ui_iface_viewmgr<T>;
+       friend class ui_iface_viewmgr;
 
 private:
        T content;                              ///< A content instance for a screen as a view.
        string name;                            ///< View name.
        string transition_style;                ///< View transition style name.
-       ui_iface_viewmgr<T> *viewmgr;           ///< Viewmgr which this view belongs to.
+       ui_iface_viewmgr *viewmgr       ;           ///< Viewmgr which this view belongs to.
        ui_view_state state;                    ///< View state.
        ui_view_indicator indicator;            ///< View indicator mode.
        bool event_block;                       ///< State of event block.
@@ -123,7 +121,7 @@ protected:
        /** @brief Return a viewmgr which this view is belonging to.
         */
        //FIXME: Is it necessary?
-       ui_iface_viewmgr<T> *get_viewmgr();
+       ui_iface_viewmgr *get_viewmgr();
 
        /** @brief This is for replacing or setting a content of the view.
         *
@@ -232,176 +230,6 @@ public:
        void on_back();
 };
 
-
-template<typename T>
-bool ui_iface_view<T>::get_event_block()
-{
-       return this->event_block;
-}
-
-template<typename T>
-ui_iface_viewmgr<T> *ui_iface_view<T>::get_viewmgr()
-{
-       return this->viewmgr;
-}
-
-template<typename T>
-void ui_iface_view<T>::set_event_block(bool block)
-{
-       this->event_block = block;
-}
-
-template<typename T>
-void ui_iface_view<T>::on_load()
-{
-       this->state = UI_VIEW_STATE_LOAD;
-}
-
-template<typename T>
-void ui_iface_view<T>::on_unload()
-{
-       this->state = UI_VIEW_STATE_UNLOAD;
-       if (this->get_removable_content())
-       {
-               this->set_content(NULL);
-               return;
-       }
-}
-
-template<typename T>
-void ui_iface_view<T>::on_activate()
-{
-       this->state = UI_VIEW_STATE_ACTIVATE;
-}
-
-template<typename T>
-void ui_iface_view<T>::on_deactivate()
-{
-       this->state = UI_VIEW_STATE_DEACTIVATE;
-}
-
-template<typename T>
-void ui_iface_view<T>::on_pause()
-{
-       this->state = UI_VIEW_STATE_PAUSE;
-}
-
-template<typename T>
-void ui_iface_view<T>::on_resume()
-{
-       this->state = UI_VIEW_STATE_ACTIVATE;
-}
-
-template<typename T>
-void ui_iface_view<T>::on_destroy()
-{
-}
-
-template<typename T>
-ui_iface_view<T>::ui_iface_view(const char *name)
-               : content(NULL), name(string(name ? name : "")), transition_style(string("default")), viewmgr(NULL), state(UI_VIEW_STATE_LOAD),
-                 indicator(UI_VIEW_INDICATOR_DEFAULT), event_block(false), removable_content(true)
-{
-       this->state = UI_VIEW_STATE_UNLOAD;
-}
-
-template<typename T>
-ui_iface_view<T>::~ui_iface_view()
-{
-       this->viewmgr->remove_view(this);
-}
-
-template<typename T>
-bool ui_iface_view<T>::set_content(T content)
-{
-       this->content = content;
-       return true;
-}
-
-template<typename T>
-T ui_iface_view<T>::unset_content()
-{
-       T prev = this->content;
-       this->content = NULL;
-       return prev;
-}
-
-template<typename T>
-bool ui_iface_view<T>::set_transition_style(const char *style)
-{
-       this->transition_style.assign(style);
-       return true;
-}
-
-template<typename T>
-bool ui_iface_view<T>::set_name(const char *name)
-{
-       this->name.assign(name);
-       return true;
-}
-
-template<typename T>
-void ui_iface_view<T>::set_removable_content(bool removable)
-{
-       this->removable_content = removable;
-
-       //FIXME: If this api is called on unload state? should we remove content right now?
-}
-
-template<typename T>
-void ui_iface_view<T>::set_indicator(ui_view_indicator indicator)
-{
-       this->indicator = indicator;
-}
-
-template<typename T>
-const char *ui_iface_view<T>::get_transition_style()
-{
-       return this->transition_style.c_str();
-}
-
-template<typename T>
-const char *ui_iface_view<T>::get_name()
-{
-       return this->name.c_str();
-}
-
-template<typename T>
-T ui_iface_view<T>::get_content()
-{
-       return this->content;
-}
-
-template<typename T>
-ui_view_state ui_iface_view<T>::get_state()
-{
-       return this->state;
-}
-
-template<typename T>
-bool ui_iface_view<T>::get_removable_content()
-{
-       return this->removable_content;
-}
-
-template<typename T>
-ui_view_indicator ui_iface_view<T>::get_indicator()
-{
-       return this->indicator;
-}
-
-template<typename T>
-void ui_iface_view<T>::on_back()
-{
-       ui_iface_viewmgr<T> *viewmgr = this->get_viewmgr();
-       if (!viewmgr)
-       {
-               LOGE("Failed to get a viewmgr, view =%p", this);
-               return;
-       }
-       viewmgr->pop_view();
-}
-
 }
 
 #endif /* _UI_IFACE_VIEW_H_ */
index 35bcd7d8ee9c4eb1348b1626715ec6b6356bab68..388ee3a10b00a8e454f68af2b5e78db31063682b 100644 (file)
 #include <app.h>
 #include <dlog.h>
 
+#define UI_EFL 1
+
+#if UI_EFL
+       #include <Elementary.h>
+       typedef Evas_Object* T;
+#else if UI_DALI
+#endif
+
 #ifdef  LOG_TAG
 #undef  LOG_TAG
 #endif
@@ -53,4 +61,13 @@ enum ui_view_state
 
 using namespace ui_viewmanager;
 
+#define _UI_DECLARE_PRIVATE_IMPL(A) \
+       class A_##impl *impl; \
+       friend class A_##impl
+
+#define _UI_DISABLE_COPY_AND_ASSIGN(A) \
+       A_##impl(const A_##impl&) = delete; \
+       const A_##impl& operator=(const A_##impl&) = delete
+
+
 #endif /* UI_IFACE_VIEWMANAGER_H */
index 30d23c159aa08dd24e66af7add77f3b59d0bf7da..6907244d7f2aa13a9b1e017193a18bf8ebce3ab7 100644 (file)
@@ -23,7 +23,6 @@ using namespace std;
 
 namespace ui_viewmanager {
 
-template<typename T>
 class ui_iface_view;
 
 /**
@@ -38,16 +37,15 @@ class ui_iface_view;
  *
  *  @warning viewmgr will remove all containing views when it's destroyed.
  */
-template<typename T>
 class ui_iface_viewmgr
 {
-       friend class ui_iface_view<T>;
+       friend class ui_iface_view;
 
 private:
-       static ui_iface_viewmgr<T> *inst;
+       static ui_iface_viewmgr *inst;
        static bool soft_key;                      //If system doesn't support HW back key, then this value is @c true.
        static bool event_block;                   //Event block on view transition. This value should be configurable by system.
-       list<ui_iface_view<T> *> view_list;        //View list.
+       list<ui_iface_view *> view_list;            //View list.
        bool activated;                            //Activated status of this viewmgr.
 
        /**
@@ -60,7 +58,7 @@ private:
         *  @warning If the given view is already connected to a viewmgr, this call will be failed.
         *  @see disconnect_view()
         */
-       bool connect_view(ui_iface_view<T> *view);
+       bool connect_view(ui_iface_view *view);
 
        /**
         *  @brief Disconnect a given view from this viewmgr.
@@ -71,7 +69,7 @@ private:
         *
         *  @see connect_view()
         */
-       bool disconnect_view(ui_iface_view<T> *view);
+       bool disconnect_view(ui_iface_view *view);
 
        /**
         *  @brief Toggle event blocking to the given view.
@@ -83,7 +81,7 @@ private:
         *  @param view A view to toggle event blocking.
         *  @param block @c true is blocking event, otherwise @c false.
         */
-       void set_event_block(ui_iface_view<T> *view, bool block);
+       void set_event_block(ui_iface_view *view, bool block);
 
 protected:
        /**
@@ -95,7 +93,7 @@ protected:
         *
         *  @warning This function must be called when push transition is finished.
         */
-       bool push_view_finished(ui_iface_view<T> *view);
+       bool push_view_finished(ui_iface_view *view);
 
        /**
         *  @brief This function is designed for finishing process for pop transition.
@@ -108,7 +106,7 @@ protected:
         *
         *  @warning This function must be called when push transition is finished.
         */
-       bool pop_view_finished(ui_iface_view<T> *view);
+       bool pop_view_finished(ui_iface_view *view);
 
        /**
         *  @brief Push a new view into this viewmgr. This function is used for when application switches a current view to a new one.
@@ -127,7 +125,7 @@ protected:
         *  @see insert_view_after()
         *  @see pop_view()
         */
-       ui_iface_view<T> *push_view(ui_iface_view<T> *view);
+       ui_iface_view *push_view(ui_iface_view *view);
 
        /**
         *  @brief Pop the top(last) view from this viewmgr view list.
@@ -152,7 +150,7 @@ protected:
         *
         *  @return @c true on success or @c false otherwise.
         */
-       bool insert_view_before(ui_iface_view<T> *view, ui_iface_view<T> *before);
+       bool insert_view_before(ui_iface_view *view, ui_iface_view *before);
 
        /**
         *  @brief Insert a view in this viewmgr view list. Specifically, insert a given @p view right after of the given view, @after.
@@ -162,7 +160,7 @@ protected:
         *
         *  @return @c true on success or @c false otherwise.
         */
-       bool insert_view_after(ui_iface_view<T> *view, ui_iface_view<T> *after);
+       bool insert_view_after(ui_iface_view *view, ui_iface_view *after);
 
        /**
         *  @brief Remove the given view from this viewmgr view list.
@@ -175,7 +173,7 @@ protected:
         *  @see insert_view_after()
         *  @see push_view()
         */
-       bool remove_view(ui_iface_view<T> *view);
+       bool remove_view(ui_iface_view *view);
 
        /**
         *  @brief Return a view which is matched with the index @p idx.
@@ -191,7 +189,7 @@ protected:
         *  @see get_view_index()
         *  @see get_view_count()
         */
-       ui_iface_view<T>* get_view(unsigned int idx);
+       ui_iface_view* get_view(unsigned int idx);
 
        /**
         *  @brief Return a view which is matched with the @p name.
@@ -205,14 +203,14 @@ protected:
         *
         *  @see ui_iface_view::set_name()
         */
-       ui_iface_view<T> *get_view(const char *name);
+       ui_iface_view *get_view(const char *name);
 
        /**
         *  @brief Return a last(top) view.
         *
         *  @return The view which is last view of the viewmgr view list.
         */
-       ui_iface_view<T> *get_last_view();
+       ui_iface_view *get_last_view();
 
        /**
         *  @brief Return a view index(page) number of the given view.
@@ -224,7 +222,7 @@ protected:
         *
         *  @warning The index number of views are variable since the view list is variable.
         */
-       int get_view_index(const ui_iface_view<T> *view);
+       int get_view_index(const ui_iface_view *view);
 
        ///Constructor.
        ui_iface_viewmgr();
@@ -286,376 +284,9 @@ public:
         *  @return @c true if soft key is required, @c false otherwise.
         */
        static bool need_soft_key();
-       static ui_iface_viewmgr<T>* get_instance();
+       static ui_iface_viewmgr* get_instance();
 };
 
-
-template<typename T> ui_iface_viewmgr<T> *ui_iface_viewmgr<T>::inst = NULL;
-
-#define VIEW_ITR typename list<ui_iface_view<T> *>::iterator
-#define VIEW_RITR typename list<ui_iface_view<T> *>::reverse_iterator
-
-//FIXME: Read system profile to decide whether support software key or not.
-template<typename T> bool ui_iface_viewmgr<T>::soft_key = true;
-//FIXME: Read system profile to decide whether support event block or not.
-template<typename T> bool ui_iface_viewmgr<T>::event_block = true;
-
-
-template<typename T>
-bool ui_iface_viewmgr<T>::insert_view_after(ui_iface_view<T> *view, ui_iface_view<T> *after)
-{
-       VIEW_ITR it;
-
-       if (!view)
-       {
-               LOGE("invalid view argument. view(NULL)");
-               return false;
-       }
-
-       if (!this->connect_view(view))
-       {
-               LOGE("connect view failed");
-               return false;
-       }
-
-       if (this->view_list.size() > 0)
-       {
-               for (it = this->view_list.begin(); it != this->view_list.end(); it++)
-               {
-                       if (after == *it)
-                       {
-                               //If the after is a last item of list.
-                               //view has to push now.
-                               if (it == this->view_list.end())
-                                       this->push_view(view);
-                               else
-                                       this->view_list.insert(++it, view);
-
-                               return true;
-                       }
-               }
-       }
-
-       //If there is no matching after view with current list.
-       //also in case of after is NULL.
-       this->push_view(view);
-
-       return true;
-}
-
-template<typename T>
-bool ui_iface_viewmgr<T>::need_soft_key()
-{
-       return ui_iface_viewmgr<T>::soft_key;
-}
-
-template<typename T>
-bool ui_iface_viewmgr<T>::connect_view(ui_iface_view<T> *view)
-{
-       //FIXME: If user call a set_viewmgr() before, It should not return false.
-       /*
-       if (view->viewmgr)
-       {
-               LOGE("view(%p) has already connected to viewmgr(%p)", view, this);
-               return false;
-       }
-       */
-
-       view->viewmgr = this;
-       return true;
-}
-
-template<typename T>
-bool ui_iface_viewmgr<T>::disconnect_view(ui_iface_view<T> *view)
-{
-       if (!view->viewmgr) return false;
-       view->viewmgr = NULL;
-       return true;
-}
-
-template<typename T>
-void ui_iface_viewmgr<T>::set_event_block(ui_iface_view<T> *view, bool block)
-{
-       if (!ui_iface_viewmgr::event_block) return;
-       view->set_event_block(block);
-}
-
-template<typename T>
-bool ui_iface_viewmgr<T>::push_view_finished(ui_iface_view<T> *view)
-{
-       ui_iface_view<T> *last = this->view_list.back();
-
-       //The previous view has been pushed. This should be unload.
-       if (last != view)
-       {
-               view->on_unload();
-               return true;
-       }
-
-       //A new view has been pushed. This should be activate.
-       view->on_activate();
-       this->set_event_block(view, false);
-
-       return true;
-}
-
-template<typename T>
-bool ui_iface_viewmgr<T>::pop_view_finished(ui_iface_view<T> *view)
-{
-       ui_iface_view<T> *last = this->view_list.back();
-
-       //This view has been popped. It should be destroyed.
-       if (last == view)
-       {
-               view->on_unload();
-               view->on_destroy();
-               delete (view);
-               return true;
-       }
-
-       //The previous view has been popped. It should become activate.
-       view->on_activate();
-       this->set_event_block(view, false);
-
-       return true;
-}
-
-template<typename T>
-ui_iface_viewmgr<T>::ui_iface_viewmgr(const ui_iface_viewmgr<T>& viewmgr)
-{
-}
-
-template<typename T>
-ui_iface_viewmgr<T>::ui_iface_viewmgr()
-               : activated(false)
-{
-       ui_iface_viewmgr<T>::inst = this;
-}
-
-template<typename T>
-ui_iface_viewmgr<T>::~ui_iface_viewmgr()
-{
-       //Terminate views
-       for (VIEW_RITR it = this->view_list.rbegin(); it != this->view_list.rend(); it++)
-       {
-               ui_iface_view<T> *view = *it;
-               view->on_deactivate();
-               view->on_unload();
-               view->on_destroy();
-               delete (view);
-       }
-
-       //FIXME: Window is destroyed. Terminate Application!
-       ui_app_exit();
-
-       ui_iface_viewmgr::inst = NULL;
-}
-
-template<typename T>
-ui_iface_view<T> *ui_iface_viewmgr<T>::push_view(ui_iface_view<T> *view)
-{
-       if (!view)
-       {
-               LOGE("invalid view argument. view(NULL)");
-               return NULL;
-       }
-
-       if (!this->connect_view(view))
-       {
-               LOGE("connect view failed");
-               return NULL;
-       }
-
-       ui_iface_view<T> *pview;
-
-       //Previous view
-       if (this->view_list.size() > 0)
-       {
-               pview = this->view_list.back();
-               pview->on_deactivate();
-               this->set_event_block(pview, true);
-       }
-
-       this->view_list.push_back(view);
-
-       if (!view->get_content())
-       {
-               view->on_load();
-       }
-
-       view->on_deactivate();
-
-       if (this->view_list.size() != 1)
-       {
-               this->set_event_block(view, true);
-       }
-
-       return view;
-}
-
-template<typename T>
-bool ui_iface_viewmgr<T>::pop_view()
-{
-       //FIXME: No more view?
-       if (this->get_view_count() == 0)
-       {
-               LOGE("No Views. Can't pop anymore!");
-               return false;
-       }
-
-       //This is the last page.
-       if (this->get_view_count() == 1)
-       {
-               //destroy viewmgr?
-               ui_iface_view<T>*view = this->view_list.back();
-               view->on_deactivate();
-               view->on_unload();
-               view->on_destroy();
-               delete(view);
-
-               return true;
-       }
-
-       //last page to be popped.
-       ui_iface_view<T>*view = this->view_list.back();
-       view->on_deactivate();
-       this->set_event_block(view, true);
-
-       //Below object has to be used in child class...
-       //Make this getter method? or define instance?
-       //previous page is to be an active page.
-       auto nx = prev(this->view_list.end(), 2);
-       ui_iface_view<T>*pview = *nx;
-       pview->on_load();
-       pview->on_deactivate();
-       this->set_event_block(pview, true);
-
-       return true;
-}
-
-template<typename T>
-bool ui_iface_viewmgr<T>::insert_view_before(ui_iface_view<T> *view, ui_iface_view<T> *before)
-{
-       VIEW_ITR it;
-
-       if (!view)
-       {
-               LOGE("invalid view argument. view(NULL)");
-               return false;
-       }
-
-       if (!this->connect_view(view))
-       {
-               LOGE("connect view failed");
-               return false;
-       }
-
-       if (this->view_list.size() > 0)
-       {
-               for (it = this->view_list.begin(); it != this->view_list.end(); it++)
-               {
-                       if (before == *it)
-                       {
-                               this->view_list.insert(it, view);
-
-                               return true;
-                       }
-               }
-       }
-
-       //If there is no matching before view with current list.
-       //also in case of before is NULL.
-       this->push_view(view);
-
-       return true;
-}
-
-template<typename T>
-bool ui_iface_viewmgr<T>::remove_view(ui_iface_view<T> *view)
-{
-       this->view_list.remove(view);
-       this->disconnect_view(view);
-
-       //TODO: If this view is the top on the stack ?
-       return true;
-}
-
-template<typename T>
-ui_iface_view<T> *ui_iface_viewmgr<T>::get_view(unsigned int idx)
-{
-       if (idx < 0 || idx >= this->view_list.size())
-       {
-               LOGE("Invalid idx(%d)! =? (idx range: %d ~ %d)", idx, 0, this->view_list.size() - 1);
-               return NULL;
-       }
-       VIEW_ITR it = this->view_list.begin();
-       advance(it, idx);
-       return *it;
-}
-
-template<typename T>
-int ui_iface_viewmgr<T>::get_view_index(const ui_iface_view<T> *view)
-{
-       int idx = 0;
-
-       for (VIEW_ITR it = this->view_list.begin(); it != this->view_list.end(); it++)
-       {
-               if (view == *it) return idx;
-               ++idx;
-       }
-
-       return -1;
-}
-
-template<typename T>
-ui_iface_view<T> *ui_iface_viewmgr<T>::get_last_view()
-{
-       int cnt = this->get_view_count();
-       return this->get_view(cnt - 1);
-}
-
-template<typename T>
-bool ui_iface_viewmgr<T>::activate()
-{
-       if (this->activated) return false;
-       if (this->get_view_count() == 0) return false;
-       this->activated = true;
-       return true;
-}
-
-template<typename T>
-bool ui_iface_viewmgr<T>::deactivate()
-{
-       if (!this->activated) return false;
-       this->activated = false;
-       return true;
-}
-
-template<typename T>
-ui_iface_view<T> *ui_iface_viewmgr<T>::get_view(const char *name)
-{
-       //FIXME: ...
-       return NULL;
-}
-
-template<typename T>
-bool ui_iface_viewmgr<T>::is_activated()
-{
-       return this->activated;
-}
-
-template<typename T>
-unsigned int ui_iface_viewmgr<T>::get_view_count()
-{
-       return this->view_list.size();
-}
-
-template<typename T>
-ui_iface_viewmgr<T>* ui_iface_viewmgr<T>::get_instance()
-{
-       return ui_iface_viewmgr::inst;
-}
-
 }
 
 #endif /* _UI_IFACE_VIEWMGR_H_ */
index e52e293797af3b0f8d2de2b6bb1a70a491dbaf51..eb85b844097a2ab9a3830d8fb7c1e53e44982b48 100644 (file)
@@ -1,4 +1,7 @@
 SET(SRCS
+     interface/ui_iface_overlay.cpp
+     interface/ui_iface_view.cpp
+     interface/ui_iface_viewmgr.cpp
      efl/ui_base_view.cpp
      efl/ui_base_viewmgr.cpp
      efl/ui_base_key_listener.cpp
diff --git a/src/lib/interface/ui_iface_overlay.cpp b/src/lib/interface/ui_iface_overlay.cpp
new file mode 100644 (file)
index 0000000..e65aa3c
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * 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/interface/ui_iface_viewmanager.h"
+
+ui_iface_overlay::ui_iface_overlay(ui_iface_view *view)
+               : view(view), content(NULL)
+{
+}
+
+ui_iface_overlay::~ui_iface_overlay()
+{
+}
+
+bool ui_iface_overlay::set_content(T content)
+{
+       this->content = content;
+       return true;
+}
+
+T ui_iface_overlay::unset_content()
+{
+       T prev = this->content;
+       this->content = NULL;
+       return prev;
+}
+
+T ui_iface_overlay::get_content()
+{
+       return this->content;
+}
+
+ui_iface_view *ui_iface_overlay::get_view()
+{
+       return this->view;
+}
+
+void ui_iface_overlay::on_back()
+{
+       this->deactivate();
+}
diff --git a/src/lib/interface/ui_iface_view.cpp b/src/lib/interface/ui_iface_view.cpp
new file mode 100644 (file)
index 0000000..c06fcca
--- /dev/null
@@ -0,0 +1,162 @@
+/*
+ * 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/interface/ui_iface_viewmanager.h"
+
+bool ui_iface_view::get_event_block()
+{
+       return this->event_block;
+}
+
+ui_iface_viewmgr *ui_iface_view::get_viewmgr()
+{
+       return this->viewmgr;
+}
+
+void ui_iface_view::set_event_block(bool block)
+{
+       this->event_block = block;
+}
+
+void ui_iface_view::on_load()
+{
+       this->state = UI_VIEW_STATE_LOAD;
+}
+
+void ui_iface_view::on_unload()
+{
+       this->state = UI_VIEW_STATE_UNLOAD;
+       if (this->get_removable_content())
+       {
+               this->set_content(NULL);
+               return;
+       }
+}
+
+void ui_iface_view::on_activate()
+{
+       this->state = UI_VIEW_STATE_ACTIVATE;
+}
+
+void ui_iface_view::on_deactivate()
+{
+       this->state = UI_VIEW_STATE_DEACTIVATE;
+}
+
+void ui_iface_view::on_pause()
+{
+       this->state = UI_VIEW_STATE_PAUSE;
+}
+
+void ui_iface_view::on_resume()
+{
+       this->state = UI_VIEW_STATE_ACTIVATE;
+}
+
+void ui_iface_view::on_destroy()
+{
+}
+
+ui_iface_view::ui_iface_view(const char *name)
+               : content(NULL), name(string(name ? name : "")), transition_style(string("default")), viewmgr(NULL), state(UI_VIEW_STATE_LOAD),
+                 indicator(UI_VIEW_INDICATOR_DEFAULT), event_block(false), removable_content(true)
+{
+       this->state = UI_VIEW_STATE_UNLOAD;
+}
+
+ui_iface_view::~ui_iface_view()
+{
+       this->viewmgr->remove_view(this);
+}
+
+bool ui_iface_view::set_content(T content)
+{
+       this->content = content;
+       return true;
+}
+
+T ui_iface_view::unset_content()
+{
+       T prev = this->content;
+       this->content = NULL;
+       return prev;
+}
+
+bool ui_iface_view::set_transition_style(const char *style)
+{
+       this->transition_style.assign(style);
+       return true;
+}
+
+bool ui_iface_view::set_name(const char *name)
+{
+       this->name.assign(name);
+       return true;
+}
+
+void ui_iface_view::set_removable_content(bool removable)
+{
+       this->removable_content = removable;
+
+       //FIXME: If this api is called on unload state? should we remove content right now?
+}
+
+void ui_iface_view::set_indicator(ui_view_indicator indicator)
+{
+       this->indicator = indicator;
+}
+
+const char *ui_iface_view::get_transition_style()
+{
+       return this->transition_style.c_str();
+}
+
+const char *ui_iface_view::get_name()
+{
+       return this->name.c_str();
+}
+
+T ui_iface_view::get_content()
+{
+       return this->content;
+}
+
+ui_view_state ui_iface_view::get_state()
+{
+       return this->state;
+}
+
+bool ui_iface_view::get_removable_content()
+{
+       return this->removable_content;
+}
+
+ui_view_indicator ui_iface_view::get_indicator()
+{
+       return this->indicator;
+}
+
+void ui_iface_view::on_back()
+{
+       ui_iface_viewmgr *viewmgr = this->get_viewmgr();
+       if (!viewmgr)
+       {
+               LOGE("Failed to get a viewmgr, view =%p", this);
+               return;
+       }
+       viewmgr->pop_view();
+}
diff --git a/src/lib/interface/ui_iface_viewmgr.cpp b/src/lib/interface/ui_iface_viewmgr.cpp
new file mode 100644 (file)
index 0000000..fe088d0
--- /dev/null
@@ -0,0 +1,360 @@
+/*
+ * 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/interface/ui_iface_viewmanager.h"
+
+ui_iface_viewmgr *ui_iface_viewmgr::inst = NULL;
+
+#define VIEW_ITR list<ui_iface_view *>::iterator
+#define VIEW_RITR list<ui_iface_view *>::reverse_iterator
+
+//FIXME: Read system profile to decide whether support software key or not.
+bool ui_iface_viewmgr::soft_key = true;
+//FIXME: Read system profile to decide whether support event block or not.
+bool ui_iface_viewmgr::event_block = true;
+
+bool ui_iface_viewmgr::insert_view_after(ui_iface_view *view, ui_iface_view *after)
+{
+       VIEW_ITR it;
+
+       if (!view)
+       {
+               LOGE("invalid view argument. view(NULL)");
+               return false;
+       }
+
+       if (!this->connect_view(view))
+       {
+               LOGE("connect view failed");
+               return false;
+       }
+
+       if (this->view_list.size() > 0)
+       {
+               for (it = this->view_list.begin(); it != this->view_list.end(); it++)
+               {
+                       if (after == *it)
+                       {
+                               //If the after is a last item of list.
+                               //view has to push now.
+                               if (it == this->view_list.end())
+                                       this->push_view(view);
+                               else
+                                       this->view_list.insert(++it, view);
+
+                               return true;
+                       }
+               }
+       }
+
+       //If there is no matching after view with current list.
+       //also in case of after is NULL.
+       this->push_view(view);
+
+       return true;
+}
+
+bool ui_iface_viewmgr::need_soft_key()
+{
+       return ui_iface_viewmgr::soft_key;
+}
+
+bool ui_iface_viewmgr::connect_view(ui_iface_view *view)
+{
+       //FIXME: If user call a set_viewmgr() before, It should not return false.
+       /*
+       if (view->viewmgr)
+       {
+               LOGE("view(%p) has already connected to viewmgr(%p)", view, this);
+               return false;
+       }
+       */
+
+       view->viewmgr = this;
+       return true;
+}
+
+bool ui_iface_viewmgr::disconnect_view(ui_iface_view *view)
+{
+       if (!view->viewmgr) return false;
+       view->viewmgr = NULL;
+       return true;
+}
+
+void ui_iface_viewmgr::set_event_block(ui_iface_view *view, bool block)
+{
+       if (!ui_iface_viewmgr::event_block) return;
+       view->set_event_block(block);
+}
+
+bool ui_iface_viewmgr::push_view_finished(ui_iface_view *view)
+{
+       ui_iface_view *last = this->view_list.back();
+
+       //The previous view has been pushed. This should be unload.
+       if (last != view)
+       {
+               view->on_unload();
+               return true;
+       }
+
+       //A new view has been pushed. This should be activate.
+       view->on_activate();
+       this->set_event_block(view, false);
+
+       return true;
+}
+
+bool ui_iface_viewmgr::pop_view_finished(ui_iface_view *view)
+{
+       ui_iface_view *last = this->view_list.back();
+
+       //This view has been popped. It should be destroyed.
+       if (last == view)
+       {
+               view->on_unload();
+               view->on_destroy();
+               delete (view);
+               return true;
+       }
+
+       //The previous view has been popped. It should become activate.
+       view->on_activate();
+       this->set_event_block(view, false);
+
+       return true;
+}
+
+ui_iface_viewmgr::ui_iface_viewmgr(const ui_iface_viewmgr& viewmgr)
+{
+}
+
+ui_iface_viewmgr::ui_iface_viewmgr()
+               : activated(false)
+{
+       ui_iface_viewmgr::inst = this;
+}
+
+ui_iface_viewmgr::~ui_iface_viewmgr()
+{
+       //Terminate views
+       for (VIEW_RITR it = this->view_list.rbegin(); it != this->view_list.rend(); it++)
+       {
+               ui_iface_view *view = *it;
+               view->on_deactivate();
+               view->on_unload();
+               view->on_destroy();
+               delete (view);
+       }
+
+       //FIXME: Window is destroyed. Terminate Application!
+       ui_app_exit();
+
+       ui_iface_viewmgr::inst = NULL;
+}
+
+ui_iface_view *ui_iface_viewmgr::push_view(ui_iface_view *view)
+{
+       if (!view)
+       {
+               LOGE("invalid view argument. view(NULL)");
+               return NULL;
+       }
+
+       if (!this->connect_view(view))
+       {
+               LOGE("connect view failed");
+               return NULL;
+       }
+
+       ui_iface_view *pview;
+
+       //Previous view
+       if (this->view_list.size() > 0)
+       {
+               pview = this->view_list.back();
+               pview->on_deactivate();
+               this->set_event_block(pview, true);
+       }
+
+       this->view_list.push_back(view);
+
+       if (!view->get_content())
+       {
+               view->on_load();
+       }
+
+       view->on_deactivate();
+
+       if (this->view_list.size() != 1)
+       {
+               this->set_event_block(view, true);
+       }
+
+       return view;
+}
+
+bool ui_iface_viewmgr::pop_view()
+{
+       //FIXME: No more view?
+       if (this->get_view_count() == 0)
+       {
+               LOGE("No Views. Can't pop anymore!");
+               return false;
+       }
+
+       //This is the last page.
+       if (this->get_view_count() == 1)
+       {
+               //destroy viewmgr?
+               ui_iface_view*view = this->view_list.back();
+               view->on_deactivate();
+               view->on_unload();
+               view->on_destroy();
+               delete(view);
+
+               return true;
+       }
+
+       //last page to be popped.
+       ui_iface_view*view = this->view_list.back();
+       view->on_deactivate();
+       this->set_event_block(view, true);
+
+       //Below object has to be used in child class...
+       //Make this getter method? or define instance?
+       //previous page is to be an active page.
+       auto nx = prev(this->view_list.end(), 2);
+       ui_iface_view*pview = *nx;
+       pview->on_load();
+       pview->on_deactivate();
+       this->set_event_block(pview, true);
+
+       return true;
+}
+
+bool ui_iface_viewmgr::insert_view_before(ui_iface_view *view, ui_iface_view *before)
+{
+       VIEW_ITR it;
+
+       if (!view)
+       {
+               LOGE("invalid view argument. view(NULL)");
+               return false;
+       }
+
+       if (!this->connect_view(view))
+       {
+               LOGE("connect view failed");
+               return false;
+       }
+
+       if (this->view_list.size() > 0)
+       {
+               for (it = this->view_list.begin(); it != this->view_list.end(); it++)
+               {
+                       if (before == *it)
+                       {
+                               this->view_list.insert(it, view);
+
+                               return true;
+                       }
+               }
+       }
+
+       //If there is no matching before view with current list.
+       //also in case of before is NULL.
+       this->push_view(view);
+
+       return true;
+}
+
+bool ui_iface_viewmgr::remove_view(ui_iface_view *view)
+{
+       this->view_list.remove(view);
+       this->disconnect_view(view);
+
+       //TODO: If this view is the top on the stack ?
+       return true;
+}
+
+ui_iface_view *ui_iface_viewmgr::get_view(unsigned int idx)
+{
+       if (idx < 0 || idx >= this->view_list.size())
+       {
+               LOGE("Invalid idx(%d)! =? (idx range: %d ~ %d)", idx, 0, this->view_list.size() - 1);
+               return NULL;
+       }
+       VIEW_ITR it = this->view_list.begin();
+       advance(it, idx);
+       return *it;
+}
+
+int ui_iface_viewmgr::get_view_index(const ui_iface_view *view)
+{
+       int idx = 0;
+
+       for (VIEW_ITR it = this->view_list.begin(); it != this->view_list.end(); it++)
+       {
+               if (view == *it) return idx;
+               ++idx;
+       }
+
+       return -1;
+}
+
+ui_iface_view *ui_iface_viewmgr::get_last_view()
+{
+       int cnt = this->get_view_count();
+       return this->get_view(cnt - 1);
+}
+
+bool ui_iface_viewmgr::activate()
+{
+       if (this->activated) return false;
+       if (this->get_view_count() == 0) return false;
+       this->activated = true;
+       return true;
+}
+
+bool ui_iface_viewmgr::deactivate()
+{
+       if (!this->activated) return false;
+       this->activated = false;
+       return true;
+}
+
+ui_iface_view *ui_iface_viewmgr::get_view(const char *name)
+{
+       //FIXME: ...
+       return NULL;
+}
+
+bool ui_iface_viewmgr::is_activated()
+{
+       return this->activated;
+}
+
+unsigned int ui_iface_viewmgr::get_view_count()
+{
+       return this->view_list.size();
+}
+
+ui_iface_viewmgr* ui_iface_viewmgr::get_instance()
+{
+       return ui_iface_viewmgr::inst;
+}