Use Property:LABEL instead of SetLabelText for buttons
[platform/core/uifw/dali-demo.git] / examples / transitions / beat-control-impl.h
1 #ifndef DALI_DEMO_INTERNAL_BEAT_CONTROL_IMPL_H
2 #define DALI_DEMO_INTERNAL_BEAT_CONTROL_IMPL_H
3
4 /*
5  * Copyright (c) 2016 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 #include "beat-control.h"
21 #include <dali/public-api/animation/animation.h>
22 #include <dali-toolkit/public-api/controls/control-impl.h>
23 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
24 #include <dali-toolkit/devel-api/visual-factory/transition-data.h>
25
26 namespace Demo
27 {
28
29 namespace Internal // To use TypeRegistry, handle and body classes need the same name
30 {
31
32 class BeatControl : public Dali::Toolkit::Internal::Control
33 {
34 public:
35   /**
36    * Instantiate a new BeatControl object
37    */
38   static Demo::BeatControl New();
39   BeatControl();
40   ~BeatControl();
41
42 public: // API
43   void StartBounceAnimation();
44
45   void StartXAnimation();
46
47   void StartYAnimation();
48
49 public:  // Properties
50   /**
51    * Called when a property of an object of this type is set.
52    * @param[in] object The object whose property is set.
53    * @param[in] index The property index.
54    * @param[in] value The new property value.
55    */
56   static void SetProperty( Dali::BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value );
57
58   /**
59    * Called to retrieve a property of an object of this type.
60    * @param[in] object The object whose property is to be retrieved.
61    * @param[in] index The property index.
62    * @return The current value of the property.
63    */
64   static Dali::Property::Value GetProperty( Dali::BaseObject* object, Dali::Property::Index propertyIndex );
65
66 private: // From Control
67   /**
68    * @copydoc Toolkit::Control::OnInitialize()
69    */
70   virtual void OnInitialize();
71
72   /**
73    * @copydoc Toolkit::Control::OnStageConnect()
74    */
75   virtual void OnStageConnection( int depth );
76
77   /**
78    * @copydoc Toolkit::Control::OnStageDisconnection()
79    */
80   virtual void OnStageDisconnection();
81
82   /**
83    * @copydoc Toolkit::Control::OnSizeSet()
84    */
85   virtual void OnSizeSet( const Dali::Vector3& targetSize );
86
87   /**
88    * @copydoc Toolkit::Control::OnRelayout()
89    */
90   virtual void OnRelayout( const Dali::Vector2& targetSize, Dali::RelayoutContainer& container );
91   /**
92    * @copydoc Toolkit::Control::GetNaturalSize
93    */
94   virtual Dali::Vector3 GetNaturalSize();
95
96   /**
97    * @copydoc Toolkit::Control::OnStyleChange
98    */
99   virtual void OnStyleChange( Dali::Toolkit::StyleManager styleManager, Dali::StyleChange::Type change );
100
101 private:
102   void OnBounceAnimationFinished( Dali::Animation& handle );
103   void OnXAnimationFinished( Dali::Animation& src );
104   void OnYAnimationFinished( Dali::Animation& src );
105
106   /**
107    * Relayout the visuals as a result of size negotiation
108    */
109   void RelayoutVisuals( const Dali::Vector2& targetSize );
110
111 private:
112   //undefined
113   BeatControl( const BeatControl& );
114   BeatControl& operator=( const BeatControl& );
115
116 private:
117   // Implementation details
118   Dali::Toolkit::Visual::Base mVisual;
119   Dali::Toolkit::TransitionData mBounceTransition;
120   Dali::Toolkit::TransitionData mLeftTransition;
121   Dali::Toolkit::TransitionData mUpTransition;
122   Dali::Animation mAnimation;
123   Dali::Animation mXAnimation;
124   Dali::Animation mYAnimation;
125 };
126
127 } // Internal
128
129 inline Internal::BeatControl& GetImpl( Demo::BeatControl& handle )
130 {
131   DALI_ASSERT_ALWAYS( handle );
132   Dali::RefObject& object = handle.GetImplementation();
133   return static_cast<Internal::BeatControl&>(object);
134 }
135
136 inline const Internal::BeatControl& GetImpl( const Demo::BeatControl& handle )
137 {
138   DALI_ASSERT_ALWAYS( handle );
139   const Dali::RefObject& object = handle.GetImplementation();
140   return static_cast<const Internal::BeatControl&>(object);
141 }
142
143 } // Demo
144
145 #endif //  DALI_DEMO_BEAT_CONTROL_IMPL_H