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.
18 * @file FUiCtrl_ToolbarPresenter.h
19 * @brief This is the header file fo r 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 DrawDivider(void);
71 void DrawDescriptionText(void);
73 void DrawEditItem(const Tizen::Graphics::FloatPoint& point);
75 void DrawDividerLine(const Tizen::Graphics::FloatPoint& point, Tizen::Graphics::Canvas* pCanvas);
79 result DrawTitleText(Tizen::Graphics::Canvas* pCanvas);
81 int GetSelectedItemIndex(void) const;
83 bool IsInitialDraw(void) const;
85 bool IsTabEditModeEnabled(void) const;
87 result SetDescriptionText(const Tizen::Base::String& description);
89 result SetItemSelected(int itemIndex, bool adjust);
91 result SetInitialDrawState(bool state);
93 result SetTabEditModeEnabled(bool enable);
95 result SetTitleText(const Tizen::Base::String& title, HorizontalAlignment alignment);
97 result SetUsableAreaBounds(const Tizen::Graphics::FloatRectangle& rect);
99 bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
101 bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
103 bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
105 bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo);
107 void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation);
109 bool OnLongPressGestureDetected(void);
111 virtual bool OnFlickGestureDetected(_TouchFlickGestureDetector& gesture);
113 virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
115 virtual void OnDrawFocus(void);
117 virtual void OnChildControlFocusMoved(const _Control& control);
119 virtual bool IsChildControlFocusManage(void) const;
121 virtual void OnFocusableStateChanged(bool focusalbeState);
123 virtual void OnFocusModeStateChanged(void);
125 virtual bool OnFocusGained(const _Control& source);
127 virtual bool OnFocusLost(const _Control& source);
129 result TimerForTitleSlideInit(void);
131 result TimerForTitleSlideStart(void);
133 result TimerForTitleSlideTimeout(void);
135 Tizen::Graphics::FloatRectangle GetTitleTextBoundsF(void) const;
137 Tizen::Graphics::FloatRectangle GetDescriptionBoundsF(void) const;
139 void OnFontChanged(Tizen::Graphics::Font* pFont);
140 void OnFontInfoRequested(unsigned long& style, int& size);
141 void OnFontInfoRequested(unsigned long& style, float& size);
142 void OnAncestorVisibleStateChanged(const _Control& control);
143 void SetFontInfo(unsigned long style, float size);
145 result AdjustItemPositionX(float distance);
146 void SetItemFit(int);
147 int GetFirstLoadedItemIndex(void);
150 result _SetModel(const _ToolbarModel& toolbarModel);
153 void StartFlickAnimation(void);
154 result StartFlickAnimationTimer(void);
155 result ResetFlickAnimationTimer(void);
157 void SetFirstLoadedItemIndex(void);
158 void SetLastLoadedItemIndex(void);
160 float CalculateProgress(float timeProgress) const;
162 void DrawTitleTextDimBitmap(void);
164 virtual void OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target);
165 virtual void OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount);
166 virtual void OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally);
169 _Toolbar* __pToolbar;
171 _ToolbarModel* __pToolbarModel;
175 bool __tabEditEnabled;
179 bool __touchInitiatedInToolbar;
183 int __pressedItemIndex;
185 _ButtonStatus __initialPressesItemStatus;
189 Tizen::Graphics::Bitmap* __pTitleBackgroundBitmap;
191 Tizen::Base::Runtime::Timer* __pTitleSlideTimer;
193 Tizen::Base::Runtime::Timer* __pFlickAnimationTimer;
195 Tizen::Graphics::FloatRectangle __titleRect;
197 Tizen::Graphics::FloatRectangle __descriptionRect;
199 Tizen::Graphics::FloatRectangle __toolbarUsableArea;
201 Tizen::Graphics::FloatPoint __currentTouchPosition;
203 Tizen::Base::String __titleText;
205 Tizen::Graphics::Font* __pTitleTextFont;
207 Tizen::Graphics::Font* __pTextFont;
209 Tizen::Graphics::_Text::TextObject* __pDescriptionTextObject;
211 Tizen::Graphics::_Text::TextObject* __pTitleTextObject;
213 Tizen::Ui::Animations::VisualElement* __pBouncingEffectVe;
215 _FlickAnimation __flickAnimation;
217 static const int FLICK_ANIMATION_TIMER_PERIOD = 3;
218 static const int FLICK_ANIMATION_FPS_TAB = 30;
219 static const int FLICK_ANIMATION_SENSITIVITY_TAB = 30;
220 static const int FLICK_ANIMATION_COUNT = 50;
223 float __moveDistance;
225 float __flickDistance;
227 int __firstLoadedItemIndex;
228 int __lastLoadedItemIndex;
230 bool __tabSlideRight;
232 Tizen::Graphics::FloatDimension __portraitSize;
233 Tizen::Graphics::FloatDimension __landscapeSize;
235 unsigned long __fontStyle;
243 _ToolbarPresenter(const _ToolbarPresenter& value);
245 _ToolbarPresenter& operator =(const _ToolbarPresenter& value);
249 }}} // Tizen::Ui::Controls
251 #endif // _FUI_CTRL_INTERNAL_TOOLBAR_PRESENTER_H_