1 #ifndef __DALI_TOOLKIT_PUSH_BUTTON_H__
2 #define __DALI_TOOLKIT_PUSH_BUTTON_H__
5 * Copyright (c) 2014 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
40 * @brief A PushButton changes its appearance when is pressed and returns to its original when is released.
42 * By default a PushButton emits a Button::PressedSignal() signal when the button is pressed, a Button::ClickedSignal() signal when it's clicked
43 * and a Button::ReleasedSignal() signal when it's released or having pressed it, the touch point leaves the boundary of the button.
45 * PushButton provides the following properties which modify signals emitted:
47 * <li>\e autorepeating
49 * When \e autorepeating is set to \e true, a Button::PressedSignal(), Button::ReleasedSignal() and Button::ClickedSignal() signals are emitted at regular
50 * intervals while the button is touched.
52 * The intervals could be modified with the PushButton::SetInitialAutoRepeatingDelay and PushButton::SetNextAutoRepeatingDelay methods.
54 * A \e togglable button can't be \e autorepeating. If the \e autorepeating property is set to \e true, then the \e togglable property is set to
55 * false but no signal is emitted.
59 * When \e togglable is set to \e true, a Button::StateChangedSignal() signal is emitted, with the selected state, every time the button is touched instead
60 * of emit Button::PressedSignal(), Button::ClickedSignal() and Button::ReleasedSignal() signals.
62 * An \e autorepeating button can't be \e togglable. If the \e togglable property is set to \e true, then the \e autorepeating property is set to false.
65 * The button's appearance could be modified by setting images or actors with PushButton::SetButtonImage, PushButton::SetBackgroundImage,
66 * PushButton::SetSelectedImage, PushButton::SetDisabledBackgroundImage and PushButton::SetDisabledImage or setting a text with
67 * PushButton::SetLabel.
69 * The \e background is always shown and doesn't change if the button is pressed or released. The \e button image is shown over the \e background image when the
70 * button is not pressed and is replaced by the \e selected image when the button is pressed. The text label is placed always on the top of all images.
72 * When the button is disabled, \e background, \e button and \e selected images are replaced by their \e disabled images.
74 * The methods used to modify the button's appearance could receive Dali::Actor objects as a parameter, so more complex images could be defined.
76 * Is not mandatory set all images. A button could be defined only by setting its \e background image or by setting its \e background and \e selected images.
78 class DALI_IMPORT_API PushButton : public Button
83 * @brief Create an uninitialized PushButton; this can be initialized with PushButton::New().
85 * Calling member functions with an uninitialized Dali::Object is not allowed.
90 * @brief Copy constructor.
92 PushButton( const PushButton& pushButton );
95 * @brief Assignment operator.
97 PushButton& operator=( const PushButton& pushButton );
102 * This is non-virtual since derived Handle types must not contain data or virtual methods.
107 * @brief Create an initialized PushButton.
109 * @return A handle to a newly allocated Dali resource.
111 static PushButton New();
114 * @brief Downcast an Object handle to PushButton.
116 * If handle points to a PushButton the downcast produces valid
117 * handle. If not the returned handle is left uninitialized.
119 * @param[in] handle Handle to an object
120 * @return handle to a PushButton or an uninitialized handle
122 static PushButton DownCast( BaseHandle handle );
125 * @brief Sets the button image.
127 * @param[in] image The button image.
129 void SetButtonImage( Image image );
132 * @brief SetButtonImage
134 * @param[in] image The Actor to be used as the button image.
136 * The natural size of the button would be the size of this Actor
137 * if it's larger than the background and label
139 void SetButtonImage( Actor image );
142 * @brief Gets the button image.
144 * @return An actor with the button image.
146 Actor GetButtonImage() const;
149 * @brief Sets the background image.
151 * @param[in] image The background image.
153 void SetBackgroundImage( Image image );
156 * @brief SetBackgroundImage
158 * @param[in] image The Actor to be used as the background image.
160 * The natural size of the button would be the size of this Actor
161 * if it's larger than the button and label
163 void SetBackgroundImage( Actor image );
166 * @brief Gets the background image.
168 * @return An actor with the background image.
170 Actor GetBackgroundImage() const;
173 * @brief Sets the selected image.
175 * @param[in] image The selected image.
177 void SetSelectedImage( Image image );
180 * @copydoc SetSelectedImage( Image image )
182 void SetSelectedImage( Actor image );
185 * @brief Gets the selected image.
187 * @return An actor with the selected image.
189 Actor GetSelectedImage() const;
192 * @brief Sets the selected background image.
194 * @param[in] image The selected background image.
196 void SetSelectedBackgroundImage( Image image );
199 * @copydoc SetSelectedBackgroundImage( Image image )
201 void SetSelectedBackgroundImage( Actor image );
204 * @brief Gets the selected background image.
206 * @return An actor with the selected background image.
208 Actor GetSelectedBackgroundImage() const;
211 * @brief Sets the disabled background image.
213 * @param[in] image The disabled background image.
215 void SetDisabledBackgroundImage( Image image );
218 * @copydoc SetDisabledBackgroundImage( Image image )
220 void SetDisabledBackgroundImage( Actor image );
223 * @brief Gets the disabled background image.
225 * @return An actor with the disabled background image.
227 Actor GetDisabledBackgroundImage() const;
230 * @brief Sets the disabled button image.
232 * @param[in] image The disabled button image.
234 void SetDisabledImage( Image image );
237 * @copydoc SetDisabledImage( Image image )
239 void SetDisabledImage( Actor image );
242 * @brief Gets the disabled image.
244 * @return An actor with the disabled image.
246 Actor GetDisabledImage() const;
248 public: // Not intended for application developers
251 * @brief Creates a handle using the Toolkit::Internal implementation.
253 * @param[in] implementation The Control implementation.
255 DALI_INTERNAL PushButton( Internal::PushButton& implementation );
258 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
260 * @param[in] internal A pointer to the internal CustomActor.
262 DALI_INTERNAL PushButton( Dali::Internal::CustomActor* internal );
265 } // namespace Toolkit
269 #endif // __DALI_TOOLKIT_PUSH_BUTTON_H__