diff options
author | Igor Nazarov <i.nazarov@samsung.com> | 2017-06-19 19:10:16 +0300 |
---|---|---|
committer | Igor Nazarov <i.nazarov@samsung.com> | 2017-06-19 19:52:11 +0300 |
commit | 6531cbaceabda1ce57571ec527639bac4eb2b87a (patch) | |
tree | 1943228c50304f2c5793e4c01217295bb5628462 | |
parent | 4ab4e23cf4525162f2104c6cba372bdb456517de (diff) | |
download | gallery-6531cbaceabda1ce57571ec527639bac4eb2b87a.tar.gz gallery-6531cbaceabda1ce57571ec527639bac4eb2b87a.tar.bz2 gallery-6531cbaceabda1ce57571ec527639bac4eb2b87a.zip |
TizenRefApp-8717 [Gallery] Update presenters according to new Presenter
functionality
- Page::prepare() method updated;
- Presenters updated according to new changes (Page and Presenter);
- Minor bug fix.
Change-Id: I05402213d89b01a709a2149a260c5898e454d8d1
22 files changed, 176 insertions, 170 deletions
diff --git a/inc/gallery/presenters/AtspiHighlightHelper.h b/inc/gallery/presenters/AtspiHighlightHelper.h index ca908e0..4175d57 100644 --- a/inc/gallery/presenters/AtspiHighlightHelper.h +++ b/inc/gallery/presenters/AtspiHighlightHelper.h @@ -29,7 +29,8 @@ namespace gallery { ucl::Widget &widget, Elm_Atspi_Relation_Type flowRelation)>; public: - static AtspiHighlightHelperSRef newInstance(ucl::ElmWidget &rootWidget); + static AtspiHighlightHelperSRef newInstance(Presenter &parent, + ucl::ElmWidget &rootWidget); void setEventHandler(EventHandler handler); void registerWidget(ucl::ElmWidget &widget); @@ -39,7 +40,7 @@ namespace gallery { AtspiHighlightHelper(ucl::IRefCountObj &rc); virtual ~AtspiHighlightHelper(); - ucl::Result prepare(ucl::ElmWidget &rootWidget); + ucl::Result prepare(Presenter &parent, ucl::ElmWidget &rootWidget); private: void onAtspiGesture(ucl::Widget &widget, void *eventInfo); diff --git a/inc/gallery/presenters/Dialog.hpp b/inc/gallery/presenters/Dialog.hpp index 8542874..35487b9 100644 --- a/inc/gallery/presenters/Dialog.hpp +++ b/inc/gallery/presenters/Dialog.hpp @@ -22,7 +22,7 @@ namespace gallery { inline ucl::Result Dialog::prepare(ucl::ElmWidget &parent, const PopupType popupType, ON_PREPARE &&onPrepare) { - UCL_FAIL_RETURN(Presenter::prepare(parent), + UCL_FAIL_RETURN(Presenter::prepare(parent, PF_DEACTIVATOR), "Presenter::prepare() failed!"); UCL_FAIL_RETURN(createPopup(parent, popupType), diff --git a/inc/gallery/presenters/MoreOptionsPresenter.h b/inc/gallery/presenters/MoreOptionsPresenter.h index de89f1a..88f45ca 100644 --- a/inc/gallery/presenters/MoreOptionsPresenter.h +++ b/inc/gallery/presenters/MoreOptionsPresenter.h @@ -47,9 +47,11 @@ namespace gallery { bool isEmpty() const; Builder &clear(); Builder &addOption(Option option); - MoreOptionsPresenterSRef build(ucl::ElmWidget &parent) const; + Builder &setParentWidget(const ucl::ElmWidgetSRef &parentWidget); + MoreOptionsPresenterSRef build(Presenter &parent) const; private: ucl::SharedRef<MoreOptions> m_options; + ucl::ElmWidgetSRef m_parentWidget; }; class IListener : public ucl::Polymorphic { @@ -81,7 +83,7 @@ namespace gallery { const MoreOptionsCSRef &options); virtual ~MoreOptionsPresenter(); - ucl::Result prepare(ucl::ElmWidget &parent); + ucl::Result prepare(Presenter &parent, ucl::ElmWidget &parentWidget); ucl::Result addItem(const Option &option); bool resetTimer(double timeout); diff --git a/inc/gallery/presenters/NoContentPage.h b/inc/gallery/presenters/NoContentPage.h index c61fbf2..4b8575c 100644 --- a/inc/gallery/presenters/NoContentPage.h +++ b/inc/gallery/presenters/NoContentPage.h @@ -42,7 +42,7 @@ namespace gallery { const ExitRequestHandler &onExitRequest); virtual ~NoContentPage(); - ucl::Result prepare(); + ucl::Result doPrepare(ucl::NaviItem &item); }; } diff --git a/inc/gallery/presenters/Page.h b/inc/gallery/presenters/Page.h index c1a1b29..201ccc7 100644 --- a/inc/gallery/presenters/Page.h +++ b/inc/gallery/presenters/Page.h @@ -53,8 +53,8 @@ namespace gallery { const ExitRequestHandler &onExitRequest); virtual ~Page(); - template <class ITEM_FACTORY> - ucl::Result prepare(ITEM_FACTORY &&makeItem); + template <class ON_PREPARE> + ucl::Result prepare(ON_PREPARE &&onPrepare); ucl::NaviItem getItem(); diff --git a/inc/gallery/presenters/Page.hpp b/inc/gallery/presenters/Page.hpp index b0e1ae7..7a8fdbd 100644 --- a/inc/gallery/presenters/Page.hpp +++ b/inc/gallery/presenters/Page.hpp @@ -18,13 +18,14 @@ namespace gallery { - template <class ITEM_FACTORY> - inline ucl::Result Page::prepare(ITEM_FACTORY &&makeItem) + template <class ON_PREPARE> + inline ucl::Result Page::prepare(ON_PREPARE &&onPrepare) { - m_item = makeItem(); - if (!m_item) { - UCL_LOG_RETURN(ucl::RES_FAIL, "m_item is NULL"); - } + UCL_FAIL_RETURN(Presenter::prepare(*m_navi), + "Presenter::prepare() failed!"); + + UCL_FAIL_RETURN(onPrepare(m_item), "onPrepare() failed!"); + return preparePart2(); } diff --git a/inc/gallery/presenters/Presenter.h b/inc/gallery/presenters/Presenter.h index d021fa4..ee39f0e 100644 --- a/inc/gallery/presenters/Presenter.h +++ b/inc/gallery/presenters/Presenter.h @@ -51,7 +51,7 @@ namespace gallery { PF_PASSIVE = 0, PF_DEACTIVATOR = (PF_ADD_DEACTIVATOR_SOURCES | PF_ADD_SELF_EXCEPT), - PF_DEFAULT = PF_DEACTIVATOR + PF_DEFAULT = PF_ADD_DEACTIVATOR_SOURCES }; protected: diff --git a/inc/gallery/presenters/PreviewPage.h b/inc/gallery/presenters/PreviewPage.h index 63c546b..38d9798 100644 --- a/inc/gallery/presenters/PreviewPage.h +++ b/inc/gallery/presenters/PreviewPage.h @@ -68,7 +68,7 @@ namespace gallery { const IMediaAlbumSRef &album, bool selectModeStartup); virtual ~PreviewPage(); - ucl::Result prepare(int startItemIndex); + ucl::Result doPrepare(int startItemIndex, ucl::NaviItem &item); void showItem(int itemIndex); void selectItem(int itemIndex); int getSafeItemIndex(int itemIndex) const; diff --git a/inc/gallery/presenters/SelectModePresenter.h b/inc/gallery/presenters/SelectModePresenter.h index 2ba0a56..3cf1fa9 100644 --- a/inc/gallery/presenters/SelectModePresenter.h +++ b/inc/gallery/presenters/SelectModePresenter.h @@ -42,8 +42,10 @@ namespace gallery { public: Builder(); Builder &setFlags(int flags); - SelectModePresenterSRef build(PageContent &content) const; + Builder &setPageContent(const PageContentSRef &content); + SelectModePresenterSRef build(Presenter &parent) const; private: + PageContentSRef m_content; int m_flags; }; @@ -74,10 +76,10 @@ namespace gallery { private: friend class ucl::ReffedObj<SelectModePresenter>; SelectModePresenter(ucl::IRefCountObj &rc, - PageContent &content, int flags); + const PageContentSRef &content, int flags); virtual ~SelectModePresenter(); - ucl::Result prepare(); + ucl::Result prepare(Presenter &parent); void doUpdate(); diff --git a/inc/gallery/presenters/ThumbnailPage.h b/inc/gallery/presenters/ThumbnailPage.h index 914d759..9ad821a 100644 --- a/inc/gallery/presenters/ThumbnailPage.h +++ b/inc/gallery/presenters/ThumbnailPage.h @@ -55,7 +55,7 @@ namespace gallery { const IMediaAlbumSRef &album); virtual ~ThumbnailPage(); - ucl::Result prepare(); + ucl::Result doPrepare(ucl::NaviItem &item); void reload(); diff --git a/inc/gallery/presenters/VideoPlayerPage.h b/inc/gallery/presenters/VideoPlayerPage.h index 61df6f6..8004c48 100644 --- a/inc/gallery/presenters/VideoPlayerPage.h +++ b/inc/gallery/presenters/VideoPlayerPage.h @@ -57,7 +57,7 @@ namespace gallery { const MediaItemSRef &media); virtual ~VideoPlayerPage(); - ucl::Result prepare(); + ucl::Result doPrepare(ucl::NaviItem &item); ucl::Result prepareSoundManager(); diff --git a/inc/gallery/presenters/ViewerPage.h b/inc/gallery/presenters/ViewerPage.h index 82ecc92..3a577d9 100644 --- a/inc/gallery/presenters/ViewerPage.h +++ b/inc/gallery/presenters/ViewerPage.h @@ -66,7 +66,8 @@ namespace gallery { const MediaItemSRef &media, bool exitOnZoomOut); virtual ~ViewerPage(); - ucl::Result prepare(int imageLoadSize, bool isImageLoadSizeFull); + ucl::Result doPrepare(int imageLoadSize, bool isImageLoadSizeFull, + ucl::NaviItem &item); void zoomIn(int originX, int originY); @@ -76,11 +77,6 @@ namespace gallery { void onJobComplete(); - // Presenter // - - virtual void onActivateBy(const DeactivatorInfo &info) final override; - virtual void onDeactivateBy(const DeactivatorInfo &info) final override; - // Page // virtual void onBackKey() final override; diff --git a/src/presenters/AtspiHighlightHelper.cpp b/src/presenters/AtspiHighlightHelper.cpp index ad589c6..d6f05c9 100644 --- a/src/presenters/AtspiHighlightHelper.cpp +++ b/src/presenters/AtspiHighlightHelper.cpp @@ -30,11 +30,11 @@ namespace gallery { using ucl::ATSPI_ON_GESTURE; AtspiHighlightHelperSRef AtspiHighlightHelper::newInstance( - ElmWidget &rootWidget) + Presenter &parent, ElmWidget &rootWidget) { auto result = makeShared<AtspiHighlightHelper>(); - FAIL_RETURN_VALUE(result->prepare(rootWidget), {}, + FAIL_RETURN_VALUE(result->prepare(parent, rootWidget), {}, "result->prepare() failed!"); return result; @@ -49,9 +49,10 @@ namespace gallery { { } - Result AtspiHighlightHelper::prepare(ElmWidget &rootWidget) + Result AtspiHighlightHelper::prepare(Presenter &parent, + ElmWidget &rootWidget) { - FAIL_RETURN(Presenter::prepare(rootWidget), + FAIL_RETURN(Presenter::prepare(parent), "Presenter::prepare() failed!"); registerWidget(rootWidget); diff --git a/src/presenters/MoreOptionsPresenter.cpp b/src/presenters/MoreOptionsPresenter.cpp index 260fa30..6a20b2d 100644 --- a/src/presenters/MoreOptionsPresenter.cpp +++ b/src/presenters/MoreOptionsPresenter.cpp @@ -82,16 +82,27 @@ namespace gallery { return *this; } + MoreOptionsPresenter::Builder &MoreOptionsPresenter::Builder:: + setParentWidget(const ElmWidgetSRef &parentWidget) + { + m_parentWidget = parentWidget; + return *this; + } + MoreOptionsPresenterSRef MoreOptionsPresenter::Builder::build( - ElmWidget &parent) const + Presenter &parent) const { if (isEmpty()) { LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "Builder is empty!"); } + if (!m_parentWidget) { + LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, + "m_parentWidget is NULL!"); + } auto result = makeShared<MoreOptionsPresenter>(m_options); - FAIL_RETURN_VALUE(result->prepare(parent), {}, + FAIL_RETURN_VALUE(result->prepare(parent, *m_parentWidget), {}, "result->prepare() failed!"); return result; @@ -116,11 +127,13 @@ namespace gallery { } } - Result MoreOptionsPresenter::prepare(ElmWidget &parent) + Result MoreOptionsPresenter::prepare(Presenter &parent, + ElmWidget &parentWidget) { - FAIL_RETURN(Presenter::prepare(parent), "Presenter::prepare() failed!"); + FAIL_RETURN(Presenter::prepare(parent, PF_DEACTIVATOR), + "Presenter::prepare() failed!"); - Evas_Object *const more = eext_more_option_add(parent); + Evas_Object *const more = eext_more_option_add(parentWidget); if (!more) { LOG_RETURN(RES_FAIL, "eext_more_option_add() failed!"); } @@ -144,6 +157,8 @@ namespace gallery { deactivateBy(m_widget.get()); + parent.addDeactivatorSource(*m_widget); + return RES_OK; } diff --git a/src/presenters/NoContentPage.cpp b/src/presenters/NoContentPage.cpp index 5dc69b3..597e513 100644 --- a/src/presenters/NoContentPage.cpp +++ b/src/presenters/NoContentPage.cpp @@ -24,8 +24,9 @@ namespace gallery { - using ucl::Layout; + using ucl::NaviItem; using ucl::NaviframeSRef; + using ucl::Layout; using ucl::LAYOUT_NO_CONTENTS; using ucl::PART_TITLE; @@ -60,7 +61,11 @@ namespace gallery { auto result = makeShared<NoContentPage>(m_navi, onExitRequest); - FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!"); + FAIL_RETURN_VALUE(result->prepare([&result](NaviItem &item) + { + return result->doPrepare(item); + }), + {}, "result->prepare() failed!"); return result; } @@ -78,7 +83,7 @@ namespace gallery { { } - Result NoContentPage::prepare() + Result NoContentPage::doPrepare(NaviItem &item) { const auto layout = Layout::Builder(). setIsOwner(true). @@ -99,12 +104,10 @@ namespace gallery { layout->setText(STR_APP_NAME, PART_TITLE); layout->setText(STR_NO_PHOTOS); - FAIL_RETURN(Page::prepare( - [this, &layout]() - { - return getNaviframe().push(*layout, NAVIFRAME_NO_CLIP); - }), - "Page::prepare() failed!"); + item = getNaviframe().push(*layout, NAVIFRAME_NO_CLIP); + if (!item) { + LOG_RETURN(RES_FAIL, "Naviframe::push() failed!"); + } layout->setIsOwner(false); diff --git a/src/presenters/Page.cpp b/src/presenters/Page.cpp index 43ed768..9ccf2ed 100644 --- a/src/presenters/Page.cpp +++ b/src/presenters/Page.cpp @@ -49,8 +49,9 @@ namespace gallery { Result Page::preparePart2() { - FAIL_RETURN(Presenter::prepare(*m_navi), - "Presenter::prepare() failed!"); + if (!m_item) { + UCL_LOG_RETURN(ucl::RES_FAIL, "m_item is NULL"); + } Evas_Object *content = m_item.getContent(); if (!content) { diff --git a/src/presenters/PreviewPage.cpp b/src/presenters/PreviewPage.cpp index d21fb77..9071dac 100644 --- a/src/presenters/PreviewPage.cpp +++ b/src/presenters/PreviewPage.cpp @@ -36,6 +36,7 @@ namespace gallery { namespace { namespace impl { namespace gallery { + using ucl::NaviItem; using ucl::NaviframeSRef; using ucl::RefCountAware; @@ -104,8 +105,11 @@ namespace gallery { auto result = makeShared<PreviewPage>( m_navi, onExitRequest, m_album, m_selectModeStartup); - FAIL_RETURN_VALUE(result->prepare(m_startItemIndex), {}, - "result->prepare() failed!"); + FAIL_RETURN_VALUE(result->prepare([this, &result](NaviItem &item) + { + return result->doPrepare(m_startItemIndex, item); + }), + {}, "result->prepare() failed!"); if (m_selectModeStartup && m_autoSelectStartItem) { result->selectItem(m_startItemIndex); @@ -152,7 +156,7 @@ namespace gallery { } m_isSelected = selected; - if (m_imageGrid.isInSelectMode()) { + if (m_imageGrid.isInSelectMode() && !m_imageGrid.isInTransition()) { ImageGrid::ItemParams params = {}; addFlags(params); m_imageGrid.updateItem(m_index, params); @@ -278,7 +282,7 @@ namespace gallery { return getSafeItemIndex(m_imageGrid->getScrolledToItemIndex()); } - Result PreviewPage::prepare(const int startItemIndex) + Result PreviewPage::doPrepare(const int startItemIndex, NaviItem &item) { m_content = PageContent::Builder(). setFlags(PageContent::FLAG_BOTTOM_BUTTON | @@ -288,6 +292,7 @@ namespace gallery { if (!m_content) { LOG_RETURN(RES_FAIL, "PageContent::build() failed!"); } + setDeactivatorSink(m_content); m_imageGrid = ImageGrid::Builder(). setListener(asWeakThis<ImageGrid::IListener>(this)). @@ -297,47 +302,44 @@ namespace gallery { if (!m_imageGrid) { LOG_RETURN(RES_FAIL, "ImageGrid::build() failed!"); } - ImageGrid::Unrealizer u(*m_imageGrid); - m_content->set(*m_imageGrid); + ImageGrid::Unrealizer u(*m_imageGrid); m_more = MoreOptionsPresenter::Builder(). + setParentWidget(m_content). addOption({impl::MORE_OPTION_ID_DELETE, STR_DELETE, nullptr, getImageTheme(ICON_MORE_OPT_DELETE)}). - build(*m_content); + build(*this); if (!m_more) { LOG_RETURN(RES_FAIL, "MoreOptionsPresenter::build() failed!"); } - m_content->set(m_more->getWidget(), PageContent::Part::MORE_OPTIONS); - addDeactivatorSource(m_more->getWidget()); m_smp = SelectModePresenter::Builder(). + setPageContent(m_content). setFlags(SelectModePresenter::FLAG_NO_MORE_OPTIONS). - build(*m_content); + build(*this); if (!m_smp) { LOG_RETURN(RES_FAIL, "SelectModePresenter::build() failed!"); } + m_atspiHelper = AtspiHighlightHelper::newInstance(*this, getWindow()); + if (!m_atspiHelper) { + LOG_RETURN(RES_FAIL, "AtspiHighlightHelper::newInstance() failed!"); + } + FAIL_RETURN(m_album->forEachMedia( DELEGATE(PreviewPage::onEachMedia, this)), "m_album->forEachMedia() failed!"); - FAIL_RETURN(Page::prepare( - [this]() - { - return getNaviframe().push(*m_content, NAVIFRAME_NO_CLIP); - }), - "Page::prepare() failed!"); + m_imageGrid->setItemCount(m_items.size()); - m_atspiHelper = AtspiHighlightHelper::newInstance(getWindow()); - if (!m_atspiHelper) { - LOG_RETURN(RES_FAIL, "AtspiHighlightHelper::newInstance() failed!"); + item = getNaviframe().push(*m_content, NAVIFRAME_NO_CLIP); + if (!item) { + LOG_RETURN(RES_FAIL, "Naviframe::push() failed!"); } - m_imageGrid->setItemCount(m_items.size()); - m_album->addChangeHandler(WEAK_DELEGATE( PreviewPage::onAlbumChanged, asWeak(*this))); @@ -413,15 +415,6 @@ namespace gallery { impl::BRING_IN_SCROLL_FRICTION); } - if (!info.isBroadcast) { - m_more->activateBy(info.deactivator); - if (m_atspiHelper) { - m_atspiHelper->activateBy(info.deactivator); - } - } - - m_smp->activateBy(info.deactivator); - if (isActive() || m_smp->isActive()) { m_imageGrid->activateRotary(); } @@ -429,13 +422,6 @@ namespace gallery { void PreviewPage::onDeactivateBy(const DeactivatorInfo &info) { - if (!info.isBroadcast) { - m_more->deactivateBy(info.deactivator); - m_atspiHelper->deactivateBy(info.deactivator); - } - - m_smp->deactivateBy(info.deactivator); - if (!m_smp->isActive()) { m_imageGrid->deactivateRotary(); } @@ -669,16 +655,16 @@ namespace gallery { item->setSelected(false); } + m_imageGrid->setSelectModeEnabled(true); + if (m_imageGrid->isInTransition()) { + deactivateBy(m_imageGrid.get()); + } + m_content->setMoreOptionsVisible(false); m_smp->setBottomButtonText(STR_DELETE_CAPS); m_smp->update(m_selectCount, m_items.size()); m_smp->setVisible(true); - - m_imageGrid->setSelectModeEnabled(true); - if (m_imageGrid->isInTransition()) { - deactivateBy(m_imageGrid.get()); - } } void PreviewPage::switchToNormalMode() @@ -688,14 +674,14 @@ namespace gallery { } m_isInSelectMode = false; - m_content->setMoreOptionsVisible(true); - - m_smp->setVisible(false); - m_imageGrid->setSelectModeEnabled(false); if (m_imageGrid->isInTransition()) { deactivateBy(m_imageGrid.get()); } + + m_content->setMoreOptionsVisible(true); + + m_smp->setVisible(false); } void PreviewPage::toggleItemSelected(const int itemIndex) diff --git a/src/presenters/ProcessingPresenter.cpp b/src/presenters/ProcessingPresenter.cpp index 619f122..3d1ad21 100644 --- a/src/presenters/ProcessingPresenter.cpp +++ b/src/presenters/ProcessingPresenter.cpp @@ -107,7 +107,7 @@ namespace gallery { const TString &processingText, const bool forceProgress) { - FAIL_RETURN(Presenter::prepare(parent), + FAIL_RETURN(Presenter::prepare(parent, PF_PASSIVE), "Presenter::prepare() failed!"); FAIL_RETURN(createWidget(parent, processingText), diff --git a/src/presenters/SelectModePresenter.cpp b/src/presenters/SelectModePresenter.cpp index 0c0e8f1..b9b333c 100644 --- a/src/presenters/SelectModePresenter.cpp +++ b/src/presenters/SelectModePresenter.cpp @@ -52,12 +52,23 @@ namespace gallery { return *this; } + SelectModePresenter::Builder &SelectModePresenter::Builder:: + setPageContent(const PageContentSRef &content) + { + m_content = content; + return *this; + } + SelectModePresenterSRef SelectModePresenter::Builder::build( - PageContent &content) const + Presenter &parent) const { - auto result = makeShared<SelectModePresenter>(content, m_flags); + if (!m_content) { + LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_content is NULL!"); + } - FAIL_RETURN_VALUE(result->prepare(), {}, + auto result = makeShared<SelectModePresenter>(m_content, m_flags); + + FAIL_RETURN_VALUE(result->prepare(parent), {}, "result->prepare() failed!"); return result; @@ -66,9 +77,9 @@ namespace gallery { // SelectModePresenter // SelectModePresenter::SelectModePresenter(IRefCountObj &rc, - PageContent &content, const int flags) : + const PageContentSRef &content, const int flags) : Presenter(rc), - m_content(asShared(content)), + m_content(content), m_flags(flags), m_totalCount(0), m_selectCount(0), @@ -86,15 +97,16 @@ namespace gallery { deletePopup(); } - Result SelectModePresenter::prepare() + Result SelectModePresenter::prepare(Presenter &parent) { - FAIL_RETURN(Presenter::prepare(*m_content), + FAIL_RETURN(Presenter::prepare(parent, PF_DEACTIVATOR), "Presenter::prepare() failed!"); m_selectButton = makeShared<StyledWidget>( elm_button_add(*m_content), true); m_selectButton->setStyle(impl::SELECT_BTN_STYLE); m_content->set(*m_selectButton, PageContent::Part::SELECT_BUTTON); + m_content->setSelectButtonVisible(false); show(*m_selectButton); m_selectButton->addEventHandler(BTN_CLICKED, WEAK_DELEGATE( @@ -115,6 +127,8 @@ namespace gallery { SelectModePresenter::onRotary), this); } + deactivateBy(m_selectButton.get()); + return RES_OK; } diff --git a/src/presenters/ThumbnailPage.cpp b/src/presenters/ThumbnailPage.cpp index c6defbb..398d7d6 100644 --- a/src/presenters/ThumbnailPage.cpp +++ b/src/presenters/ThumbnailPage.cpp @@ -36,6 +36,7 @@ namespace gallery { namespace { namespace impl { namespace gallery { + using ucl::NaviItem; using ucl::NaviframeSRef; using ucl::RefCountAware; @@ -80,7 +81,11 @@ namespace gallery { auto result = makeShared<ThumbnailPage>( m_navi, onExitRequest, m_album); - FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!"); + FAIL_RETURN_VALUE(result->prepare([&result](NaviItem &item) + { + return result->doPrepare(item); + }), + {}, "result->prepare() failed!"); return result; } @@ -169,7 +174,7 @@ namespace gallery { m_imageGrid->setItemCount(m_mediaItems.size()); } - Result ThumbnailPage::prepare() + Result ThumbnailPage::doPrepare(NaviItem &item) { m_content = PageContent::Builder(). setFlags(PageContent::FLAG_MORE_OPTIONS). @@ -177,6 +182,7 @@ namespace gallery { if (!m_content) { LOG_RETURN(RES_FAIL, "PageContent::build() failed!"); } + setDeactivatorSink(m_content); m_imageGrid = ImageGrid::Builder(). setListener(asWeakThis<ImageGrid::IListener>(this)). @@ -185,39 +191,35 @@ namespace gallery { if (!m_imageGrid) { LOG_RETURN(RES_FAIL, "ImageGrid::build() failed!"); } - m_content->set(*m_imageGrid); m_more = MoreOptionsPresenter::Builder(). + setParentWidget(m_content). addOption({impl::MORE_OPTION_ID_DELETE, STR_DELETE, nullptr, getImageTheme(ICON_MORE_OPT_DELETE)}). - build(*m_content); + build(*this); if (!m_more) { LOG_RETURN(RES_FAIL, "MoreOptionsPresenter::build() failed!"); } - m_content->set(m_more->getWidget(), PageContent::Part::MORE_OPTIONS); - addDeactivatorSource(m_more->getWidget()); + + m_atspiHelper = AtspiHighlightHelper::newInstance(*this, getWindow()); + if (!m_atspiHelper) { + LOG_RETURN(RES_FAIL, "AtspiHighlightHelper::newInstance() failed!"); + } FAIL_RETURN(m_album->forEachMedia( DELEGATE(ThumbnailPage::onEachMedia, this)), "m_album->forEachMedia() failed!"); - FAIL_RETURN(Page::prepare( - [this]() - { - return getNaviframe().push(*m_content, NAVIFRAME_NO_CLIP); - }), - "Page::prepare() failed!"); + m_imageGrid->setItemCount(m_mediaItems.size()); - m_atspiHelper = AtspiHighlightHelper::newInstance(getWindow()); - if (!m_atspiHelper) { - LOG_RETURN(RES_FAIL, "AtspiHighlightHelper::newInstance() failed!"); + item = getNaviframe().push(*m_content, NAVIFRAME_NO_CLIP); + if (!item) { + LOG_RETURN(RES_FAIL, "Naviframe::push() failed!"); } - m_imageGrid->setItemCount(m_mediaItems.size()); - m_album->addChangeHandler(WEAK_DELEGATE( ThumbnailPage::onAlbumChanged, asWeak(*this))); @@ -251,13 +253,6 @@ namespace gallery { impl::BRING_IN_SCROLL_FRICTION); } - if (!info.isBroadcast) { - m_more->activateBy(info.deactivator); - if (m_atspiHelper) { - m_atspiHelper->activateBy(info.deactivator); - } - } - if (isActive()) { m_imageGrid->activateRotary(); } @@ -265,11 +260,6 @@ namespace gallery { void ThumbnailPage::onDeactivateBy(const DeactivatorInfo &info) { - if (!info.isBroadcast) { - m_more->deactivateBy(info.deactivator); - m_atspiHelper->deactivateBy(info.deactivator); - } - m_imageGrid->deactivateRotary(); } diff --git a/src/presenters/VideoPlayerPage.cpp b/src/presenters/VideoPlayerPage.cpp index cc0bf22..cbc1192 100644 --- a/src/presenters/VideoPlayerPage.cpp +++ b/src/presenters/VideoPlayerPage.cpp @@ -77,8 +77,9 @@ namespace gallery { using ucl::AutoAppCtrl; - using ucl::Layout; + using ucl::NaviItem; using ucl::NaviframeSRef; + using ucl::Layout; using ucl::StyledWidgetSRef; using ucl::WidgetEventHandler; @@ -126,7 +127,11 @@ namespace gallery { auto result = makeShared<VideoPlayerPage>( m_navi, onExitRequest, m_media); - FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!"); + FAIL_RETURN_VALUE(result->prepare([&result](NaviItem &item) + { + return result->doPrepare(item); + }), + {}, "result->prepare() failed!"); return result; } @@ -184,7 +189,7 @@ namespace gallery { } } - Result VideoPlayerPage::prepare() + Result VideoPlayerPage::doPrepare(NaviItem &item) { m_content = Layout::Builder(). setTheme(impl::LAYOUT_VIDEO_PLAYER). @@ -194,12 +199,10 @@ namespace gallery { LOG_RETURN(RES_FAIL, "m_content is NULL"); } - FAIL_RETURN(Page::prepare( - [this]() - { - return getNaviframe().push(*m_content, NAVIFRAME_NO_CLIP); - }), - "Page::prepare() failed!"); + item = getNaviframe().push(*m_content, NAVIFRAME_NO_CLIP); + if (!item) { + LOG_RETURN(RES_FAIL, "Naviframe::push() failed!"); + } createImage(); diff --git a/src/presenters/ViewerPage.cpp b/src/presenters/ViewerPage.cpp index 3dbd236..87135b8 100644 --- a/src/presenters/ViewerPage.cpp +++ b/src/presenters/ViewerPage.cpp @@ -29,6 +29,7 @@ namespace gallery { namespace { namespace impl { namespace gallery { + using ucl::NaviItem; using ucl::NaviframeSRef; // ViewerPage::Builder // @@ -102,8 +103,12 @@ namespace gallery { auto result = makeShared<ViewerPage>( m_navi, onExitRequest, m_media, m_exitOnZoomOut); - FAIL_RETURN_VALUE(result->prepare(m_imageLoadSize, - m_isImageLoadSizeFull), {}, "result->prepare() failed!"); + FAIL_RETURN_VALUE(result->prepare([this, &result](NaviItem &item) + { + return result->doPrepare(m_imageLoadSize, + m_isImageLoadSizeFull, item); + }), + {}, "result->prepare() failed!"); if ((m_zoomInX >= 0) && (m_zoomInY >= 0)) { result->zoomIn(m_zoomInX, m_zoomInY); @@ -132,8 +137,8 @@ namespace gallery { } } - Result ViewerPage::prepare(const int imageLoadSize, - const bool isImageLoadSizeFull) + Result ViewerPage::doPrepare(const int imageLoadSize, + const bool isImageLoadSizeFull, NaviItem &item) { const int mediaFlags = m_media->getFlags(); const bool canSave = (mediaFlags & MediaItem::FLAG_SAVE); @@ -159,22 +164,23 @@ namespace gallery { if (!m_content) { LOG_RETURN(RES_FAIL, "PageContent::build() failed!"); } + setDeactivatorSink(m_content); rootWidget = m_content.get(); m_content->set(*m_imageViewer); m_more = MoreOptionsPresenter::Builder(). + setParentWidget(m_content). addOption({impl::MORE_OPTION_ID_SAVE, STR_SAVE_TO_GEAR, nullptr, getImageTheme(ICON_MORE_OPT_SAVE)}). - build(*m_content); + build(*this); if (!m_more) { LOG_RETURN(RES_FAIL, "MoreOptionsPresenter::build() failed!"); } m_content->set(m_more->getWidget(), PageContent::Part::MORE_OPTIONS); - addDeactivatorSource(m_more->getWidget()); m_more->setListener(asWeakThis< MoreOptionsPresenter::IListener>(this)); @@ -191,17 +197,16 @@ namespace gallery { m_imageViewer->addEventHandler(IMAGE_VIEWER_ZOOM_END, WEAK_DELEGATE(ViewerPage::onZoomEnd, asWeak(*this))); - FAIL_RETURN(Page::prepare( - [this, rootWidget]() - { - const auto topItem = getNaviframe().getTopItem(); - if (topItem) { - return getNaviframe().insertAfter(topItem, - *rootWidget, NAVIFRAME_NO_CLIP); - } - return getNaviframe().push(*rootWidget, NAVIFRAME_NO_CLIP); - }), - "Page::prepare() failed!"); + const auto topItem = getNaviframe().getTopItem(); + if (topItem) { + item = getNaviframe().insertAfter(topItem, + *rootWidget, NAVIFRAME_NO_CLIP); + } else { + item = getNaviframe().push(*rootWidget, NAVIFRAME_NO_CLIP); + } + if (!item) { + LOG_RETURN(RES_FAIL, "Naviframe::push() failed!"); + } m_touchParser = makeShared<TouchParser>(*m_imageViewer); m_touchParser->setDoubleTapHandler(WEAK_DELEGATE( @@ -246,20 +251,6 @@ namespace gallery { } } - void ViewerPage::onActivateBy(const DeactivatorInfo &info) - { - if (m_more && (info.deactivator == &getNaviframe())) { - m_more->activateBy(info.deactivator); - } - } - - void ViewerPage::onDeactivateBy(const DeactivatorInfo &info) - { - if (m_more && (info.deactivator == &getNaviframe())) { - m_more->deactivateBy(info.deactivator); - } - } - void ViewerPage::onBackKey() { if (m_imageViewer->isZoomedOut()) { |