1 #ifndef DALI_TOOLKIT_TOGGLE_BUTTON_H
2 #define DALI_TOOLKIT_TOGGLE_BUTTON_H
5 * Copyright (c) 2020 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>
28 // Forward declarations
30 namespace Internal DALI_INTERNAL
32 // Forward declarations
35 } // namespace DALI_INTERNAL
37 * @addtogroup dali_toolkit_controls_buttons
42 * @brief A ToggleButton allows the user to change a setting between two or more states.
44 * By default a ToggleButton emits a Button::StateChangedSignal() signal when it's clicked.
50 * void ToggleButtonExample::Create( Application& application )
52 * ToggleButton button = ToggleButton::New();
53 * button.SetProperty( Toolkit::ToggleButton::Property::STATE_VISUALS, Property::Array()
59 * Property::Map propertyMap1;
60 * Vector4 testColor1( 1.f, 0.5f, 0.3f, 0.2f );
61 * propertyMap1.Insert(Visual::Property::TYPE, Visual::COLOR);
62 * propertyMap1.Insert(ColorVisual::Property::MIX_COLOR, testColor1);
64 * Property::Map propertyMap2;
65 * Vector4 testColor2( 0.5f, 1.f, 0.3f, 0.2f );
66 * propertyMap2.Insert(Visual::Property::TYPE, Visual::COLOR);
67 * propertyMap2.Insert(ColorVisual::Property::MIX_COLOR, testColor2);
69 * Property::Map propertyMap3;
70 * Vector4 testColor3( 1.f, 0.5f, 1.f, 0.2f );
71 * propertyMap3.Insert(Visual::Property::TYPE, Visual::COLOR);
72 * propertyMap3.Insert(ColorVisual::Property::MIX_COLOR, testColor3);
74 * button.SetProperty( Toolkit::ToggleButton::Property::STATE_VISUALS, Property::Array()
75 * .Add( propertyMap1 )
76 * .Add( propertyMap2 )
77 * .Add( propertyMap3 ));
79 * button.SetProperty( Toolkit::ToggleButton::Property::TOOLTIPS, Property::Array()
84 * Stage::GetCurrent().Add( button );
86 * // Connect to button signals emitted by the button
87 * button.ClickedSignal().Connect( this, &ToggleButtonExample::OnButtonClicked );
90 * bool ToggleButtonExample::OnButtonClicked( Button button )
92 * // Do something when the button is clicked
97 * See Button for more detail on signals and modifying states via properties.
99 class DALI_TOOLKIT_API ToggleButton : public Button
103 * @brief The start and end property ranges for this control.
107 PROPERTY_START_INDEX = Button::PROPERTY_END_INDEX + 1, ///< Toggle button start index
108 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserving 1000 property indices
112 * @brief An enumeration of properties belonging to the ToggleButton class.
119 * @brief The state visual array of toggle button.
120 * @details Name "stateVisuals", type Property::Array.
121 * It's a property array of property-maps or a property array of strings,
122 * property map expects a description of visual and
123 * string represents an image url.
126 STATE_VISUALS = PROPERTY_START_INDEX,
129 * @brief The tooltips of toggle button.
130 * @details Name "tooltips", type Property::Array.
131 * It's an array of toggle state tooltip strings.
132 * Each tooltip string should match a toggle state strictly.
138 * @brief The current state index of toggle button.
139 * @details Name "currentStateIndex", type integer.
140 * It just provides a property to get current state index.
142 * @note The index is automatically changed when toggle button is clicked.
150 * @brief Create an uninitialized ToggleButton; this can be initialized with ToggleButton::New().
152 * Calling member functions with an uninitialized Dali::Object is not allowed.
157 * @brief Copy constructor.
158 * @param[in] toggleButton Handle to an object
160 ToggleButton(const ToggleButton& toggleButton);
163 * @brief Assignment operator.
164 * @param[in] toggleButton Handle to an object
165 * @return A reference to this
167 ToggleButton& operator=(const ToggleButton& toggleButton);
172 * This is non-virtual since derived Handle types must not contain data or virtual methods.
177 * @brief Create an initialized ToggleButton.
179 * @return A handle to a newly allocated Dali resource.
181 static ToggleButton New();
184 * @brief Downcast a handle to ToggleButton handle.
186 * If handle points to a ToggleButton the downcast produces valid
187 * handle. If not the returned handle is left uninitialized.
189 * @param[in] handle Handle to an object
190 * @return handle to a ToggleButton or an uninitialized handle
192 static ToggleButton DownCast(BaseHandle handle);
194 public: // Not intended for application developers
197 * @brief Creates a handle using the Toolkit::Internal implementation.
199 * @param[in] implementation The Control implementation.
201 DALI_INTERNAL ToggleButton(Internal::ToggleButton& implementation);
204 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
206 * @param[in] internal A pointer to the internal CustomActor.
208 DALI_INTERNAL ToggleButton(Dali::Internal::CustomActor* internal);
215 } // namespace Toolkit
219 #endif // DALI_TOOLKIT_TOGGLE_BUTTON_H