2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
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;
53 class _GalleryPresenter
54 : public Tizen::Ui::_PropertyBase
55 , public _IGalleryRendererNotiListener
56 , public Tizen::Ui::_IPropertyChangeEventListener
57 , public Tizen::Base::Runtime::ITimerEventListener
58 , virtual public Tizen::Base::Runtime::IEventListener
61 DECLARE_CLASS_BEGIN(_GalleryPresenter, _PropertyBase);
62 DECLARE_PROPERTY("slideShowViewDuration", GetPropertySlideShowViewDuration, SetPropertySlideShowViewDuration);
63 DECLARE_PROPERTY("slideShowAnimationDuration", GetPropertySlideShowAnimationDuration, SetPropertySlideShowAnimationDuration);
64 DECLARE_PROPERTY("textOfEmptyGallery", GetPropertyTextOfEmptyGallery, SetPropertyTextOfEmptyGallery);
65 DECLARE_PROPERTY("zoomingEnabled", GetPropertyZoomingEnabled, SetPropertyZoomingEnabled);
69 virtual ~_GalleryPresenter(void);
71 static _GalleryPresenter* CreateGalleryPresenterN(_IGalleryRenderer& galleryRenderer, _GalleryItemProviderAdaptorImpl* pGalleryItemProviderAdaptor);
73 int GetCurrentItemIndex(void) const;
74 result SetCurrentItemIndex(int index, bool eventFire = true);
75 result SetCurrentItem(int index);
77 int GetItemCount(void) const;
79 void SetItemSpacing(int spacing);
80 int GetItemSpacing(void) const;
82 _GallerySlideShowType GetSlideShowType(void) const;
83 result SetSlideShowType(_GallerySlideShowType slideShowType);
85 int GetSlideShowAnimationDuration(void) const;
86 result SetSlideShowAnimationDuration(int duration);
88 int GetSlideShowViewDuration(void) const;
89 result SetSlideShowViewDuration(int duration);
91 result StartSlideShow(bool repeat = false);
92 result StopSlideShow(void);
93 bool IsSlideShowStarted(void) const;
95 Tizen::Base::String GetTextOfEmptyGallery(void) const;
96 result SetTextOfEmptyGallery(const Tizen::Base::String& text);
97 result SetBitmapOfEmptyGallery(const _GalleryBitmap* pBitmap);
99 result SetZoomingEnabled(bool enable);
100 bool IsZoomingEnabled(void) const;
102 bool PostEvent(_GalleryViewEvent& event);
103 bool OnBoundsChanged(void);
106 result SetCoreEventListener(const _IGalleryCoreEventListener& coreEventListener);
107 result RemoveCoreEventListener(const _IGalleryCoreEventListener& coreEventListener);
109 bool ClickedItem(void);
110 bool ChangedItem(void);
113 result RequestToLoadItem(int index);
114 result RequestToUnloadItem(int index);
115 result RequestToUnloadAllItems(void);
116 result RequestToUpdateItem(int index);
117 result RequestToUpdateAllItems(void);
118 result RequestToUpdateItemCount(void);
121 virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
123 // renderer noti listener
124 virtual void OnTransitionCancel(void);
125 virtual void OnTransitionCompleted(void);
126 virtual void OnCanvasAnimationCancel(void);
127 virtual void OnCanvasAnimationCompleted(void);
128 virtual void OnCanvasAnimationStarted(void);
130 // data binding event listener
131 virtual void OnPropertyChanging(Tizen::Ui::_PropertyBase& source, const Tizen::Base::String& name, const Variant& oldProperty, const Variant& newProperty);
132 virtual void OnPropertyChanged(Tizen::Ui::_PropertyBase& source, const Tizen::Base::String& name, const Variant& oldProperty, const Variant& newProperty);
135 void SetFontSize(int size);
136 int GetFontSize(void) const;
137 void SetFontStyle(Tizen::Graphics::FontStyle style);
138 Tizen::Graphics::FontStyle GetFontStyle(void) const;
139 void OnFontChanged(void);
141 virtual void OnFontInfoRequested(unsigned long& style, int& size);
145 _GalleryPresenter(_IGalleryRenderer& galleryRenderer);
146 result Construct(_GalleryItemProviderAdaptorImpl* pGalleryItemProviderAdaptor);
148 // property getter/setter
149 Variant GetPropertySlideShowViewDuration(void) const;
150 result SetPropertySlideShowViewDuration(const Variant& variant);
151 Variant GetPropertySlideShowAnimationDuration(void) const;
152 result SetPropertySlideShowAnimationDuration(const Variant& variant);
153 Variant GetPropertyTextOfEmptyGallery(void) const;
154 result SetPropertyTextOfEmptyGallery(const Variant& variant);
155 Variant GetPropertyZoomingEnabled(void) const;
156 result SetPropertyZoomingEnabled(const Variant& variant);
159 _GalleryPresenter(const _GalleryPresenter& rhs);
160 _GalleryPresenter& operator=(const _GalleryPresenter& rhs);
162 result SetCanvasImage(int itemIndex);
163 result SetPartialCanvasImage(void);
164 int SearchCanvasIndex(int itemIndex);
165 int GetEmptyCanvasIndex(void) const;
166 result SetCanvasIndex(int canvasIndex, int itemIndex);
167 int ClearCanvasIndex(int currentItemIndex);
168 void SortItemToCanvasIndex(int itemIndex, bool add);
170 result StartSlideShowTimer(int duration);
171 void StopSlideShowTimer(void);
172 result PlaySlideShow(void);
175 _IGalleryRenderer& __galleryRenderer;
176 _GalleryViewEventHandler* __pGalleryViewEventHandler;
177 _GalleryCoreEvent* __pGalleryCoreEvent;
178 _GalleryItemProvider* __pGalleryItemProvider;
179 _GalleryModel* __pGalleryModel;
180 _GalleryImageReader* __pGalleryImageReader;
182 //_GalleryBitmap* __pPartialImage;
183 _GalleryBitmap* __pEmptyGalleryImage;
184 Tizen::Base::String __emptyText;
185 int __slideShowAnimationDuration;
186 int __slideShowViewDuration;
187 _GallerySlideShowType __gallerySlideShowType;
188 int __currentItemIndex;
189 bool __slideShowRepeat;
190 bool __slideShowStarted;
191 bool __zoomingEnabled;
192 Tizen::Base::Runtime::Timer* __pSlideShowTimer;
193 int __slideShowPlayCount;
195 int* __pItemToCanvas;
196 _GalleryFittingType __fittingType;
197 _GalleryVerticalAlignment __verticalAlignment;
198 _GalleryHorizontalAlignment __horizontalAlignment;
201 Tizen::Graphics::FontStyle __emptyFontStyle;
203 friend class _GalleryViewEventHandler;
204 }; // _GalleryPresenter
206 }}} // Tizen::Ui::Controls
208 #endif //_FUI_CTRL_INTERNAL_GALLERY_PRESENTER_H