DALi signals refactor to remove V2 naming
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / controls / buttons / button.h
1 #ifndef __DALI_TOOLKIT_BUTTON_H__
2 #define __DALI_TOOLKIT_BUTTON_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
22 #include <dali-toolkit/public-api/controls/control.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 namespace Internal DALI_INTERNAL
31 {
32 class Button;
33 }
34
35 /**
36  * @brief Button is a base class for different kind of buttons.
37  *
38  * This class provides the dimmed property and the clicked signal.
39  *
40  * A ClickedSignal() is emitted when the button is touched and the touch
41  * point doesn't leave the boundary of the button.
42  *
43  * When the \e dimmed property is set to \e true, no signal is emitted.
44  */
45 class DALI_IMPORT_API Button : public Control
46 {
47 public:
48
49   // Signal Names
50   static const char* const SIGNAL_CLICKED; ///< name "clicked"
51   static const char* const SIGNAL_TOGGLED; ///< name "toggled"
52
53   // Properties
54   static const Property::Index PROPERTY_DIMMED; ///< name "dimmed", @see SetDimmed(), type BOOLEAN
55
56 public:
57
58   /**
59    * @brief Create an uninitialized Button.
60    *
61    * Only derived versions can be instantiated.  Calling member
62    * functions with an uninitialized Dali::Object is not allowed.
63    */
64   Button();
65
66   /**
67    * @brief Copy constructor.
68    */
69   Button( const Button& button );
70
71   /**
72    * @brief Assignment operator.
73    */
74   Button& operator=( const Button& button );
75
76   /**
77    * @brief Downcast an Object handle to Button.
78    *
79    * If handle points to a Button the downcast produces valid
80    * handle. If not the returned handle is left uninitialized.
81    *
82    * @param[in] handle Handle to an object
83    * @return handle to a Button or an uninitialized handle
84    */
85   static Button DownCast( BaseHandle handle );
86
87   /**
88    * @brief Destructor
89    *
90    * This is non-virtual since derived Handle types must not contain data or virtual methods.
91    */
92   ~Button();
93
94   /**
95    * @brief Sets the button as \e dimmed.
96    *
97    * No signals are emitted when the \e dimmed property is set.
98    *
99    * @param[in] dimmed property.
100    */
101   void SetDimmed( bool dimmed );
102
103   /**
104    * @return \e true if the button is \e dimmed.
105    */
106   bool IsDimmed() const;
107
108   /**
109    * @brief Sets the animation time.
110    *
111    * @param [in] animationTime The animation time in seconds.
112    */
113   void SetAnimationTime( float animationTime );
114
115   /**
116    * @brief Retrieves button's animation time.
117    *
118    * @return The animation time in seconds.
119    */
120   float GetAnimationTime() const;
121
122 public: //Signals
123
124   /**
125    * @brief Button Clicked signal type
126    */
127   typedef Signal< bool ( Button ) > ClickedSignalType;
128
129   /**
130    * @brief Button toggled signal type
131    */
132   typedef Signal< bool ( Button, bool ) > ToggledSignalType;
133
134   /**
135    * @brief Signal emitted when the button is touched and the touch point doesn't leave the boundary of the button.
136    */
137   ClickedSignalType& ClickedSignal();
138
139   /**
140    * @brief Signal emitted when the button's state is toggled.
141    */
142   ToggledSignalType& ToggledSignal();
143
144 public: // Not intended for application developers
145
146   /**
147    * @brief Creates a handle using the Toolkit::Internal implementation.
148    *
149    * @param[in]  implementation  The Control implementation.
150    */
151   DALI_INTERNAL Button( Internal::Button& implementation );
152
153   /**
154    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
155    *
156    * @param[in]  internal  A pointer to the internal CustomActor.
157    */
158   DALI_INTERNAL Button( Dali::Internal::CustomActor* internal );
159 };
160
161 } // namespace Toolkit
162
163 } // namespace Dali
164
165 #endif // __DALI_TOOLKIT_BUTTON_H__