diff options
author | Igor Nazarov <i.nazarov@samsung.com> | 2017-05-08 13:18:20 +0300 |
---|---|---|
committer | Igor Nazarov <i.nazarov@samsung.com> | 2017-05-08 13:34:30 +0300 |
commit | 2e33b69cc393c78c38f5e4428a487b1bd52adad5 (patch) | |
tree | 527a09b7e13c064e63bd23532e4b0c9f3ab83190 | |
parent | 98fbc3c9ecd86adb6bc8d1eb89111809c488866c (diff) | |
download | gallery-2e33b69cc393c78c38f5e4428a487b1bd52adad5.tar.gz gallery-2e33b69cc393c78c38f5e4428a487b1bd52adad5.tar.bz2 gallery-2e33b69cc393c78c38f5e4428a487b1bd52adad5.zip |
[Gallery] Implemented More Options in ThumbnailPage
- Implemented More Options in ThumbnailPage;
- setAutoSelectStartItem() added to PreviewPage::Builder;
- MoreOptionsPresenter added auto close logic if opened when not active;
- ImageGrid HcombInfo slot per page changed to 1;
- ImageGrid fixed getScrolledToItemIndex() calculations;
- fixed std::nullptr_t LLVM build.
Change-Id: I3e66e016391c34344405dd20b2b95fc051a772d6
24 files changed, 134 insertions, 47 deletions
diff --git a/inc/presenters/PreviewPage.h b/inc/presenters/PreviewPage.h index 7a3cc8b..286fa80 100644 --- a/inc/presenters/PreviewPage.h +++ b/inc/presenters/PreviewPage.h @@ -39,12 +39,14 @@ namespace gallery { Builder &setAlbum(const IMediaAlbumSRef &album); Builder &setStartItemIndex(int index); Builder &setSelectModeStartup(bool value); + Builder &setAutoSelectStartItem(bool value); PreviewPageWRef build(ExitRequestHandler onExitRequest) const; private: ucl::NaviframeSRef m_navi; IMediaAlbumSRef m_album; int m_startItemIndex; bool m_selectModeStartup; + bool m_autoSelectStartItem; }; public: diff --git a/inc/presenters/ThumbnailPage.h b/inc/presenters/ThumbnailPage.h index cbf889e..ca5431c 100644 --- a/inc/presenters/ThumbnailPage.h +++ b/inc/presenters/ThumbnailPage.h @@ -21,10 +21,13 @@ #include "view/IImageGridListener.h" +#include "IMoreOptionsListener.h" + namespace gallery { class ThumbnailPage final : public Page, - private IImageGridListener { + private IImageGridListener, + private IMoreOptionsListener { public: class Builder { public: @@ -57,8 +60,8 @@ namespace gallery { // Page // - virtual void onActivate() final override; - virtual void onDeactivate() final override; + virtual void onActivateBy(const DeactivatorInfo &info) final override; + virtual void onDeactivateBy(const DeactivatorInfo &info) final override; // IImageGridListener // @@ -67,6 +70,11 @@ namespace gallery { virtual void onItemEvent(int itemIndex, int event, int x, int y) final override; + // IMoreOptionsListener // + + virtual void onMoreOptionClicked(MoreOptionsPresenter &sender, + const MoreOption &option) final override; + private: class RealizedItem; using RealizedItemUPtr = std::unique_ptr<RealizedItem>; @@ -77,7 +85,9 @@ namespace gallery { std::vector<RealizedItemUPtr> m_realizedItems; + PageContentSRef m_content; ImageGridSRef m_imageGrid; + MoreOptionsPresenterSRef m_more; PageWRef m_page; }; diff --git a/src/presenters/MoreOptionsPresenter.cpp b/src/presenters/MoreOptionsPresenter.cpp index 012865c..fa2d059 100644 --- a/src/presenters/MoreOptionsPresenter.cpp +++ b/src/presenters/MoreOptionsPresenter.cpp @@ -174,15 +174,20 @@ namespace gallery { void MoreOptionsPresenter::onOpened(Widget &widget, void *eventInfo) { + const auto keepAliver = asShared(*this); sendDeactivateBy(*m_widget, this); activateBy(m_widget.get()); if (m_listener) { m_listener->onMoreOptionsOpened(*this); } + if (!isActive()) { + setOpened(false); + } } void MoreOptionsPresenter::onClosed(Widget &widget, void *eventInfo) { + const auto keepAliver = asShared(*this); deactivateBy(m_widget.get()); sendActivateBy(*m_widget, this); if (m_listener) { diff --git a/src/presenters/PreviewPage.cpp b/src/presenters/PreviewPage.cpp index 5a25a59..70a5f7e 100644 --- a/src/presenters/PreviewPage.cpp +++ b/src/presenters/PreviewPage.cpp @@ -50,7 +50,8 @@ namespace gallery { PreviewPage::Builder::Builder() : m_startItemIndex(0), - m_selectModeStartup(false) + m_selectModeStartup(false), + m_autoSelectStartItem(false) { } @@ -86,6 +87,13 @@ namespace gallery { return *this; } + PreviewPage::Builder &PreviewPage::Builder::setAutoSelectStartItem( + const bool value) + { + m_autoSelectStartItem = value; + return *this; + } + PreviewPageWRef PreviewPage::Builder::build( const ExitRequestHandler onExitRequest) const { @@ -108,7 +116,7 @@ namespace gallery { if (m_startItemIndex > 0) { result->showItem(m_startItemIndex); } - if (m_selectModeStartup) { + if (m_selectModeStartup && m_autoSelectStartItem) { result->selectItem(m_startItemIndex); } @@ -276,8 +284,6 @@ namespace gallery { Result PreviewPage::prepare() { - ILOG("m_selectModeStartup: %d", m_selectModeStartup); - m_content = PageContent::Builder(). setFlags(PageContent::FLAG_BOTTOM_BUTTON | PageContent::FLAG_SELECT_BUTTON | @@ -441,7 +447,7 @@ namespace gallery { void PreviewPage::onItemEvent(const int itemIndex, const int event, const int x, const int y) { - if (m_more->isOpened()) { + if (!isActive() || m_more->isOpened()) { return; } diff --git a/src/presenters/ThumbnailPage.cpp b/src/presenters/ThumbnailPage.cpp index 20af9fb..76d5c0e 100644 --- a/src/presenters/ThumbnailPage.cpp +++ b/src/presenters/ThumbnailPage.cpp @@ -19,16 +19,23 @@ #include "model/IMediaAlbum.h" #include "model/MediaItem.h" +#include "view/PageContent.h" #include "view/ImageGrid.h" +#include "presenters/MoreOptionsPresenter.h" #include "presenters/PreviewPage.h" +#include "resources.h" #include "common.h" namespace gallery { namespace { namespace impl { constexpr auto BRING_IN_SCROLL_FRICTION = 0.5; constexpr auto PAGE_SCROLL_IN_FRICTION = 0.5; + + enum { + MORE_OPTION_ID_DELETE + }; }}} namespace gallery { @@ -156,22 +163,43 @@ namespace gallery { Result ThumbnailPage::prepare() { - FAIL_RETURN(m_album->forEachMedia( - DELEGATE(ThumbnailPage::onEachMedia, this)), - "m_album->forEachMedia() failed!"); + m_content = PageContent::Builder(). + setFlags(PageContent::FLAG_MORE_OPTIONS). + build(getNaviframe()); + if (!m_content) { + LOG_RETURN(RES_FAIL, "PageContent::build() failed!"); + } m_imageGrid = ImageGrid::Builder(). setListener(this). setType(ImageGrid::Type::HCOMB_3X3). - build(getNaviframe()); + build(*m_content); if (!m_imageGrid) { LOG_RETURN(RES_FAIL, "ImageGrid::build() failed!"); } + m_content->set(*m_imageGrid); + + m_more = MoreOptionsPresenter::Builder(). + addOption({impl::MORE_OPTION_ID_DELETE, + STR_DELETE, nullptr, + getImageTheme(ICON_MORE_OPT_DELETE)}). + build(*m_content); + if (!m_more) { + LOG_RETURN(RES_FAIL, "MoreOptionsPresenter::build() failed!"); + } + + m_content->set(m_more->getWidget(), PageContent::Part::MORE_OPTIONS); + addDeactivatorSource(m_more->getWidget()); + + FAIL_RETURN(m_album->forEachMedia( + DELEGATE(ThumbnailPage::onEachMedia, this)), + "m_album->forEachMedia() failed!"); + FAIL_RETURN(Page::prepare( [this]() { - return getNaviframe().push(*m_imageGrid, NAVIFRAME_EMPTY); + return getNaviframe().push(*m_content, NAVIFRAME_EMPTY); }), "Page::prepare() failed!"); @@ -180,6 +208,8 @@ namespace gallery { m_album->addChangeHandler(WEAK_DELEGATE( ThumbnailPage::onAlbumChanged, asWeak(*this))); + m_more->setListener(asWeakThis<IMoreOptionsListener>(this)); + return RES_OK; } @@ -196,18 +226,28 @@ namespace gallery { return true; } - void ThumbnailPage::onActivate() + void ThumbnailPage::onActivateBy(const DeactivatorInfo &info) { - elm_config_scroll_page_scroll_friction_set( - impl::PAGE_SCROLL_IN_FRICTION); - elm_config_scroll_bring_in_scroll_friction_set( - impl::BRING_IN_SCROLL_FRICTION); + if (info.deactivator == &getNaviframe()) { + elm_config_scroll_page_scroll_friction_set( + impl::PAGE_SCROLL_IN_FRICTION); + elm_config_scroll_bring_in_scroll_friction_set( + impl::BRING_IN_SCROLL_FRICTION); + + m_more->activateBy(info.deactivator); + } - m_imageGrid->activateRotary(); + if (isActive()) { + m_imageGrid->activateRotary(); + } } - void ThumbnailPage::onDeactivate() + void ThumbnailPage::onDeactivateBy(const DeactivatorInfo &info) { + if (info.deactivator == &getNaviframe()) { + m_more->deactivateBy(info.deactivator); + } + m_imageGrid->deactivateRotary(); } @@ -234,7 +274,7 @@ namespace gallery { void ThumbnailPage::onItemEvent(const int itemIndex, const int event, const int x, const int y) { - if (!isActive()) { + if (!isActive() || m_more->isOpened()) { return; } @@ -253,11 +293,32 @@ namespace gallery { m_page = PreviewPage::Builder(). setNaviframe(asShared(getNaviframe())). setAlbum(m_album). - setSelectModeStartup(selectModeStartup). setStartItemIndex(itemIndex). + setSelectModeStartup(selectModeStartup). + setAutoSelectStartItem(true). build(DELEGATE(ThumbnailPage::onPageExitRequest, this)); } + void ThumbnailPage::onMoreOptionClicked(MoreOptionsPresenter &sender, + const MoreOption &option) + { + sender.setOpened(false); + + switch (option.id) { + case impl::MORE_OPTION_ID_DELETE: + m_page = PreviewPage::Builder(). + setNaviframe(asShared(getNaviframe())). + setAlbum(m_album). + setStartItemIndex(m_imageGrid->getScrolledToItemIndex()). + setSelectModeStartup(true). + build(DELEGATE(ThumbnailPage::onPageExitRequest, this)); + break; + default: + WLOG("Unknown option id: %d;", option.id); + break; + } + } + void ThumbnailPage::onPageExitRequest(Page &page) { if (const PreviewPageSRef previewPage = diff --git a/src/view/ImageGrid.cpp b/src/view/ImageGrid.cpp index f1c0df4..96b1617 100644 --- a/src/view/ImageGrid.cpp +++ b/src/view/ImageGrid.cpp @@ -175,7 +175,7 @@ namespace gallery { HcombInfo(const int totalLength, const std::array<LayoutTheme, 2> &slotThemes) : Info(slotThemes, {{(totalLength / 2), ceilDiv<2>(totalLength)}}, - impl::HCOMB_SCROLL_LIMIT, (totalLength - 1), true), + impl::HCOMB_SCROLL_LIMIT, 1, true), totalLength(totalLength) { } @@ -917,8 +917,11 @@ namespace gallery { int ImageGrid::getScrolledToItemIndex() const { - return std::min(static_cast<long>(m_itemCount - 1), - std::lround(1.0 * m_scrollOffset / m_slotSize)); + const int evenSlotIndex = (std::lround(1.0 * m_scrollOffset / + m_slotSize) * 2); + return std::min((m_itemCount - 1), std::min( + m_info.calcItemIndexFromCell(evenSlotIndex, 0), + m_info.calcItemIndexFromCell((evenSlotIndex + 1), 0))); } Result ImageGrid::scrollToItem(const int itemIndex) diff --git a/ucl/inc/ucl/gui/Theme.h b/ucl/inc/ucl/gui/Theme.h index f82d675..d8b5b31 100644 --- a/ucl/inc/ucl/gui/Theme.h +++ b/ucl/inc/ucl/gui/Theme.h @@ -29,7 +29,7 @@ namespace ucl { public: Theme(); - Theme(nullptr_t); + Theme(std::nullptr_t); explicit Theme(Elm_Theme *th, bool isOwner = false); Theme(Theme &&tmp); Theme &operator=(Theme &&tmp); diff --git a/ucl/inc/ucl/gui/Theme.hpp b/ucl/inc/ucl/gui/Theme.hpp index dac1d57..65910df 100644 --- a/ucl/inc/ucl/gui/Theme.hpp +++ b/ucl/inc/ucl/gui/Theme.hpp @@ -31,7 +31,7 @@ namespace ucl { { } - inline Theme::Theme(nullptr_t) : + inline Theme::Theme(std::nullptr_t) : Theme() { } diff --git a/ucl/inc/ucl/gui/WidgetItem.h b/ucl/inc/ucl/gui/WidgetItem.h index edef5e9..7794444 100644 --- a/ucl/inc/ucl/gui/WidgetItem.h +++ b/ucl/inc/ucl/gui/WidgetItem.h @@ -24,7 +24,7 @@ namespace ucl { class WidgetItem { public: constexpr WidgetItem(); - constexpr WidgetItem(nullptr_t); + constexpr WidgetItem(std::nullptr_t); explicit WidgetItem(Elm_Object_Item *it); Elm_Object_Item *getIt() const; diff --git a/ucl/inc/ucl/gui/WidgetItem.hpp b/ucl/inc/ucl/gui/WidgetItem.hpp index 9880816..26b6cbd 100644 --- a/ucl/inc/ucl/gui/WidgetItem.hpp +++ b/ucl/inc/ucl/gui/WidgetItem.hpp @@ -21,7 +21,7 @@ namespace ucl { { } - constexpr WidgetItem::WidgetItem(nullptr_t) : + constexpr WidgetItem::WidgetItem(std::nullptr_t) : WidgetItem() { } diff --git a/ucl/inc/ucl/gui/types.h b/ucl/inc/ucl/gui/types.h index ed7d03f..f4deb13 100644 --- a/ucl/inc/ucl/gui/types.h +++ b/ucl/inc/ucl/gui/types.h @@ -105,7 +105,7 @@ namespace ucl { const char *style; constexpr LayoutTheme(); - constexpr LayoutTheme(nullptr_t); + constexpr LayoutTheme(std::nullptr_t); constexpr LayoutTheme(const char *klass, const char *group, const char *style); }; diff --git a/ucl/inc/ucl/gui/types.hpp b/ucl/inc/ucl/gui/types.hpp index 95521a2..7f128c8 100644 --- a/ucl/inc/ucl/gui/types.hpp +++ b/ucl/inc/ucl/gui/types.hpp @@ -27,7 +27,7 @@ namespace ucl { { } - constexpr LayoutTheme::LayoutTheme(nullptr_t) : + constexpr LayoutTheme::LayoutTheme(std::nullptr_t) : LayoutTheme() { } diff --git a/ucl/inc/ucl/misc/Aspect.h b/ucl/inc/ucl/misc/Aspect.h index 9b40f98..082cd91 100644 --- a/ucl/inc/ucl/misc/Aspect.h +++ b/ucl/inc/ucl/misc/Aspect.h @@ -26,7 +26,7 @@ namespace ucl { const char *name; constexpr Aspect(); - constexpr Aspect(nullptr_t); + constexpr Aspect(std::nullptr_t); explicit constexpr Aspect(const char *name); constexpr operator const char *() const; diff --git a/ucl/inc/ucl/misc/Aspect.hpp b/ucl/inc/ucl/misc/Aspect.hpp index 03127ec..aac7ddb 100644 --- a/ucl/inc/ucl/misc/Aspect.hpp +++ b/ucl/inc/ucl/misc/Aspect.hpp @@ -27,7 +27,7 @@ namespace ucl { } template <class CHILD> - constexpr Aspect<CHILD>::Aspect(nullptr_t) : + constexpr Aspect<CHILD>::Aspect(std::nullptr_t) : Aspect() { } diff --git a/ucl/inc/ucl/misc/Variant.h b/ucl/inc/ucl/misc/Variant.h index a69866b..3bfa6d6 100644 --- a/ucl/inc/ucl/misc/Variant.h +++ b/ucl/inc/ucl/misc/Variant.h @@ -72,7 +72,7 @@ namespace ucl { public: Variant() noexcept; - Variant(nullptr_t) noexcept; + Variant(std::nullptr_t) noexcept; Variant(bool aBool) noexcept; Variant(int anInt) noexcept; @@ -83,7 +83,7 @@ namespace ucl { Variant(const char *aString, int length); Variant(const std::string &aString); - Variant(nullptr_t, int arrayLength); + Variant(std::nullptr_t, int arrayLength); Variant(const Variant *anArray, int length); Variant(const VarVector &anArray); template <size_t N> diff --git a/ucl/inc/ucl/misc/Variant.hpp b/ucl/inc/ucl/misc/Variant.hpp index 86ad92e..04c6650 100644 --- a/ucl/inc/ucl/misc/Variant.hpp +++ b/ucl/inc/ucl/misc/Variant.hpp @@ -74,7 +74,7 @@ namespace ucl { { } - inline Variant::Variant(nullptr_t) noexcept : + inline Variant::Variant(std::nullptr_t) noexcept : Variant() { } diff --git a/ucl/inc/ucl/util/delegation/BaseDelegate.h b/ucl/inc/ucl/util/delegation/BaseDelegate.h index e49ce22..d5c518c 100644 --- a/ucl/inc/ucl/util/delegation/BaseDelegate.h +++ b/ucl/inc/ucl/util/delegation/BaseDelegate.h @@ -35,7 +35,7 @@ namespace ucl { public: constexpr BaseDelegate() noexcept; - constexpr BaseDelegate(nullptr_t) noexcept; + constexpr BaseDelegate(std::nullptr_t) noexcept; template <class FUNC_SIG> BaseDelegate(const BaseDelegate2<FUNC_SIG, DATA> &d) noexcept; diff --git a/ucl/inc/ucl/util/delegation/BaseDelegate.hpp b/ucl/inc/ucl/util/delegation/BaseDelegate.hpp index 9fe4369..4cb9741 100644 --- a/ucl/inc/ucl/util/delegation/BaseDelegate.hpp +++ b/ucl/inc/ucl/util/delegation/BaseDelegate.hpp @@ -25,7 +25,7 @@ namespace ucl { template <class R, class ...ARGS, class DATA> constexpr BaseDelegate<R(ARGS...), DATA>:: - BaseDelegate(nullptr_t) noexcept : + BaseDelegate(std::nullptr_t) noexcept : BaseDelegate() { } diff --git a/ucl/inc/ucl/util/memory/SharedRef.h b/ucl/inc/ucl/util/memory/SharedRef.h index 9e4793f..4bd7ca0 100644 --- a/ucl/inc/ucl/util/memory/SharedRef.h +++ b/ucl/inc/ucl/util/memory/SharedRef.h @@ -34,7 +34,7 @@ namespace ucl { public: constexpr SharedRef() noexcept; - constexpr SharedRef(nullptr_t) noexcept; + constexpr SharedRef(std::nullptr_t) noexcept; SharedRef(RefCountObjBase *rc, T *ptr) noexcept; diff --git a/ucl/inc/ucl/util/memory/SharedRef.hpp b/ucl/inc/ucl/util/memory/SharedRef.hpp index d6b4ee6..5b5ad55 100644 --- a/ucl/inc/ucl/util/memory/SharedRef.hpp +++ b/ucl/inc/ucl/util/memory/SharedRef.hpp @@ -24,7 +24,7 @@ namespace ucl { } template <class T> - constexpr SharedRef<T>::SharedRef(nullptr_t) noexcept + constexpr SharedRef<T>::SharedRef(std::nullptr_t) noexcept { } diff --git a/ucl/inc/ucl/util/memory/WeakRef.h b/ucl/inc/ucl/util/memory/WeakRef.h index c8edef4..78450a5 100644 --- a/ucl/inc/ucl/util/memory/WeakRef.h +++ b/ucl/inc/ucl/util/memory/WeakRef.h @@ -34,7 +34,7 @@ namespace ucl { public: constexpr WeakRef() noexcept; - constexpr WeakRef(nullptr_t) noexcept; + constexpr WeakRef(std::nullptr_t) noexcept; WeakRef(RefCountObjBase *rc, T *ptr) noexcept; diff --git a/ucl/inc/ucl/util/memory/WeakRef.hpp b/ucl/inc/ucl/util/memory/WeakRef.hpp index 7508815..b1681ed 100644 --- a/ucl/inc/ucl/util/memory/WeakRef.hpp +++ b/ucl/inc/ucl/util/memory/WeakRef.hpp @@ -22,7 +22,7 @@ namespace ucl { } template <class T> - constexpr WeakRef<T>::WeakRef(nullptr_t) noexcept + constexpr WeakRef<T>::WeakRef(std::nullptr_t) noexcept { } diff --git a/ucl/inc/ucl/util/memory/helpers.h b/ucl/inc/ucl/util/memory/helpers.h index ad78591..4e6c0e0 100644 --- a/ucl/inc/ucl/util/memory/helpers.h +++ b/ucl/inc/ucl/util/memory/helpers.h @@ -87,28 +87,28 @@ namespace ucl { template <class T, class = typename std::enable_if< std::is_base_of<BaseRef<typename T::Type>, T>::value>::type> - inline bool operator==(const T &lhs, nullptr_t rhs) noexcept + inline bool operator==(const T &lhs, std::nullptr_t rhs) noexcept { return !lhs; } template <class T, class = typename std::enable_if< std::is_base_of<BaseRef<typename T::Type>, T>::value>::type> - bool operator==(nullptr_t lhs, const T &rhs) noexcept + bool operator==(std::nullptr_t lhs, const T &rhs) noexcept { return !rhs; } template <class T, class = typename std::enable_if< std::is_base_of<BaseRef<typename T::Type>, T>::value>::type> - bool operator!=(const T &lhs, nullptr_t rhs) noexcept + bool operator!=(const T &lhs, std::nullptr_t rhs) noexcept { return lhs; } template <class T, class = typename std::enable_if< std::is_base_of<BaseRef<typename T::Type>, T>::value>::type> - bool operator!=(nullptr_t lhs, const T &rhs) noexcept + bool operator!=(std::nullptr_t lhs, const T &rhs) noexcept { return rhs; } diff --git a/ucl/src/misc/Variant.cpp b/ucl/src/misc/Variant.cpp index 3859bc5..4509118 100644 --- a/ucl/src/misc/Variant.cpp +++ b/ucl/src/misc/Variant.cpp @@ -38,7 +38,7 @@ namespace ucl { } } - Variant::Variant(nullptr_t, const int arrayLength) : + Variant::Variant(std::nullptr_t, const int arrayLength) : m_type(static_cast<int>((arrayLength > 0) ? TYPE_ARRAY : TYPE_NIL)) { if (arrayLength > 0) { |