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 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, bool adjust);
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 virtual void OnDrawFocus(void);
115 virtual void OnChildControlFocusMoved(const _Control& control);
117 virtual bool IsChildControlFocusManage(void) const;
119 virtual void OnFocusableStateChanged(bool focusalbeState);
121 virtual void OnFocusModeStateChanged(void);
123 virtual bool OnFocusGained(const _Control& source);
125 virtual bool OnFocusLost(const _Control& source);
127 result TimerForTitleSlideInit(void);
129 result TimerForTitleSlideStart(void);
131 result TimerForTitleSlideTimeout(void);
133 Tizen::Graphics::FloatRectangle GetTitleTextBoundsF(void) const;
135 Tizen::Graphics::FloatRectangle GetDescriptionBoundsF(void) const;
137 void OnFontChanged(Tizen::Graphics::Font* pFont);
138 void OnFontInfoRequested(unsigned long& style, int& size);
139 void OnFontInfoRequested(unsigned long& style, float& size);
140 void OnAncestorVisibleStateChanged(const _Control& control);
141 void SetFontInfo(unsigned long style, float size);
143 result AdjustItemPositionX(float distance);
144 void SetItemFit(int);
145 int GetFirstLoadedItemIndex(void);
148 result _SetModel(const _ToolbarModel& toolbarModel);
151 void StartFlickAnimation(void);
152 result StartFlickAnimationTimer(void);
153 result ResetFlickAnimationTimer(void);
155 void SetFirstLoadedItemIndex(void);
156 void SetLastLoadedItemIndex(void);
158 float CalculateProgress(float timeProgress) const;
160 void DrawTitleTextDimBitmap(void);
162 virtual void OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target);
163 virtual void OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount);
164 virtual void OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally);
167 _Toolbar* __pToolbar;
169 _ToolbarModel* __pToolbarModel;
173 bool __tabEditEnabled;
177 bool __touchInitiatedInToolbar;
181 int __pressedItemIndex;
183 _ButtonStatus __initialPressesItemStatus;
187 Tizen::Graphics::Bitmap* __pTitleBackgroundBitmap;
189 Tizen::Base::Runtime::Timer* __pTitleSlideTimer;
191 Tizen::Base::Runtime::Timer* __pFlickAnimationTimer;
193 Tizen::Graphics::FloatRectangle __titleRect;
195 Tizen::Graphics::FloatRectangle __descriptionRect;
197 Tizen::Graphics::FloatRectangle __toolbarUsableArea;
199 Tizen::Graphics::FloatPoint __currentTouchPosition;
201 Tizen::Base::String __titleText;
203 Tizen::Graphics::Font* __pTitleTextFont;
205 Tizen::Graphics::Font* __pTextFont;
207 Tizen::Graphics::_Text::TextObject* __pDescriptionTextObject;
209 Tizen::Graphics::_Text::TextObject* __pTitleTextObject;
211 _FlickAnimation __flickAnimation;
213 static const int FLICK_ANIMATION_TIMER_PERIOD = 3;
214 static const int FLICK_ANIMATION_FPS_TAB = 30;
215 static const int FLICK_ANIMATION_SENSITIVITY_TAB = 30;
216 static const int FLICK_ANIMATION_COUNT = 50;
219 float __moveDistance;
221 float __flickDistance;
223 int __firstLoadedItemIndex;
224 int __lastLoadedItemIndex;
226 bool __tabSlideRight;
228 Tizen::Graphics::FloatDimension __portraitSize;
229 Tizen::Graphics::FloatDimension __landscapeSize;
231 unsigned long __fontStyle;
239 _ToolbarPresenter(const _ToolbarPresenter& value);
241 _ToolbarPresenter& operator =(const _ToolbarPresenter& value);
245 }}} // Tizen::Ui::Controls
247 #endif // _FUI_CTRL_INTERNAL_TOOLBAR_PRESENTER_H_