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.
18 * @file FUiCtrl_ToolbarPresenter.h
19 * @brief This is the header file for the _ToolbarPresenter class.
21 * This header file contains the declarations of the %_ToolbarPresenter class.
24 #ifndef _FUI_CTRL_INTERNAL_TOOLBAR_PRESENTER_H_
25 #define _FUI_CTRL_INTERNAL_TOOLBAR_PRESENTER_H_
27 #include <FBaseObject.h>
28 #include <FUiAnimIVisualElementAnimationStatusEventListener.h>
29 #include <FGrp_TextTextObject.h>
30 #include "FUiCtrl_FlickAnimation.h"
31 #include "FUiCtrl_Toolbar.h"
33 namespace Tizen { namespace Ui { namespace Animations {
34 class VisualElementAnimation;
35 }}} // Tizen::Ui::Animations
37 namespace Tizen { namespace Ui { namespace Controls
43 class _FlickAnimation;
46 * @class _ToolbarPresenter
47 * @brief The presenter class of _Toolbar class
50 class _ToolbarPresenter
51 : public Tizen::Base::Object
52 , public Tizen::Base::Runtime::ITimerEventListener
53 , public Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener
54 , virtual public Tizen::Base::Runtime::IEventListener
57 _ToolbarPresenter(void);
59 virtual ~_ToolbarPresenter(void);
61 result Construct(const _Toolbar& toolbar);
67 void DrawBackground(void);
69 void DrawDescriptionText(void);
71 void DrawEditItem(const Tizen::Graphics::FloatPoint& point);
73 void DrawDivider(const Tizen::Graphics::FloatPoint& point, Tizen::Graphics::Canvas* pCanvas);
77 result DrawTitleText(Tizen::Graphics::Canvas* pCanvas);
79 int GetSelectedItemIndex(void) const;
81 bool IsInitialDraw(void) const;
83 bool IsTabEditModeEnabled(void) const;
85 result SetDescriptionText(const Tizen::Base::String& description);
87 result SetItemSelected(int itemIndex);
89 result SetInitialDrawState(bool state);
91 result SetTabEditModeEnabled(bool enable);
93 result SetTitleText(const Tizen::Base::String& title, HorizontalAlignment alignment);
95 result SetUsableAreaBounds(const Tizen::Graphics::FloatRectangle& rect);
97 bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
99 bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
101 bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
103 bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo);
105 void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation);
107 bool OnLongPressGestureDetected(void);
109 virtual bool OnFlickGestureDetected(_TouchFlickGestureDetector& gesture);
111 virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
113 result TimerForTitleSlideInit(void);
115 result TimerForTitleSlideStart(void);
117 result TimerForTitleSlideTimeout(void);
119 Tizen::Graphics::FloatRectangle GetTitleTextBoundsF(void) const;
121 Tizen::Graphics::FloatRectangle GetDescriptionBoundsF(void) const;
123 void OnFontChanged(Tizen::Graphics::Font* pFont);
124 void OnFontInfoRequested(unsigned long& style, int& size);
125 void OnFontInfoRequested(unsigned long& style, float& size);
126 void OnAncestorVisibleStateChanged(const _Control& control);
127 void SetFontInfo(unsigned long style, float size);
130 result AdjustItemPositionX(float distance);
133 result _SetModel(const _ToolbarModel& toolbarModel);
136 void SetBouncingVisualElement(float startX, float startY);
138 void StartFlickAnimation(void);
139 result StartFlickAnimationTimer(void);
140 result ResetFlickAnimationTimer(void);
142 void SetFirstLoadedItemIndex(void);
143 void SetLastLoadedItemIndex(void);
145 float CalculateProgress(float timeProgress) const;
147 void SetItemFit(int);
149 virtual void OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target);
150 virtual void OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount);
151 virtual void OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally);
154 _Toolbar* __pToolbar;
156 _ToolbarModel* __pToolbarModel;
160 bool __tabEditEnabled;
164 bool __touchInitiatedInToolbar;
168 int __pressedItemIndex;
170 _ButtonStatus __initialPressesItemStatus;
174 Tizen::Graphics::Bitmap* __pTitleBackgroundBitmap;
176 Tizen::Base::Runtime::Timer* __pTitleSlideTimer;
178 Tizen::Base::Runtime::Timer* __pFlickAnimationTimer;
180 Tizen::Graphics::FloatRectangle __titleRect;
182 Tizen::Graphics::FloatRectangle __descriptionRect;
184 Tizen::Graphics::FloatRectangle __toolbarUsableArea;
186 Tizen::Graphics::FloatPoint __currentTouchPosition;
188 Tizen::Base::String __titleText;
190 Tizen::Graphics::Font* __pTitleTextFont;
192 Tizen::Graphics::Font* __pTextFont;
194 Tizen::Graphics::_Text::TextObject* __pDescriptionTextObject;
196 Tizen::Graphics::_Text::TextObject* __pTitleTextObject;
198 _FlickAnimation __flickAnimation;
200 static const int FLICK_ANIMATION_TIMER_PERIOD = 3;
201 static const int FLICK_ANIMATION_FPS_TAB = 30;
202 static const int FLICK_ANIMATION_SENSITIVITY_TAB = 30;
203 static const int FLICK_ANIMATION_COUNT = 50;
206 float __moveDistance;
208 float __flickDistance;
210 int __firstLoadedItemIndex;
211 int __lastLoadedItemIndex;
213 bool __tabSlideRight;
215 Tizen::Graphics::FloatDimension __portraitSize;
216 Tizen::Graphics::FloatDimension __landscapeSize;
218 unsigned long __fontStyle;
226 _ToolbarPresenter(const _ToolbarPresenter& value);
228 _ToolbarPresenter& operator =(const _ToolbarPresenter& value);
232 }}} // Tizen::Ui::Controls
234 #endif // _FUI_CTRL_INTERNAL_TOOLBAR_PRESENTER_H_