1 #ifndef __DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H__
2 #define __DALI_TOOLKIT_INTERNAL_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.
22 #include <dali/public-api/common/vector-wrapper.h>
25 #include <dali-toolkit/public-api/controls/buttons/push-button.h>
26 #include "button-impl.h"
38 * PushButton implementation class.
40 * \sa Dali::Toolkit::PushButton
42 class PushButton : public Button
47 * Create a new PushButton.
48 * @return A smart-pointer to the newly allocated PushButton.
50 static Dali::Toolkit::PushButton New();
55 * Construct a new PushButton.
60 * A reference counted object may only be deleted by calling Unreference()
62 virtual ~PushButton();
69 * Enum for the alignment modes of the icon.
81 * Called when a property of an object of this type is set.
82 * @param[in] object The object whose property is set.
83 * @param[in] index The property index.
84 * @param[in] value The new property value.
86 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
89 * Called to retrieve a property of an object of this type.
90 * @param[in] object The object whose property is to be retrieved.
91 * @param[in] index The property index.
92 * @return The current value of the property.
94 static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
96 private: // From Button
99 * @copydoc Toolkit::Internal::Button::OnInitialize
101 virtual void OnInitialize();
104 * @copydoc Toolkit::Internal::Button::OnLabelSet
106 virtual void OnLabelSet( bool noPadding );
109 * @copydoc Toolkit::Internal::Button::OnButtonImageSet
111 virtual void OnButtonImageSet();
114 * @copydoc Toolkit::Internal::Button::OnSelectedImageSet
116 virtual void OnSelectedImageSet();
119 * @copydoc Toolkit::Internal::Button::OnBackgroundImage
121 virtual void OnBackgroundImageSet();
124 * @copydoc Toolkit::Internal::Button::OnSelectedBackgroundImageSet
126 virtual void OnSelectedBackgroundImageSet();
129 * @copydoc Toolkit::Internal::Button::OnDisabledImageSet
131 virtual void OnDisabledImageSet();
134 * @copydoc Toolkit::Internal::Button::OnDisabledSelectedImageSet
136 virtual void OnDisabledSelectedImageSet();
139 * @copydoc Toolkit::Internal::Button::OnDisabledBackgroundImageSet
141 virtual void OnDisabledBackgroundImageSet();
144 * @copydoc Toolkit::Internal::Button::PrepareForTranstionIn( Actor actor )
146 virtual void PrepareForTranstionIn( Actor actor );
149 * @copydoc Toolkit::Internal::Button::PrepareForTranstionOut( Actor actor )
151 virtual void PrepareForTranstionOut( Actor actor );
154 * @copydoc Toolkit::Internal::Button::OnTransitionIn( Actor actor )
156 virtual void OnTransitionIn( Actor actor );
159 * @copydoc Toolkit::Internal::Button::OnTransitionOut( Actor actor )
161 virtual void OnTransitionOut( Actor actor );
163 private: // From Control
166 * @copydoc CustomActorImpl::OnSizeSet( const Vector3& targetSize )
168 virtual void OnSizeSet( const Vector3& targetSize );
171 * @copydoc Toolkit::Control::GetNaturalSize
173 virtual Vector3 GetNaturalSize();
176 * @copydoc Toolkit::Control::OnSetResizePolicy
178 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension );
183 * It adds the actor to the root actor and to the fade in animation.
184 * @param[inout] actor The actor.
185 * @param[in] opacity The opacity to fade to
187 void FadeImageTo( Actor actor, float opacity );
190 * @brief Custom configuration for size negotiation
192 void ConfigureSizeNegotiation();
195 * @brief Configure size negotiation for a given dimension
197 * @param[in] dimension The dimension to configure
198 * @param[in] images The list of images to configure
199 * @param[in] label The text label to configure
201 void ConfigureSizeNegotiationDimension( Dimension::Type dimension, const std::vector< Actor >& images, Actor& label );
204 * @brief Sets either the selected or unselected icon.
206 * @param[in] state The icon state to set
207 * @param[in] iconFilename The filename of the icon
209 void SetIcon( DecorationState state, const std::string iconFilename );
212 * @brief Gets either the selected or unselected icon.
214 * @param[in] state The icon state to get
215 * @return The filename of the icon
217 std::string& GetIcon( DecorationState state );
220 * @brief Sets the alignment mode to use to align the icon to the label.
222 * @param[in] iconAlignment The alignment mode to use
224 void SetIconAlignment( const PushButton::IconAlignment iconAlignment );
227 * @brief Gets the alignment mode used to align the icon to the label.
229 * @return The alignment mode in use
231 const PushButton::IconAlignment GetIconAlignment() const;
234 * @brief Sets the padding for the label.
236 * @param[in] padding The padding to set
238 void SetLabelPadding( const Vector4& padding );
241 * @brief Gets the padding for the label.
243 * @return The label padding
245 Vector4 GetLabelPadding();
248 * @brief Sets the padding for the icon.
250 * @param[in] padding The padding to set
252 void SetIconPadding( const Vector4& padding );
255 * @brief Gets the padding for the icon.
257 * @return The icon padding
259 Vector4 GetIconPadding();
264 PushButton( const PushButton& );
267 PushButton& operator=( const PushButton& );
271 std::string mIconName[ DECORATION_STATES ]; ///< The original filenames for the icons.
272 Padding mLabelPadding; ///< The padding around the label (if present).
273 Padding mIconPadding; ///< The padding around the icon (if present).
274 IconAlignment mIconAlignment; ///< The alignment of the icon against the label.
275 Vector3 mSize; ///< The button's size.
278 } // namespace Internal
280 // Helpers for public-api forwarding methods
282 inline Toolkit::Internal::PushButton& GetImplementation( Toolkit::PushButton& button )
284 DALI_ASSERT_ALWAYS( button );
286 Dali::RefObject& handle = button.GetImplementation();
288 return static_cast<Toolkit::Internal::PushButton&>( handle );
291 inline const Toolkit::Internal::PushButton& GetImplementation( const Toolkit::PushButton& button )
293 DALI_ASSERT_ALWAYS( button );
295 const Dali::RefObject& handle = button.GetImplementation();
297 return static_cast<const Toolkit::Internal::PushButton&>( handle );
300 } // namespace Toolkit
304 #endif // __DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H__