summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Nazarov <i.nazarov@samsung.com>2017-04-05 19:05:40 +0300
committerIgor Nazarov <i.nazarov@samsung.com>2017-04-05 19:47:11 +0300
commitdef076221c5ec77c5fd6060e4097d91bbf565e52 (patch)
treef5e41e2d5be651b1afce80bc27fd75217f42c92d
parent581e583758436c3c33498d16417b4bc371a37a11 (diff)
downloadgallery-def076221c5ec77c5fd6060e4097d91bbf565e52.tar.gz
gallery-def076221c5ec77c5fd6060e4097d91bbf565e52.tar.bz2
gallery-def076221c5ec77c5fd6060e4097d91bbf565e52.zip
TizenRefApp-8331 [Gallery] Integrate TouchParser and ViewerPage into
application - ImageGrid updated. Added support of double tap event using TouchParser; - TouchParser integrated into ViewerPage; - ViewerPage integrated with PreviewPage; - Minor UCL update. Change-Id: Ie9eb5f98f35f33e76917df72a6b2dd4d29717451
-rw-r--r--edc/button.edc23
-rw-r--r--edc/image-grid.edc9
-rw-r--r--inc/model/MediaItem.h2
-rw-r--r--inc/presentation/IImageGridListener.h2
-rw-r--r--inc/presentation/ImageGrid.h10
-rw-r--r--inc/presentation/PreviewPage.h6
-rw-r--r--inc/presentation/ThumbnailPage.h3
-rw-r--r--inc/presentation/ViewerPage.h9
-rw-r--r--src/model/MediaItem.cpp5
-rw-r--r--src/presentation/ImageGrid.cpp51
-rw-r--r--src/presentation/ImageViewer.cpp5
-rw-r--r--src/presentation/PreviewPage.cpp44
-rw-r--r--src/presentation/ThumbnailPage.cpp7
-rw-r--r--src/presentation/ViewerPage.cpp51
-rw-r--r--ucl/inc/ucl/gui/EdjeWidget.h3
-rw-r--r--ucl/inc/ucl/gui/WidgetItem.h3
16 files changed, 198 insertions, 35 deletions
diff --git a/edc/button.edc b/edc/button.edc
index 9d3f15c..75be9d6 100644
--- a/edc/button.edc
+++ b/edc/button.edc
@@ -153,6 +153,17 @@ group{ "elm/button/base/gallery_image";
color: GALLERY_COLOR_IMG_EF_DISABLED;
}
}
+ rect { "blocker";
+ norepeat;
+ desc { "default";
+ color: 0 0 0 0;
+ hid;
+ }
+ desc { "block";
+ inherit: "default";
+ vis;
+ }
+ }
}
programs {
program { "on_disabled";
@@ -179,5 +190,17 @@ group{ "elm/button/base/gallery_image";
action: STATE_SET "default";
target: "event";
}
+ program { "on_block_clicks";
+ signal: "gallery,block,clicks";
+ source: "";
+ action: STATE_SET "block";
+ target: "blocker";
+ }
+ program { "on_unblock_clicks";
+ signal: "gallery,unblock,clicks";
+ source: "";
+ action: STATE_SET "default";
+ target: "blocker";
+ }
}
}
diff --git a/edc/image-grid.edc b/edc/image-grid.edc
index f8e368b..751509e 100644
--- a/edc/image-grid.edc
+++ b/edc/image-grid.edc
@@ -167,14 +167,5 @@ group { "elm/layout/gallery_image_grid/linear";
rel2.to: "image_mask_0";
}
}
- rect { "blocker";
- norepeat;
- desc { "default";
- fixed: 1 1;
- color: 0 0 0 0;
- rel1.to: "image_mask_0";
- rel2.to: "image_mask_0";
- }
- }
}
}
diff --git a/inc/model/MediaItem.h b/inc/model/MediaItem.h
index 1c504a3..fb0310d 100644
--- a/inc/model/MediaItem.h
+++ b/inc/model/MediaItem.h
@@ -33,6 +33,8 @@ namespace gallery {
bool isValid() const;
MediaType getType() const;
+ const std::string &getId() const;
+
void getResolution(int &x, int &y) const;
const std::string &getFilePath() const;
diff --git a/inc/presentation/IImageGridListener.h b/inc/presentation/IImageGridListener.h
index abc1abf..dd77813 100644
--- a/inc/presentation/IImageGridListener.h
+++ b/inc/presentation/IImageGridListener.h
@@ -25,7 +25,7 @@ namespace gallery {
public:
virtual void onItemRealized(int itemIndex) = 0;
virtual void onItemUnrealized(int itemIndex) = 0;
- virtual void onItemClicked(int itemIndex) = 0;
+ virtual void onItemEvent(int itemIndex, int event, int x, int y) = 0;
};
}
diff --git a/inc/presentation/ImageGrid.h b/inc/presentation/ImageGrid.h
index f8373a1..dd0694d 100644
--- a/inc/presentation/ImageGrid.h
+++ b/inc/presentation/ImageGrid.h
@@ -32,6 +32,11 @@ namespace gallery {
LINEAR
};
+ enum ItemEvent {
+ ITEM_EVENT_CLICK,
+ ITEM_EVENT_DOUBLE_TAP
+ };
+
class Builder {
public:
Builder();
@@ -45,7 +50,8 @@ namespace gallery {
enum {
UF_LOSE_IMAGE = 1,
- UF_LOSE_BG = 2
+ UF_LOSE_BG = 2,
+ UF_BLOCK_CLICKS = 4
};
struct ItemParams {
@@ -106,7 +112,7 @@ namespace gallery {
void addUnrealizeLock();
void removeUnrealizeLock();
- void handleItemClick(int itemIndex) const;
+ void handleItemEvent(int itemIndex, int event, int x, int y) const;
// Initialization
void prepare();
diff --git a/inc/presentation/PreviewPage.h b/inc/presentation/PreviewPage.h
index 6c32acb..a2ea01e 100644
--- a/inc/presentation/PreviewPage.h
+++ b/inc/presentation/PreviewPage.h
@@ -56,6 +56,8 @@ namespace gallery {
bool onEachMedia(MediaItemSRef &&media);
+ void onPageExitRequest(Page &page);
+
// Page //
virtual void onActivate() final override;
@@ -65,7 +67,8 @@ namespace gallery {
virtual void onItemRealized(int itemIndex) final override;
virtual void onItemUnrealized(int itemIndex) final override;
- virtual void onItemClicked(int itemIndex) final override;
+ virtual void onItemEvent(int itemIndex,
+ int event, int x, int y) final override;
private:
class Item;
@@ -75,6 +78,7 @@ namespace gallery {
const IMediaAlbumSRef m_album;
ImageGridSRef m_imageGrid;
std::vector<ItemUPtr> m_items;
+ PageWRef m_page;
};
}
diff --git a/inc/presentation/ThumbnailPage.h b/inc/presentation/ThumbnailPage.h
index 13ec7a8..0b53f14 100644
--- a/inc/presentation/ThumbnailPage.h
+++ b/inc/presentation/ThumbnailPage.h
@@ -64,7 +64,8 @@ namespace gallery {
virtual void onItemRealized(int itemIndex) final override;
virtual void onItemUnrealized(int itemIndex) final override;
- virtual void onItemClicked(int itemIndex) final override;
+ virtual void onItemEvent(int itemIndex,
+ int event, int x, int y) final override;
private:
class RealizedItem;
diff --git a/inc/presentation/ViewerPage.h b/inc/presentation/ViewerPage.h
index fc4fcb7..3d298fb 100644
--- a/inc/presentation/ViewerPage.h
+++ b/inc/presentation/ViewerPage.h
@@ -31,16 +31,19 @@ namespace gallery {
~Builder();
Builder &setNaviframe(const ucl::NaviframeSRef &navi);
Builder &setMedia(const MediaItemSRef &media);
+ Builder &setZoomIn(int x, int y);
Builder &setExitOnZoomOut(bool value);
ViewerPageSRef build(ExitRequestHandler onExitRequest) const;
private:
ucl::NaviframeSRef m_navi;
MediaItemSRef m_media;
+ int m_zoomInX;
+ int m_zoomInY;
bool m_exitOnZoomOut;
};
public:
- void zoomIn(int originX, int originY);
+ const std::string &getMediaId() const;
private:
friend class ucl::RefCountObj<ViewerPage>;
@@ -51,8 +54,11 @@ namespace gallery {
ucl::Result prepare();
+ void zoomIn(int originX, int originY);
+
void onThumbnail(ucl::Result result, const std::string &path);
void onZoomEnd(ucl::Widget &widget, void *eventInfo);
+ void onDoubleTap(int x, int y);
// Page //
@@ -62,6 +68,7 @@ namespace gallery {
const MediaItemSRef m_media;
const bool m_exitOnZoomOut;
ImageViewerSRef m_imageViewer;
+ TouchParserSRef m_touchParser;
};
}
diff --git a/src/model/MediaItem.cpp b/src/model/MediaItem.cpp
index 5771b7d..c25d2c3 100644
--- a/src/model/MediaItem.cpp
+++ b/src/model/MediaItem.cpp
@@ -133,6 +133,11 @@ namespace gallery {
return m_type;
}
+ const std::string &MediaItem::getId() const
+ {
+ return m_mediaId;
+ }
+
void MediaItem::getResolution(int &x, int &y) const
{
x = m_resolutionX;
diff --git a/src/presentation/ImageGrid.cpp b/src/presentation/ImageGrid.cpp
index a998b5e..76aefa2 100644
--- a/src/presentation/ImageGrid.cpp
+++ b/src/presentation/ImageGrid.cpp
@@ -22,6 +22,7 @@
#include "ucl/gui/Layout.h"
#include "presentation/IImageGridListener.h"
+#include "presentation/TouchParser.h"
#include "common.h"
@@ -36,6 +37,8 @@ namespace gallery { namespace { namespace impl {
constexpr ElmStyle ITEM_BTN_STYLE {"gallery_image"};
constexpr EdjePart PART_BTN_BG {"swallow.bg"};
constexpr SmartEvent BTN_CLICKED {"clicked"};
+ constexpr EdjeSignal BTN_BLOCK_CLICKS {"gallery,block,clicks"};
+ constexpr EdjeSignal BTN_UNBLOCK_CLICKS {"gallery,unblock,clicks"};
// Other //
constexpr auto HCOMB_SCROLL_LIMIT = 1000;
@@ -200,7 +203,8 @@ namespace gallery {
m_image(elm_image_add(m_btn)),
m_realizeIndex(-1),
m_imageLoadSize(0),
- m_wasUpdated(false)
+ m_wasUpdated(false),
+ m_isClicksBlocked(false)
{
m_btn.setFocusAlowed(false);
m_btn.setStyle(impl::ITEM_BTN_STYLE);
@@ -214,6 +218,10 @@ namespace gallery {
m_btn.addEventHandler(impl::BTN_CLICKED, WEAK_DELEGATE(
Item::onClicked, asWeak(*this)));
+
+ m_touchParser = makeShared<TouchParser>(m_btn);
+ m_touchParser->setDoubleTapHandler(
+ DELEGATE(Item::onDoubleTap, this));
}
Widget &getWidget()
@@ -273,6 +281,7 @@ namespace gallery {
return false;
}
+ updateClicksBlock(params);
updateImage(params);
updateBgImage(params);
@@ -284,6 +293,19 @@ namespace gallery {
}
private:
+ void updateClicksBlock(const ItemParams &params)
+ {
+ if (params.flags & UF_BLOCK_CLICKS) {
+ if (!m_isClicksBlocked) {
+ m_isClicksBlocked = true;
+ m_btn.emitSignal(impl::BTN_BLOCK_CLICKS);
+ }
+ } else if (m_isClicksBlocked) {
+ m_isClicksBlocked = false;
+ m_btn.emitSignal(impl::BTN_UNBLOCK_CLICKS);
+ }
+ }
+
void updateImage(const ItemParams &params)
{
if (isEmpty(params.imagePath)) {
@@ -333,7 +355,16 @@ namespace gallery {
void onClicked(Widget &wifget, void *eventInfo)
{
if (isRealized()) {
- m_imageGrid.handleItemClick(m_realizeIndex);
+ m_imageGrid.handleItemEvent(m_realizeIndex,
+ ITEM_EVENT_CLICK, -1, -1);
+ }
+ }
+
+ void onDoubleTap(const int x, const int y)
+ {
+ if (isRealized()) {
+ m_imageGrid.handleItemEvent(m_realizeIndex,
+ ITEM_EVENT_DOUBLE_TAP, x, y);
}
}
@@ -342,9 +373,11 @@ namespace gallery {
StyledWidget m_btn;
StyledWidget m_image;
WidgetSRef m_bgImage;
+ TouchParserSRef m_touchParser;
int m_realizeIndex;
int m_imageLoadSize;
bool m_wasUpdated;
+ bool m_isClicksBlocked;
};
public:
@@ -566,8 +599,13 @@ namespace gallery {
"eext_circle_object_scroller_add() failed!");
}
- eext_circle_object_scroller_policy_set(m_circleScroller,
- ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
+ if (m_info.isHorizontal) {
+ eext_circle_object_scroller_policy_set(m_circleScroller,
+ ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
+ } else {
+ eext_circle_object_scroller_policy_set(m_circleScroller,
+ ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
+ }
}
void ImageGrid::setListener(IImageGridListener *const listener)
@@ -705,10 +743,11 @@ namespace gallery {
}
}
- void ImageGrid::handleItemClick(const int itemIndex) const
+ void ImageGrid::handleItemEvent(const int itemIndex, const int event,
+ const int x, const int y) const
{
if (m_listener) {
- m_listener->onItemClicked(itemIndex);
+ m_listener->onItemEvent(itemIndex, event, x, y);
}
}
diff --git a/src/presentation/ImageViewer.cpp b/src/presentation/ImageViewer.cpp
index a74f194..4fd2764 100644
--- a/src/presentation/ImageViewer.cpp
+++ b/src/presentation/ImageViewer.cpp
@@ -22,6 +22,7 @@ namespace gallery { namespace { namespace impl {
constexpr auto ANIMATION_START_TIMEOUT_SEC = (1.0 / 30.0);
constexpr auto ANIMATION_RUNTIME_SEC = (300.0 / 1000.0);
+ constexpr auto ANIMATION_STOP_POS = 0.999999;
}}}
namespace gallery {
@@ -110,6 +111,8 @@ namespace gallery {
elm_scroller_bounce_set(*m_scroller, EINA_TRUE, EINA_TRUE);
elm_scroller_policy_set(*m_scroller,
ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
+ elm_scroller_single_direction_set(*m_scroller,
+ ELM_SCROLLER_SINGLE_DIRECTION_NONE);
elm_object_scroll_freeze_push(*m_scroller);
show(*m_scroller);
@@ -342,7 +345,7 @@ namespace gallery {
updateGridSize();
updateScrollOffset();
- if (pos == 1.0) {
+ if (pos >= impl::ANIMATION_STOP_POS) {
m_animator = nullptr;
if (m_state == State::ZOOMING_IN) {
m_state = State::ZOOMED_IN;
diff --git a/src/presentation/PreviewPage.cpp b/src/presentation/PreviewPage.cpp
index bf70d87..1020226 100644
--- a/src/presentation/PreviewPage.cpp
+++ b/src/presentation/PreviewPage.cpp
@@ -20,6 +20,7 @@
#include "model/MediaItem.h"
#include "presentation/ImageGrid.h"
+#include "presentation/ViewerPage.h"
#include "common.h"
@@ -108,6 +109,11 @@ namespace gallery {
m_media->cancelThumbnailPathGet();
}
+ MediaItemSRef getMedia()
+ {
+ return m_media;
+ }
+
private:
void onThumbnail(const Result result, const std::string &path)
{
@@ -117,6 +123,7 @@ namespace gallery {
m_media->getResolution(params.aspectX, params.aspectY);
params.imagePath = m_media->getFilePath();
params.bgImagePath = path;
+ params.flags = ImageGrid::UF_BLOCK_CLICKS;
m_imageGrid.updateItem(m_index, params);
}
@@ -140,6 +147,9 @@ namespace gallery {
PreviewPage::~PreviewPage()
{
+ if (m_page) {
+ m_page->exitNoTransition();
+ }
m_imageGrid->setListener(nullptr);
}
@@ -154,6 +164,22 @@ namespace gallery {
"m_album->forEachMedia() failed!");
m_imageGrid->setItemCount(m_items.size());
+
+ const auto viewerPage = dynamicRefCast<ViewerPage>(m_page);
+ if (viewerPage) {
+ const auto mediaId = viewerPage->getMediaId();
+ const auto it = std::find_if(m_items.begin(), m_items.end(),
+ [&mediaId](const ItemUPtr &item)
+ {
+ return (item->getMedia()->getId() == mediaId);
+ });
+ if (it == m_items.end()) {
+ DLOG("Viewed media item was removed.");
+ deleteTo();
+ } else {
+ m_imageGrid->scrollToItem(it - m_items.begin());
+ }
+ }
}
Result PreviewPage::prepare()
@@ -214,8 +240,22 @@ namespace gallery {
m_items[itemIndex]->unrealize();
}
- void PreviewPage::onItemClicked(const int itemIndex)
+ void PreviewPage::onItemEvent(const int itemIndex,
+ const int event, const int x, const int y)
+ {
+ if (!isActive() || (event != ImageGrid::ITEM_EVENT_DOUBLE_TAP)) {
+ return;
+ }
+
+ m_page = ViewerPage::Builder().
+ setNaviframe(asShared(getNaviframe())).
+ setZoomIn(x, y).
+ setMedia(m_items[itemIndex]->getMedia()).
+ build(DELEGATE(PreviewPage::onPageExitRequest, this));
+ }
+
+ void PreviewPage::onPageExitRequest(Page &page)
{
- ILOG("TODO Not implemented. Item: %d;", itemIndex);
+ deleteTo();
}
}
diff --git a/src/presentation/ThumbnailPage.cpp b/src/presentation/ThumbnailPage.cpp
index 6ce0344..2628d98 100644
--- a/src/presentation/ThumbnailPage.cpp
+++ b/src/presentation/ThumbnailPage.cpp
@@ -211,8 +211,13 @@ namespace gallery {
}
}
- void ThumbnailPage::onItemClicked(const int itemIndex)
+ void ThumbnailPage::onItemEvent(const int itemIndex,
+ const int event, const int x, const int y)
{
+ if (!isActive() || (event != ImageGrid::ITEM_EVENT_CLICK)) {
+ return;
+ }
+
m_page = PreviewPage::Builder().
setNaviframe(asShared(getNaviframe())).
setAlbum(m_album).
diff --git a/src/presentation/ViewerPage.cpp b/src/presentation/ViewerPage.cpp
index 99e75e0..60ad7c2 100644
--- a/src/presentation/ViewerPage.cpp
+++ b/src/presentation/ViewerPage.cpp
@@ -19,6 +19,7 @@
#include "model/MediaItem.h"
#include "presentation/ImageViewer.h"
+#include "presentation/TouchParser.h"
#include "common.h"
@@ -29,6 +30,8 @@ namespace gallery {
// ViewerPage::Builder //
ViewerPage::Builder::Builder() :
+ m_zoomInX(-1),
+ m_zoomInY(-1),
m_exitOnZoomOut(true)
{
}
@@ -51,6 +54,14 @@ namespace gallery {
return *this;
}
+ ViewerPage::Builder &ViewerPage::Builder::setZoomIn(
+ const int x, const int y)
+ {
+ m_zoomInX = x;
+ m_zoomInY = y;
+ return *this;
+ }
+
ViewerPage::Builder &ViewerPage::Builder::setExitOnZoomOut(const bool value)
{
m_exitOnZoomOut = value;
@@ -76,6 +87,10 @@ namespace gallery {
FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+ if ((m_zoomInX >= 0) && (m_zoomInY >= 0)) {
+ result->zoomIn(m_zoomInX, m_zoomInY);
+ }
+
return result;
}
@@ -96,11 +111,6 @@ namespace gallery {
{
}
- void ViewerPage::zoomIn(const int originX, const int originY)
- {
- m_imageViewer->zoomIn(originX, originY);
- }
-
Result ViewerPage::prepare()
{
int mediaW = 0;
@@ -135,9 +145,23 @@ namespace gallery {
}),
"Page::prepare() failed!");
+ m_touchParser = makeShared<TouchParser>(*m_imageViewer);
+ m_touchParser->setDoubleTapHandler(
+ DELEGATE(ViewerPage::onDoubleTap, this));
+
return RES_OK;
}
+ void ViewerPage::zoomIn(const int originX, const int originY)
+ {
+ m_imageViewer->zoomIn(originX, originY);
+ }
+
+ const std::string &ViewerPage::getMediaId() const
+ {
+ return m_media->getId();
+ }
+
void ViewerPage::onThumbnail(const Result result, const std::string &path)
{
FAIL_RETURN_VOID(result, "Failed to get thumbnail!");
@@ -152,13 +176,24 @@ namespace gallery {
}
}
+ void ViewerPage::onDoubleTap(int x, int y)
+ {
+ if (!isActive()) {
+ return;
+ }
+ if (m_imageViewer->isZoomedOut()) {
+ m_imageViewer->zoomIn(x, y);
+ } else if (m_imageViewer->isZoomedIn()) {
+ m_imageViewer->zoomOut();
+ }
+ }
+
void ViewerPage::onBackKey()
{
if (m_imageViewer->isZoomedOut()) {
requestExit();
- return;
+ } else if (m_imageViewer->isZoomedIn()) {
+ m_imageViewer->zoomOut();
}
-
- m_imageViewer->zoomOut();
}
}
diff --git a/ucl/inc/ucl/gui/EdjeWidget.h b/ucl/inc/ucl/gui/EdjeWidget.h
index 5700187..ee3313d 100644
--- a/ucl/inc/ucl/gui/EdjeWidget.h
+++ b/ucl/inc/ucl/gui/EdjeWidget.h
@@ -39,7 +39,8 @@ namespace ucl {
Evas_Object *getContent() const;
Evas_Object *getContent(EdjePart part) const;
- void emitSignal(EdjeSignal signal, EdjeSignalSrc source);
+ void emitSignal(EdjeSignal signal, EdjeSignalSrc source =
+ EdjeSignalSrc(""));
protected:
EdjeWidget(RefCountObjBase *rc, Evas_Object *eo, bool isOwner = false);
diff --git a/ucl/inc/ucl/gui/WidgetItem.h b/ucl/inc/ucl/gui/WidgetItem.h
index db76965..daef146 100644
--- a/ucl/inc/ucl/gui/WidgetItem.h
+++ b/ucl/inc/ucl/gui/WidgetItem.h
@@ -57,7 +57,8 @@ namespace ucl {
Evas_Object *getContent() const;
Evas_Object *getContent(EdjePart part) const;
- void emitSignal(EdjeSignal signal, EdjeSignalSrc source) const;
+ void emitSignal(EdjeSignal signal,EdjeSignalSrc source =
+ EdjeSignalSrc("")) const;
private:
Elm_Object_Item *m_it;