2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0/
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.
17 #ifndef _FUI_CTRL_INTERNAL_GALLERY_PRESENTER_H
18 #define _FUI_CTRL_INTERNAL_GALLERY_PRESENTER_H
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"
28 namespace Tizen { namespace Base { namespace Runtime {
32 }}} // Tizen::Base::RunTime
34 namespace Tizen { namespace Ui { namespace Controls {
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;
41 class _GalleryViewEvent;
43 class _IGalleryRenderer;
44 class _IGalleryCoreEventListener;
45 class _GalleryViewEventHandler;
47 class _GalleryImageReader;
48 class _GalleryCoreEvent;
49 class _GalleryItemProvider;
51 class _GalleryItemProviderAdaptorImpl;
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
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);
70 virtual ~_GalleryPresenter(void);
72 static _GalleryPresenter* CreateGalleryPresenterN(_IGalleryRenderer& galleryRenderer,
73 _GalleryItemProviderAdaptorImpl* pGalleryItemProviderAdaptor, _Gallery* pGalleryView);
75 int GetCurrentItemIndex(void) const;
76 result SetCurrentItemIndex(int index, bool eventFire = true);
77 result SetCurrentItem(int index);
79 int GetItemCount(void) const;
81 void SetItemSpacing(int spacing);
82 int GetItemSpacing(void) const;
84 _GallerySlideShowType GetSlideShowType(void) const;
85 result SetSlideShowType(_GallerySlideShowType slideShowType);
87 int GetSlideShowAnimationDuration(void) const;
88 result SetSlideShowAnimationDuration(int duration);
90 int GetSlideShowViewDuration(void) const;
91 result SetSlideShowViewDuration(int duration);
93 result StartSlideShow(bool repeat = false);
94 result StopSlideShow(void);
95 bool IsSlideShowStarted(void) const;
97 Tizen::Base::String GetTextOfEmptyGallery(void) const;
98 result SetTextOfEmptyGallery(const Tizen::Base::String& text);
99 result SetBitmapOfEmptyGallery(const _GalleryBitmap* pBitmap);
101 result SetZoomingEnabled(bool enable);
102 bool IsZoomingEnabled(void) const;
104 bool PostEvent(_GalleryViewEvent& event);
105 bool OnBoundsChanged(void);
108 result SetCoreEventListener(const _IGalleryCoreEventListener& coreEventListener);
109 result RemoveCoreEventListener(const _IGalleryCoreEventListener& coreEventListener);
111 bool ClickedItem(void);
112 bool ChangedItem(void);
114 int SearchCanvasIndex(int itemIndex);
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);
125 virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
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);
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);
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);
145 virtual void OnFontInfoRequested(unsigned long& style, int& size);
147 void UpdateEmptyString(void);
150 _GalleryPresenter(_IGalleryRenderer& galleryRenderer);
151 result Construct(_GalleryItemProviderAdaptorImpl* pGalleryItemProviderAdaptor, _Gallery* pGalleryView);
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);
164 _GalleryPresenter(const _GalleryPresenter& rhs);
165 _GalleryPresenter& operator=(const _GalleryPresenter& rhs);
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);
174 result StartSlideShowTimer(int duration);
175 void StopSlideShowTimer(void);
176 result PlaySlideShow(void);
179 _IGalleryRenderer& __galleryRenderer;
180 _GalleryViewEventHandler* __pGalleryViewEventHandler;
181 _GalleryCoreEvent* __pGalleryCoreEvent;
182 _GalleryItemProvider* __pGalleryItemProvider;
183 _GalleryModel* __pGalleryModel;
184 _GalleryImageReader* __pGalleryImageReader;
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;
199 int* __pItemToCanvas;
200 _GalleryFittingType __fittingType;
201 _GalleryVerticalAlignment __verticalAlignment;
202 _GalleryHorizontalAlignment __horizontalAlignment;
205 Tizen::Graphics::FontStyle __emptyFontStyle;
206 bool __userSetEmptyText;
208 _Gallery* __pGalleryView;
210 friend class _GalleryViewEventHandler;
211 }; // _GalleryPresenter
213 }}} // Tizen::Ui::Controls
215 #endif //_FUI_CTRL_INTERNAL_GALLERY_PRESENTER_H