Merge "fixed bug (TapGesture improvement)" into tizen_2.1
[platform/framework/native/uifw.git] / src / ui / inc / FUiCtrl_GalleryPresenter.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0/
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_PRESENTER_H
18 #define _FUI_CTRL_INTERNAL_GALLERY_PRESENTER_H
19
20 #include <FBaseString.h>
21 #include <FBaseRtITimerEventListener.h>
22 #include <FGrpFontCommon.h>
23 #include <FUiCtrlGalleryTypes.h>
24 #include "FUi_PropertyBase.h"
25 #include "FUiCtrl_GalleryTypes.h"
26 #include "FUiCtrl_IGalleryRendererNotiListener.h"
27
28 namespace Tizen { namespace Base { namespace Runtime {
29
30 class Timer;
31
32 }}} // Tizen::Base::RunTime
33
34 namespace Tizen { namespace Ui { namespace Controls {
35
36 const int MAX_CANVAS_COUNT = 4;
37 const int NOT_EXIST_CANVAS = -1;
38 const int NOT_USED_CANVAS = -1;
39 const int NO_CURRENT_IMAGE = -1;
40
41 class _GalleryViewEvent;
42 class _GalleryBitmap;
43 class _IGalleryRenderer;
44 class _IGalleryCoreEventListener;
45 class _GalleryViewEventHandler;
46 class _GalleryModel;
47 class _GalleryImageReader;
48 class _GalleryCoreEvent;
49 class _GalleryItemProvider;
50 class _GalleryBitmap;
51 class _GalleryItemProviderAdaptorImpl;
52 class _Gallery;
53
54 class _GalleryPresenter
55         : public Tizen::Ui::_PropertyBase
56         , public _IGalleryRendererNotiListener
57         , public Tizen::Ui::_IPropertyChangeEventListener
58         , public Tizen::Base::Runtime::ITimerEventListener
59         , virtual public Tizen::Base::Runtime::IEventListener
60 {
61 // Declare Properties
62         DECLARE_CLASS_BEGIN(_GalleryPresenter, _PropertyBase);
63         DECLARE_PROPERTY("slideShowViewDuration", GetPropertySlideShowViewDuration, SetPropertySlideShowViewDuration);
64         DECLARE_PROPERTY("slideShowAnimationDuration", GetPropertySlideShowAnimationDuration, SetPropertySlideShowAnimationDuration);
65         DECLARE_PROPERTY("textOfEmptyGallery", GetPropertyTextOfEmptyGallery, SetPropertyTextOfEmptyGallery);
66         DECLARE_PROPERTY("zoomingEnabled", GetPropertyZoomingEnabled, SetPropertyZoomingEnabled);
67         DECLARE_CLASS_END();
68
69 public:
70         virtual ~_GalleryPresenter(void);
71
72         static _GalleryPresenter* CreateGalleryPresenterN(_IGalleryRenderer& galleryRenderer,
73                         _GalleryItemProviderAdaptorImpl* pGalleryItemProviderAdaptor, _Gallery* pGalleryView);
74
75         int GetCurrentItemIndex(void) const;
76         result SetCurrentItemIndex(int index, bool eventFire = true);
77         result SetCurrentItem(int index);
78
79         int GetItemCount(void) const;
80
81         void SetItemSpacing(int spacing);
82         int GetItemSpacing(void) const;
83
84         _GallerySlideShowType GetSlideShowType(void) const;
85         result SetSlideShowType(_GallerySlideShowType slideShowType);
86
87         int GetSlideShowAnimationDuration(void) const;
88         result SetSlideShowAnimationDuration(int duration);
89
90         int GetSlideShowViewDuration(void) const;
91         result SetSlideShowViewDuration(int duration);
92
93         result StartSlideShow(bool repeat = false);
94         result StopSlideShow(void);
95         bool IsSlideShowStarted(void) const;
96
97         Tizen::Base::String GetTextOfEmptyGallery(void) const;
98         result SetTextOfEmptyGallery(const Tizen::Base::String& text);
99         result SetBitmapOfEmptyGallery(const _GalleryBitmap* pBitmap);
100
101         result SetZoomingEnabled(bool enable);
102         bool IsZoomingEnabled(void) const;
103
104         bool PostEvent(_GalleryViewEvent& event);
105         bool OnBoundsChanged(void);
106         void OnDraw(void);
107
108         result SetCoreEventListener(const _IGalleryCoreEventListener& coreEventListener);
109         result RemoveCoreEventListener(const _IGalleryCoreEventListener& coreEventListener);
110
111         bool ClickedItem(void);
112         bool ChangedItem(void);
113
114         int SearchCanvasIndex(int itemIndex);
115
116         // model access
117         result RequestToLoadItem(int index);
118         result RequestToUnloadItem(int index);
119         result RequestToUnloadAllItems(void);
120         result RequestToUpdateItem(int index);
121         result RequestToUpdateAllItems(void);
122         result RequestToUpdateItemCount(void);
123
124         // timer
125         virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
126
127         // renderer noti listener
128         virtual void OnTransitionCancel(void);
129         virtual void OnTransitionCompleted(void);
130         virtual void OnCanvasAnimationCancel(void);
131         virtual void OnCanvasAnimationCompleted(void);
132         virtual void OnCanvasAnimationStarted(void);
133
134         // data binding event listener
135         virtual void OnPropertyChanging(Tizen::Ui::_PropertyBase& source, const Tizen::Base::String& name, const Variant& oldProperty, const Variant& newProperty);
136         virtual void OnPropertyChanged(Tizen::Ui::_PropertyBase& source, const Tizen::Base::String& name, const Variant& oldProperty, const Variant& newProperty);
137
138         // font function
139         void SetFontSize(int size);
140         int GetFontSize(void) const;
141         void SetFontStyle(Tizen::Graphics::FontStyle style);
142         Tizen::Graphics::FontStyle GetFontStyle(void) const;
143         void OnFontChanged(void);
144
145         virtual void OnFontInfoRequested(unsigned long& style, int& size);
146
147         void UpdateEmptyString(void);
148
149 protected:
150         _GalleryPresenter(_IGalleryRenderer& galleryRenderer);
151         result Construct(_GalleryItemProviderAdaptorImpl* pGalleryItemProviderAdaptor, _Gallery* pGalleryView);
152
153         // property getter/setter
154         Variant GetPropertySlideShowViewDuration(void) const;
155         result SetPropertySlideShowViewDuration(const Variant& variant);
156         Variant GetPropertySlideShowAnimationDuration(void) const;
157         result SetPropertySlideShowAnimationDuration(const Variant& variant);
158         Variant GetPropertyTextOfEmptyGallery(void) const;
159         result SetPropertyTextOfEmptyGallery(const Variant& variant);
160         Variant GetPropertyZoomingEnabled(void) const;
161         result SetPropertyZoomingEnabled(const Variant& variant);
162
163 private:
164         _GalleryPresenter(const _GalleryPresenter& rhs);
165         _GalleryPresenter& operator=(const _GalleryPresenter& rhs);
166
167         result SetCanvasImage(int itemIndex);
168         result SetPartialCanvasImage(void);
169         int GetEmptyCanvasIndex(void) const;
170         result SetCanvasIndex(int canvasIndex, int itemIndex);
171         int ClearCanvasIndex(int currentItemIndex);
172         void SortItemToCanvasIndex(int itemIndex, bool add);
173
174         result StartSlideShowTimer(int duration);
175         void StopSlideShowTimer(void);
176         result PlaySlideShow(void);
177
178 private:
179         _IGalleryRenderer& __galleryRenderer;
180         _GalleryViewEventHandler* __pGalleryViewEventHandler;
181         _GalleryCoreEvent* __pGalleryCoreEvent;
182         _GalleryItemProvider* __pGalleryItemProvider;
183         _GalleryModel* __pGalleryModel;
184         _GalleryImageReader* __pGalleryImageReader;
185
186         //_GalleryBitmap* __pPartialImage;
187         _GalleryBitmap* __pEmptyGalleryImage;
188         Tizen::Base::String __emptyText;
189         int __slideShowAnimationDuration;
190         int __slideShowViewDuration;
191         _GallerySlideShowType __gallerySlideShowType;
192         int __currentItemIndex;
193         bool __slideShowRepeat;
194         bool __slideShowStarted;
195         bool __zoomingEnabled;
196         Tizen::Base::Runtime::Timer* __pSlideShowTimer;
197         int __slideShowPlayCount;
198         int __itemSpacing;
199         int* __pItemToCanvas;
200         _GalleryFittingType __fittingType;
201         _GalleryVerticalAlignment __verticalAlignment;
202         _GalleryHorizontalAlignment __horizontalAlignment;
203
204         int __emptyFontSize;
205         Tizen::Graphics::FontStyle __emptyFontStyle;
206         bool __userSetEmptyText;
207
208         _Gallery* __pGalleryView;
209
210 friend class _GalleryViewEventHandler;
211 }; // _GalleryPresenter
212
213 }}} // Tizen::Ui::Controls
214
215 #endif //_FUI_CTRL_INTERNAL_GALLERY_PRESENTER_H