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