1 #ifndef DALI_DEMO_INTERNAL_SHADOW_BUTTON_IMPL_H
2 #define DALI_DEMO_INTERNAL_SHADOW_BUTTON_IMPL_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.
20 #include "shadow-button.h"
21 #include <dali/public-api/animation/animation.h>
22 #include <dali-toolkit/public-api/controls/control-impl.h>
23 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
24 #include <dali-toolkit/devel-api/visual-factory/transition-data.h>
29 namespace Internal // To use TypeRegistry, handle and body classes need the same name
32 class ShadowButton : public Dali::Toolkit::Internal::Control
36 * Instantiate a new ShadowButton object
38 static Demo::ShadowButton New();
44 * @brief Set the button to be active or inactive.
46 * The button will perform a transition if there is a state change.
47 * @param[in] active The active state
49 void SetActiveState( bool active );
52 * Get the active state
53 * @return the active state
55 bool GetActiveState();
59 * @param[in] checkState The state of the checkbox
61 void SetCheckState( bool checkState );
65 * @return the check state
71 * Called when a property of an object of this type is set.
72 * @param[in] object The object whose property is set.
73 * @param[in] index The property index.
74 * @param[in] value The new property value.
76 static void SetProperty( Dali::BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value );
79 * Called to retrieve a property of an object of this type.
80 * @param[in] object The object whose property is to be retrieved.
81 * @param[in] index The property index.
82 * @return The current value of the property.
84 static Dali::Property::Value GetProperty( Dali::BaseObject* object, Dali::Property::Index propertyIndex );
86 private: // From Control
88 * @copydoc Toolkit::Button::OnInitialize()
90 virtual void OnInitialize();
93 * @copydoc Toolkit::Button::OnStageConnect()
95 virtual void OnStageConnection( int depth );
98 * @copydoc Toolkit::Button::OnStageDisconnection()
100 virtual void OnStageDisconnection();
103 * @copydoc Toolkit::Button::OnSizeSet()
105 virtual void OnSizeSet( const Dali::Vector3& targetSize );
108 * @copydoc Toolkit::Button::OnRelayout()
110 virtual void OnRelayout( const Dali::Vector2& targetSize, Dali::RelayoutContainer& container );
112 * @copydoc Toolkit::Button::GetNaturalSize
114 virtual Dali::Vector3 GetNaturalSize();
117 * @copydoc Toolkit::Button::OnStyleChange
119 virtual void OnStyleChange( Dali::Toolkit::StyleManager styleManager, Dali::StyleChange::Type change );
124 Dali::Property::Index mTransitionId;
125 Dali::Toolkit::TransitionData mTransitionData;
126 Dali::Animation mAnimation;
129 Transition( Dali::Property::Index index, Dali::Toolkit::TransitionData transitionData )
130 : mTransitionId( index ),
131 mTransitionData( transitionData ),
139 typedef std::vector<Transition> Transitions;
143 Dali::Property::Index mTransformId;
144 Dali::Property::Map mTransform;
146 Transform( Dali::Property::Index index, Dali::Property::Map& map )
147 : mTransformId(index),
152 typedef std::vector<Transform> Transforms;
155 void StartTransition( Dali::Property::Index transitionId );
157 void OnTransitionFinished( Dali::Animation& handle );
159 Transitions::iterator FindTransition( Dali::Property::Index index );
161 Transforms::iterator FindTransform( Dali::Property::Index index );
164 * Relayout the visuals as a result of size negotiation using
165 * the transforms provided in the stylesheet
167 void RelayoutVisuals( const Dali::Vector2& targetSize );
170 * Relayout the visuals as a result of size negotiation using
171 * programmatically generated transforms
173 void RelayoutVisualsManually( const Dali::Vector2& targetSize );
175 void ResetVisual( Dali::Property::Index index,
176 Dali::Toolkit::Visual::Base& visual,
177 const Dali::Property::Value& value );
179 void ResetTransition( Dali::Property::Index index,
180 const Dali::Property::Value& value );
182 void StoreTargetLayouts( Dali::Toolkit::TransitionData transitionData );
186 ShadowButton( const ShadowButton& );
187 ShadowButton& operator=( const ShadowButton& );
191 Dali::Toolkit::Visual::Base mBackgroundVisual;
192 Dali::Toolkit::Visual::Base mCheckboxBgVisual;
193 Dali::Toolkit::Visual::Base mCheckboxFgVisual;
194 Dali::Toolkit::Visual::Base mLabelVisual;
196 Transitions mTransitions;
197 Transforms mTransforms;
204 inline Internal::ShadowButton& GetImpl( Demo::ShadowButton& handle )
206 DALI_ASSERT_ALWAYS( handle );
207 Dali::RefObject& object = handle.GetImplementation();
208 return static_cast<Internal::ShadowButton&>(object);
211 inline const Internal::ShadowButton& GetImpl( const Demo::ShadowButton& handle )
213 DALI_ASSERT_ALWAYS( handle );
214 const Dali::RefObject& object = handle.GetImplementation();
215 return static_cast<const Internal::ShadowButton&>(object);
220 #endif // DALI_DEMO_SHADOW_BUTTON_IMPL_H