template interfaces. 63/64463/2
authorHermet Park <hermet@hermet.pe.kr>
Fri, 1 Apr 2016 09:13:00 +0000 (18:13 +0900)
committerHermet Park <hermet@hermet.pe.kr>
Fri, 1 Apr 2016 10:44:44 +0000 (19:44 +0900)
Change-Id: I33aa6e7a7a54b5181f6432bde05096b6ce420d15

15 files changed:
src/examples/efl/CMakeLists.txt
src/include/efl/mobile/ui_view.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_view.h
src/include/interface/ui_iface_viewmanager.h
src/include/interface/ui_iface_viewmgr.h
src/lib/CMakeLists.txt
src/lib/efl/mobile/ui_view.cpp
src/lib/efl/ui_base_view.cpp
src/lib/efl/ui_base_viewmgr.cpp
src/lib/interface/ui_iface_view.cpp [deleted file]
src/lib/interface/ui_iface_viewmgr.cpp [deleted file]

index b5e528db0394e0bdeb87dba9e5c395185a2946a2..91dca422c1db3243687e8c5785f571676b6b7b52 100644 (file)
@@ -1,7 +1,5 @@
 SET(EXAM_NAME viewmgr_demo)
 SET(EXAM_SRCS
-         ../../lib/interface/ui_iface_view.cpp
-         ../../lib/interface/ui_iface_viewmgr.cpp
          ../../lib/efl/ui_base_view.cpp
          ../../lib/efl/ui_base_viewmgr.cpp
          ../../lib/efl/ui_base_key_listener.cpp
index 070129b4c2a0fbe99b2ec0db74a418437d7da4b8..ccc3b2c81483c5b737b1880336befef8b3de08f0 100644 (file)
@@ -53,7 +53,6 @@ protected:
        ui_menu *on_menu_pre();
        void on_menu_post();
        virtual void on_menu(ui_menu *menu);
-       virtual void unload_content();
        virtual void set_event_block(bool block);
        virtual void on_back();
        virtual void on_rotate(int degree);
index 71dc9f549e19c51f84019ecc727949d3801c6a84..6aa75e4807e3ac29e7b778e5467c1d7ca3e4fc22 100644 (file)
@@ -35,17 +35,11 @@ namespace efl_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.
  */
-class ui_base_view: public viewmgr::ui_iface_view, public viewmgr::ui_iface_rotatable
+class ui_base_view: public viewmgr::ui_iface_view<Evas_Object *>
 {
        friend class ui_base_viewmgr;
 
 protected:
-       /** @brief Unload current view's content
-        *
-        *  @note Make this view's content as NULL, then destroy content.
-        */
-       virtual void unload_content();
-
        /** @brief Get a parent object of view.
         *
         *  @note This is calling viewmgr get_base() method internally.
@@ -91,9 +85,6 @@ public:
         */
        virtual Evas_Object *get_base();
 
-       //FIXME: public?
-       virtual void on_back();
-
        /** @brief Set the indicator mode.
         *
         *  @param indicator The mode to set, one of #ui_base_view_indicator.
index 82fa69fafaf3eac4dde317ea8ae33ee81ca91d12..0bca5f59366d42bf57bcceac03454274b1fc866c 100644 (file)
@@ -21,8 +21,6 @@
 #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"
index f80929c956e59498705070e73415b189e0f29634..f59916d2f77e1939c24a8126d8f0fdab98b29b2c 100644 (file)
@@ -44,7 +44,7 @@ class ui_base_view;
  *
  *  @warning viewmgr will remove all containing views when it's destroyed.
  */
-class ui_base_viewmgr: public singleton<ui_base_viewmgr>, public viewmgr::ui_iface_viewmgr
+class ui_base_viewmgr: public singleton<ui_base_viewmgr>, public viewmgr::ui_iface_viewmgr<Evas_Object *>
 {
        friend class ui_base_view;
 
index 17aa7add9939e10ee2f307785311c9ee53631b12..540940846d2525233130742e1d50f744abe82aaa 100644 (file)
 namespace viewmgr
 {
 
+template<typename T>
 class ui_iface_view;
 
 template<typename T>
 class ui_iface_overlay: public ui_iface_rotatable
 {
 private:
-       ui_iface_view *view;
+       ui_iface_view<T> *view;
        T content;
 
 protected:
-       ui_iface_overlay(ui_iface_view *view);
+       ui_iface_overlay(ui_iface_view<T> *view);
        virtual ~ui_iface_overlay();
-       virtual bool set_content(T content);
-       virtual T unset_content();
 
 public:
-       ui_iface_view *get_view();
+       virtual bool set_content(T content);
+       virtual T unset_content();
+       ui_iface_view<T> *get_view();
        virtual T get_content();
        virtual void on_back();
        virtual bool activate() = 0;
@@ -46,7 +47,7 @@ public:
 
 
 template<typename T>
-ui_iface_overlay<T>::ui_iface_overlay(ui_iface_view *view)
+ui_iface_overlay<T>::ui_iface_overlay(ui_iface_view<T> *view)
                : view(view), content(NULL)
 {
 }
@@ -79,7 +80,7 @@ T ui_iface_overlay<T>::get_content()
 }
 
 template<typename T>
-ui_iface_view *ui_iface_overlay<T>::get_view()
+ui_iface_view<T> *ui_iface_overlay<T>::get_view()
 {
        return this->view;
 }
index 50012bc8a53d1f800c0c296b13f5a85f20a496fe..2cc26c82f6e5d4b692b54e656d93828409708d0b 100644 (file)
@@ -23,6 +23,8 @@ using namespace std;
 
 namespace viewmgr {
 
+
+template<typename T>
 class ui_iface_viewmgr;
 
 /**
@@ -38,26 +40,16 @@ 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.
  */
-class ui_iface_view
+template<typename T>
+class ui_iface_view : public ui_iface_rotatable
 {
-       friend class ui_iface_viewmgr;
+       friend class ui_iface_viewmgr<T>;
 
 private:
-       /// View state definition
-       enum ui_view_state
-       {
-               UI_VIEW_STATE_LOAD = 0,        ///< Load state
-               UI_VIEW_STATE_UNLOAD,          ///< Unload state
-               UI_VIEW_STATE_ACTIVATE,        ///< Activate state
-               UI_VIEW_STATE_DEACTIVATE,      ///< Deactivate state
-               UI_VIEW_STATE_PAUSE,           ///< Pause state
-               UI_VIEW_STATE_LAST
-       };
-
        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 *viewmgr;              ///< Viewmgr which this view belongs to.
+       ui_iface_viewmgr<T> *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,34 +115,16 @@ protected:
         */
        virtual void on_destroy();
 
-       //Make this view's content as NULL, then destroy content.
-       virtual void unload_content() = 0;
-
        /** @brief Return the state of event block.
         *
         *  @see set_event_block()
         */
-       bool get_event_block()
-       {
-               return this->event_block;
-       }
+       bool get_event_block();
 
        /** @brief Return a viewmgr which this view is belonging to.
         */
-       ui_iface_viewmgr *get_viewmgr()
-       {
-               return this->viewmgr;
-       }
-
-public:
-       /** @brief This is a constructor for initializing this view resources.
-        *
-        *  @param name view name.
-        */
-       ui_iface_view(const char *name = NULL);
-
-       ///Destructor for terminating view.
-       virtual ~ui_iface_view();
+       //FIXME: Is it necessary?
+       ui_iface_viewmgr<T> *get_viewmgr();
 
        /** @brief This is for replacing or setting a content of the view.
         *
@@ -159,15 +133,25 @@ public:
         *
         *  @param content a new content. It allows @c NULL for canceling the previous content.
         *
-        *  @return A previous content. If it wasn't, return value will be @c NULL.
+        *  @return true if it succeed, false otherwise.
         */
-       T set_content(T content);
+       virtual bool set_content(T content);
 
        /** @brief This is for unsetting a content of the view.
         *
         *  @return A previous content. If it wasn't, return value will be @c NULL.
         */
-       T unset_content();
+       virtual T unset_content();
+
+public:
+       /** @brief This is a constructor for initializing this view resources.
+        *
+        *  @param name view name.
+        */
+       ui_iface_view(const char *name = NULL);
+
+       ///Destructor for terminating view.
+       virtual ~ui_iface_view();
 
        /** @brief set transition style of a view.
         *
@@ -214,61 +198,211 @@ public:
         *
         *  @return style name of view.
         */
-       const char *get_transition_style()
-       {
-               return this->transition_style.c_str();
-       }
+       const char *get_transition_style();
 
        /** @brief Return a name of this view.
         *
         *  @return name of view.
         */
-       const char *get_name()
-       {
-               return this->name.c_str();
-       }
+       const char *get_name();
 
        /** @brief Return a content instance of this view.
         *
         *  @return content of view.
         */
-       T get_content()
-       {
-               return this->content;
-       }
+       T get_content();
 
        /** @brief Return a state of this view.
         *
         *  #return current state of view.
         */
-       ui_view_state get_state()
-       {
-               return this->state;
-       }
+       ui_view_state get_state();
 
        /** @brief Return a state of removable content.
         *
         *  @return true if the view's content is removable, otherwise false.
         */
-       bool get_removable_content()
-       {
-               return this->removable_content;
-       }
+       bool get_removable_content();
 
        /** @brief Return the indicator mode of this view.
         *
         *  @return indicator state of view.
         */
-       ui_view_indicator get_indicator()
+       ui_view_indicator get_indicator();
+
+       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())
        {
-               return this->indicator;
+               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);
+}
 
-       virtual int get_degree()
+template<typename T>
+bool ui_iface_view<T>::set_content(T content)
+{
+       T prev = this->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)
        {
-               return 0;
+               LOGE("Failed to get a viewmgr, view =%p", this);
+               return;
        }
-};
+       viewmgr->pop_view();
+}
 
 }
 
index 5175c27a2eaea1aff5b3762515b968e7f12c7ed1..d301de5a8d6cf758f6b61da3d1927cc6380daea6 100644 (file)
@@ -35,11 +35,19 @@ enum ui_view_indicator
        UI_VIEW_INDICATOR_LAST
 };
 
-typedef void* T;
+enum ui_view_state
+{
+       UI_VIEW_STATE_LOAD = 0,        ///< Load state
+       UI_VIEW_STATE_UNLOAD,          ///< Unload state
+       UI_VIEW_STATE_ACTIVATE,        ///< Activate state
+       UI_VIEW_STATE_DEACTIVATE,      ///< Deactivate state
+       UI_VIEW_STATE_PAUSE,           ///< Pause state
+       UI_VIEW_STATE_LAST
+};
 
 #include "ui_iface_rotatable.h"
 #include "ui_iface_overlay.h"
-#include "ui_iface_viewmgr.h"
 #include "ui_iface_view.h"
+#include "ui_iface_viewmgr.h"
 
 #endif /* UI_IFACE_VIEWMANAGER_H */
index 4fce48eb0791dba2a91131ee5078e9d4cec8dbee..13b0cdadb4c05764d4449ac1afc2b192c96043b9 100644 (file)
@@ -23,6 +23,7 @@ using namespace std;
 
 namespace viewmgr {
 
+template<typename T>
 class ui_iface_view;
 
 /**
@@ -37,15 +38,16 @@ 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;
+       friend class ui_iface_view<T>;
 
 private:
-       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 *> view_list;    //View list.
-       bool activated;                     //Activated status of this viewmgr.
+       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.
+       bool activated;                        //Activated status of this viewmgr.
 
        /**
         *  @brief Connect a given view to this viewmgr.
@@ -57,7 +59,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 *view);
+       bool connect_view(ui_iface_view<T> *view);
 
        /**
         *  @brief Disconnect a given view from this viewmgr.
@@ -68,7 +70,7 @@ private:
         *
         *  @see connect_view()
         */
-       bool disconnect_view(ui_iface_view *view);
+       bool disconnect_view(ui_iface_view<T> *view);
 
        /**
         *  @brief Toggle event blocking to the given view.
@@ -80,7 +82,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 *view, bool block);
+       void set_event_block(ui_iface_view<T> *view, bool block);
 
 protected:
        /**
@@ -92,7 +94,7 @@ protected:
         *
         *  @warning This function must be called when push transition is finished.
         */
-       bool push_view_finished(ui_iface_view *view);
+       bool push_view_finished(ui_iface_view<T> *view);
 
        /**
         *  @brief This function is designed for finishing process for pop transition.
@@ -105,7 +107,7 @@ protected:
         *
         *  @warning This function must be called when push transition is finished.
         */
-       bool pop_view_finished(ui_iface_view *view);
+       bool pop_view_finished(ui_iface_view<T> *view);
 
 //FIXME: Necessary?
 #if 0
@@ -116,7 +118,7 @@ protected:
         *
         *  @warning Don't modify this view list.
         */
-       const list<ui_iface_view*>* const get_view_list()
+       const list<ui_iface_view<T>*>* const get_view_list()
        {
                return &this->view_list;
        }
@@ -139,7 +141,7 @@ protected:
         *  @see insert_view_after()
         *  @see pop_view()
         */
-       ui_iface_view *push_view(ui_iface_view *view);
+       ui_iface_view<T> *push_view(ui_iface_view<T> *view);
 
        /**
         *  @brief Pop the top(last) view from this viewmgr view list.
@@ -164,7 +166,7 @@ protected:
         *
         *  @return @c true on success or @c false otherwise.
         */
-       bool insert_view_before(ui_iface_view *view, ui_iface_view *before);
+       bool insert_view_before(ui_iface_view<T> *view, ui_iface_view<T> *before);
 
        /**
         *  @brief Insert a view in this viewmgr view list. Specifically, insert a given @p view right after of the given view, @after.
@@ -174,7 +176,7 @@ protected:
         *
         *  @return @c true on success or @c false otherwise.
         */
-       bool insert_view_after(ui_iface_view *view, ui_iface_view *after);
+       bool insert_view_after(ui_iface_view<T> *view, ui_iface_view<T> *after);
 
        /**
         *  @brief Remove the given view from this viewmgr view list.
@@ -187,7 +189,7 @@ protected:
         *  @see insert_view_after()
         *  @see push_view()
         */
-       bool remove_view(ui_iface_view *view);
+       bool remove_view(ui_iface_view<T> *view);
 
        /**
         *  @brief Return a view which is matched with the index @p idx.
@@ -203,7 +205,7 @@ protected:
         *  @see get_view_index()
         *  @see get_view_count()
         */
-       ui_iface_view* get_view(unsigned int idx);
+       ui_iface_view<T>* get_view(unsigned int idx);
 
        /**
         *  @brief Return a view which is matched with the @p name.
@@ -217,14 +219,14 @@ protected:
         *
         *  @see ui_iface_view::set_name()
         */
-       ui_iface_view *get_view(const char *name);
+       ui_iface_view<T> *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 *get_last_view();
+       ui_iface_view<T> *get_last_view();
 
        /**
         *  @brief Return a view index(page) number of the given view.
@@ -236,7 +238,7 @@ protected:
         *
         *  @warning The index number of views are variable since the view list is variable.
         */
-       int get_view_index(const ui_iface_view *view);
+       int get_view_index(const ui_iface_view<T> *view);
 
 public:
        ///Constructor.
@@ -299,6 +301,359 @@ public:
        static bool need_soft_key();
 };
 
+
+#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;
+       }
+
+       ui_iface_view<T> *bview;
+
+       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()
+               : activated(false)
+{
+}
+
+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();
+}
+
+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();
+}
+
 }
 
 #endif /* UI_IFACE_VIEWMGR_H_ */
index 173841dcc9e6f8d499ba5e77670ab57cf99f3d27..2efcc44944a7bd8576ce7fe0cbad85bed9984c0d 100644 (file)
@@ -1,6 +1,4 @@
 SET(LIB_SRCS
-     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
index 5766f61e37f2888df276fee67a38daa689aec972..2339d072fddd43d96db97dde87a7ec4aa44a6958 100644 (file)
@@ -99,7 +99,7 @@ bool ui_view::create_layout()
 
        if (this->get_content())
        {
-               elm_object_part_content_set(layout, "elm.swallow.content", CONVERT_TO_EO(this->get_content()));
+               elm_object_part_content_set(layout, "elm.swallow.content", this->get_content());
        }
 
        //Set software back key, if it's needed
index f56212ec91b6352fc79288385dc31d24c37f43b9..f76f279eb2eb6f26c3bda68309b634b3d361da47 100644 (file)
@@ -44,22 +44,20 @@ bool ui_base_view::set_content(Evas_Object *content)
        if (content)
        {
                evas_object_event_callback_add(content, EVAS_CALLBACK_DEL, content_del_cb, this);
-               ui_iface_view::set_content(CONVERT_TO_T(content));
+               ui_iface_view::set_content(content);
        }
        return true;
 }
 
 Evas_Object *ui_base_view::unset_content()
 {
-       T pcontent = ui_iface_view::unset_content();
-       if (pcontent)
+       Evas_Object *obj = ui_iface_view::unset_content();
+       if (obj)
        {
-               Evas_Object *obj = CONVERT_TO_EO(pcontent);
                evas_object_event_callback_del(obj, EVAS_CALLBACK_DEL, content_del_cb);
                evas_object_hide(obj);
-               return obj;
        }
-       return NULL;
+       return obj;
 }
 
 Evas_Object *ui_base_view::get_base()
@@ -75,8 +73,8 @@ Evas_Object *ui_base_view::get_base()
 //FIXME: seems it could be replaced with set_content(NULL);
 void ui_base_view::unload_content()
 {
-       pcontent = this->get_content();
-       if (pcontent) evas_object_del(CONVERT_TO_EO(pcontent));
+       Evas_Object *pcontent = this->get_content();
+       if (pcontent) evas_object_del(pcontent);
        this->set_content(NULL);
 }
 
@@ -137,7 +135,7 @@ void ui_base_view::on_landscape()
 void ui_base_view::set_event_block(bool block)
 {
        ui_iface_view::set_event_block(block);
-       evas_object_freeze_events_set(CONVERT_TO_EO(this->get_content()), block);
+       evas_object_freeze_events_set(this->get_content(), block);
 }
 
 int ui_base_view::get_degree()
index 542902bcac006790ee78c57ce15d9c4a57392001..5f6b0c326e1e99116de6d84f9c9eecdcb0450cf9 100644 (file)
@@ -109,11 +109,11 @@ void ui_base_viewmgr::activate_top_view()
        Evas_Object *content;
        if (view->get_base() == this->get_base())
        {
-               content = CONVERT_TO_EO(view->get_content());
+               content = view->get_content();
        }
        else
        {
-               content = CONVERT_TO_EO(view->get_base());
+               content = view->get_base();
        }
 
        elm_object_part_content_set(this->get_base(), "content", content);
@@ -325,10 +325,10 @@ bool ui_base_viewmgr::pop_view()
        }
 
        //Trigger Effects.
-       Evas_Object *prv = CONVERT_TO_EO(this->get_base() == pview->get_base() ? pview->get_content() : pview->get_base());
+       Evas_Object *prv = this->get_base() == pview->get_base() ? pview->get_content() : pview->get_base();
        elm_layout_content_set(effect, "content", prv);
 
-       Evas_Object *cur = CONVERT_TO_EO(this->get_base() == view->get_base() ? view->get_content() : view->get_base());
+       Evas_Object *cur = this->get_base() == view->get_base() ? view->get_content() : view->get_base();
        elm_layout_content_set(effect, "pcontent", cur);
 
        elm_layout_signal_emit(effect, "view,pop", "viewmgr");
@@ -372,10 +372,10 @@ ui_base_view * ui_base_viewmgr::push_view(ui_base_view *view)
        }
 
        //Trigger Effects.
-       Evas_Object *prv = CONVERT_TO_EO(this->get_base() == pview->get_base() ? pview->get_content() : pview->get_base());
+       Evas_Object *prv = this->get_base() == pview->get_base() ? pview->get_content() : pview->get_base();
        elm_layout_content_set(effect, "pcontent", prv);
 
-       Evas_Object *cur = CONVERT_TO_EO(this->get_base() == view->get_base() ? view->get_content() : view->get_base());
+       Evas_Object *cur = this->get_base() == view->get_base() ? view->get_content() : view->get_base();
        elm_layout_content_set(effect, "content", cur);
 
        elm_layout_signal_emit(effect, "view,push", "viewmgr");
diff --git a/src/lib/interface/ui_iface_view.cpp b/src/lib/interface/ui_iface_view.cpp
deleted file mode 100644 (file)
index 4cef532..0000000
+++ /dev/null
@@ -1,113 +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/interface/ui_iface_viewmanager.h"
-
-using namespace 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->unload_content();
-               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);
-}
-
-T ui_iface_view::set_content(T content)
-{
-       T prev = this->content;
-       this->content = content;
-       return prev;
-}
-
-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;
-}
diff --git a/src/lib/interface/ui_iface_viewmgr.cpp b/src/lib/interface/ui_iface_viewmgr.cpp
deleted file mode 100644 (file)
index 8b2a78e..0000000
+++ /dev/null
@@ -1,351 +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/interface/ui_iface_viewmanager.h"
-
-using namespace viewmgr;
-
-
-typedef list<ui_iface_view *> ::iterator view_itr;
-typedef list<ui_iface_view*>::reverse_iterator view_ritr;
-
-//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::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()
-               : activated(false)
-{
-}
-
-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_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();
-
-       //FIXME: First view has no effect?
-       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::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;
-       }
-
-       ui_iface_view *bview;
-
-       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::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();
-}