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.
19 * @file FUiAnimations.h
20 * @brief This is the header file for the %Animations namespace.
22 * This header file contains the declarations and descriptions of the %Animations namespace.
25 #ifndef _FUI_ANIMATIONS_H_
26 #define _FUI_ANIMATIONS_H_
28 #include <FUiAnimTypes.h>
29 #include <FUiAnimAnimationBase.h>
30 #include <FUiAnimAnimationGroup.h>
31 #include <FUiAnimParallelAnimationGroup.h>
32 #include <FUiAnimSequentialAnimationGroup.h>
33 #include <FUiAnimDimensionAnimation.h>
34 #include <FUiAnimFloatAnimation.h>
35 #include <FUiAnimIntegerAnimation.h>
36 #include <FUiAnimPointAnimation.h>
37 #include <FUiAnimRectangleAnimation.h>
38 #include <FUiAnimRotateAnimation.h>
39 #include <FUiAnimControlAnimator.h>
40 #include <FUiAnimFrameAnimator.h>
42 #include <FUiAnimAnimationTransaction.h>
43 #include <FUiAnimIAnimationTransactionEventListener.h>
45 #include <FUiAnimIControlAnimatorDetailedEventListener.h>
46 #include <FUiAnimIControlAnimatorEventListener.h>
47 #include <FUiAnimIFrameAnimatorEventListener.h>
49 #include <FUiAnimIVisualElementAnimationStatusEventListener.h>
50 #include <FUiAnimIVisualElementAnimationTickEventListener.h>
51 #include <FUiAnimIVisualElementAnimationTimingFunction.h>
52 #include <FUiAnimIVisualElementAnimationValueInterpolator.h>
54 #include <FUiAnimVisualElementAnimation.h>
55 #include <FUiAnimVisualElementAnimationGroup.h>
56 #include <FUiAnimVisualElementPropertyAnimation.h>
57 #include <FUiAnimVisualElementValueAnimation.h>
59 #include <FUiAnimBezierTimingFunction.h>
60 #include <FUiAnimDiscreteTimingFunction.h>
61 #include <FUiAnimEaseElasticInTimingFunction.h>
62 #include <FUiAnimEaseElasticOutTimingFunction.h>
63 #include <FUiAnimEaseInOutTimingFunction.h>
64 #include <FUiAnimEaseInTimingFunction.h>
65 #include <FUiAnimEaseOutInTimingFunction.h>
66 #include <FUiAnimEaseOutTimingFunction.h>
67 #include <FUiAnimExpInTimingFunction.h>
68 #include <FUiAnimExpOutTimingFunction.h>
69 #include <FUiAnimLinearTimingFunction.h>
71 #include <FUiAnimDisplayContext.h>
72 #include <FUiAnimVisualElement.h>
73 #include <FUiAnimVisualElementSurface.h>
74 #include <FUiAnimVisualElementAnimationProvider.h>
75 #include <FUiAnimVisualElementContentProvider.h>
76 #include <FUiAnimIVisualElementAnimationProvider.h>
77 #include <FUiAnimIVisualElementContentProvider.h>
78 #include <FUiAnimIVisualElementEventListener.h>
85 * @namespace Tizen::Ui::Animations
86 * @brief This namespace contains the classes for the animation-related functionalities.
89 * @remarks @b Header @b %file: @b \#include @b <FUiAnimations.h> @n
90 * @b Library : @b osp-uifw
94 * The %Animations namespace provides animation capabilities for the UI controls.
96 * For more information on the %Animations namespace features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/animation.htm">Animations Guide</a>.
98 * The following diagram illustrates the relationships between the classes belonging to the %Animations namespace.
99 * @image html ui_animations_classdiagram.png
101 * The following examples demonstrate how to use the %Animations namespace.
104 // Sample code for Control Animation using ControlAnimator
106 #include <FUiAnimations.h>
108 using namespace Tizen::Ui;
109 using namespace Tizen::Ui::Controls;
110 using namespace Tizen::Ui::Animations;
111 using namespace Tizen::Graphics;
113 class AnimationSample
114 : public Tizen::Ui::Controls::Form
115 , public Tizen::Ui::IActionEventListener
118 virtual result OnInitializing(void);
119 virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
122 static const int ID_BUTTON = 101;
123 Tizen::Ui::Controls::Button *__pButton;
127 AnimationSample::OnInitializing(void)
129 result r = E_SUCCESS;
131 // Creates an instance of Button
132 __pButton = new Button();
133 __pButton->Construct(Rectangle(10, 200, 460, 100));
134 __pButton->SetText(L"Start animation");
135 __pButton->SetActionId(ID_BUTTON);
136 __pButton->AddActionEventListener(*this);
137 AddControl(__pButton);
143 AnimationSample::OnActionPerformed(const Control& source, int actionId)
149 // Starts an animation
150 result r = E_SUCCESS;
152 ControlAnimator* pButtonAnimator = __pButton->GetControlAnimator();
153 Point startPos = __pButton->GetPosition();
154 Point endPos(startPos.x, startPos.y + 200);
155 PointAnimation pointAnimation(startPos,
158 ANIMATION_INTERPOLATOR_LINEAR);
160 pointAnimation.SetAutoReverseEnabled(true);
162 r = pButtonAnimator->StartUserAnimation(ANIMATION_TARGET_POSITION, pointAnimation);
165 AppLog("Start Animation on Button Failed.\n");
175 // Sample code for Form Transition Animation using FrameAnimator
177 #include <FUiAnimations.h>
179 using namespace Tizen::App;
180 using namespace Tizen::Ui;
181 using namespace Tizen::Ui::Controls;
182 using namespace Tizen::Ui::Animations;
185 FrameAnimatorSample::OnAppInitializing(AppRegistry& appRegistry)
187 // Creates instances of Form
188 Form1 *pForm1 = new Form1();
189 pForm1->Initialize();
191 Form2* pForm2 = new Form2();
192 pForm2->Initialize();
194 // Adds forms to the frame
195 Frame *pFrame = GetAppFrame()->GetFrame();
196 pFrame->AddControl(pForm1);
197 pFrame->AddControl(pForm2);
199 // Sets the current form
200 pFrame->SetCurrentForm(pForm1);
203 pForm1->Invalidate();
208 // Transition from Form1 to Form2
210 Form1::OnActionPerformed(const Control& source, int actionId)
214 case ID_FOOTER_BUTTON_TRANSIT:
216 result r = E_SUCCESS;
218 Frame *pFrame = UiApp::GetInstance()->GetAppFrame()->GetFrame();
219 FrameAnimator *pFrameAnimator = pFrame->GetFrameAnimator();
221 Form *nextForm = static_cast<Form*>(pFrame->GetControl(L"Form2"));
223 if(pFrameAnimator->GetStatus() == ANIMATOR_STATUS_STOPPED)
225 pFrameAnimator->SetFormTransitionAnimation (FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_TRANSLATE_LEFT,
227 ANIMATION_INTERPOLATOR_LINEAR );
228 r = pFrameAnimator->SetCurrentForm (nextForm);
231 AppLog("SetCurrentForm on the Form2 Failed.\n");
242 // Transition from Form2 to Form1
244 Form2::OnActionPerformed(const Control& source, int actionId)
248 case ID_FOOTER_BUTTON_TRANSIT:
250 result r = E_SUCCESS;
252 Frame *pFrame = UiApp::GetInstance()->GetAppFrame()->GetFrame();
253 FrameAnimator *pFrameAnimator = pFrame->GetFrameAnimator();
255 Form *nextForm = static_cast<Form*>(pFrame->GetControl(L"Form1"));
256 if(pFrameAnimator->GetStatus() == ANIMATOR_STATUS_STOPPED)
258 pFrameAnimator->SetFormTransitionAnimation(FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_TRANSLATE_RIGHT,
260 ANIMATION_INTERPOLATOR_LINEAR );
261 r = pFrameAnimator->SetCurrentForm (nextForm);
264 AppLog("SetCurrentForm on the Form1 Failed.\n");
277 // Sample code for VisualElement and VisualElementAnimation
280 #include <FUiAnimations.h>
282 using namespace Tizen::Ui::Animations;
283 using namespace Tizen::Ui::Controls;
284 using namespace Tizen::Graphics;
286 class VisualElementSample
287 : public Tizen::Ui::Controls::Form
288 , public Tizen::Ui::IActionEventListener
289 , public Tizen::Ui::Animations::VisualElementContentProvider
292 virtual result OnInitializing(void);
293 virtual result OnTerminating(void);
295 virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
297 virtual void DrawContent(Tizen::Ui::Animations::VisualElement& target, Tizen::Graphics::Canvas& canvas);
300 static const int ID_FOOTER_START_ANIMATION = 101;
302 Tizen::Ui::Animations::VisualElement* __pRect;
306 VisualElementSample::OnInitializing(void)
308 __pRect = new VisualElement();
309 __pRect->Construct();
310 __pRect->SetName(L"Rect");
311 __pRect->SetBounds(FloatRectangle(50.0f, 50.0f, 200.0f, 200.0f));
312 __pRect->SetShowState(true);
313 __pRect->SetContentProvider(this);
315 GetVisualElement()->AttachChild(__pRect);
316 __pRect->InvalidateRectangle(null);
322 VisualElementSample::OnTerminating(void)
330 VisualElementSample::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
334 case ID_FOOTER_START_ANIMATION:
336 VisualElementPropertyAnimation* pAnimation = new VisualElementPropertyAnimation();
337 pAnimation->SetPropertyName(L"opacity");
338 pAnimation->SetStartValue(1.0f);
339 pAnimation->SetEndValue(0.0f);
340 pAnimation->SetDuration(500);
341 pAnimation->SetAutoReverseEnabled(true);
343 __pRect->AddAnimation(*pAnimation);
354 VisualElementSample::DrawContent(Tizen::Ui::Animations::VisualElement& target, Tizen::Graphics::Canvas& canvas)
356 if (target.GetName() == L"Rect")
358 canvas.FillRectangle(Color::GetColor(COLOR_ID_WHITE), Rectangle(0, 0, 200, 200));
373 #endif // _FUI_ANIMATIONS_H_