cluster-style-impl.h
7.21 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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
/*
* Copyright (c) 2015 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.
*
*/
// EXTERNAL INCLUDES
#include <dali/public-api/object/ref-object.h>
#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/math/vector3.h>
#include <dali/public-api/object/base-object.h>
// INTERNAL INCLUDES
#include "cluster-style.h"
namespace Dali
{
namespace Demo
{
namespace Internal
{
class ClusterStyle;
typedef IntrusivePtr<ClusterStyle> ClusterStylePtr;
/**
* ClusterStyle internal implementation
*/
class ClusterStyle : public Dali::BaseObject
{
public:
/**
* @copydoc Demo::ClusterStyle::GetMaximumNumberOfChildren
*/
unsigned int GetMaximumNumberOfChildren() const;
/**
* @copydoc Demo::ClusterStyle::ApplyStyle
*/
virtual void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds) = 0;
/**
* @copydoc Demo::ClusterStyle::ApplyStyleToBackground
*/
virtual void ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds);
/**
* @copydoc Demo::ClusterStyle::ApplyStyleToTitle
*/
virtual void ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds);
/**
* Set the size of cluster
*/
void SetClusterSize( const Vector3& clusterSize );
protected:
/**
* Set the maximum number of children this Style can handle.
* @param[in] The maximum number of children.
*/
void SetMaximumNumberOfChildren(unsigned int children);
/**
* Set the title properties
* @param[in] relativePosition Relative position of the title
* @param[in] offsetPosition Offset position of the title
* @param[in] size The size of the title
*/
void SetTitleProperties(const Vector3& relativePosition,
const Vector3& offsetPosition,
const Vector3& size);
/**
* Set the background properties
* @param[in] relativePosition Relative position of the background
* @param[in] offsetPosition Offset position of the background
* @param[in] size The size of the title
*/
void SetBackgroundProperties(const Vector3& relativePosition,
const Vector3& offsetPosition,
const Vector3& size);
/**
* Get the size of cluster.
* @return the cluster size
*/
Vector3 GetClusterSize() const;
/**
* Apply the given position & size to the actor
* @param[in] position The target position
* @param[in] size The target size
* @param[in] size The size to resize to
* @param[in] alpha The alpha function to use.
* @param[in] durationSeconds The time period to apply this style.
*/
void Apply( Actor actor,
const Vector3& position,
const Vector3& size,
AlphaFunction alpha,
const TimePeriod& durationSeconds);
/**
* Apply the given position & size to the actor
* @param[in] actor The actor to apply the changes
* @param[in] position The target position
* @param[in] size The target size
* @param[in] rotation The target Quaternion value
* @param[in] scale The target scale
* @param[in] alpha The alpha function to use.
* @param[in] durationSeconds The time period to apply this style.
*/
void Apply( Actor actor,
const Vector3& position,
const Vector3& size,
const Quaternion& rotation,
const Vector3& scale,
AlphaFunction alpha,
const TimePeriod& durationSeconds);
protected:
/**
* Protected constructor see ClusterStyle::New().
*/
ClusterStyle();
/**
* A reference counted object may only be deleted by calling Unreference()
*/
virtual ~ClusterStyle();
protected:
unsigned int mMaxChildren; ///< Maximum number of children that this style supports
Vector3 mTitlePositionRelative; ///< Title's position relative to size of cluster
Vector3 mTitlePositionOffset; ///< Title's position offset
Vector3 mTitleSize; ///< Title's size relative to size of cluster
Vector3 mBackgroundPositionRelative; ///< Background's position relative to size of cluster
Vector3 mBackgroundPositionOffset; ///< Background's position offset
Vector3 mBackgroundSize; ///< Background's size relative to size of cluster
Vector3 mClusterSize; ///< The size of cluster
};
/**
* ClusterStyleStandard internal implementation
*/
class ClusterStyleStandard : public ClusterStyle
{
public:
typedef Demo::ClusterStyleStandard::StyleType StyleType;
public:
/**
* Create a new cluster style.
* @param[in] style The style type to create.
* @return A smart-pointer to the newly allocated ClusterStyle.
*/
static ClusterStylePtr New(StyleType style);
public:
/**
* @copydoc Demo::ClusterStyle::ApplyStyle
*/
void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds);
private:
/**
* Set the relative sizes of the children
* @param[in] size The list of sizes for the children
*/
void SetSizes(const float *sizes);
/**
* Set the relative positions of the children
* @param[in] positions The list of positions for the children
*/
void SetPositions(const Vector3 *positions);
protected:
/**
* Protected constructor see ClusterStyleRandom::New().
*/
ClusterStyleStandard(StyleType style);
private:
const float *mSizes; ///< List of sizes
const Vector3 *mPositions; ///< List of positions
};
/**
* ClusterStyleRandom internal implementation
*/
class ClusterStyleRandom : public ClusterStyle
{
public:
/**
* Create a new cluster style.
* @return A smart-pointer to the newly allocated ClusterStyle.
*/
static ClusterStylePtr New();
public:
/**
* @copydoc Demo::ClusterStyle::ApplyStyle
*/
void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds);
protected:
/**
* Protected constructor see ClusterStyleRandom::New().
*/
ClusterStyleRandom();
private:
};
} // namespace Internal
// Helpers for public-api forwarding methods
inline Internal::ClusterStyle& GetImpl(Demo::ClusterStyle& pub)
{
DALI_ASSERT_ALWAYS(pub);
Dali::RefObject& handle = pub.GetBaseObject();
return static_cast<Internal::ClusterStyle&>(handle);
}
inline const Internal::ClusterStyle& GetImpl(const Demo::ClusterStyle& pub)
{
DALI_ASSERT_ALWAYS(pub);
const Dali::RefObject& handle = pub.GetBaseObject();
return static_cast<const Internal::ClusterStyle&>(handle);
}
} // namespace Demo
} // namespace Dali