Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / inc / FUiCtrl_GalleryViewEventHandler.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 #ifndef _FUI_CTRL_INTERNAL_GALLERY_VIEW_EVENT_HANDLER_H_
18 #define _FUI_CTRL_INTERNAL_GALLERY_VIEW_EVENT_HANDLER_H_
19
20 #include <FBaseObject.h>
21 #include <FGrpPoint.h>
22 #include "FUiCtrl_GalleryTypes.h"
23 #include "FUiCtrl_IGalleryRendererNotiListener.h"
24
25 namespace Tizen { namespace Graphics {
26
27 class Dimension;
28
29 }} // Tizen::Graphics
30
31 namespace Tizen { namespace Ui { namespace Controls {
32
33 enum FlickDirection
34 {
35         FLICK_DIRECTION_NONE = 0,
36         FLICK_DIRECTION_LEFT,
37         FLICK_DIRECTION_RIGHT
38 };
39
40 class _GalleryImageReader;
41 class _GalleryModel;
42 class _GalleryPresenter;
43 class _GalleryViewEventInfo;
44 class _IGalleryRenderer;
45
46 class _GalleryViewEventHandler
47         : public Tizen::Base::Object
48         , public _IGalleryRendererNotiListener
49         , virtual public Tizen::Base::Runtime::IEventListener
50 {
51 public:
52         _GalleryViewEventHandler(_GalleryPresenter& galleryPresenter, _IGalleryRenderer& galleryRenderer, _GalleryImageReader& galleryModel);
53         virtual ~_GalleryViewEventHandler(void);
54
55         result Construct(void);
56
57         bool OnTouchPressed(_GalleryViewEventInfo& eventInfo);
58         bool OnTouchDoublePressed(_GalleryViewEventInfo& eventInfo);
59         bool OnTouchReleased(_GalleryViewEventInfo& eventInfo);
60         bool OnTouchPinchZoom(_GalleryViewEventInfo& eventInfo);
61         bool OnTouchMoved(_GalleryViewEventInfo& eventInfo);
62         bool OnTouchFlicked(_GalleryViewEventInfo& eventInfo);
63
64         //notiListener
65         virtual void OnTransitionCancel(void);
66         virtual void OnTransitionCompleted(void);
67         virtual void OnCanvasAnimationCancel(void);
68         virtual void OnCanvasAnimationCompleted(void);
69         virtual void OnCanvasAnimationStarted(void);
70
71         void SetZoomFlag(bool zoomMode);
72         bool IsZoomFlag(void) const;
73         result SetVisibleCanvas(void);
74         result AlignCanvas(bool animation = true);
75         bool CorrectCanvasPosition(Tizen::Graphics::Rectangle& canvasBounds, const Tizen::Graphics::Rectangle& imageBounds);
76
77 private:
78         _GalleryViewEventHandler(const _GalleryViewEventHandler& rhs);
79         _GalleryViewEventHandler& operator=(const _GalleryViewEventHandler& rhs);
80
81         result RefreshView(void);
82
83         result SetInvisibleCanvas(void);
84
85         result FlickToTheRight(void);
86         result FlickToTheLeft(void);
87
88         result ZoomCanvas(int distance, const Tizen::Graphics::Point& center, bool zoomIn, _GalleryAnimationTiming* pAnimation = null);
89         result PinchZoomCanvas(int area, const Tizen::Graphics::Point& center, bool zoomIn);
90         result MoveCanvas(const Tizen::Graphics::Dimension& distance, _GalleryAnimationTiming* pAnimation = null);
91
92         void SetRollbackCanvas(void);
93         int CalculateRound(float value);
94         result SetCurrentItemIndex(int index);
95         result CallChangeItemIndex(void);
96
97 private:
98         _GalleryPresenter& __galleryPresenter;
99         _IGalleryRenderer& __galleryRenderer;
100         _GalleryImageReader& __galleryImageReader;
101         Tizen::Graphics::Point __previousPosition;
102         Tizen::Graphics::Point __startPinchCenterPosition;
103         FlickDirection __flickingDirection;
104         int __pinchInitialArea;
105         bool __pressed;
106         bool __moving;
107         bool __zoomMode;
108         bool __zoomAnimationComplete;
109         bool __pinchMode;
110         unsigned long __touchPointId;
111         int __currentItemIndex;
112 }; // _GalleryViewEventHandler
113
114 }}} // Tizen::Ui::Controls
115
116 #endif // _FUI_CTRL_INTERNAL_GALLERY_VIEW_EVENT_HANDLER_H_