Dali 3D User Interface Engine
animation-impl.h
Go to the documentation of this file.
1 #ifndef __DALI_INTERNAL_ANIMATION_H__
2 #define __DALI_INTERNAL_ANIMATION_H__
3 
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20 
21 // INTERNAL INCLUDES
29 
30 namespace Dali
31 {
32 
33 namespace Internal
34 {
35 
36 namespace SceneGraph
37 {
38 class Animation;
39 class UpdateManager;
40 }
41 
42 class Actor;
43 class Animation;
44 class AnimationPlaylist;
45 class Object;
47 
49 typedef std::vector<AnimationPtr> AnimationContainer;
50 
51 typedef AnimationContainer::iterator AnimationIter;
52 typedef AnimationContainer::const_iterator AnimationConstIter;
53 
59 class Animation : public BaseObject
60 {
61 public:
62 
65 
66  typedef void (*FinishedCallback)(Object* object);
67 
73  static AnimationPtr New(float durationSeconds);
74 
78  void SetDuration(float seconds);
79 
83  float GetDuration() const;
84 
88  void SetLooping(bool on);
89 
93  void SetLoopCount(int count);
94 
98  int GetLoopCount();
99 
103  int GetCurrentLoop();
104 
108  bool IsLooping() const;
109 
113  void SetEndAction(EndAction action);
114 
118  EndAction GetEndAction() const;
119 
123  void SetDisconnectAction(EndAction action);
124 
129 
134  {
135  mDefaultAlpha = alpha;
136  }
137 
142  {
143  return mDefaultAlpha;
144  }
145 
149  void Play();
150 
154  void PlayFrom( float progress );
155 
159  void Pause();
160 
165 
169  void Stop();
170 
174  void Clear();
175 
181  bool HasFinished();
182 
187 
191  void EmitSignalFinish();
192 
202  static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
203 
211  static bool DoAction(BaseObject* object, const std::string& actionName, const Property::Map& attributes);
212 
218  void SetFinishedCallback( FinishedCallback callback, Object* object );
219 
223  void AnimateBy(Property& target, Property::Value& relativeValue);
224 
228  void AnimateBy(Property& target, Property::Value& relativeValue, AlphaFunction alpha);
229 
233  void AnimateBy(Property& target, Property::Value& relativeValue, TimePeriod period);
234 
238  void AnimateBy(Property& target, Property::Value& relativeValue, AlphaFunction alpha, TimePeriod period);
239 
243  void AnimateTo(Property& target, Property::Value& destinationValue);
244 
248  void AnimateTo(Property& target, Property::Value& destinationValue, AlphaFunction alpha);
249 
253  void AnimateTo(Property& target, Property::Value& destinationValue, TimePeriod period);
254 
258  void AnimateTo(Property& target, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period);
259 
269  void AnimateTo(Object& targetObject, Property::Index targetPropertyIndex, int componentIndex, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period);
270 
274  void AnimateBetween(Property target, const KeyFrames& keyFrames);
275 
279  void AnimateBetween(Property target, const KeyFrames& keyFrames, Interpolation interpolation );
280 
284  void AnimateBetween(Property target, const KeyFrames& keyFrames, TimePeriod period);
285 
289  void AnimateBetween(Property target, const KeyFrames& keyFrames, TimePeriod period, Interpolation interpolation);
290 
294  void AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha);
295 
299  void AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, Interpolation interpolation);
300 
304  void AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period);
305 
309  void AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period, Interpolation interpolation );
310 
311  // Actor-specific convenience functions
312 
316  void Animate( Actor& actor, const Path& path, const Vector3& forward );
317 
321  void Animate( Actor& actor, const Path& path, const Vector3& forward, AlphaFunction alpha );
322 
326  void Animate( Actor& actor, const Path& path, const Vector3& forward, TimePeriod period );
327 
331  void Animate( Actor& actor, const Path& path, const Vector3& forward, AlphaFunction alpha, TimePeriod period);
332 
336  void Show(Actor& actor, float delaySeconds);
337 
341  void Hide(Actor& actor, float delaySeconds);
342 
343  /*
344  * @copydoc Dali::Animation::SetCurrentProgress()
345  */
346  void SetCurrentProgress(float progress);
347 
348  /*
349  * @copydoc Dali::Animation::GetCurrentProgress()
350  */
351  float GetCurrentProgress();
352 
353  /*
354  * @copydoc Dali::Animation::SetSpeedFactor()
355  */
356  void SetSpeedFactor( float factor );
357 
358  /*
359  * @copydoc Dali::Animation::GetSpeedFactor()
360  */
361  float GetSpeedFactor() const;
362 
363  /*
364  * @copydoc Dali::Animation::SetPlayRange()
365  */
366  void SetPlayRange( const Vector2& range );
367 
368  /*
369  * @copydoc Dali::Animation::GetPlayRange
370  */
371  Vector2 GetPlayRange() const;
372 
373 public: // For connecting animators to animations
374 
379  void AddAnimatorConnector( AnimatorConnectorBase* connector );
380 
386  {
387  return mAnimation;
388  }
389 
395  {
396  return mEventThreadServices;
397  }
398 
399 protected:
400 
410  Animation( EventThreadServices& eventThreadServices,
411  AnimationPlaylist& playlist,
412  float durationSeconds,
413  EndAction endAction,
414  EndAction disconnectAction,
415  AlphaFunction defaultAlpha);
416 
420  void Initialize();
421 
425  void CreateSceneObject();
426 
430  void DestroySceneObject();
431 
435  virtual ~Animation();
436 
437 private:
438 
443  void ExtendDuration( const TimePeriod& timePeriod );
444 
445  // Undefined
446  Animation(const Animation&);
447 
448  // Undefined
449  Animation& operator=(const Animation& rhs);
450 
451 private:
454 
456 
458 
460 
463 
465 
466  // Cached for public getters
476 
477 };
478 
479 } // namespace Internal
480 
481 // Helpers for public-api forwarding methods
482 
484 {
485  DALI_ASSERT_ALWAYS( animation && "Animation handle is empty" );
486 
487  BaseObject& handle = animation.GetBaseObject();
488 
489  return static_cast<Internal::Animation&>(handle);
490 }
491 
493 {
494  DALI_ASSERT_ALWAYS( animation && "Animation handle is empty" );
495 
496  const BaseObject& handle = animation.GetBaseObject();
497 
498  return static_cast<const Internal::Animation&>(handle);
499 }
500 
501 } // namespace Dali
502 
503 #endif // __DALI_INTERNAL_ANIMATION_H__
Dali Docs Home
Read more about Dali