shadow-button-impl.h
5.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#ifndef DALI_DEMO_INTERNAL_SHADOW_BUTTON_IMPL_H
#define DALI_DEMO_INTERNAL_SHADOW_BUTTON_IMPL_H
/*
* Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dali-toolkit/devel-api/visual-factory/transition-data.h>
#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali/public-api/animation/animation.h>
#include "shadow-button.h"
namespace Demo
{
namespace Internal // To use TypeRegistry, handle and body classes need the same name
{
class ShadowButton : public Dali::Toolkit::Internal::Control
{
public:
/**
* Instantiate a new ShadowButton object
*/
static Demo::ShadowButton New();
ShadowButton();
~ShadowButton();
public: // API
/**
* @brief Set the button to be active or inactive.
*
* The button will perform a transition if there is a state change.
* @param[in] active The active state
*/
void SetActiveState(bool active);
/**
* Get the active state
* @return the active state
*/
bool GetActiveState();
/**
* Set the check state
* @param[in] checkState The state of the checkbox
*/
void SetCheckState(bool checkState);
/**
* Get the check state
* @return the check state
*/
bool GetCheckState();
public: // Properties
/**
* Called when a property of an object of this type is set.
* @param[in] object The object whose property is set.
* @param[in] index The property index.
* @param[in] value The new property value.
*/
static void SetProperty(Dali::BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value);
/**
* Called to retrieve a property of an object of this type.
* @param[in] object The object whose property is to be retrieved.
* @param[in] index The property index.
* @return The current value of the property.
*/
static Dali::Property::Value GetProperty(Dali::BaseObject* object, Dali::Property::Index propertyIndex);
private: // From Control
/**
* @copydoc Toolkit::Button::OnInitialize()
*/
virtual void OnInitialize();
/**
* @copydoc Toolkit::Button::OnSceneConnection()
*/
virtual void OnSceneConnection(int depth);
/**
* @copydoc Toolkit::Button::OnSceneDisconnection()
*/
virtual void OnSceneDisconnection();
/**
* @copydoc Toolkit::Button::OnSizeSet()
*/
virtual void OnSizeSet(const Dali::Vector3& targetSize);
/**
* @copydoc Toolkit::Button::OnRelayout()
*/
virtual void OnRelayout(const Dali::Vector2& targetSize, Dali::RelayoutContainer& container);
/**
* @copydoc Toolkit::Button::GetNaturalSize
*/
virtual Dali::Vector3 GetNaturalSize();
/**
* @copydoc Toolkit::Button::OnStyleChange
*/
virtual void OnStyleChange(Dali::Toolkit::StyleManager styleManager, Dali::StyleChange::Type change);
private:
struct Transition
{
Dali::Property::Index mTransitionId;
Dali::Toolkit::TransitionData mTransitionData;
Dali::Animation mAnimation;
bool mPlaying;
Transition(Dali::Property::Index index, Dali::Toolkit::TransitionData transitionData)
: mTransitionId(index),
mTransitionData(transitionData),
mPlaying(false)
{
}
private:
Transition();
};
typedef std::vector<Transition> Transitions;
struct Transform
{
Dali::Property::Index mTransformId;
Dali::Property::Map mTransform;
Transform(Dali::Property::Index index, Dali::Property::Map& map)
: mTransformId(index),
mTransform(map)
{
}
};
typedef std::vector<Transform> Transforms;
private:
void StartTransition(Dali::Property::Index transitionId);
void OnTransitionFinished(Dali::Animation& handle);
Transitions::iterator FindTransition(Dali::Property::Index index);
Transforms::iterator FindTransform(Dali::Property::Index index);
/**
* Relayout the visuals as a result of size negotiation using
* the transforms provided in the stylesheet
*/
void RelayoutVisuals(const Dali::Vector2& targetSize);
/**
* Relayout the visuals as a result of size negotiation using
* programmatically generated transforms
*/
void RelayoutVisualsManually(const Dali::Vector2& targetSize);
void ResetVisual(Dali::Property::Index index,
Dali::Toolkit::Visual::Base& visual,
const Dali::Property::Value& value);
void ResetTransition(Dali::Property::Index index,
const Dali::Property::Value& value);
void StoreTargetLayouts(Dali::Toolkit::TransitionData transitionData);
private:
// undefined
ShadowButton(const ShadowButton&);
ShadowButton& operator=(const ShadowButton&);
private:
// Data
Dali::Toolkit::Visual::Base mBackgroundVisual;
Dali::Toolkit::Visual::Base mCheckboxBgVisual;
Dali::Toolkit::Visual::Base mCheckboxFgVisual;
Dali::Toolkit::Visual::Base mLabelVisual;
Transitions mTransitions;
Transforms mTransforms;
bool mCheckState;
bool mActiveState;
};
} // namespace Internal
inline Internal::ShadowButton& GetImpl(Demo::ShadowButton& handle)
{
DALI_ASSERT_ALWAYS(handle);
Dali::RefObject& object = handle.GetImplementation();
return static_cast<Internal::ShadowButton&>(object);
}
inline const Internal::ShadowButton& GetImpl(const Demo::ShadowButton& handle)
{
DALI_ASSERT_ALWAYS(handle);
const Dali::RefObject& object = handle.GetImplementation();
return static_cast<const Internal::ShadowButton&>(object);
}
} // namespace Demo
#endif // DALI_DEMO_SHADOW_BUTTON_IMPL_H