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);
148 _GalleryPresenter(_IGalleryRenderer& galleryRenderer);
149 result Construct(_GalleryItemProviderAdaptorImpl* pGalleryItemProviderAdaptor, _Gallery* pGalleryView);
151 // property getter/setter
152 Variant GetPropertySlideShowViewDuration(void) const;
153 result SetPropertySlideShowViewDuration(const Variant& variant);
154 Variant GetPropertySlideShowAnimationDuration(void) const;
155 result SetPropertySlideShowAnimationDuration(const Variant& variant);
156 Variant GetPropertyTextOfEmptyGallery(void) const;
157 result SetPropertyTextOfEmptyGallery(const Variant& variant);
158 Variant GetPropertyZoomingEnabled(void) const;
159 result SetPropertyZoomingEnabled(const Variant& variant);
162 _GalleryPresenter(const _GalleryPresenter& rhs);
163 _GalleryPresenter& operator=(const _GalleryPresenter& rhs);
165 result SetCanvasImage(int itemIndex);
166 result SetPartialCanvasImage(void);
167 int GetEmptyCanvasIndex(void) const;
168 result SetCanvasIndex(int canvasIndex, int itemIndex);
169 int ClearCanvasIndex(int currentItemIndex);
170 void SortItemToCanvasIndex(int itemIndex, bool add);
172 result StartSlideShowTimer(int duration);
173 void StopSlideShowTimer(void);
174 result PlaySlideShow(void);
177 _IGalleryRenderer& __galleryRenderer;
178 _GalleryViewEventHandler* __pGalleryViewEventHandler;
179 _GalleryCoreEvent* __pGalleryCoreEvent;
180 _GalleryItemProvider* __pGalleryItemProvider;
181 _GalleryModel* __pGalleryModel;
182 _GalleryImageReader* __pGalleryImageReader;
184 //_GalleryBitmap* __pPartialImage;
185 _GalleryBitmap* __pEmptyGalleryImage;
186 Tizen::Base::String __emptyText;
187 int __slideShowAnimationDuration;
188 int __slideShowViewDuration;
189 _GallerySlideShowType __gallerySlideShowType;
190 int __currentItemIndex;
191 bool __slideShowRepeat;
192 bool __slideShowStarted;
193 bool __zoomingEnabled;
194 Tizen::Base::Runtime::Timer* __pSlideShowTimer;
195 int __slideShowPlayCount;
197 int* __pItemToCanvas;
198 _GalleryFittingType __fittingType;
199 _GalleryVerticalAlignment __verticalAlignment;
200 _GalleryHorizontalAlignment __horizontalAlignment;
203 Tizen::Graphics::FontStyle __emptyFontStyle;
205 _Gallery* __pGalleryView;
207 friend class _GalleryViewEventHandler;
208 }; // _GalleryPresenter
210 }}} // Tizen::Ui::Controls
212 #endif //_FUI_CTRL_INTERNAL_GALLERY_PRESENTER_H