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.
19 * @file FUiCtrl_FastScrollPresenter.h
20 * @brief This is the header file for the _FastScrollPresenter class.
22 * This header file contains the declarations of the %_FastScrollPresenter class.
25 #ifndef _FUICTRL_INTERNAL_FASTSCROLL_PRESENTER_H_
26 #define _FUICTRL_INTERNAL_FASTSCROLL_PRESENTER_H_
28 #include "FBaseString.h"
29 #include "FGrpFloatMatrix4.h"
31 #include "FGrpBitmap.h"
32 #include "FGrpRectangle.h"
33 #include "FGrpColor.h"
34 #include "FGrpDimension.h"
35 #include "FGrp_TextTextObject.h"
37 #include "FUi_Control.h"
38 #include "FUiCtrl_IFastScrollListener.h"
39 #include "FUiCtrl_UiFastScrollEvent.h"
41 #include "FUiAnim_VisualElement.h"
42 #include "FUiAnimVisualElementAnimation.h"
43 #include "FUiAnimVisualElementAnimationProvider.h"
44 #include "FUiAnimIVisualElementAnimationStatusEventListener.h"
45 #include "FUiAnimVisualElementContentProvider.h"
46 #include "FUiAnimIVisualElementContentProvider.h"
48 #include "FUiCtrl_FastScroll.h"
49 #include "FUiCtrl_FastScrollIndex.h"
50 #include "FUiCtrl_FastScrollModel.h"
53 namespace Tizen { namespace Ui { namespace Controls
56 class _FastScrollViewConfig
59 virtual ~_FastScrollViewConfig(void);
60 static _FastScrollViewConfig* CreateFastScrollViewConfigN(Tizen::Ui::_ControlOrientation orientation);
62 result ReloadConfig(Tizen::Ui::_ControlOrientation orientation);
63 void ReleaseResources(void);
66 _FastScrollViewConfig(const _FastScrollViewConfig& rhs);
67 _FastScrollViewConfig& operator =(const _FastScrollViewConfig& rhs);
69 _FastScrollViewConfig(void);
70 result Construct(Tizen::Ui::_ControlOrientation orientation);
73 friend class _FastScrollIndexView;
74 friend class _FastScrollPopupView;
75 friend class _FastScrollPresenter;
77 Tizen::Graphics::Color __indexBgColor;
78 Tizen::Graphics::Color __indexHighlightColor;
79 Tizen::Graphics::Color __indexLeftLineColor;
80 Tizen::Graphics::Color __indexTextColor;
81 Tizen::Graphics::Color __indexSeparatorColor;
82 Tizen::Graphics::Color __selectedIndexBgColor;
83 Tizen::Graphics::Color __selectedIndexTextColor;
84 Tizen::Graphics::Color __selectedIndexOutlineColor;
85 Tizen::Graphics::Color __popupBgColor;
86 Tizen::Graphics::Color __popupTextColor;
88 Tizen::Graphics::Dimension __indexSizeMin;
89 Tizen::Graphics::Dimension __popupSize;
91 int __indexMarginRight;
95 int __indexLeftLineThickness;
97 int __indexSeparatorThickness;
98 int __selectedIndexMarginRight;
99 int __selectedIndexHeight;
100 int __popupWidthIncrement;
102 int __popupShadowRight;
103 int __popupShadowBottom;
105 Tizen::Graphics::Bitmap* __pIndexBgBitmap;
106 Tizen::Graphics::Bitmap* __pSelectedIndexBgBitmap;
107 Tizen::Graphics::Bitmap* __pSelectedIndexOutlineBitmap;
108 Tizen::Graphics::Bitmap* __pPopupBgBitmap;
109 Tizen::Graphics::Bitmap* __pPopupBgEffectBitmap;
111 Tizen::Graphics::Font* __pFont;
115 class _FastScrollIndexView
116 : public Tizen::Base::Object
117 , public Tizen::Ui::Animations::VisualElementAnimationProvider
118 , public Tizen::Ui::Animations::VisualElementContentProvider
119 , public Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener
120 , virtual public Tizen::Ui::Animations::IVisualElementAnimationProvider
121 , virtual public _IUiEventListener
124 virtual ~_FastScrollIndexView(void);
126 static _FastScrollIndexView* CreateFastScrollIndexViewN(Tizen::Ui::Animations::_VisualElement& parentVe, _FastScrollViewConfig& viewConfig);
128 result FadeOutAndDestroy(void);
130 result SetBaseIndex(_FastScrollIndex* pIndex);
131 _FastScrollIndex* GetBaseIndex(void) const;
133 result SetIndexBounds(const Tizen::Graphics::Rectangle& indexBounds);
134 Tizen::Graphics::Rectangle GetIndexBounds(void) const;
135 result SetSelectedBgBounds(const Tizen::Graphics::Rectangle& indexBounds);
136 Tizen::Graphics::Rectangle GetSelectedBgBounds(void) const;
137 result SetSelectedIndexBounds(const Tizen::Graphics::Rectangle& indexBounds);
138 Tizen::Graphics::Rectangle GetSelectedIndexBounds(void) const;
140 _FastScrollIndex* GetIndexAtPoint(const Tizen::Graphics::Point& point) const;
141 _FastScrollIndex* GetOmissionIndexAtPoint(_FastScrollIndex* pIndex, const Tizen::Graphics::Point& point) const;
142 int GetIndexHeight(void) const;
143 result SelectIndex(int indexOrder);
144 result SelectIndex(_FastScrollIndex* pIndex, bool animation);
145 int GetSelectedIndexOrder(void) const;
146 _FastScrollIndex* GetSelectedIndex(void) const;
147 void SetSelectedIndexInOmittedIndex(_FastScrollIndex* pIndex);
148 _FastScrollIndex* GetSelectedIndexInOmittedIndex(void) const;
149 _FastScrollIndex* GetFormerIndex(void) const;
151 bool IsOnAnimation(void) const;
152 void RemoveAllAnimations(void);
154 result SetIndexVisibility(bool visibility);
155 bool GetIndexVisibility(void) const;
156 result SetSelectedIndexVisibility(bool visibility, bool bAnimation);
157 bool GetSelectedIndexVisibility(void) const;
158 result AddAccessibilityElement(const Tizen::Ui::_AccessibilityContainer& control);
160 result UpdateIndex(bool bNeedUpdateBaseIndex);
161 Tizen::Graphics::Rectangle CalculateSelectedBg(void);
164 void DrawBaseIndex(void);
165 void DrawSelectedBg(void);
166 void DrawSelectedIndex(void);
167 result DrawBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& bounds, const Tizen::Graphics::Bitmap& bitmap);
168 result DrawBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& srcRect, const Tizen::Graphics::Bitmap& bitmap, const Tizen::Graphics::Rectangle& dstRect);
170 virtual Tizen::Ui::Animations::VisualElementAnimation* CreateAnimationForProperty(Tizen::Ui::Animations::VisualElement& target, const Tizen::Base::String& property);
171 virtual void OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target);
172 virtual void OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount);
173 virtual void OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally);
176 _FastScrollIndexView(const _FastScrollIndexView& rhs);
177 _FastScrollIndexView& operator =(const _FastScrollIndexView& rhs);
179 _FastScrollIndexView(Tizen::Ui::Animations::_VisualElement& parentVe, _FastScrollViewConfig& viewConfig);
180 result Construct(void);
183 Tizen::Ui::Animations::_VisualElement& __parentVe;
184 _FastScrollViewConfig& __viewConfig;
186 _FastScrollIndex* __pBaseIndex;
187 _FastScrollIndex* __pSelectedIndex;
188 _FastScrollIndex* __pSelectedIndexInOmittedIndex;
189 _FastScrollIndex* __pFormerIndex;
190 Tizen::Ui::Animations::_VisualElement* __pBaseIndexVe;
191 Tizen::Ui::Animations::_VisualElement* __pSelectedBgVe;
192 Tizen::Ui::Animations::_VisualElement* __pSelectedIndexVe;
194 bool __needUpdateBaseIndex;
195 bool __needUpdateSelectedIndex;
196 bool __needDestroySelf;
199 class _FastScrollPopupView
200 : public Tizen::Ui::Animations::VisualElementAnimationProvider
201 , public Tizen::Ui::Animations::VisualElementContentProvider
202 , public Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener
203 , virtual public Tizen::Ui::Animations::IVisualElementAnimationProvider
204 , virtual public _IUiEventListener
207 virtual ~_FastScrollPopupView(void);
209 static _FastScrollPopupView* CreateFastScrollPopupViewN(Tizen::Ui::Animations::_VisualElement& parentVe, _FastScrollViewConfig& viewConfig);
211 result FadeOutAndDestroy(void);
213 result SelectIndex(int indexLevel, _FastScrollIndex* pIndex, _FastScrollIndex* pFormerIndex);
214 result AddPopupIndexVe(int indexLevel);
215 result RemovePopupIndexVe(int indexLevel);
217 result SetPopupBounds(const Tizen::Graphics::Rectangle& indexBounds);
218 Tizen::Graphics::Rectangle GetPopupBounds(void) const;
219 result SetPopupIndexBounds(int indexLevel, const _FastScrollIndex* pBaseIndex);
220 Tizen::Graphics::Rectangle GetPopupIndexBounds(int indexLevel) const;
221 Tizen::Ui::Animations::_VisualElement* GetIndexVe(int indexLevel) const;
222 int GetIndexVeCount(void) const;
224 bool IsOnAnimation(void) const;
225 void RemoveAllAnimations(void);
227 result SetPopupVisibility(bool visibility);
228 bool GetPopupVisibility(void) const;
229 void SetPopupVeUpdateNeeded(bool needUpdate);
231 result UpdateIndex(void);
233 void DrawPopupVe(void);
234 void DrawPopupIndexVe(int indexLevel, const _FastScrollIndex* pBaseIndex, const _FastScrollIndex* pSelectedIndex);
236 void OnDraw(int indexLevel, const _FastScrollIndex* pBaseIndex, const _FastScrollIndex* pSelectedIndex);
237 result DrawBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& bounds, const Tizen::Graphics::Bitmap& bitmap);
238 result DrawBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& srcRect, const Tizen::Graphics::Bitmap& bitmap, const Tizen::Graphics::Rectangle& dstRect);
240 virtual Tizen::Ui::Animations::VisualElementAnimation* CreateAnimationForProperty(Tizen::Ui::Animations::VisualElement& target, const Tizen::Base::String& property);
241 virtual void OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target);
242 virtual void OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount);
243 virtual void OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally);
246 _FastScrollPopupView(const _FastScrollPopupView& rhs);
247 _FastScrollPopupView& operator =(const _FastScrollPopupView& rhs);
249 _FastScrollPopupView(Tizen::Ui::Animations::_VisualElement& parentVe, _FastScrollViewConfig& viewConfig);
250 result Construct(void);
253 Tizen::Ui::Animations::_VisualElement& __parentVe;
254 _FastScrollViewConfig& __viewConfig;
256 Tizen::Ui::Animations::_VisualElement* __pPopupVe;
257 Tizen::Base::Collection::ArrayList __indexViews;
259 Tizen::Graphics::FloatMatrix4 __matrixOrigin;
260 Tizen::Graphics::FloatMatrix4 __matrixFadeInStart;
261 Tizen::Graphics::FloatMatrix4 __matrixFadeOutEnd;
263 bool __needUpdatePopupVe;
264 bool __needUpdatePopupIndexVe;
265 bool __needDestroySelf;
271 class _FastScrollPresenter
272 : public Tizen::Ui::Animations::VisualElementAnimationProvider
273 , public Tizen::Ui::Animations::VisualElementContentProvider
274 , public Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener
275 , public _IFastScrollIndexObserver
276 , virtual public Tizen::Ui::Animations::IVisualElementAnimationProvider
277 , virtual public _IUiEventListener
280 virtual ~_FastScrollPresenter(void);
282 static _FastScrollPresenter* CreateFastScrollPresenterN(Tizen::Ui::_Control& parentCtrl,
283 _FastScroll& fastScroll,
284 bool visibility = false);
286 result SetRootIndex(_FastScrollIndex* pIndex);
287 _FastScrollIndex* GetRootIndex(void) const;
288 result UpdateIndex(void);
290 void EnableFadeEffect(bool enable);
291 bool IsEnabledFadeEffect(void) const;
292 bool IsOnFadeEffect(void) const;
293 bool IsScrollVisible(void) const;
294 result SetScrollVisibility(bool visibility);
295 bool GetScrollVisibility(void) const;
296 void CancelFadeEffect(void);
298 void AddFastScrollEventListener(const Tizen::Ui::Controls::_IUiFastScrollListener& listener);
299 void RemoveFastScrollEventListener(const Tizen::Ui::Controls::_IUiFastScrollListener& listener);
300 result AddAccessibilityElement(const Tizen::Ui::_AccessibilityContainer& control, bool onAccessibility);
302 void OnParentBoundsChanged(void);
305 bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
306 bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
307 bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
308 bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo);
309 void OnFontChanged(Tizen::Graphics::Font* pFont);
310 void OnFontInfoRequested(unsigned long& style, int& size);
311 result SetFontInfo(unsigned long style, int size);
312 Tizen::Ui::Animations::HitTestResult HitTest(const Tizen::Graphics::FloatPoint& point);
314 virtual Tizen::Ui::Animations::VisualElementAnimation* CreateAnimationForProperty(Tizen::Ui::Animations::VisualElement& target, const Tizen::Base::String& property);
315 virtual void OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target);
316 virtual void OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount);
317 virtual void OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally);
319 virtual void OnIndexDataUpdated(_FastScrollIndex& updatedIndex);
320 virtual void OnIndexDeleted(_FastScrollIndex& deletedIndex);
321 virtual void OnChildIndexAttached(_FastScrollIndex& parentIndex, int attachedOrder, _FastScrollIndex& attachedIndex);
322 virtual void OnChildIndexDetached(_FastScrollIndex& parentIndex, int detachedOrder, _FastScrollIndex& detachedIndex);
325 _FastScrollPresenter(const _FastScrollPresenter& rhs);
326 _FastScrollPresenter& operator =(const _FastScrollPresenter& rhs);
328 _FastScrollPresenter(Tizen::Ui::_Control& parentCtrl, _FastScroll& fastScroll, bool visibility);
329 result Construct(void);
331 Tizen::Graphics::Rectangle CalculateFastScrollBounds(int indexCount);
332 Tizen::Graphics::Rectangle CalculateIndexBounds(int indexLevel, _FastScrollIndex& pIndex);
333 Tizen::Graphics::Rectangle CalculatePopupBounds(void);
334 void RelayoutFastScrollChildren(void);
336 _FastScrollIndex* SelectOnIndexViews(const Tizen::Graphics::Point& point, bool animation);
337 result DeselectIndexViews(void);
339 result SetPopupIndex(_FastScrollIndex& popupIndex, const Tizen::Graphics::Point& point);
340 result ClearPopupIndex(void);
342 result FireFastScrollEvent(_FastScrollIndex& selectedIndex);
344 bool OnTouchPressedAndMoved(const Tizen::Graphics::Point& point, bool animation);
345 bool OnTouchReleasedAndCanceled(void);
347 result AddIndexView(_FastScrollIndex& baseIndex);
348 result AddIndexView(int indexLevel, _FastScrollIndex& baseIndex);
349 result RemoveIndexView(int indexLevel, bool fadeout);
350 result RemoveAllIndexViews(bool fadeout);
352 _FastScrollIndexView* GetIndexView(int indexLevel) const;
353 int GetIndexViewCount(void) const;
356 Tizen::Ui::_Control& __parentCtrl;
357 _FastScroll& __fastScroll;
358 Tizen::Ui::Animations::_VisualElement* __pCtrlVe;
360 _FastScrollViewConfig* __pViewConfig;
362 _UiFastScrollEvent* __pFastScrollEvent;
363 _FastScrollModel* __pFastScrollModel;
364 unsigned long __fontStyle;
367 _FastScrollPopupView* __pPopupView;
368 Tizen::Base::Collection::ArrayList __indexViews;
370 int __focusedIndexLevel;
371 _FastScrollIndex* __pSelectedIndex;
373 bool __enableFadeEffect;
377 bool __scrollVisibility;
378 int __fadeEffectDuration_ms;
382 } } } // Tizen::Ui::Controls
384 #endif //_FUICTRL_INTERNAL_FASTSCROLL_PRESENTER_H_