1 #ifndef DALI_DEMO_INTERNAL_SHADOW_BUTTON_IMPL_H
2 #define DALI_DEMO_INTERNAL_SHADOW_BUTTON_IMPL_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.
20 #include <dali-toolkit/devel-api/visual-factory/transition-data.h>
21 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
22 #include <dali-toolkit/public-api/controls/control-impl.h>
23 #include <dali/public-api/animation/animation.h>
24 #include "shadow-button.h"
28 namespace Internal // To use TypeRegistry, handle and body classes need the same name
30 class ShadowButton : public Dali::Toolkit::Internal::Control
34 * Instantiate a new ShadowButton object
36 static Demo::ShadowButton New();
42 * @brief Set the button to be active or inactive.
44 * The button will perform a transition if there is a state change.
45 * @param[in] active The active state
47 void SetActiveState(bool active);
50 * Get the active state
51 * @return the active state
53 bool GetActiveState();
57 * @param[in] checkState The state of the checkbox
59 void SetCheckState(bool checkState);
63 * @return the check state
69 * Called when a property of an object of this type is set.
70 * @param[in] object The object whose property is set.
71 * @param[in] index The property index.
72 * @param[in] value The new property value.
74 static void SetProperty(Dali::BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value);
77 * Called to retrieve a property of an object of this type.
78 * @param[in] object The object whose property is to be retrieved.
79 * @param[in] index The property index.
80 * @return The current value of the property.
82 static Dali::Property::Value GetProperty(Dali::BaseObject* object, Dali::Property::Index propertyIndex);
84 private: // From Control
86 * @copydoc Toolkit::Button::OnInitialize()
88 virtual void OnInitialize();
91 * @copydoc Toolkit::Button::OnSceneConnection()
93 virtual void OnSceneConnection(int depth);
96 * @copydoc Toolkit::Button::OnSceneDisconnection()
98 virtual void OnSceneDisconnection();
101 * @copydoc Toolkit::Button::OnSizeSet()
103 virtual void OnSizeSet(const Dali::Vector3& targetSize);
106 * @copydoc Toolkit::Button::OnRelayout()
108 virtual void OnRelayout(const Dali::Vector2& targetSize, Dali::RelayoutContainer& container);
110 * @copydoc Toolkit::Button::GetNaturalSize
112 virtual Dali::Vector3 GetNaturalSize();
115 * @copydoc Toolkit::Button::OnStyleChange
117 virtual void OnStyleChange(Dali::Toolkit::StyleManager styleManager, Dali::StyleChange::Type change);
122 Dali::Property::Index mTransitionId;
123 Dali::Toolkit::TransitionData mTransitionData;
124 Dali::Animation mAnimation;
127 Transition(Dali::Property::Index index, Dali::Toolkit::TransitionData transitionData)
128 : mTransitionId(index),
129 mTransitionData(transitionData),
138 typedef std::vector<Transition> Transitions;
142 Dali::Property::Index mTransformId;
143 Dali::Property::Map mTransform;
145 Transform(Dali::Property::Index index, Dali::Property::Map& map)
146 : mTransformId(index),
151 typedef std::vector<Transform> Transforms;
154 void StartTransition(Dali::Property::Index transitionId);
156 void OnTransitionFinished(Dali::Animation& handle);
158 Transitions::iterator FindTransition(Dali::Property::Index index);
160 Transforms::iterator FindTransform(Dali::Property::Index index);
163 * Relayout the visuals as a result of size negotiation using
164 * the transforms provided in the stylesheet
166 void RelayoutVisuals(const Dali::Vector2& targetSize);
169 * Relayout the visuals as a result of size negotiation using
170 * programmatically generated transforms
172 void RelayoutVisualsManually(const Dali::Vector2& targetSize);
174 void ResetVisual(Dali::Property::Index index,
175 Dali::Toolkit::Visual::Base& visual,
176 const Dali::Property::Value& value);
178 void ResetTransition(Dali::Property::Index index,
179 const Dali::Property::Value& value);
181 void StoreTargetLayouts(Dali::Toolkit::TransitionData transitionData);
185 ShadowButton(const ShadowButton&);
186 ShadowButton& operator=(const ShadowButton&);
190 Dali::Toolkit::Visual::Base mBackgroundVisual;
191 Dali::Toolkit::Visual::Base mCheckboxBgVisual;
192 Dali::Toolkit::Visual::Base mCheckboxFgVisual;
193 Dali::Toolkit::Visual::Base mLabelVisual;
195 Transitions mTransitions;
196 Transforms mTransforms;
201 } // namespace Internal
203 inline Internal::ShadowButton& GetImpl(Demo::ShadowButton& handle)
205 DALI_ASSERT_ALWAYS(handle);
206 Dali::RefObject& object = handle.GetImplementation();
207 return static_cast<Internal::ShadowButton&>(object);
210 inline const Internal::ShadowButton& GetImpl(const Demo::ShadowButton& handle)
212 DALI_ASSERT_ALWAYS(handle);
213 const Dali::RefObject& object = handle.GetImplementation();
214 return static_cast<const Internal::ShadowButton&>(object);
219 #endif // DALI_DEMO_SHADOW_BUTTON_IMPL_H