1 #ifndef __DALI_TOOLKIT_PUSH_BUTTON_H__
2 #define __DALI_TOOLKIT_PUSH_BUTTON_H__
5 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
30 // Forward declarations
32 namespace Internal DALI_INTERNAL
34 // Forward declarations
39 * @addtogroup dali_toolkit_controls_buttons
44 * @brief A PushButton changes its appearance when is pressed and returns to its original when is released.
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.
52 * // in Creating a DALi Application
53 * void HelloWorldExample::Create( Application& application )
55 * PushButton button = PushButton::New();
56 * button.SetParentOrigin( ParentOrigin::CENTER );
57 * button.SetProperty( Button::Property::LABEL, "Press" );
58 * Stage::GetCurrent().Add( button );
60 * // Connect to button signals emitted by the button
61 * button.ClickedSignal().Connect( this, &HelloWorldExample::OnButtonClicked );
62 * button.PressedSignal().Connect( this, &HelloWorldExample::OnButtonPressed );
63 * button.ReleasedSignal().Connect( this, &HelloWorldExample::OnButtonReleased );
66 * bool HelloWorldExample::OnButtonClicked( Button button )
68 * // Do something when the button is clicked
72 * bool HelloWorldExample::OnButtonPressed( Button button )
74 * // Do something when the button is pressed
78 * bool HelloWorldExample::OnButtonReleased( Button button )
80 * // Do something when the button is released
85 * See Button for more detail on signals and modifying appearance via properties.
88 class DALI_IMPORT_API PushButton : public Button
93 * @brief The start and end property ranges for this control.
98 PROPERTY_START_INDEX = Button::PROPERTY_END_INDEX + 1, ///< @SINCE_1_0.0
99 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserving 1000 property indices @SINCE_1_0.0
103 * @brief An enumeration of properties belonging to the PushButton class.
109 * @brief An enumeration of properties belonging to the PushButton class.
114 UNSELECTED_ICON = PROPERTY_START_INDEX, ///< Property, name "unselectedIcon", type std::string @SINCE_1_0.0 @DEPRECATED_1_2.XX Button::Property::UNSELECTED_VISUAL
115 SELECTED_ICON, ///< Property, name "selectedIcon", type std::string @SINCE_1_0.0 @DEPRECATED_1_2.XX Button::Property::SELECTED_VISUAL
116 ICON_ALIGNMENT, ///< Property, name "iconAlignment", type std::string @SINCE_1_0.0 @DEPRECATED_1_2.XX Use Button::Property::LABEL_RELATIVE_ALIGNMENT
117 LABEL_PADDING, ///< Property, name "labelPadding", type Vector4 @SINCE_1_0.0
118 ICON_PADDING, ///< Property, name "iconPadding", type Vector4 @SINCE_1_0.0
125 * @brief Create an uninitialized PushButton; this can be initialized with PushButton::New().
127 * Calling member functions with an uninitialized Dali::Object is not allowed.
133 * @brief Copy constructor.
135 * @param[in] pushButton Handle to an object
137 PushButton( const PushButton& pushButton );
140 * @brief Assignment operator.
142 * @param[in] pushButton Handle to an object
143 * @return A reference to this
145 PushButton& operator=( const PushButton& pushButton );
150 * This is non-virtual since derived Handle types must not contain data or virtual methods.
156 * @brief Create an initialized PushButton.
159 * @return A handle to a newly allocated Dali resource.
161 static PushButton New();
164 * @brief Downcast a handle to PushButton handle.
166 * If handle points to a PushButton the downcast produces valid
167 * handle. If not the returned handle is left uninitialized.
170 * @param[in] handle Handle to an object
171 * @return handle to a PushButton or an uninitialized handle
173 static PushButton DownCast( BaseHandle handle );
175 ///////////////////////////////////////////////////////////////////////////
178 using Button::SetButtonImage;
181 * @DEPRECATED_1_0.50. Instead, use Button::SetUnselectedImage.
183 * @brief Sets the unselected image with an Actor.
186 * @param[in] image The Actor to use.
188 void SetButtonImage( Actor image ) DALI_DEPRECATED_API;
190 using Button::SetBackgroundImage;
193 * @DEPRECATED_1_0.50. Instead, use Button::SetBackgroundImage.
195 * @brief Sets the background image with an Actor.
198 * @param[in] image The Actor to use.
200 void SetBackgroundImage( Actor image ) DALI_DEPRECATED_API;
202 using Button::SetSelectedImage;
205 * @DEPRECATED_1_0.50. Instead, use Button::SetSelectedImage( const std::string& filename ).
207 * @brief Sets the selected image with an Actor.
210 * @param[in] image The Actor to use.
212 void SetSelectedImage( Actor image ) DALI_DEPRECATED_API;
214 using Button::SetSelectedBackgroundImage;
217 * @DEPRECATED_1_0.50. Instead, use Button::SetSelectedBackgroundImage.
219 * @brief Sets the selected background image with an Actor.
222 * @param[in] image The Actor to use.
224 void SetSelectedBackgroundImage( Actor image ) DALI_DEPRECATED_API;
226 using Button::SetDisabledBackgroundImage;
229 * @DEPRECATED_1_0.50. Instead, use Button::SetDisabledBackgroundImage.
231 * @brief Sets the disabled background image with an Actor.
234 * @param[in] image The Actor to use.
236 void SetDisabledBackgroundImage( Actor image ) DALI_DEPRECATED_API;
238 using Button::SetDisabledImage;
241 * @DEPRECATED_1_0.50. Instead, use Button::SetDisabledImage.
243 * @brief Sets the disabled image with an Actor.
246 * @param[in] image The Actor to use.
248 void SetDisabledImage( Actor image ) DALI_DEPRECATED_API;
250 using Button::SetDisabledSelectedImage;
253 * @DEPRECATED_1_0.50. Instead, use Button::SetDisabledSelectedImage.
255 * @brief Sets the disabled selected image with an Actor.
258 * @param[in] image The Actor to use.
260 void SetDisabledSelectedImage( Actor image ) DALI_DEPRECATED_API;
263 public: // Not intended for application developers
267 * @brief Creates a handle using the Toolkit::Internal implementation.
270 * @param[in] implementation The Control implementation.
272 DALI_INTERNAL PushButton( Internal::PushButton& implementation );
275 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
278 * @param[in] internal A pointer to the internal CustomActor.
280 DALI_INTERNAL PushButton( Dali::Internal::CustomActor* internal );
287 } // namespace Toolkit
291 #endif // __DALI_TOOLKIT_PUSH_BUTTON_H__