1 #include "test-custom-actor.h"
5 std::vector<std::string> MasterCallStack;
6 bool gOnRelayout = false;
12 struct TestCustomActor;
15 TestCustomActor TestCustomActor::New()
17 Impl::TestCustomActor* impl = new Impl::TestCustomActor;
18 TestCustomActor custom(*impl); // takes ownership
25 TestCustomActor TestCustomActor::NewNegoSize()
27 Impl::TestCustomActor* impl = new Impl::TestCustomActor(true);
28 TestCustomActor custom(*impl); // takes ownership
29 custom.SetProperty(Dali::Actor::Property::NAME, "SizeNegotiationActor");
36 TestCustomActor TestCustomActor::NewVariant1(Actor childToAdd)
38 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant1(childToAdd);
39 TestCustomActor custom(*impl); // takes ownership
46 TestCustomActor TestCustomActor::NewVariant2()
48 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant2();
49 TestCustomActor custom(*impl); // takes ownership
56 TestCustomActor TestCustomActor::NewVariant3(Actor childToAdd)
58 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant3(childToAdd);
59 TestCustomActor custom(*impl); // takes ownership
66 TestCustomActor TestCustomActor::NewVariant4()
68 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant4();
69 TestCustomActor custom(*impl); // takes ownership
76 TestCustomActor TestCustomActor::NewVariant5(Integration::Scene scene)
78 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant5(scene);
79 TestCustomActor custom(*impl); // takes ownership
86 TestCustomActor TestCustomActor::NewVariant6(Integration::Scene scene)
88 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant6(scene);
89 TestCustomActor custom(*impl); // takes ownership
96 TestCustomActor TestCustomActor::NewVariant7(const char* name)
98 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant7();
99 TestCustomActor custom(*impl); // takes ownership
101 impl->Initialize(name);
106 TestCustomActor TestCustomActor::NewVariant8(Actor rival)
108 Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant8(rival);
109 TestCustomActor custom(*impl); // takes ownership
116 TestCustomActor::~TestCustomActor()
120 Impl::TestCustomActor& TestCustomActor::GetImpl()
122 return static_cast<Impl::TestCustomActor&>(GetImplementation());
125 std::vector<std::string>& TestCustomActor::GetMethodsCalled()
127 return GetImpl().mMethodsCalled;
130 void TestCustomActor::ResetCallStack()
132 GetImpl().ResetCallStack();
135 void TestCustomActor::SetDaliProperty(std::string s)
137 GetImpl().SetDaliProperty(s);
140 Vector3 TestCustomActor::GetSize()
142 return GetImpl().mSizeSet;
145 Vector3 TestCustomActor::GetTargetSize()
147 return GetImpl().mTargetSize;
150 Vector3 TestCustomActor::GetNaturalSize()
152 return GetImpl().GetNaturalSize();
155 float TestCustomActor::GetHeightForWidth(float width)
157 return GetImpl().GetHeightForWidth(width);
160 float TestCustomActor::GetWidthForHeight(float height)
162 return GetImpl().GetWidthForHeight(height);
165 void TestCustomActor::OnRelayout(const Vector2& size, RelayoutContainer& container)
169 void TestCustomActor::OnLayoutNegotiated(float size, Dimension::Type dimension)
173 void TestCustomActor::OnCalculateRelayoutSize(Dimension::Type dimension)
177 void TestCustomActor::TestRelayoutRequest()
179 GetImpl().TestRelayoutRequest();
182 float TestCustomActor::TestGetHeightForWidthBase(float width)
184 return GetImpl().TestGetHeightForWidthBase(width);
187 float TestCustomActor::TestGetWidthForHeightBase(float height)
189 return GetImpl().TestGetWidthForHeightBase(height);
192 float TestCustomActor::TestCalculateChildSizeBase(const Dali::Actor& child, Dimension::Type dimension)
194 return GetImpl().TestCalculateChildSizeBase(child, dimension);
197 bool TestCustomActor::TestRelayoutDependentOnChildrenBase(Dimension::Type dimension)
199 return GetImpl().TestRelayoutDependentOnChildrenBase(dimension);
202 uint32_t TestCustomActor::GetDepth()
204 return GetImpl().mDepth;
207 void TestCustomActor::SetTransparent(bool transparent)
209 return GetImpl().SetTransparent(transparent);
212 bool TestCustomActor::IsTransparent()
214 return GetImpl().IsTransparent();
217 TestCustomActor::TestCustomActor()
221 TestCustomActor::TestCustomActor(Impl::TestCustomActor& impl)
226 TestCustomActor::TestCustomActor(Dali::Internal::CustomActor* internal)
227 : CustomActor(internal)
231 TestCustomActor TestCustomActor::DownCast(BaseHandle handle)
233 TestCustomActor actor;
234 CustomActor custom = Dali::CustomActor::DownCast(handle);
237 CustomActorImpl& customImpl = custom.GetImplementation();
239 Test::Impl::TestCustomActor* impl = dynamic_cast<Test::Impl::TestCustomActor*>(&customImpl);
242 actor = TestCustomActor(customImpl.GetOwner());
250 TestCustomActor::TestCustomActor()
251 : CustomActorImpl(ActorFlags(DISABLE_SIZE_NEGOTIATION)),
252 mDaliProperty(Property::INVALID_INDEX),
253 mSizeSet(Vector3::ZERO),
254 mTargetSize(Vector3::ZERO),
261 TestCustomActor::TestCustomActor(bool nego)
262 : CustomActorImpl(ActorFlags()),
263 mDaliProperty(Property::INVALID_INDEX),
264 mSizeSet(Vector3::ZERO),
265 mTargetSize(Vector3::ZERO),
273 TestCustomActor::~TestCustomActor()
277 void TestCustomActor::Initialize(const char* name)
279 mDaliProperty = Self().RegisterProperty("Dali", std::string("no"), Property::READ_WRITE);
284 void TestCustomActor::OnInitialize(const char* name)
289 * Resets the call stack
291 void TestCustomActor::ResetCallStack()
293 mSizeSet = Vector3();
294 mTargetSize = Vector3();
295 mMethodsCalled.clear();
298 void TestCustomActor::AddToCallStacks(const char* method)
300 mMethodsCalled.push_back(method);
302 // Combine Actor name with method string
303 std::string nameAndMethod(Self().GetProperty<std::string>(Dali::Actor::Property::NAME));
304 if(0 == nameAndMethod.size())
306 nameAndMethod = "Unknown: ";
310 nameAndMethod += ": ";
312 nameAndMethod += method;
314 MasterCallStack.push_back(nameAndMethod);
317 // From CustomActorImpl
318 void TestCustomActor::OnSceneConnection(int depth)
320 AddToCallStacks("OnSceneConnection");
323 void TestCustomActor::OnSceneDisconnection()
325 AddToCallStacks("OnSceneDisconnection");
327 void TestCustomActor::OnChildAdd(Actor& child)
329 AddToCallStacks("OnChildAdd");
331 void TestCustomActor::OnChildRemove(Actor& child)
333 AddToCallStacks("OnChildRemove");
335 void TestCustomActor::OnPropertySet(Property::Index index, const Property::Value& propertyValue)
337 AddToCallStacks("OnPropertySet");
339 void TestCustomActor::OnSizeSet(const Vector3& targetSize)
341 mSizeSet = targetSize;
342 AddToCallStacks("OnSizeSet");
344 void TestCustomActor::OnSizeAnimation(Animation& animation, const Vector3& targetSize)
346 mTargetSize = targetSize;
347 AddToCallStacks("OnSizeAnimation");
349 void TestCustomActor::OnKeyInputFocusGained()
351 AddToCallStacks("OnKeyInputFocusGained");
353 void TestCustomActor::OnKeyInputFocusLost()
355 AddToCallStacks("OnKeyInputFocusLost");
357 Vector3 TestCustomActor::GetNaturalSize()
361 void TestCustomActor::SetNaturalSize(const Vector3& size)
366 float TestCustomActor::GetHeightForWidth(float width)
368 return mH4Wfactor * width;
371 float TestCustomActor::GetWidthForHeight(float height)
373 return mW4Hfactor * height;
376 void TestCustomActor::OnRelayout(const Vector2& size, RelayoutContainer& container)
381 void TestCustomActor::OnSetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension)
385 void TestCustomActor::OnCalculateRelayoutSize(Dimension::Type dimension)
389 float TestCustomActor::CalculateChildSize(const Dali::Actor& child, Dimension::Type dimension)
391 return CustomActorImpl::CalculateChildSizeBase(child, dimension);
394 void TestCustomActor::OnLayoutNegotiated(float size, Dimension::Type dimension)
398 bool TestCustomActor::RelayoutDependentOnChildren(Dimension::Type dimension)
400 return CustomActorImpl::RelayoutDependentOnChildrenBase(dimension);
403 void TestCustomActor::SetTransparent(bool transparent)
405 CustomActorImpl::SetTransparent(transparent);
408 bool TestCustomActor::IsTransparent() const
410 return CustomActorImpl::IsTransparent();
413 void TestCustomActor::SetDaliProperty(std::string s)
415 Self().SetProperty(mDaliProperty, s);
417 void TestCustomActor::TestRelayoutRequest()
422 float TestCustomActor::TestGetHeightForWidthBase(float width)
424 return GetHeightForWidthBase(width);
427 float TestCustomActor::TestGetWidthForHeightBase(float height)
429 return GetWidthForHeightBase(height);
432 float TestCustomActor::TestCalculateChildSizeBase(const Dali::Actor& child, Dimension::Type dimension)
434 return CalculateChildSizeBase(child, dimension);
437 bool TestCustomActor::TestRelayoutDependentOnChildrenBase(Dimension::Type dimension)
439 return RelayoutDependentOnChildrenBase(dimension);
442 void TestCustomActor::SetProperty(BaseObject* object, Property::Index index, const Property::Value& value)
444 Test::TestCustomActor actor = Test::TestCustomActor::DownCast(Dali::BaseHandle(object));
448 TestCustomActor& actorImpl = GetImpl(actor);
451 case Test::TestCustomActor::Property::TEST_PROPERTY1:
453 actorImpl.prop1 = value.Get<float>();
456 case Test::TestCustomActor::Property::TEST_PROPERTY2:
458 actorImpl.prop2 = value.Get<Vector4>();
461 case Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY3:
463 actorImpl.develProp3 = value.Get<Vector4>();
466 case Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY4:
468 actorImpl.develProp4 = value.Get<int>();
471 case Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY5:
473 actorImpl.develProp5 = value.Get<float>();
480 Property::Value TestCustomActor::GetProperty(BaseObject* object, Property::Index index)
482 Test::TestCustomActor actor = Test::TestCustomActor::DownCast(Dali::BaseHandle(object));
486 TestCustomActor& actorImpl = GetImpl(actor);
489 case Test::TestCustomActor::Property::TEST_PROPERTY1:
491 return Property::Value(actorImpl.prop1);
493 case Test::TestCustomActor::Property::TEST_PROPERTY2:
495 return Property::Value(actorImpl.prop2);
497 case Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY3:
499 return Property::Value(actorImpl.develProp3);
501 case Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY4:
503 return Property::Value(actorImpl.develProp4);
505 case Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY5:
507 return Property::Value(actorImpl.develProp5);
509 case Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY6:
511 return Property::Value(actorImpl.develProp6);
515 return Property::Value();
518 BaseHandle CreateActor()
520 return Test::TestCustomActor::New();
523 DALI_TYPE_REGISTRATION_BEGIN(Test::TestCustomActor, Dali::CustomActor, CreateActor);
525 DALI_PROPERTY_REGISTRATION(Test, TestCustomActor, "testProperty1", FLOAT, TEST_PROPERTY1)
526 DALI_PROPERTY_REGISTRATION(Test, TestCustomActor, "testProperty2", VECTOR4, TEST_PROPERTY2)
527 DALI_DEVEL_PROPERTY_REGISTRATION(Test, TestCustomActor, "develTestProperty3", VECTOR4, DEVEL_TEST_PROPERTY3)
528 DALI_DEVEL_PROPERTY_REGISTRATION(Test, TestCustomActor, "develTestProperty4", INTEGER, DEVEL_TEST_PROPERTY4)
529 DALI_DEVEL_PROPERTY_REGISTRATION(Test, TestCustomActor, "develTestProperty5", FLOAT, DEVEL_TEST_PROPERTY5)
530 DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY(Test, TestCustomActor, "develTestProperty6", FLOAT, DEVEL_TEST_PROPERTY6)
532 DALI_TYPE_REGISTRATION_END()