From: Hermet Park Date: Wed, 30 Nov 2016 10:22:57 +0000 (+0900) Subject: Fix the insertViewAfter() wrong behaviors. X-Git-Tag: submit/tizen_3.0/20161201.104015~2^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=df85e39cf8c8601d90771ba2911d2b52b5e162fe;p=platform%2Fcore%2Fuifw%2Fui-viewmgr.git Fix the insertViewAfter() wrong behaviors. I missed the UiBaseViewmgr hasn't overridden the pushView() method that violates the UiIfaceViewmgr insertViewAfter() expectation. insertViewAfter() API internally calls Viewmgr's pushView() logically. This designed to lead to UiBaseViewmgr 's pushView() in the end. But It won't be happened because UiBaseViewmgr didn't override pushView(). Changed to override the UiIfaceViewmgr PushView() so that PushView() of the UiBaseViewmgr can be triggered by UiIfaceViewmgr properly. Change-Id: I45548a725a3b58b1e456e17a130927a15489e069 --- diff --git a/src/include/efl/UiBaseViewmgr.h b/src/include/efl/UiBaseViewmgr.h index 95b6e16..c594719 100644 --- a/src/include/efl/UiBaseViewmgr.h +++ b/src/include/efl/UiBaseViewmgr.h @@ -86,7 +86,7 @@ public: * @see insertViewAfter() * @see popView() */ - virtual int pushView(UiBaseView *view); + virtual int pushView(ui_viewmanager::UiIfaceView *view) override; /** * @brief Pop the top(last) view from this viewmgr view list. @@ -106,32 +106,6 @@ public: */ virtual int popView() override; - /** - * @brief Insert a view in this viewmgr view list. Specifically, insert a given @a view right before of the given view, @before. - * - * @param[in] view A view to insert in the viewmgr view list. - * @param[in] before A view that will be just inserted after @a view. If you pass @c nullptr, @a view will be inserted at the front of the view list. - * - * @return @c 0 on success, otherwise a negative error value. - * @retval #UI_VIEWMGR_ERROR_NONE Successful - * @retval #UI_VIEWMGR_ERROR_NOT_PERMITTED @a view was already inserted. - * @retval #UI_VIEWMGR_ERROR_INVALID_PARAMETER @a view is not valid. - */ - virtual int insertViewBefore(UiBaseView *view, UiBaseView *before); - - /** - * @brief Insert a view in this viewmgr view list. Specifically, insert a given @a view right after of the given view, @after. - * - * @param[in] view A view to insert in the viewmgr view list. - * @param[in] after A view that will be just inserted before the @a view. If you pass @c nullptr, @a view will be inserted at the end of the view list. - * - * @return @c 0 on success, otherwise a negative error value. - * @retval #UI_VIEWMGR_ERROR_NONE Successful - * @retval #UI_VIEWMGR_ERROR_NOT_PERMITTED @a view was already inserted. - * @retval #UI_VIEWMGR_ERROR_INVALID_PARAMETER @a view is not valid. - */ - virtual int insertViewAfter(UiBaseView *view, UiBaseView *after); - /** * @brief Return a window object of viewmgr. * diff --git a/src/include/interface/UiIfaceViewmgr.h b/src/include/interface/UiIfaceViewmgr.h index ec6e044..1d0ec57 100644 --- a/src/include/interface/UiIfaceViewmgr.h +++ b/src/include/interface/UiIfaceViewmgr.h @@ -35,6 +35,73 @@ class UiIfaceView; class UiIfaceViewmgr { public: + /** + * @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 @a view instantly, + * only when viewmgr state is activated. Otherwise, the @a 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(). + * or use the view transition style function. + * If you want to pop the current view, the please use pop_view(). + * + * @param[in] view A view to insert at the end of viewmgr view list. + * + * @return @c 0 on success, otherwise a negative error value. + * @retval #UI_VIEWMGR_ERROR_INVALID_PARAMETER @a view is not valid. + * @retval #UI_VIEWMGR_ERROR_NOT_PERMITTED @a view was already inserted. + * + * @see activated() + * @see insertViewBefore() + * @see insertViewAfter() + * @see popView() + * @see UiIfaceView::setTransitionStyle() + */ + virtual int pushView(UiIfaceView *view); + + /** + * @brief Pop the top(last) view from this viewmgr view list. + * This function is used when 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 deactivated automatically since the ui application might be invalid anymore. Otherwise, + * the application will be terminated. It's up to system configuration. + * + * @return @c 0 on success, otherwise a negative error value. + * @retval #UI_VIEWMGR_ERROR_NONE Successful + * @retval #UI_VIEWMGR_ERROR_NOT_PERMITTED No more views to pop. + * @retval #UI_VIEWMGR_ERROR_ALREADY_IN_PROGRESS On a certain profile, it may not allow to pop multiple views at the same time. + * + * @see deactivate() + * @see pushView() + */ + virtual int popView(); + + /** + * @brief Insert a view in this viewmgr view list. Specifically, insert a given @a view right before of the given view, @before. + * + * @param[in] view A view to insert in the viewmgr view list. + * @param[in] before A view that will be just inserted after @a view. If you pass @c nullptr, @a view will be inserted at the front of the view list. + * + * @return @c 0 on success, otherwise a negative error value. + * @retval #UI_VIEWMGR_ERROR_NONE Successful + * @retval #UI_VIEWMGR_ERROR_NOT_PERMITTED @a view was already inserted. + * @retval #UI_VIEWMGR_ERROR_INVALID_PARAMETER @a view is not valid. + */ + int insertViewBefore(UiIfaceView *view, UiIfaceView *before); + + /** + * @brief Insert a view in this viewmgr view list. Specifically, insert a given @a view right after of the given view, @after. + * + * @param[in] view A view to insert in the viewmgr view list. + * @param[in] after A view that will be just inserted before the @a view. If you pass @c nullptr, @a view will be inserted at the end of the view list. + * + * @return @c 0 on success, otherwise a negative error value. + * @retval #UI_VIEWMGR_ERROR_NONE Successful + * @retval #UI_VIEWMGR_ERROR_NOT_PERMITTED @a view was already inserted. + * @retval #UI_VIEWMGR_ERROR_INVALID_PARAMETER @a view is not valid. + */ + int insertViewAfter(UiIfaceView *view, UiIfaceView *after); + /** * @brief Activate this view manager. * @@ -133,73 +200,6 @@ protected: */ virtual void popViewFinished(UiIfaceView *view); - /** - * @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 @a view instantly, - * only when viewmgr state is activated. Otherwise, the @a 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(). - * or use the view transition style function. - * If you want to pop the current view, the please use pop_view(). - * - * @param[in] view A view to insert at the end of viewmgr view list. - * - * @return @c 0 on success, otherwise a negative error value. - * @retval #UI_VIEWMGR_ERROR_INVALID_PARAMETER @a view is not valid. - * @retval #UI_VIEWMGR_ERROR_NOT_PERMITTED @a view was already inserted. - * - * @see activated() - * @see insertViewBefore() - * @see insertViewAfter() - * @see popView() - * @see UiIfaceView::setTransitionStyle() - */ - virtual int pushView(UiIfaceView *view); - - /** - * @brief Pop the top(last) view from this viewmgr view list. - * This function is used when 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 deactivated automatically since the ui application might be invalid anymore. Otherwise, - * the application will be terminated. It's up to system configuration. - * - * @return @c 0 on success, otherwise a negative error value. - * @retval #UI_VIEWMGR_ERROR_NONE Successful - * @retval #UI_VIEWMGR_ERROR_NOT_PERMITTED No more views to pop. - * @retval #UI_VIEWMGR_ERROR_ALREADY_IN_PROGRESS On a certain profile, it may not allow to pop multiple views at the same time. - * - * @see deactivate() - * @see pushView() - */ - virtual int popView(); - - /** - * @brief Insert a view in this viewmgr view list. Specifically, insert a given @a view right before of the given view, @before. - * - * @param[in] view A view to insert in the viewmgr view list. - * @param[in] before A view that will be just inserted after @a view. If you pass @c nullptr, @a view will be inserted at the front of the view list. - * - * @return @c 0 on success, otherwise a negative error value. - * @retval #UI_VIEWMGR_ERROR_NONE Successful - * @retval #UI_VIEWMGR_ERROR_NOT_PERMITTED @a view was already inserted. - * @retval #UI_VIEWMGR_ERROR_INVALID_PARAMETER @a view is not valid. - */ - int insertViewBefore(UiIfaceView *view, UiIfaceView *before); - - /** - * @brief Insert a view in this viewmgr view list. Specifically, insert a given @a view right after of the given view, @after. - * - * @param[in] view A view to insert in the viewmgr view list. - * @param[in] after A view that will be just inserted before the @a view. If you pass @c nullptr, @a view will be inserted at the end of the view list. - * - * @return @c 0 on success, otherwise a negative error value. - * @retval #UI_VIEWMGR_ERROR_NONE Successful - * @retval #UI_VIEWMGR_ERROR_NOT_PERMITTED @a view was already inserted. - * @retval #UI_VIEWMGR_ERROR_INVALID_PARAMETER @a view is not valid. - */ - int insertViewAfter(UiIfaceView *view, UiIfaceView *after); - /** * @brief Remove the given view from this viewmgr view list. * diff --git a/src/lib/efl/UiBaseViewmgr.cpp b/src/lib/efl/UiBaseViewmgr.cpp index 754123a..afb4632 100644 --- a/src/lib/efl/UiBaseViewmgr.cpp +++ b/src/lib/efl/UiBaseViewmgr.cpp @@ -495,26 +495,16 @@ int UiBaseViewmgr::popView() return UI_VIEWMGR_ERROR_NONE; } -int UiBaseViewmgr::pushView(UiBaseView *view) +int UiBaseViewmgr::pushView(UiIfaceView *view) { int ret = UiIfaceViewmgr::pushView(view); if (ret != UI_VIEWMGR_ERROR_NONE) return ret; - this->_impl->pushView(view); + this->_impl->pushView(dynamic_cast(view)); return UI_VIEWMGR_ERROR_NONE; } -int UiBaseViewmgr::insertViewBefore(UiBaseView *view, UiBaseView *before) -{ - return UiIfaceViewmgr::insertViewBefore(view, before); -} - -int UiBaseViewmgr::insertViewAfter(UiBaseView *view, UiBaseView *after) -{ - return UiIfaceViewmgr::insertViewAfter(view, after); -} - UiBaseView *UiBaseViewmgr::getView(unsigned int idx) { return dynamic_cast(UiIfaceViewmgr::getView(idx)); diff --git a/src/lib/interface/UiIfaceView.cpp b/src/lib/interface/UiIfaceView.cpp index 947edd5..8124272 100644 --- a/src/lib/interface/UiIfaceView.cpp +++ b/src/lib/interface/UiIfaceView.cpp @@ -155,8 +155,9 @@ UiIfaceViewImpl::~UiIfaceViewImpl() activateTopView = true; } - this->onUnload(); - this->onDestroy(); + this->_view->onDeactivate(); + this->_view->onUnload(); + this->_view->onDestroy(); } if (this->_viewmgr) { diff --git a/src/lib/interface/UiIfaceViewmgr.cpp b/src/lib/interface/UiIfaceViewmgr.cpp index 1e813f9..8f69e56 100644 --- a/src/lib/interface/UiIfaceViewmgr.cpp +++ b/src/lib/interface/UiIfaceViewmgr.cpp @@ -88,7 +88,6 @@ int UiIfaceViewmgrImpl::insertViewAfter(UiIfaceView *view, UiIfaceView *after) if (view == after) { LOGE("invalid view argument. view == after?"); return UI_VIEWMGR_ERROR_INVALID_PARAMETER; - } int ret = this->connectView(view); @@ -98,22 +97,23 @@ int UiIfaceViewmgrImpl::insertViewAfter(UiIfaceView *view, UiIfaceView *after) return ret; } - if (this->_viewList.size() > 0) { - for (auto it = this->_viewList.begin(); it != this->_viewList.end(); it++) { - if (after == *it) { - //If the after is a last item of list. - //view has to push now. - if (it == this->_viewList.end()) - this->pushView(view); - else - this->_viewList.insert(++it, view); - + for (auto it = this->_viewList.begin(); it != this->_viewList.end(); ++it) { + if (after == *it) { + //If the after is a last item of list, view has to push now. + auto it2 = it; + if ((++it2) == this->_viewList.end()) + { + return this->_inst->pushView(view); + } + else + { + this->_viewList.insert(++it, view); return UI_VIEWMGR_ERROR_NONE; } } } - return this->pushView(view); + return this->_inst->pushView(view); } bool UiIfaceViewmgrImpl::needSoftKey() noexcept