Merge "New handle flip implementation." into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / buttons / push-button.h
1 #ifndef __DALI_TOOLKIT_PUSH_BUTTON_H__
2 #define __DALI_TOOLKIT_PUSH_BUTTON_H__
3
4 /*
5  * Copyright (c) 2015 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 "button.h"
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 // Forward declarations
31
32 namespace Internal DALI_INTERNAL
33 {
34 // Forward declarations
35
36 class PushButton;
37 }
38 /**
39  * @addtogroup dali-toolkit-controls-buttons
40  * @{
41  */
42
43 /**
44  * @brief A PushButton changes its appearance when is pressed and returns to its original when is released.
45  *
46  * By default a PushButton emits a Button::PressedSignal() signal when the button is pressed, a Button::ClickedSignal() signal when it's clicked
47  * and a Button::ReleasedSignal() signal when it's released or having pressed it, the touch point leaves the boundary of the button.
48  *
49  * See Button for more detail on signals and modifying appearance via properties.
50  */
51 class DALI_IMPORT_API PushButton : public Button
52 {
53 public:
54
55   /**
56    * @brief The start and end property ranges for this control.
57    */
58   enum PropertyRange
59   {
60     PROPERTY_START_INDEX = Button::PROPERTY_END_INDEX + 1,
61     PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000              ///< Reserving 1000 property indices
62   };
63
64   /**
65    * @brief An enumeration of properties belonging to the PushButton class.
66    */
67   struct Property
68   {
69     enum
70     {
71       UNSELECTED_ICON = PROPERTY_START_INDEX, ///< Property, name "unselected-icon", type std::string
72       SELECTED_ICON,                          ///< Property, name "selected-icon",   type std::string
73       ICON_ALIGNMENT,                         ///< Property, name "icon-alignment",  type std::string
74       LABEL_PADDING,                          ///< Property, name "label-padding",   type Vector4
75       ICON_PADDING,                           ///< Property, name "icon-padding",    type Vector4
76     };
77   };
78
79 public:
80
81   /**
82    * @brief Create an uninitialized PushButton; this can be initialized with PushButton::New().
83    *
84    * Calling member functions with an uninitialized Dali::Object is not allowed.
85    */
86   PushButton();
87
88   /**
89    * @brief Copy constructor.
90    */
91   PushButton( const PushButton& pushButton );
92
93   /**
94    * @brief Assignment operator.
95    */
96   PushButton& operator=( const PushButton& pushButton );
97
98   /**
99    * @brief Destructor
100    *
101    * This is non-virtual since derived Handle types must not contain data or virtual methods.
102    */
103   ~PushButton();
104
105   /**
106    * @brief Create an initialized PushButton.
107    *
108    * @return A handle to a newly allocated Dali resource.
109    */
110   static PushButton New();
111
112   /**
113    * @brief Downcast an Object handle to PushButton.
114    *
115    * If handle points to a PushButton the downcast produces valid
116    * handle. If not the returned handle is left uninitialized.
117    *
118    * @param[in] handle Handle to an object
119    * @return handle to a PushButton or an uninitialized handle
120    */
121   static PushButton DownCast( BaseHandle handle );
122
123
124   // Deprecated API
125
126   using Button::SetButtonImage;
127
128   /**
129    * @deprecated Sets the unselected image with an Actor.
130    * @param[in] image The Actor to use.
131    */
132   void SetButtonImage( Actor image );
133
134   using Button::SetBackgroundImage;
135
136   /**
137    * @deprecated Sets the background image with an Actor.
138    * @param[in] image The Actor to use.
139    */
140   void SetBackgroundImage( Actor image );
141
142   using Button::SetSelectedImage;
143
144   /**
145    * @deprecated Sets the selected image with an Actor.
146    * @param[in] image The Actor to use.
147    */
148   void SetSelectedImage( Actor image );
149
150   using Button::SetSelectedBackgroundImage;
151
152   /**
153    * @deprecated Sets the selected background image with an Actor.
154    * @param[in] image The Actor to use.
155    */
156   void SetSelectedBackgroundImage( Actor image );
157
158   using Button::SetDisabledBackgroundImage;
159
160   /**
161    * @deprecated Sets the disabled background image with an Actor.
162    * @param[in] image The Actor to use.
163    */
164   void SetDisabledBackgroundImage( Actor image );
165
166   using Button::SetDisabledImage;
167
168   /**
169    * @deprecated Sets the disabled image with an Actor.
170    * @param[in] image The Actor to use.
171    */
172   void SetDisabledImage( Actor image );
173
174   using Button::SetDisabledSelectedImage;
175
176   /**
177    * @deprecated Sets the disabled selected image with an Actor.
178    * @param[in] image The Actor to use.
179    */
180   void SetDisabledSelectedImage( Actor image );
181
182
183 public: // Not intended for application developers
184
185   /**
186    * @brief Creates a handle using the Toolkit::Internal implementation.
187    *
188    * @param[in]  implementation  The Control implementation.
189    */
190   DALI_INTERNAL PushButton( Internal::PushButton& implementation );
191
192   /**
193    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
194    *
195    * @param[in]  internal  A pointer to the internal CustomActor.
196    */
197   DALI_INTERNAL PushButton( Dali::Internal::CustomActor* internal );
198 };
199
200 /**
201  * @}
202  */
203 } // namespace Toolkit
204
205 } // namespace Dali
206
207 #endif // __DALI_TOOLKIT_PUSH_BUTTON_H__