From: Hermet Park Date: Sat, 20 Feb 2016 05:37:03 +0000 (+0900) Subject: ui_viewmgr_interface: clean up code. X-Git-Tag: submit/tizen/20160617.075742~129 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e2905b4cc09d944ce155e48be041f02b500301ed;p=platform%2Fcore%2Fuifw%2Fui-viewmgr.git ui_viewmgr_interface: clean up code. update doc. get_soft_back_key() -> need_soft_key(). fix typo. Change-Id: I1c095f118ac9c5e70ae47f545ecb1f241343e239 --- diff --git a/src/efl/mobile/ui_basic_view.cpp b/src/efl/mobile/ui_basic_view.cpp index 7d060c7..78cfb96 100644 --- a/src/efl/mobile/ui_basic_view.cpp +++ b/src/efl/mobile/ui_basic_view.cpp @@ -58,9 +58,9 @@ bool ui_basic_view::create_layout() elm_object_part_content_set(layout, "elm.swallow.content", CONVERT_TO_EO(this->get_content())); } - //Set soft back key, if it's needed + //Set software back key, if it's needed ui_viewmgr *viewmgr = dynamic_cast(ui_view_interface::get_viewmgr()); - if (viewmgr->get_soft_back_key()) + if (viewmgr->need_soft_key()) { Evas_Object *prev_btn = elm_button_add(layout); diff --git a/src/efl/ui_viewmgr.cpp b/src/efl/ui_viewmgr.cpp index 020ffc6..f944b96 100644 --- a/src/efl/ui_viewmgr.cpp +++ b/src/efl/ui_viewmgr.cpp @@ -218,8 +218,7 @@ bool ui_viewmgr::pop_view() return true; } -ui_view * -ui_viewmgr::push_view(ui_view *view) +ui_view * ui_viewmgr::push_view(ui_view *view) { ui_viewmgr_interface::push_view(view); @@ -243,3 +242,8 @@ ui_viewmgr::push_view(ui_view *view) return view; } + +ui_view *ui_viewmgr::get_last_view() +{ + return dynamic_cast(ui_viewmgr_interface::get_last_view()); +} diff --git a/src/efl/ui_viewmgr.h b/src/efl/ui_viewmgr.h index f19190f..519b831 100644 --- a/src/efl/ui_viewmgr.h +++ b/src/efl/ui_viewmgr.h @@ -66,6 +66,8 @@ public: { return this->conform; } + + ui_view *get_last_view(); }; } diff --git a/src/interface/ui_controller_interface.h b/src/interface/ui_controller_interface.h index cd7a806..0ecd060 100644 --- a/src/interface/ui_controller_interface.h +++ b/src/interface/ui_controller_interface.h @@ -22,15 +22,11 @@ namespace viewmgr { class ui_view_interface; /** - * @class ui_controller_base + * @class ui_controller_interface * - * @ingroup ui_viewmgr + * @ingroup viewmgr * * @brief UI Controller Interface. This interface is designed for handling of life-cycle events from user side. - * - * @date 2016/01/15 - * @author Hermet Park - * */ class ui_controller_interface { diff --git a/src/interface/ui_view_interface.cpp b/src/interface/ui_view_interface.cpp index 6fd0436..66f5348 100644 --- a/src/interface/ui_view_interface.cpp +++ b/src/interface/ui_view_interface.cpp @@ -131,6 +131,12 @@ bool ui_view_interface::set_style(const char *style) return true; } +bool ui_view_interface::set_name(const char *name) +{ + this->name.assign(name); + return true; +} + void ui_view_interface::set_removable_content(bool removable) { this->removable_content = removable; diff --git a/src/interface/ui_view_interface.h b/src/interface/ui_view_interface.h index 8250834..faed8b8 100644 --- a/src/interface/ui_view_interface.h +++ b/src/interface/ui_view_interface.h @@ -31,7 +31,7 @@ class ui_controller_interface; /** * @class ui_view_interface * - * @ingroup ui_viewmgr + * @ingroup viewmgr * * @brief UI View Base Class. This is the base class of view. A view must have one content instance which represents a view for a current screen. * UI View may have it's own show/hide transition styles. That means, it's available that views have different show/hide effects on demands. @@ -39,9 +39,6 @@ class ui_controller_interface; * * @warning When the transitions are finished, the view must to call ui_viewmgr_interface :: _push_finished(), ui_viewmgr_interface :: _pop_finished() in order that * The ui_viewmgr_interface keeps the view states exactly. - * - * @date 2016/01/15 - * @author Hermet Park */ class ui_view_interface { @@ -211,6 +208,8 @@ public: */ bool set_style(const char *style); + bool set_name(const char *name); + /** @brief set content removable * * @param removable if @p removable is @c true, content of this view will be removed on unload state. @c false otherwise. diff --git a/src/interface/ui_viewmanager_interface.h b/src/interface/ui_viewmanager_interface.h index 67fdd79..235e8e5 100644 --- a/src/interface/ui_viewmanager_interface.h +++ b/src/interface/ui_viewmanager_interface.h @@ -31,6 +31,7 @@ enum ui_view_indicator UI_VIEW_INDICATOR_OPTIMAL, UI_VIEW_INDICATOR_OVERLAP, UI_VIEW_INDICATOR_HIDE, + UI_VIEW_INDICATOR_SHOW, UI_VIEW_INDICATOR_LAST }; diff --git a/src/interface/ui_viewmgr_interface.cpp b/src/interface/ui_viewmgr_interface.cpp index 14e544e..18a4003 100644 --- a/src/interface/ui_viewmgr_interface.cpp +++ b/src/interface/ui_viewmgr_interface.cpp @@ -18,6 +18,16 @@ using namespace viewmgr; +//FIXME: Read system profile to decide whether support software key or not. +bool ui_viewmgr_interface::soft_key = true; +//FIXME: Read system profile to decide whether support event block or not. +bool ui_viewmgr_interface::event_block = true; + +bool ui_viewmgr_interface::need_soft_key() +{ + return ui_viewmgr_interface::soft_key; +} + bool ui_viewmgr_interface::connect_view(ui_view_interface *view) { if (view->viewmgr) @@ -40,7 +50,7 @@ bool ui_viewmgr_interface::disconnect_view(ui_view_interface *view) void ui_viewmgr_interface::set_event_block(ui_view_interface *view, bool block) { - if (!this->event_block) return; + if (!ui_viewmgr_interface::event_block) return; view->set_event_block(block); } @@ -83,11 +93,8 @@ bool ui_viewmgr_interface::pop_view_finished(ui_view_interface *view) } ui_viewmgr_interface::ui_viewmgr_interface() - : event_block(true), activated(false) + : activated(false) { - //FIXME: Read binary profile to decide whether support software back key or not. - // software back key is needed in latest UX(Tizen_2.4) - this->soft_back_key = true; } ui_viewmgr_interface::~ui_viewmgr_interface() @@ -259,3 +266,19 @@ bool ui_viewmgr_interface::deactivate() this->activated = false; return true; } + +ui_view_interface *ui_viewmgr_interface::get_view(const char *name) +{ + //FIXME: ... + return NULL; +} + +bool ui_viewmgr_interface::is_activated() +{ + return this->activated; +} + +unsigned int ui_viewmgr_interface::get_view_count() +{ + return this->view_list.size(); +} diff --git a/src/interface/ui_viewmgr_interface.h b/src/interface/ui_viewmgr_interface.h index 986826c..72f709f 100644 --- a/src/interface/ui_viewmgr_interface.h +++ b/src/interface/ui_viewmgr_interface.h @@ -28,223 +28,261 @@ class ui_view_interface; /** * @class ui_viewmgr_interface * - * @ingroup ui_viewmgr + * @ingroup viewmgr * - * @brief This is a base class of viewmgr. One viewmgr represents a window which contains multiple views. - * A viewmgr manages not only views life-cycle but constructs some basic infrastructure. It's up to derived classes. + * @brief This is a interface class of viewmgr. One viewmgr represents a window which contains multiple views. + * A viewmgr manages not only views life-cycle but constructs basic infrastructures such as key event handlings, transition effects, transient views. + * This interface guide you a basic policy of a view manager. * * @warning viewmgr will remove all containing views when it's destroyed. - * @date 2016/01/29 - * @author Hermet Park */ class ui_viewmgr_interface { friend class ui_view_interface; private: - list view_list; //view list. - bool event_block; //event block on view transition. This value should be configurable by system. - bool activated; //activated status of this viewmgr. - bool soft_back_key; //If system doesn't support HW back key, then this value is true. + 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 view_list; //View list. + bool activated; //Activated status of this viewmgr. /** - * @brief link a given view to this viewmgr. + * @brief Connect a given view to this viewmgr. * - * @param view a view to connect to this viewmgr. - * @return success or not. + * @param view A view to connect to this viewmgr which means the @p view is to belong to this viewmgr. + * @return @c true success or @c false not. * - * @note This is s a friend function of ui_view_interface + * @warning If the given view is already connected to a viewmgr, this call will be failed. + * @see disconnect_view() */ bool connect_view(ui_view_interface *view); /** - * @brief unlink a given view from this viewmgr. + * @brief Disconnect a given view from this viewmgr. * - * @param view a view to disconnect from this viewmgr. - * @return @c true success or @c false not. + * @param view A view to disconnect from this viewmgr. + * @return @c true on success or @c false otherwise. * - * @note This is s a friend function of ui_view_interface + * @see connect_view() */ bool disconnect_view(ui_view_interface *view); /** - * @brief toggle event blocking to the given view. + * @brief Toggle event blocking to the given view. * - * @param view a view to toggle event blocking - * @param block @c true is block event, otherwise @c false. + * @param view A view to toggle event blocking + * @param block @c true is blocking event, otherwise @c false. * - * @note This is s a friend function of ui_view_interface + * @note If the event is blocked, product users won't be able to enter any inputs to this @p view. These inputs are mouse clicks, key press, + * screen touches, etc. Event if this function is called, @p view will be event-blocked only when system requires event blocking. + * Most of the times, This function should be used on transition. @see also push_view(), push_view_finished(), pop_view(), pop_view_finished(). */ void set_event_block(ui_view_interface *view, bool block); protected: /** - * @brief This function is designed for end of push transition. + * @brief This function is designed for finishing process of push transition. * - * @param view view which is finished pushing. - * @return @c true success or @c false not. + * @param view A view which is finished pushing. + * @return @c true on success or @c false otherwise. * - * @warning This function must be called definitely when push transition is finished. - * @note This is s a friend function of ui_view_interface + * @warning This function must be called when push transition is finished. */ bool push_view_finished(ui_view_interface *view); /** - * @brief This function is designed for end of pop transition. + * @brief This function is designed for finishing process for pop transition. * - * @param view view which is finished popping. - * @return @c true success or @c false not. + * @note If a new view is pushed + * @param view A view which is finished popping. + * @return @c true on success or @c false otherwise. * - * @warning This function must be called definitely when push transition is finished. - * @note This is s a friend function of ui_view_interface + * @warning This function must be called when push transition is finished. */ bool pop_view_finished(ui_view_interface *view); +#if 0 /** * @brief Return a list of views which this viewmgr has. * * @return a pointer of list of views. + * + * @warning Don't modify this view list. */ const list* const get_view_list() { return &this->view_list; } +#endif /** - * @brief Push a new view into the viewmgr stack. - * This function is used for application switches the current view to a new one. + * @brief Push a new view into this viewmgr. This function is used for when application switches a current view to a new one. + * + * @note Normally, the current view will be hidden by a new view. In default, when user calls this API, view will be switched to @p view instantly, + * only when viewmgr state is activated. Otherwise, the @p view will be shown later when viewmgr is activated. push_view() is designed for providing + * view transition effect. If you want push view instantly without any transition, you could use insert_view_before() or insert_view_after(). + * If you want to pop the current view, the please use pop_view() + * + * @return @p view, @c NULL when it fails to push a @p view. * - * @note Normally, the current view will be hidden by a new view. - * @return @c true on success, @c false otherwise. + * @see activated() + * @see insert_view_before() + * @see insert_view_after() + * @see pop_view() */ ui_view_interface *push_view(ui_view_interface *view); /** - * @brief Pop the top view from the viewmgr stack. + * @brief Pop the top(last) view from this viewmgr view list. * This function is used for application switches the current view back to the previous view. * The top view will be removed from the view stack and then it will be deleted by the viewmgr. * - * @note If the view is just one left, then viewmgr would be destroyed since the application might be terminated. - * But this behavior is optional. + * @note If the view is just one left, then viewmgr would be deactivated since the ui application might be invalid anymore. Otherwise, the application will + * be terminated. It's up to system configuration. * - * @return A view pointer which was popped. If it's failed to pop, @c NULL will be returned. + * @return @c true on success or @c false otherwise. + * + * @see deactivate() + * @see push_view() */ bool pop_view(); /** - * @brief Insert a view into this viewmgr stack. Specially, right before of the given view, @before + * @brief Insert a view in this viewmgr view list. Specifically, insert a given @p view right before of the given view, @before + * + * @param view A view to insert in the viewmgr view list. + * @param before A view that will be just inserted after @p view. If you pass @c NULL, @p view will be inserted at the front of the view list. + * @return @c true on success or @c false otherwise. * - * @param view a view to push into the viewmgr stack - * @param before a view that will be just after the @c view. - * If you pass @c NULL, @c view will be inserted at the front of the view stack. - * @return @c true success or @c false not. */ bool insert_view_before(ui_view_interface *view, ui_view_interface *before); /** - * @brief Insert a view into this viewmgr stack. Specially, right after of the given view, @after + * @brief Insert a view in this viewmgr view list. Specifically, insert a given @p view right after of the given view, @after + * + * @param view A view to insert in the viewmgr view list + * @param after A view that will be just inserted before the @p view. If you pass @c NULL, @p view will be inserted at the end of the view list. + * @return @c true on success or @c false otherwise. * - * @param view a view to push into the viewmgr stack - * @param after a view that will be just before the @c view. - * If you pass @c NULL, @c view will be inserted at the end of the view stack. - * @return @c true success or @c false not. */ bool insert_view_after(ui_view_interface *view, ui_view_interface *after); /** - * @brief Remove the given view from this viewmgr stack. + * @brief Remove the given view from this viewmgr view list. * - * @return @c true on success or @c false if not. + * @return @c true on success or @c false otherwise. * + * @see insert_view_before() + * @see insert_view_after() + * @see push_view() */ bool remove_view(ui_view_interface *view); /** - * @brief Return a stack index number of the given view. - * You could use this function to query the given view stack order. + * @brief Return a view which is matched with the index @p idx. + * + * @param idx A index of the view which you are looking for. + * @return The view which index is matched with @p idx + * If there were no views with index @p idx, @c NULL will be returned. * - * @param idx a view to query the index. - * @return an index of the give view. - * If there were no views on the idx, @c NULL will be returned. + * @note You could use the index as the page numbers of the views. + * @warning the index number of views are variable since the view list is variable. * - * @warning the index number is variable since the view stack size is also variable. + * @see get_view_index() + * @see get_view_count() */ ui_view_interface* get_view(unsigned int idx); /** - * @brief Return a view which is matched with the @c name. + * @brief Return a view which is matched with the @p name. * - * @param name the name of the view which you find. - * @return the view which name is matched with @c name. + * @note Every view have their names as their own identifiers. + * + * @param name The name of the view which you are looking for. + * @return The view which name is matched with @p name. * If there were no views name matched, @c NULL will be returned. * + * @see ui_view_interface::set_name() */ - ui_view_interface *get_view(const char *name) - { - //FIXME: ... - return NULL; - } + ui_view_interface *get_view(const char *name); + + /** + * @brief Return a last(top) view. + * + * @return The view which is last view of the viewmgr view list. + */ + ui_view_interface *get_last_view(); /** - * @brief Return a stack index number of the given view. - * You could use this function to query the given view stack order. + * @brief Return a view index(page) number of the given view. + * You could use this function to query the given @p view list order. * - * @param a view to query the index. - * @return an index of the give view on success, otherwise, -1. + * @param view A view to query the index. + * @return An index of the give @p view on success, otherwise, -1. * - * @warning the index number is variable since the view stack size is also variable. + * @warning The index number of views are variable since the view list is variable. */ int get_view_index(const ui_view_interface *view); - //Activate a viewmgr. - bool activate(); - - //Deactivate a viewmgr. - bool deactivate(); - public: - ///Constructor. + ///Constructor ui_viewmgr_interface(); - ///Destructor. Delete all contained views. + ///Destructor virtual ~ui_viewmgr_interface(); - //FIXME: Doc. - ui_view_interface *get_last_view(); + /** + * @brief Activate this view manager. + * + * @note viewmgr window and views will be shown once activate() is called. Usually this activate() should be called after applications set their all views + * on initialization time. + * + * @return @c true on success or @c false otherwise. + * + * @see deactivate() + */ + bool activate(); /** - * @brief Return the number of views which this viewmgr has. + * @brief Deactivate this view manager. * - * @return the number of view + * @note viewmgr window and views will be hidden once deactivate() is called. deactivate() behavior is up ui system, but usually it hides(unmap) + * current window in order that application go background. + * + * @return @c true success or @c false not. * + * @see deactivate() */ - unsigned int get_view_count() - { - return this->view_list.size(); - } + bool deactivate(); /** * @brief Return the active status of viewmgr. * - * @return active status + * @return @c true if viewmgr is active, @c false otherwise. * + * @see activate() + * @see deactivate() */ - bool is_activated() - { - return this->activated; - } + bool is_activated(); /** - * @brief Return the whether software back key need or not. - * - * @return whether need software back key. + * @brief Return the number of views which this viewmgr has. * + * @return the number of view */ - bool get_soft_back_key() - { - return this->soft_back_key; - } + unsigned int get_view_count(); + /** + * @brief Return whether soft key is required or not. + * + * @note Soft key is kind of like the software back button. It's used for product users to change current view to a previous view (pop). + * If a device doesn't have any hardware back buttons, Soft back key is necessary which means this function will return @c true. + * Some devices may needs software back key as well as hardware back key at the same time. That decision is up to product design. + * And soft_key initial value should read from the system configuration. + * + * @return @c true if soft key is required, @c false otherwise. + */ + static bool need_soft_key(); }; }