1 #ifndef __DALI_TOOLKIT_TOGGLE_BUTTON_H__
2 #define __DALI_TOOLKIT_TOGGLE_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.
22 #include <dali-toolkit/public-api/controls/buttons/button.h>
30 // Forward declarations
32 namespace Internal DALI_INTERNAL
34 // Forward declarations
39 * @addtogroup dali_toolkit_controls_buttons
44 * @brief A ToggleButton allows the user to change a setting between two or more states.
46 * By default a ToggleButton emits a Button::StateChangedSignal() signal when it's clicked.
52 * void ToggleButtonExample::Create( Application& application )
54 * ToggleButton button = ToggleButton::New();
55 * button.SetProperty( Toolkit::ToggleButton::Property::STATE_VISUALS, Property::Array()
61 * Property::Map propertyMap1;
62 * Vector4 testColor1( 1.f, 0.5f, 0.3f, 0.2f );
63 * propertyMap1.Insert(Visual::Property::TYPE, Visual::COLOR);
64 * propertyMap1.Insert(ColorVisual::Property::MIX_COLOR, testColor1);
66 * Property::Map propertyMap2;
67 * Vector4 testColor2( 0.5f, 1.f, 0.3f, 0.2f );
68 * propertyMap2.Insert(Visual::Property::TYPE, Visual::COLOR);
69 * propertyMap2.Insert(ColorVisual::Property::MIX_COLOR, testColor2);
71 * Property::Map propertyMap3;
72 * Vector4 testColor3( 1.f, 0.5f, 1.f, 0.2f );
73 * propertyMap3.Insert(Visual::Property::TYPE, Visual::COLOR);
74 * propertyMap3.Insert(ColorVisual::Property::MIX_COLOR, testColor3);
76 * button.SetProperty( Toolkit::ToggleButton::Property::STATE_VISUALS, Property::Array()
77 * .Add( propertyMap1 )
78 * .Add( propertyMap2 )
79 * .Add( propertyMap3 ));
81 * button.SetProperty( Toolkit::ToggleButton::Property::TOOLTIPS, Property::Array()
86 * Stage::GetCurrent().Add( button );
88 * // Connect to button signals emitted by the button
89 * button.ClickedSignal().Connect( this, &ToggleButtonExample::OnButtonClicked );
92 * bool ToggleButtonExample::OnButtonClicked( Button button )
94 * // Do something when the button is clicked
99 * See Button for more detail on signals and modifying states via properties.
101 class DALI_IMPORT_API ToggleButton : public Button
105 * @brief The start and end property ranges for this control.
109 PROPERTY_START_INDEX = Button::PROPERTY_END_INDEX + 1, ///< Toggle button start index
110 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserving 1000 property indices
114 * @brief An enumeration of properties belonging to the ToggleButton class.
121 * @brief The state visual array of toggle button.
122 * @details Name "stateVisuals", type Property::Array.
123 * It's a property array of property-maps or a property array of strings,
124 * property map expects a description of visual and
125 * string represents an image url.
128 STATE_VISUALS = PROPERTY_START_INDEX,
131 * @brief The tooltips of toggle button.
132 * @details Name "tooltips", type Property::Array.
133 * It's an array of toggle state tooltip strings.
134 * Each tooltip string should match a toggle state strictly.
140 * @brief The current state index of toggle button.
141 * @details Name "currentStateIndex", type integer.
142 * It just provides a property to get current state index.
144 * @note The index is automatically changed when toggle button is clicked.
153 * @brief Create an uninitialized ToggleButton; this can be initialized with ToggleButton::New().
155 * Calling member functions with an uninitialized Dali::Object is not allowed.
160 * @brief Copy constructor.
161 * @param[in] toggleButton Handle to an object
163 ToggleButton( const ToggleButton& toggleButton );
166 * @brief Assignment operator.
167 * @param[in] toggleButton Handle to an object
168 * @return A reference to this
170 ToggleButton& operator=( const ToggleButton& toggleButton );
175 * This is non-virtual since derived Handle types must not contain data or virtual methods.
180 * @brief Create an initialized ToggleButton.
182 * @return A handle to a newly allocated Dali resource.
184 static ToggleButton New();
187 * @brief Downcast a handle to ToggleButton handle.
189 * If handle points to a ToggleButton the downcast produces valid
190 * handle. If not the returned handle is left uninitialized.
192 * @param[in] handle Handle to an object
193 * @return handle to a ToggleButton or an uninitialized handle
195 static ToggleButton DownCast( BaseHandle handle );
197 public: // Not intended for application developers
201 * @brief Creates a handle using the Toolkit::Internal implementation.
203 * @param[in] implementation The Control implementation.
205 DALI_INTERNAL ToggleButton( Internal::ToggleButton& implementation );
208 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
210 * @param[in] internal A pointer to the internal CustomActor.
212 DALI_INTERNAL ToggleButton( Dali::Internal::CustomActor* internal );
219 } // namespace Toolkit
223 #endif // __DALI_TOOLKIT_TOGGLE_BUTTON_H__