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
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);
* @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.
*/
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.
#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"
*
* @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;
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;
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)
{
}
}
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;
}
namespace viewmgr {
+
+template<typename T>
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.
*/
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.
*
*
* @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.
*
*
* @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();
+}
}
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 */
namespace viewmgr {
+template<typename T>
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.
* @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.
*
* @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.
* @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:
/**
*
* @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.
*
* @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
*
* @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;
}
* @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.
*
* @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.
*
* @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.
* @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.
* @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.
*
* @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.
*
* @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.
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_ */
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
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
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()
//FIXME: seems it could be replaced with set_content(NULL);
void ui_base_view::unload_content()
{
- T 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);
}
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()
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);
}
//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");
}
//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");
+++ /dev/null
-/*
- * 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;
-}
+++ /dev/null
-/*
- * 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();
-}