diff options
author | Igor Nazarov <i.nazarov@samsung.com> | 2017-04-26 20:00:59 +0300 |
---|---|---|
committer | Igor Nazarov <i.nazarov@samsung.com> | 2017-04-27 16:59:04 +0300 |
commit | daffffec07188a36438c0973e270066971eb4707 (patch) | |
tree | 355edea67c676bdc334475c8dce337871d58fa8c | |
parent | 5e89a33949342e5d5a3dab9b6e04360c55e94103 (diff) | |
download | gallery-daffffec07188a36438c0973e270066971eb4707.tar.gz gallery-daffffec07188a36438c0973e270066971eb4707.tar.bz2 gallery-daffffec07188a36438c0973e270066971eb4707.zip |
TizenRefApp-8431 [Gallery] Change ProcessingPresenter to use modal view
- ProcessingPresenter Chnaged to use modal view;
- ProcessingPresenter derived from Presenter.
Change-Id: I6cdf203671f963173b0df141dbe77524a97b8171
-rw-r--r-- | inc/presenters/ProcessingPresenter.h | 15 | ||||
-rw-r--r-- | src/presenters/ProcessingPresenter.cpp | 83 |
2 files changed, 66 insertions, 32 deletions
diff --git a/inc/presenters/ProcessingPresenter.h b/inc/presenters/ProcessingPresenter.h index ed6c410..270c7ec 100644 --- a/inc/presenters/ProcessingPresenter.h +++ b/inc/presenters/ProcessingPresenter.h @@ -20,11 +20,11 @@ #include "ucl/gui/Layout.h" #include "ucl/gui/StyledWidget.h" -#include "types.h" +#include "Presenter.h" namespace gallery { - class ProcessingPresenter final : public ucl::RefCountAware { + class ProcessingPresenter final : public Presenter { public: enum class IconType { NONE, @@ -49,9 +49,9 @@ namespace gallery { using DismissHandler = ucl::WeakDelegate<void()>; public: - ucl::Widget &getWidget(); + void complete(); - void complete(const DismissHandler &dismissHandler); + void setDismissHandler(const DismissHandler &handler); private: friend class ucl::RefCountObj<ProcessingPresenter>; @@ -65,6 +65,7 @@ namespace gallery { ucl::Result createWidget(ucl::ElmWidget &parent, const ucl::TString &processingText); + ucl::Result moveWidget(); ucl::Result createProgress(); ucl::Result createPopup(const ucl::TString &completeText); ucl::Result createIcon(); @@ -75,7 +76,8 @@ namespace gallery { void showProgress(); void tryShowPopup(); - void dismissPopup(bool force = false); + void dismissPopup(); + void deletePopup(); void animateIcon(); @@ -95,13 +97,14 @@ namespace gallery { private: const IconType m_iconType; ucl::LayoutSRef m_widget; - ucl::StyledWidgetWRef m_popup; + ucl::StyledWidgetSRef m_popup; ucl::LayoutWRef m_icon; DismissHandler m_dismissHandler; Ecore_Timer *m_timer; State m_state; bool m_mayComplete; bool m_isComplete; + bool m_isDismissed; }; } diff --git a/src/presenters/ProcessingPresenter.cpp b/src/presenters/ProcessingPresenter.cpp index 42887ed..a6631a8 100644 --- a/src/presenters/ProcessingPresenter.cpp +++ b/src/presenters/ProcessingPresenter.cpp @@ -16,6 +16,8 @@ #include "presenters/ProcessingPresenter.h" +#include "ucl/gui/Window.h" + #include "common.h" namespace gallery { namespace { namespace impl { @@ -23,7 +25,7 @@ namespace gallery { namespace { namespace impl { using namespace ucl; constexpr auto IDLE_WAIT_TIME_SEC = 0.2; - constexpr auto PROCESSING_MIN_TIME_SEC = 1.0; + constexpr auto PROCESSING_MIN_TIME_SEC = 0.5; constexpr auto POPUP_SHOW_TIME_SEC = 0.3; constexpr auto POPUP_DURATION_SEC = 2.0; @@ -102,19 +104,20 @@ namespace gallery { ProcessingPresenter::ProcessingPresenter(RefCountObjBase &rc, const IconType iconType) : - RefCountAware(&rc), + Presenter(rc), m_iconType(iconType), m_timer(nullptr), m_state(State::WAITING), m_mayComplete(true), - m_isComplete(false) + m_isComplete(false), + m_isDismissed(false) { } ProcessingPresenter::~ProcessingPresenter() { stopTimer(); - dismissPopup(true); + deletePopup(); } Result ProcessingPresenter::prepare(ElmWidget &parent, @@ -122,8 +125,12 @@ namespace gallery { const TString &completeText, const bool forceProgress) { + FAIL_RETURN(Presenter::prepare(parent), + "Presenter::prepare() failed!"); + FAIL_RETURN(createWidget(parent, processingText), "createWidget() failed!"); + FAIL_RETURN(moveWidget(), "moveWidget() failed!"); FAIL_RETURN(createProgress(), "createProgress() failed!"); @@ -139,6 +146,9 @@ namespace gallery { LOG_RETURN(RES_FAIL, "resetTimer() failed!"); } + addDeactivatorException(this); + broadcastDeactivateBy(this); + return RES_OK; } @@ -158,6 +168,22 @@ namespace gallery { return RES_OK; } + Result ProcessingPresenter::moveWidget() + { + const auto win = m_widget->getWindow(); + if (!win) { + LOG_RETURN(RES_FAIL, "win is NULL!"); + } + + int w = 0; + int h = 0; + win->getScreenSize(&w, &h); + + m_widget->setGeometry(0, 0, w, h); + + return RES_OK; + } + Result ProcessingPresenter::createProgress() { Evas_Object *const progressEo = elm_progressbar_add(*m_widget); @@ -176,12 +202,12 @@ namespace gallery { Result ProcessingPresenter::createPopup(const TString &completeText) { - Evas_Object *const popupEo = elm_popup_add(*m_widget); + Evas_Object *const popupEo = elm_popup_add(m_widget->getTopWidget()); if (!popupEo) { LOG_RETURN(RES_FAIL, "elm_popup_add() failed!"); } - m_popup = makeShared<StyledWidget>(popupEo); + m_popup = makeShared<StyledWidget>(popupEo, true); m_popup->setStyle(impl::POPUP_STYLE); m_popup->setText(completeText, PART_TEXT); @@ -251,17 +277,25 @@ namespace gallery { } } - void ProcessingPresenter::dismissPopup(const bool force) + void ProcessingPresenter::dismissPopup() + { + if (m_popup && !m_isDismissed) { + m_isDismissed = true; + deactivateBy(m_popup.get()); + elm_popup_dismiss(*m_popup); + } + } + + void ProcessingPresenter::deletePopup() { if (m_popup) { eext_object_event_callback_del(*m_popup, EEXT_CALLBACK_BACK, CALLBACK_A(ProcessingPresenter::onPopupHWBackKey)); - if (force) { - m_popup->markForDeletion(); - } else { - elm_popup_dismiss(*m_popup); - } + m_popup.reset(); + + broadcastActivateBy(this); + m_rc->unref(); } } @@ -305,40 +339,37 @@ namespace gallery { void ProcessingPresenter::onPopupDismissed(Widget &widget, void *eventInfo) { - widget.markForDeletion(); - + const auto keepAliver = asShared(*this); if (m_dismissHandler) { m_dismissHandler(); } + deletePopup(); } void ProcessingPresenter::onPopupHWBackKey( Evas_Object *obj, void *eventInfo) { - if (m_popup) { + if (isActive()) { m_widget->emit(impl::SIGNAL_HIDE); stopTimer(); dismissPopup(); } } - Widget &ProcessingPresenter::getWidget() - { - return *m_widget; - } - - void ProcessingPresenter::complete(const DismissHandler &dismissHandler) + void ProcessingPresenter::complete() { - if (!dismissHandler) { - LOG_RETURN_VOID(RES_INVALID_ARGUMENTS, "dismissHandler is NULL"); - } if (m_isComplete) { LOG_RETURN_VOID(RES_ILLEGAL_STATE, "Already in complete state!"); } - - m_dismissHandler = dismissHandler; m_isComplete = true; + m_rc->ref(); + tryShowPopup(); } + + void ProcessingPresenter::setDismissHandler(const DismissHandler &handler) + { + m_dismissHandler = handler; + } } |