- ViewerPage was renamed to PreviewPage.
Change-Id: Ia2e61a072ba54f0ecab0742309c43d2db5399f07
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __GALLERY_PRESENTATION_PREVIEW_PAGE_H__
+#define __GALLERY_PRESENTATION_PREVIEW_PAGE_H__
+
+#include "Page.h"
+
+#include "IImageGridListener.h"
+
+#include "model/types.h"
+
+namespace gallery {
+
+ class PreviewPage final : public Page,
+ private IImageGridListener {
+ public:
+ class Builder {
+ public:
+ Builder();
+ ~Builder();
+ Builder &setNaviframe(const ucl::NaviframeSRef &navi);
+ Builder &setAlbum(const IMediaAlbumSRef &album);
+ Builder &setStartItemIndex(int index);
+ PreviewPageSRef build(ExitRequestHandler onExitRequest) const;
+ private:
+ ucl::NaviframeSRef m_navi;
+ IMediaAlbumSRef m_album;
+ int m_startItemIndex;
+ };
+
+ public:
+ void reload();
+
+ private:
+ friend class ucl::RefCountObj<PreviewPage>;
+ PreviewPage(ucl::RefCountObjBase &rc, const ucl::NaviframeSRef &navi,
+ ExitRequestHandler onExitRequest, const IMediaAlbumSRef &album);
+ virtual ~PreviewPage();
+
+ ucl::Result prepare();
+ void showItem(int itemIndex);
+
+ bool onEachMedia(MediaItemUPtr &&media);
+
+ // Page //
+
+ virtual void onActivate() final override;
+ virtual void onDeactivate() final override;
+
+ // IImageGridListener //
+
+ virtual void onItemRealized(int itemIndex) final override;
+ virtual void onItemUnrealized(int itemIndex) final override;
+ virtual void onItemClicked(int itemIndex) final override;
+
+ private:
+ class Item;
+ using ItemUPtr = std::unique_ptr<Item>;
+
+ private:
+ const IMediaAlbumSRef m_album;
+ ImageGridSRef m_imageGrid;
+ std::vector<ItemUPtr> m_items;
+ };
+}
+
+#endif // __GALLERY_PRESENTATION_PREVIEW_PAGE_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_PRESENTATION_VIEWER_PAGE_H__
-#define __GALLERY_PRESENTATION_VIEWER_PAGE_H__
-
-#include "Page.h"
-
-#include "IImageGridListener.h"
-
-#include "model/types.h"
-
-namespace gallery {
-
- class ViewerPage final : public Page,
- private IImageGridListener {
- public:
- class Builder {
- public:
- Builder();
- ~Builder();
- Builder &setNaviframe(const ucl::NaviframeSRef &navi);
- Builder &setAlbum(const IMediaAlbumSRef &album);
- Builder &setStartItemIndex(int index);
- ViewerPageSRef build(ExitRequestHandler onExitRequest) const;
- private:
- ucl::NaviframeSRef m_navi;
- IMediaAlbumSRef m_album;
- int m_startItemIndex;
- };
-
- public:
- void reload();
-
- private:
- friend class ucl::RefCountObj<ViewerPage>;
- ViewerPage(ucl::RefCountObjBase &rc, const ucl::NaviframeSRef &navi,
- ExitRequestHandler onExitRequest, const IMediaAlbumSRef &album);
- virtual ~ViewerPage();
-
- ucl::Result prepare();
- void showItem(int itemIndex);
-
- bool onEachMedia(MediaItemUPtr &&media);
-
- // Page //
-
- virtual void onActivate() final override;
- virtual void onDeactivate() final override;
-
- // IImageGridListener //
-
- virtual void onItemRealized(int itemIndex) final override;
- virtual void onItemUnrealized(int itemIndex) final override;
- virtual void onItemClicked(int itemIndex) final override;
-
- private:
- class Item;
- using ItemUPtr = std::unique_ptr<Item>;
-
- private:
- const IMediaAlbumSRef m_album;
- ImageGridSRef m_imageGrid;
- std::vector<ItemUPtr> m_items;
- };
-}
-
-#endif // __GALLERY_PRESENTATION_VIEWER_PAGE_H__
UCL_DECLARE_REF_ALIASES(Page);
UCL_DECLARE_REF_ALIASES(ThumbnailPage);
- UCL_DECLARE_REF_ALIASES(ViewerPage);
+ UCL_DECLARE_REF_ALIASES(PreviewPage);
UCL_DECLARE_REF_ALIASES(NoContentPage);
}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "presentation/PreviewPage.h"
+
+#include "model/IMediaAlbum.h"
+#include "model/MediaItem.h"
+
+#include "presentation/ImageGrid.h"
+
+#include "common.h"
+
+namespace gallery {
+
+ using namespace ucl;
+
+ // PreviewPage::Builder //
+
+ PreviewPage::Builder::Builder() :
+ m_startItemIndex(0)
+ {
+ }
+
+ PreviewPage::Builder::~Builder()
+ {
+ }
+
+ PreviewPage::Builder &PreviewPage::Builder::setNaviframe(
+ const NaviframeSRef &navi)
+ {
+ m_navi = navi;
+ return *this;
+ }
+
+ PreviewPage::Builder &PreviewPage::Builder::setAlbum(
+ const IMediaAlbumSRef &album)
+ {
+ m_album = album;
+ return *this;
+ }
+
+ PreviewPage::Builder &PreviewPage::Builder::setStartItemIndex(
+ const int index)
+ {
+ m_startItemIndex = index;
+ return *this;
+ }
+
+ PreviewPageSRef PreviewPage::Builder::build(
+ const ExitRequestHandler onExitRequest) const
+ {
+ if (!onExitRequest) {
+ LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
+ "onExitRequest is NULL");
+ }
+ if (!m_navi) {
+ LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_navi is NULL");
+ }
+ if (!m_album) {
+ LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_album is NULL");
+ }
+
+ auto result = makeShared<PreviewPage>(
+ m_navi, onExitRequest, m_album);
+
+ FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+
+ if (m_startItemIndex > 0) {
+ result->showItem(m_startItemIndex);
+ }
+
+ return result;
+ }
+
+ // PreviewPage::Item //
+
+ class PreviewPage::Item : public NonCopyable {
+ public:
+ Item(MediaItemUPtr &&media, ImageGrid &imageGrid, const int itemIndex) :
+ m_media(std::move(media)),
+ m_imageGrid(imageGrid),
+ m_index(itemIndex)
+ {
+ }
+
+ void realize()
+ {
+ FAIL_LOG(m_media->getThumbnailPath(
+ DELEGATE(Item::onThumbnail, this)),
+ "getThumbnailPath() failed!");
+ }
+
+ void unrealize()
+ {
+ m_media->cancelThumbnailPathGet();
+ }
+
+ private:
+ void onThumbnail(const Result result, const std::string &path)
+ {
+ FAIL_LOG(result, "Failed to get thumbnail!");
+
+ ImageGrid::ItemParams params = {};
+ m_media->getResolution(params.aspectX, params.aspectY);
+ params.imagePath = m_media->getFilePath();
+ params.bgImagePath = path;
+
+ m_imageGrid.updateItem(m_index, params);
+ }
+
+ private:
+ const MediaItemUPtr m_media;
+ ImageGrid &m_imageGrid;
+ const int m_index;
+ };
+
+ // PreviewPage //
+
+ PreviewPage::PreviewPage(RefCountObjBase &rc,
+ const NaviframeSRef &navi,
+ const ExitRequestHandler onExitRequest,
+ const IMediaAlbumSRef &album) :
+ Page(rc, navi, onExitRequest),
+ m_album(album)
+ {
+ }
+
+ PreviewPage::~PreviewPage()
+ {
+ m_imageGrid->setListener(nullptr);
+ }
+
+ void PreviewPage::reload()
+ {
+ ImageGrid::Unrealizer u(*m_imageGrid);
+
+ m_items.clear();
+
+ FAIL_LOG(m_album->forEachMedia(
+ DELEGATE(PreviewPage::onEachMedia, this)),
+ "m_album->forEachMedia() failed!");
+
+ m_imageGrid->setItemCount(m_items.size());
+ }
+
+ Result PreviewPage::prepare()
+ {
+ m_imageGrid = ImageGrid::Builder().
+ setListener(this).
+ setType(ImageGrid::Type::LINEAR).
+ build(getNaviframe());
+ if (!m_imageGrid) {
+ LOG_RETURN(RES_FAIL, "ImageGrid::build() failed!");
+ }
+
+ FAIL_RETURN(m_album->forEachMedia(
+ DELEGATE(PreviewPage::onEachMedia, this)),
+ "m_album->forEachMedia() failed!");
+
+ FAIL_RETURN(Page::prepare(
+ [this]()
+ {
+ return getNaviframe().push(*m_imageGrid);
+ }),
+ "Page::prepare() failed!");
+
+ m_imageGrid->setItemCount(m_items.size());
+
+ return RES_OK;
+ }
+
+ void PreviewPage::showItem(const int itemIndex)
+ {
+ m_imageGrid->scrollToItem(itemIndex);
+ }
+
+ bool PreviewPage::onEachMedia(MediaItemUPtr &&media)
+ {
+ m_items.emplace_back(
+ new Item(std::move(media), *m_imageGrid, m_items.size()));
+ return true;
+ }
+
+ void PreviewPage::onActivate()
+ {
+ m_imageGrid->activateRotary();
+ }
+
+ void PreviewPage::onDeactivate()
+ {
+ m_imageGrid->deactivateRotary();
+ }
+
+ void PreviewPage::onItemRealized(const int itemIndex)
+ {
+ m_items[itemIndex]->realize();
+ }
+
+ void PreviewPage::onItemUnrealized(const int itemIndex)
+ {
+ m_items[itemIndex]->unrealize();
+ }
+
+ void PreviewPage::onItemClicked(const int itemIndex)
+ {
+ ILOG("TODO Not implemented. Item: %d;", itemIndex);
+ }
+}
#include "model/MediaItem.h"
#include "presentation/ImageGrid.h"
-#include "presentation/ViewerPage.h"
+#include "presentation/PreviewPage.h"
#include "common.h"
m_imageGrid->setItemCount(m_mediaItems.size());
- if (const auto vp = dynamic_cast<ViewerPage *>(m_page.get())) {
+ if (const auto vp = dynamic_cast<PreviewPage *>(m_page.get())) {
vp->reload();
}
}
void ThumbnailPage::onItemClicked(const int itemIndex)
{
- m_page = ViewerPage::Builder().
+ m_page = PreviewPage::Builder().
setNaviframe(asShared(getNaviframe())).
setAlbum(m_album).
setStartItemIndex(itemIndex).
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "presentation/ViewerPage.h"
-
-#include "model/IMediaAlbum.h"
-#include "model/MediaItem.h"
-
-#include "presentation/ImageGrid.h"
-
-#include "common.h"
-
-namespace gallery {
-
- using namespace ucl;
-
- // ViewerPage::Builder //
-
- ViewerPage::Builder::Builder() :
- m_startItemIndex(0)
- {
- }
-
- ViewerPage::Builder::~Builder()
- {
- }
-
- ViewerPage::Builder &ViewerPage::Builder::setNaviframe(
- const NaviframeSRef &navi)
- {
- m_navi = navi;
- return *this;
- }
-
- ViewerPage::Builder &ViewerPage::Builder::setAlbum(
- const IMediaAlbumSRef &album)
- {
- m_album = album;
- return *this;
- }
-
- ViewerPage::Builder &ViewerPage::Builder::setStartItemIndex(
- const int index)
- {
- m_startItemIndex = index;
- return *this;
- }
-
- ViewerPageSRef ViewerPage::Builder::build(
- const ExitRequestHandler onExitRequest) const
- {
- if (!onExitRequest) {
- LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
- "onExitRequest is NULL");
- }
- if (!m_navi) {
- LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_navi is NULL");
- }
- if (!m_album) {
- LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_album is NULL");
- }
-
- auto result = makeShared<ViewerPage>(
- m_navi, onExitRequest, m_album);
-
- FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
-
- if (m_startItemIndex > 0) {
- result->showItem(m_startItemIndex);
- }
-
- return result;
- }
-
- // ViewerPage::Item //
-
- class ViewerPage::Item : public NonCopyable {
- public:
- Item(MediaItemUPtr &&media, ImageGrid &imageGrid, const int itemIndex) :
- m_media(std::move(media)),
- m_imageGrid(imageGrid),
- m_index(itemIndex)
- {
- }
-
- void realize()
- {
- FAIL_LOG(m_media->getThumbnailPath(
- DELEGATE(Item::onThumbnail, this)),
- "getThumbnailPath() failed!");
- }
-
- void unrealize()
- {
- m_media->cancelThumbnailPathGet();
- }
-
- private:
- void onThumbnail(const Result result, const std::string &path)
- {
- FAIL_LOG(result, "Failed to get thumbnail!");
-
- ImageGrid::ItemParams params = {};
- m_media->getResolution(params.aspectX, params.aspectY);
- params.imagePath = m_media->getFilePath();
- params.bgImagePath = path;
-
- m_imageGrid.updateItem(m_index, params);
- }
-
- private:
- const MediaItemUPtr m_media;
- ImageGrid &m_imageGrid;
- const int m_index;
- };
-
- // ViewerPage //
-
- ViewerPage::ViewerPage(RefCountObjBase &rc,
- const NaviframeSRef &navi,
- const ExitRequestHandler onExitRequest,
- const IMediaAlbumSRef &album) :
- Page(rc, navi, onExitRequest),
- m_album(album)
- {
- }
-
- ViewerPage::~ViewerPage()
- {
- m_imageGrid->setListener(nullptr);
- }
-
- void ViewerPage::reload()
- {
- ImageGrid::Unrealizer u(*m_imageGrid);
-
- m_items.clear();
-
- FAIL_LOG(m_album->forEachMedia(
- DELEGATE(ViewerPage::onEachMedia, this)),
- "m_album->forEachMedia() failed!");
-
- m_imageGrid->setItemCount(m_items.size());
- }
-
- Result ViewerPage::prepare()
- {
- m_imageGrid = ImageGrid::Builder().
- setListener(this).
- setType(ImageGrid::Type::LINEAR).
- build(getNaviframe());
- if (!m_imageGrid) {
- LOG_RETURN(RES_FAIL, "ImageGrid::build() failed!");
- }
-
- FAIL_RETURN(m_album->forEachMedia(
- DELEGATE(ViewerPage::onEachMedia, this)),
- "m_album->forEachMedia() failed!");
-
- FAIL_RETURN(Page::prepare(
- [this]()
- {
- return getNaviframe().push(*m_imageGrid);
- }),
- "Page::prepare() failed!");
-
- m_imageGrid->setItemCount(m_items.size());
-
- return RES_OK;
- }
-
- void ViewerPage::showItem(const int itemIndex)
- {
- m_imageGrid->scrollToItem(itemIndex);
- }
-
- bool ViewerPage::onEachMedia(MediaItemUPtr &&media)
- {
- m_items.emplace_back(
- new Item(std::move(media), *m_imageGrid, m_items.size()));
- return true;
- }
-
- void ViewerPage::onActivate()
- {
- m_imageGrid->activateRotary();
- }
-
- void ViewerPage::onDeactivate()
- {
- m_imageGrid->deactivateRotary();
- }
-
- void ViewerPage::onItemRealized(const int itemIndex)
- {
- m_items[itemIndex]->realize();
- }
-
- void ViewerPage::onItemUnrealized(const int itemIndex)
- {
- m_items[itemIndex]->unrealize();
- }
-
- void ViewerPage::onItemClicked(const int itemIndex)
- {
- ILOG("TODO Not implemented. Item: %d;", itemIndex);
- }
-}