2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/event/actors/actor-property-handler.h>
22 #include <dali/public-api/math/vector2.h>
23 #include <dali/public-api/math/vector3.h>
25 #include <dali/devel-api/actors/actor-devel.h>
27 #include <dali/internal/event/actors/actor-impl.h>
28 #include <dali/internal/event/actors/actor-relayouter.h>
29 #include <dali/internal/event/actors/actor-sizer.h>
30 #include <dali/internal/event/common/property-helper.h>
31 #include <dali/internal/update/nodes/node-declarations.h>
32 #include <dali/internal/update/nodes/node-messages.h>
34 using Dali::Internal::SceneGraph::AnimatableProperty;
35 using Dali::Internal::SceneGraph::Node;
36 using Dali::Internal::SceneGraph::PropertyBase;
42 namespace // unnamed namespace
50 DALI_ENUM_TO_STRING_TABLE_BEGIN_WITH_TYPE(AnchorValue, ANCHOR_CONSTANT)
51 DALI_ENUM_TO_STRING_WITH_SCOPE(AnchorPoint, TOP_LEFT)
52 DALI_ENUM_TO_STRING_WITH_SCOPE(AnchorPoint, TOP_CENTER)
53 DALI_ENUM_TO_STRING_WITH_SCOPE(AnchorPoint, TOP_RIGHT)
54 DALI_ENUM_TO_STRING_WITH_SCOPE(AnchorPoint, CENTER_LEFT)
55 DALI_ENUM_TO_STRING_WITH_SCOPE(AnchorPoint, CENTER)
56 DALI_ENUM_TO_STRING_WITH_SCOPE(AnchorPoint, CENTER_RIGHT)
57 DALI_ENUM_TO_STRING_WITH_SCOPE(AnchorPoint, BOTTOM_LEFT)
58 DALI_ENUM_TO_STRING_WITH_SCOPE(AnchorPoint, BOTTOM_CENTER)
59 DALI_ENUM_TO_STRING_WITH_SCOPE(AnchorPoint, BOTTOM_RIGHT)
60 DALI_ENUM_TO_STRING_TABLE_END(ANCHOR_CONSTANT)
62 DALI_ENUM_TO_STRING_TABLE_BEGIN(COLOR_MODE)
63 DALI_ENUM_TO_STRING(USE_OWN_COLOR)
64 DALI_ENUM_TO_STRING(USE_PARENT_COLOR)
65 DALI_ENUM_TO_STRING(USE_OWN_MULTIPLY_PARENT_COLOR)
66 DALI_ENUM_TO_STRING(USE_OWN_MULTIPLY_PARENT_ALPHA)
67 DALI_ENUM_TO_STRING_TABLE_END(COLOR_MODE)
69 DALI_ENUM_TO_STRING_TABLE_BEGIN(DRAW_MODE)
70 DALI_ENUM_TO_STRING_WITH_SCOPE(DrawMode, NORMAL)
71 DALI_ENUM_TO_STRING_WITH_SCOPE(DrawMode, OVERLAY_2D)
72 DALI_ENUM_TO_STRING_TABLE_END(DRAW_MODE)
74 DALI_ENUM_TO_STRING_TABLE_BEGIN(RESIZE_POLICY)
75 DALI_ENUM_TO_STRING_WITH_SCOPE(ResizePolicy, FIXED)
76 DALI_ENUM_TO_STRING_WITH_SCOPE(ResizePolicy, USE_NATURAL_SIZE)
77 DALI_ENUM_TO_STRING_WITH_SCOPE(ResizePolicy, FILL_TO_PARENT)
78 DALI_ENUM_TO_STRING_WITH_SCOPE(ResizePolicy, SIZE_RELATIVE_TO_PARENT)
79 DALI_ENUM_TO_STRING_WITH_SCOPE(ResizePolicy, SIZE_FIXED_OFFSET_FROM_PARENT)
80 DALI_ENUM_TO_STRING_WITH_SCOPE(ResizePolicy, FIT_TO_CHILDREN)
81 DALI_ENUM_TO_STRING_WITH_SCOPE(ResizePolicy, DIMENSION_DEPENDENCY)
82 DALI_ENUM_TO_STRING_WITH_SCOPE(ResizePolicy, USE_ASSIGNED_SIZE)
83 DALI_ENUM_TO_STRING_TABLE_END(RESIZE_POLICY)
85 DALI_ENUM_TO_STRING_TABLE_BEGIN(SIZE_SCALE_POLICY)
86 DALI_ENUM_TO_STRING_WITH_SCOPE(SizeScalePolicy, USE_SIZE_SET)
87 DALI_ENUM_TO_STRING_WITH_SCOPE(SizeScalePolicy, FIT_WITH_ASPECT_RATIO)
88 DALI_ENUM_TO_STRING_WITH_SCOPE(SizeScalePolicy, FILL_WITH_ASPECT_RATIO)
89 DALI_ENUM_TO_STRING_TABLE_END(SIZE_SCALE_POLICY)
91 DALI_ENUM_TO_STRING_TABLE_BEGIN(CLIPPING_MODE)
92 DALI_ENUM_TO_STRING_WITH_SCOPE(ClippingMode, DISABLED)
93 DALI_ENUM_TO_STRING_WITH_SCOPE(ClippingMode, CLIP_CHILDREN)
94 DALI_ENUM_TO_STRING_TABLE_END(CLIPPING_MODE)
96 DALI_ENUM_TO_STRING_TABLE_BEGIN(LAYOUT_DIRECTION)
97 DALI_ENUM_TO_STRING_WITH_SCOPE(LayoutDirection, LEFT_TO_RIGHT)
98 DALI_ENUM_TO_STRING_WITH_SCOPE(LayoutDirection, RIGHT_TO_LEFT)
99 DALI_ENUM_TO_STRING_TABLE_END(LAYOUT_DIRECTION)
101 bool GetAnchorPointConstant(const std::string& value, Vector3& anchor)
103 for(uint32_t i = 0; i < ANCHOR_CONSTANT_TABLE_COUNT; ++i)
105 uint32_t sizeIgnored = 0;
106 if(CompareTokens(value.c_str(), ANCHOR_CONSTANT_TABLE[i].name, sizeIgnored))
108 anchor = ANCHOR_CONSTANT_TABLE[i].value;
115 inline bool GetParentOriginConstant(const std::string& value, Vector3& parentOrigin)
117 // Values are the same so just use the same table as anchor-point
118 return GetAnchorPointConstant(value, parentOrigin);
121 } // unnamed namespace
123 void Actor::PropertyHandler::SetDefaultProperty(Internal::Actor& actor, Property::Index index, const Property::Value& property)
127 case Dali::Actor::Property::PARENT_ORIGIN:
129 Property::Type type = property.GetType();
130 if(type == Property::VECTOR3)
132 actor.SetParentOrigin(property.Get<Vector3>());
134 else if(type == Property::STRING)
136 std::string parentOriginString;
137 property.Get(parentOriginString);
138 Vector3 parentOrigin;
139 if(GetParentOriginConstant(parentOriginString, parentOrigin))
141 actor.SetParentOrigin(parentOrigin);
147 case Dali::Actor::Property::PARENT_ORIGIN_X:
149 const Vector3& current = actor.GetCurrentParentOrigin();
150 actor.SetParentOrigin(Vector3(property.Get<float>(), current.y, current.z));
154 case Dali::Actor::Property::PARENT_ORIGIN_Y:
156 const Vector3& current = actor.GetCurrentParentOrigin();
157 actor.SetParentOrigin(Vector3(current.x, property.Get<float>(), current.z));
161 case Dali::Actor::Property::PARENT_ORIGIN_Z:
163 const Vector3& current = actor.GetCurrentParentOrigin();
164 actor.SetParentOrigin(Vector3(current.x, current.y, property.Get<float>()));
168 case Dali::Actor::Property::ANCHOR_POINT:
170 Property::Type type = property.GetType();
171 if(type == Property::VECTOR3)
173 actor.SetAnchorPoint(property.Get<Vector3>());
175 else if(type == Property::STRING)
177 std::string anchorPointString;
178 property.Get(anchorPointString);
180 if(GetAnchorPointConstant(anchorPointString, anchor))
182 actor.SetAnchorPoint(anchor);
188 case Dali::Actor::Property::ANCHOR_POINT_X:
190 const Vector3& current = actor.GetCurrentAnchorPoint();
191 actor.SetAnchorPoint(Vector3(property.Get<float>(), current.y, current.z));
195 case Dali::Actor::Property::ANCHOR_POINT_Y:
197 const Vector3& current = actor.GetCurrentAnchorPoint();
198 actor.SetAnchorPoint(Vector3(current.x, property.Get<float>(), current.z));
202 case Dali::Actor::Property::ANCHOR_POINT_Z:
204 const Vector3& current = actor.GetCurrentAnchorPoint();
205 actor.SetAnchorPoint(Vector3(current.x, current.y, property.Get<float>()));
209 case Dali::Actor::Property::SIZE:
211 Property::Type type = property.GetType();
212 if(type == Property::VECTOR2)
214 actor.SetSize(property.Get<Vector2>());
216 else if(type == Property::VECTOR3)
218 actor.SetSize(property.Get<Vector3>());
223 case Dali::Actor::Property::SIZE_WIDTH:
225 actor.SetWidth(property.Get<float>());
229 case Dali::Actor::Property::SIZE_HEIGHT:
231 actor.SetHeight(property.Get<float>());
235 case Dali::Actor::Property::SIZE_DEPTH:
237 actor.SetDepth(property.Get<float>());
241 case Dali::Actor::Property::POSITION:
243 Property::Type type = property.GetType();
244 if(type == Property::VECTOR2)
246 Vector2 position = property.Get<Vector2>();
247 actor.SetPosition(Vector3(position.x, position.y, 0.0f));
249 else if(type == Property::VECTOR3)
251 actor.SetPosition(property.Get<Vector3>());
256 case Dali::Actor::Property::POSITION_X:
258 actor.SetX(property.Get<float>());
262 case Dali::Actor::Property::POSITION_Y:
264 actor.SetY(property.Get<float>());
268 case Dali::Actor::Property::POSITION_Z:
270 actor.SetZ(property.Get<float>());
274 case Dali::Actor::Property::ORIENTATION:
276 actor.SetOrientation(property.Get<Quaternion>());
280 case Dali::Actor::Property::SCALE:
282 Property::Type type = property.GetType();
283 if(type == Property::FLOAT)
285 float scale = property.Get<float>();
286 actor.SetScale(scale, scale, scale);
288 else if(type == Property::VECTOR3)
290 actor.SetScale(property.Get<Vector3>());
295 case Dali::Actor::Property::SCALE_X:
297 actor.SetScaleX(property.Get<float>());
301 case Dali::Actor::Property::SCALE_Y:
303 actor.SetScaleY(property.Get<float>());
307 case Dali::Actor::Property::SCALE_Z:
309 actor.SetScaleZ(property.Get<float>());
313 case Dali::Actor::Property::VISIBLE:
315 actor.SetVisible(property.Get<bool>());
319 case Dali::Actor::Property::COLOR:
321 Property::Type type = property.GetType();
322 if(type == Property::VECTOR3)
324 Vector3 color = property.Get<Vector3>();
325 actor.SetColor(Vector4(color.r, color.g, color.b, 1.0f));
327 else if(type == Property::VECTOR4)
329 actor.SetColor(property.Get<Vector4>());
334 case Dali::Actor::Property::COLOR_RED:
336 actor.SetColorRed(property.Get<float>());
340 case Dali::Actor::Property::COLOR_GREEN:
342 actor.SetColorGreen(property.Get<float>());
346 case Dali::Actor::Property::COLOR_BLUE:
348 actor.SetColorBlue(property.Get<float>());
352 case Dali::Actor::Property::COLOR_ALPHA:
353 case Dali::Actor::Property::OPACITY:
356 if(property.Get(value))
358 actor.SetOpacity(value);
363 case Dali::Actor::Property::NAME:
365 actor.SetName(property.Get<std::string>());
369 case Dali::Actor::Property::SENSITIVE:
371 actor.SetSensitive(property.Get<bool>());
375 case Dali::Actor::Property::LEAVE_REQUIRED:
377 actor.SetLeaveRequired(property.Get<bool>());
381 case Dali::Actor::Property::INHERIT_POSITION:
383 actor.SetInheritPosition(property.Get<bool>());
387 case Dali::Actor::Property::INHERIT_ORIENTATION:
389 actor.SetInheritOrientation(property.Get<bool>());
393 case Dali::Actor::Property::INHERIT_SCALE:
395 actor.SetInheritScale(property.Get<bool>());
399 case Dali::Actor::Property::COLOR_MODE:
401 ColorMode mode = actor.mColorMode;
402 if(Scripting::GetEnumerationProperty<ColorMode>(property, COLOR_MODE_TABLE, COLOR_MODE_TABLE_COUNT, mode))
404 actor.SetColorMode(mode);
409 case Dali::Actor::Property::DRAW_MODE:
411 DrawMode::Type mode = actor.mDrawMode;
412 if(Scripting::GetEnumerationProperty<DrawMode::Type>(property, DRAW_MODE_TABLE, DRAW_MODE_TABLE_COUNT, mode))
414 actor.SetDrawMode(mode);
419 case Dali::Actor::Property::SIZE_MODE_FACTOR:
421 actor.SetSizeModeFactor(property.Get<Vector3>());
425 case Dali::Actor::Property::WIDTH_RESIZE_POLICY:
427 ResizePolicy::Type type = actor.mSizer.GetResizePolicy(Dimension::WIDTH);
428 if(Scripting::GetEnumerationProperty<ResizePolicy::Type>(property, RESIZE_POLICY_TABLE, RESIZE_POLICY_TABLE_COUNT, type))
430 actor.mSizer.SetResizePolicy(type, Dimension::WIDTH);
435 case Dali::Actor::Property::HEIGHT_RESIZE_POLICY:
437 ResizePolicy::Type type = actor.mSizer.GetResizePolicy(Dimension::HEIGHT);
438 if(Scripting::GetEnumerationProperty<ResizePolicy::Type>(property, RESIZE_POLICY_TABLE, RESIZE_POLICY_TABLE_COUNT, type))
440 actor.mSizer.SetResizePolicy(type, Dimension::HEIGHT);
445 case Dali::Actor::Property::SIZE_SCALE_POLICY:
447 SizeScalePolicy::Type type = actor.mSizer.GetSizeScalePolicy();
448 if(Scripting::GetEnumerationProperty<SizeScalePolicy::Type>(property, SIZE_SCALE_POLICY_TABLE, SIZE_SCALE_POLICY_TABLE_COUNT, type))
450 actor.mSizer.SetSizeScalePolicy(type);
455 case Dali::Actor::Property::WIDTH_FOR_HEIGHT:
457 if(property.Get<bool>())
459 actor.mSizer.SetResizePolicy(ResizePolicy::DIMENSION_DEPENDENCY, Dimension::WIDTH);
464 case Dali::Actor::Property::HEIGHT_FOR_WIDTH:
466 if(property.Get<bool>())
468 actor.mSizer.SetResizePolicy(ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT);
473 case Dali::Actor::Property::PADDING:
475 Vector4 padding = property.Get<Vector4>();
476 actor.SetPadding(Vector2(padding.x, padding.y), Dimension::WIDTH);
477 actor.SetPadding(Vector2(padding.z, padding.w), Dimension::HEIGHT);
481 case Dali::Actor::Property::MINIMUM_SIZE:
483 Vector2 size = property.Get<Vector2>();
484 actor.SetMinimumSize(size.x, Dimension::WIDTH);
485 actor.SetMinimumSize(size.y, Dimension::HEIGHT);
489 case Dali::Actor::Property::MAXIMUM_SIZE:
491 Vector2 size = property.Get<Vector2>();
492 actor.SetMaximumSize(size.x, Dimension::WIDTH);
493 actor.SetMaximumSize(size.y, Dimension::HEIGHT);
497 case Dali::DevelActor::Property::SIBLING_ORDER:
501 if(property.Get(value))
503 Actor* parent = actor.GetParent();
506 parent->SetSiblingOrderOfChild(actor, value);
512 case Dali::Actor::Property::CLIPPING_MODE:
514 ClippingMode::Type convertedValue = actor.mClippingMode;
515 if(Scripting::GetEnumerationProperty<ClippingMode::Type>(property, CLIPPING_MODE_TABLE, CLIPPING_MODE_TABLE_COUNT, convertedValue))
517 actor.mClippingMode = convertedValue;
518 SetClippingModeMessage(actor.GetEventThreadServices(), actor.GetNode(), actor.mClippingMode);
523 case Dali::Actor::Property::POSITION_USES_ANCHOR_POINT:
526 if(property.Get(value) && value != actor.mPositionUsesAnchorPoint)
528 actor.mPositionUsesAnchorPoint = value;
529 SetPositionUsesAnchorPointMessage(actor.GetEventThreadServices(), actor.GetNode(), actor.mPositionUsesAnchorPoint);
534 case Dali::Actor::Property::LAYOUT_DIRECTION:
536 Dali::LayoutDirection::Type direction = actor.mLayoutDirection;
537 actor.mInheritLayoutDirection = false;
539 if(Scripting::GetEnumerationProperty<LayoutDirection::Type>(property, LAYOUT_DIRECTION_TABLE, LAYOUT_DIRECTION_TABLE_COUNT, direction))
541 actor.mParentImpl.InheritLayoutDirectionRecursively(direction, true);
546 case Dali::Actor::Property::INHERIT_LAYOUT_DIRECTION:
549 if(property.Get(value))
551 actor.SetInheritLayoutDirection(value);
556 case Dali::Actor::Property::KEYBOARD_FOCUSABLE:
559 if(property.Get(value))
561 actor.SetKeyboardFocusable(value);
566 case Dali::DevelActor::Property::UPDATE_SIZE_HINT:
568 actor.SetUpdateSizeHint(property.Get<Vector2>());
572 case Dali::DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START:
574 bool boolValue = false;
575 if(property.Get(boolValue))
577 actor.mCaptureAllTouchAfterStart = boolValue;
582 case Dali::DevelActor::Property::TOUCH_AREA_OFFSET:
585 if(property.Get(rectValue))
587 actor.SetTouchAreaOffset(rectValue);
592 case Dali::DevelActor::Property::BLEND_EQUATION:
595 if(property.Get(value))
597 actor.SetBlendEquation(static_cast<DevelBlendEquation::Type>(value));
602 case Dali::DevelActor::Property::TOUCH_FOCUSABLE:
605 if(property.Get(value))
607 actor.SetTouchFocusable(value);
612 case Dali::DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN:
615 if(property.Get(value))
617 actor.SetKeyboardFocusableChildren(value);
624 // this can happen in the case of a non-animatable default property so just do nothing
630 void Actor::PropertyHandler::SetSceneGraphProperty(
631 Property::Index index,
632 const PropertyMetadata& entry,
633 const Property::Value& value,
634 EventThreadServices& eventThreadServices,
635 const SceneGraph::Node& node)
637 switch(entry.GetType())
639 case Property::BOOLEAN:
641 const AnimatableProperty<bool>* property = dynamic_cast<const AnimatableProperty<bool>*>(entry.GetSceneGraphProperty());
642 DALI_ASSERT_DEBUG(NULL != property);
644 // property is being used in a separate thread; queue a message to set the property
645 SceneGraph::NodePropertyMessage<bool>::Send(eventThreadServices, &node, property, &AnimatableProperty<bool>::Bake, value.Get<bool>());
650 case Property::INTEGER:
652 const AnimatableProperty<int>* property = dynamic_cast<const AnimatableProperty<int>*>(entry.GetSceneGraphProperty());
653 DALI_ASSERT_DEBUG(NULL != property);
655 // property is being used in a separate thread; queue a message to set the property
656 SceneGraph::NodePropertyMessage<int>::Send(eventThreadServices, &node, property, &AnimatableProperty<int>::Bake, value.Get<int>());
661 case Property::FLOAT:
663 const AnimatableProperty<float>* property = dynamic_cast<const AnimatableProperty<float>*>(entry.GetSceneGraphProperty());
664 DALI_ASSERT_DEBUG(NULL != property);
666 // property is being used in a separate thread; queue a message to set the property
667 SceneGraph::NodePropertyMessage<float>::Send(eventThreadServices, &node, property, &AnimatableProperty<float>::Bake, value.Get<float>());
672 case Property::VECTOR2:
674 const AnimatableProperty<Vector2>* property = dynamic_cast<const AnimatableProperty<Vector2>*>(entry.GetSceneGraphProperty());
675 DALI_ASSERT_DEBUG(NULL != property);
677 // property is being used in a separate thread; queue a message to set the property
678 if(entry.componentIndex == 0)
680 SceneGraph::NodePropertyComponentMessage<Vector2>::Send(eventThreadServices, &node, property, &AnimatableProperty<Vector2>::BakeX, value.Get<float>());
682 else if(entry.componentIndex == 1)
684 SceneGraph::NodePropertyComponentMessage<Vector2>::Send(eventThreadServices, &node, property, &AnimatableProperty<Vector2>::BakeY, value.Get<float>());
688 SceneGraph::NodePropertyMessage<Vector2>::Send(eventThreadServices, &node, property, &AnimatableProperty<Vector2>::Bake, value.Get<Vector2>());
694 case Property::VECTOR3:
696 const AnimatableProperty<Vector3>* property = dynamic_cast<const AnimatableProperty<Vector3>*>(entry.GetSceneGraphProperty());
697 DALI_ASSERT_DEBUG(NULL != property);
699 // property is being used in a separate thread; queue a message to set the property
700 if(entry.componentIndex == 0)
702 SceneGraph::NodePropertyComponentMessage<Vector3>::Send(eventThreadServices, &node, property, &AnimatableProperty<Vector3>::BakeX, value.Get<float>());
704 else if(entry.componentIndex == 1)
706 SceneGraph::NodePropertyComponentMessage<Vector3>::Send(eventThreadServices, &node, property, &AnimatableProperty<Vector3>::BakeY, value.Get<float>());
708 else if(entry.componentIndex == 2)
710 SceneGraph::NodePropertyComponentMessage<Vector3>::Send(eventThreadServices, &node, property, &AnimatableProperty<Vector3>::BakeZ, value.Get<float>());
714 SceneGraph::NodePropertyMessage<Vector3>::Send(eventThreadServices, &node, property, &AnimatableProperty<Vector3>::Bake, value.Get<Vector3>());
720 case Property::VECTOR4:
722 const AnimatableProperty<Vector4>* property = dynamic_cast<const AnimatableProperty<Vector4>*>(entry.GetSceneGraphProperty());
723 DALI_ASSERT_DEBUG(NULL != property);
725 // property is being used in a separate thread; queue a message to set the property
726 if(entry.componentIndex == 0)
728 SceneGraph::NodePropertyComponentMessage<Vector4>::Send(eventThreadServices, &node, property, &AnimatableProperty<Vector4>::BakeX, value.Get<float>());
730 else if(entry.componentIndex == 1)
732 SceneGraph::NodePropertyComponentMessage<Vector4>::Send(eventThreadServices, &node, property, &AnimatableProperty<Vector4>::BakeY, value.Get<float>());
734 else if(entry.componentIndex == 2)
736 SceneGraph::NodePropertyComponentMessage<Vector4>::Send(eventThreadServices, &node, property, &AnimatableProperty<Vector4>::BakeZ, value.Get<float>());
738 else if(entry.componentIndex == 3)
740 SceneGraph::NodePropertyComponentMessage<Vector4>::Send(eventThreadServices, &node, property, &AnimatableProperty<Vector4>::BakeW, value.Get<float>());
744 SceneGraph::NodePropertyMessage<Vector4>::Send(eventThreadServices, &node, property, &AnimatableProperty<Vector4>::Bake, value.Get<Vector4>());
750 case Property::ROTATION:
752 const AnimatableProperty<Quaternion>* property = dynamic_cast<const AnimatableProperty<Quaternion>*>(entry.GetSceneGraphProperty());
753 DALI_ASSERT_DEBUG(NULL != property);
755 // property is being used in a separate thread; queue a message to set the property
756 SceneGraph::NodePropertyMessage<Quaternion>::Send(eventThreadServices, &node, property, &AnimatableProperty<Quaternion>::Bake, value.Get<Quaternion>());
761 case Property::MATRIX:
763 const AnimatableProperty<Matrix>* property = dynamic_cast<const AnimatableProperty<Matrix>*>(entry.GetSceneGraphProperty());
764 DALI_ASSERT_DEBUG(NULL != property);
766 // property is being used in a separate thread; queue a message to set the property
767 SceneGraph::NodePropertyMessage<Matrix>::Send(eventThreadServices, &node, property, &AnimatableProperty<Matrix>::Bake, value.Get<Matrix>());
772 case Property::MATRIX3:
774 const AnimatableProperty<Matrix3>* property = dynamic_cast<const AnimatableProperty<Matrix3>*>(entry.GetSceneGraphProperty());
775 DALI_ASSERT_DEBUG(NULL != property);
777 // property is being used in a separate thread; queue a message to set the property
778 SceneGraph::NodePropertyMessage<Matrix3>::Send(eventThreadServices, &node, property, &AnimatableProperty<Matrix3>::Bake, value.Get<Matrix3>());
785 // nothing to do for other types
790 void Actor::PropertyHandler::OnNotifyDefaultPropertyAnimation(Internal::Actor& actor, Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType)
792 switch(animationType)
795 case Animation::BETWEEN:
799 case Dali::Actor::Property::SIZE:
802 if(value.Get(targetSize))
804 actor.mSizer.OnAnimateSize(animation, targetSize, false);
809 case Dali::Actor::Property::SIZE_WIDTH:
814 actor.mSizer.OnAnimateWidth(animation, width, false);
819 case Dali::Actor::Property::SIZE_HEIGHT:
822 if(value.Get(height))
824 actor.mSizer.OnAnimateHeight(animation, height, false);
829 case Dali::Actor::Property::SIZE_DEPTH:
834 actor.mSizer.OnAnimateDepth(animation, depth, false);
839 case Dali::Actor::Property::POSITION:
841 value.Get(actor.mTargetPosition);
845 case Dali::Actor::Property::POSITION_X:
847 value.Get(actor.mTargetPosition.x);
851 case Dali::Actor::Property::POSITION_Y:
853 value.Get(actor.mTargetPosition.y);
857 case Dali::Actor::Property::POSITION_Z:
859 value.Get(actor.mTargetPosition.z);
863 case Dali::Actor::Property::ORIENTATION:
865 value.Get(actor.mTargetOrientation);
869 case Dali::Actor::Property::SCALE:
871 value.Get(actor.mTargetScale);
875 case Dali::Actor::Property::SCALE_X:
877 value.Get(actor.mTargetScale.x);
881 case Dali::Actor::Property::SCALE_Y:
883 value.Get(actor.mTargetScale.y);
887 case Dali::Actor::Property::SCALE_Z:
889 value.Get(actor.mTargetScale.z);
893 case Dali::Actor::Property::VISIBLE:
895 actor.SetVisibleInternal(value.Get<bool>(), SendMessage::FALSE);
899 case Dali::Actor::Property::COLOR:
901 value.Get(actor.mTargetColor);
905 case Dali::Actor::Property::COLOR_RED:
907 value.Get(actor.mTargetColor.r);
911 case Dali::Actor::Property::COLOR_GREEN:
913 value.Get(actor.mTargetColor.g);
917 case Dali::Actor::Property::COLOR_BLUE:
919 value.Get(actor.mTargetColor.b);
923 case Dali::Actor::Property::COLOR_ALPHA:
924 case Dali::Actor::Property::OPACITY:
926 value.Get(actor.mTargetColor.a);
932 // Not an animatable property. Do nothing.
943 case Dali::Actor::Property::SIZE:
946 if(value.Get(targetSize))
948 actor.mSizer.OnAnimateSize(animation, targetSize, true);
953 case Dali::Actor::Property::SIZE_WIDTH:
958 actor.mSizer.OnAnimateWidth(animation, width, true);
963 case Dali::Actor::Property::SIZE_HEIGHT:
966 if(value.Get(height))
968 actor.mSizer.OnAnimateHeight(animation, height, true);
973 case Dali::Actor::Property::SIZE_DEPTH:
978 actor.mSizer.OnAnimateDepth(animation, depth, true);
983 case Dali::Actor::Property::POSITION:
985 AdjustValue<Vector3>(actor.mTargetPosition, value);
989 case Dali::Actor::Property::POSITION_X:
991 AdjustValue<float>(actor.mTargetPosition.x, value);
995 case Dali::Actor::Property::POSITION_Y:
997 AdjustValue<float>(actor.mTargetPosition.y, value);
1001 case Dali::Actor::Property::POSITION_Z:
1003 AdjustValue<float>(actor.mTargetPosition.z, value);
1007 case Dali::Actor::Property::ORIENTATION:
1009 Quaternion relativeValue;
1010 if(value.Get(relativeValue))
1012 actor.mTargetOrientation *= relativeValue;
1017 case Dali::Actor::Property::SCALE:
1019 AdjustValue<Vector3>(actor.mTargetScale, value);
1023 case Dali::Actor::Property::SCALE_X:
1025 AdjustValue<float>(actor.mTargetScale.x, value);
1029 case Dali::Actor::Property::SCALE_Y:
1031 AdjustValue<float>(actor.mTargetScale.y, value);
1035 case Dali::Actor::Property::SCALE_Z:
1037 AdjustValue<float>(actor.mTargetScale.z, value);
1041 case Dali::Actor::Property::VISIBLE:
1043 bool relativeValue = false;
1044 if(value.Get(relativeValue))
1046 bool visible = actor.mVisible || relativeValue;
1047 actor.SetVisibleInternal(visible, SendMessage::FALSE);
1052 case Dali::Actor::Property::COLOR:
1054 AdjustValue<Vector4>(actor.mTargetColor, value);
1058 case Dali::Actor::Property::COLOR_RED:
1060 AdjustValue<float>(actor.mTargetColor.r, value);
1064 case Dali::Actor::Property::COLOR_GREEN:
1066 AdjustValue<float>(actor.mTargetColor.g, value);
1070 case Dali::Actor::Property::COLOR_BLUE:
1072 AdjustValue<float>(actor.mTargetColor.b, value);
1076 case Dali::Actor::Property::COLOR_ALPHA:
1077 case Dali::Actor::Property::OPACITY:
1079 AdjustValue<float>(actor.mTargetColor.a, value);
1085 // Not an animatable property. Do nothing.
1094 const PropertyBase* Actor::PropertyHandler::GetSceneObjectAnimatableProperty(Property::Index index, const SceneGraph::Node& node)
1096 const PropertyBase* property(nullptr);
1100 case Dali::Actor::Property::SIZE: // FALLTHROUGH
1101 case Dali::Actor::Property::SIZE_WIDTH: // FALLTHROUGH
1102 case Dali::Actor::Property::SIZE_HEIGHT: // FALLTHROUGH
1103 case Dali::Actor::Property::SIZE_DEPTH:
1105 property = &node.mSize;
1108 case Dali::Actor::Property::POSITION: // FALLTHROUGH
1109 case Dali::Actor::Property::POSITION_X: // FALLTHROUGH
1110 case Dali::Actor::Property::POSITION_Y: // FALLTHROUGH
1111 case Dali::Actor::Property::POSITION_Z:
1113 property = &node.mPosition;
1116 case Dali::Actor::Property::ORIENTATION:
1118 property = &node.mOrientation;
1121 case Dali::Actor::Property::SCALE: // FALLTHROUGH
1122 case Dali::Actor::Property::SCALE_X: // FALLTHROUGH
1123 case Dali::Actor::Property::SCALE_Y: // FALLTHROUGH
1124 case Dali::Actor::Property::SCALE_Z:
1126 property = &node.mScale;
1129 case Dali::Actor::Property::VISIBLE:
1131 property = &node.mVisible;
1134 case Dali::Actor::Property::COLOR: // FALLTHROUGH
1135 case Dali::Actor::Property::COLOR_RED: // FALLTHROUGH
1136 case Dali::Actor::Property::COLOR_GREEN: // FALLTHROUGH
1137 case Dali::Actor::Property::COLOR_BLUE: // FALLTHROUGH
1138 case Dali::Actor::Property::COLOR_ALPHA: // FALLTHROUGH
1139 case Dali::Actor::Property::OPACITY:
1141 property = &node.mColor;
1153 const PropertyInputImpl* Actor::PropertyHandler::GetSceneObjectInputProperty(Property::Index index, const SceneGraph::Node& node)
1155 const PropertyInputImpl* property(nullptr);
1159 case Dali::Actor::Property::PARENT_ORIGIN: // FALLTHROUGH
1160 case Dali::Actor::Property::PARENT_ORIGIN_X: // FALLTHROUGH
1161 case Dali::Actor::Property::PARENT_ORIGIN_Y: // FALLTHROUGH
1162 case Dali::Actor::Property::PARENT_ORIGIN_Z:
1164 property = &node.mParentOrigin;
1167 case Dali::Actor::Property::ANCHOR_POINT: // FALLTHROUGH
1168 case Dali::Actor::Property::ANCHOR_POINT_X: // FALLTHROUGH
1169 case Dali::Actor::Property::ANCHOR_POINT_Y: // FALLTHROUGH
1170 case Dali::Actor::Property::ANCHOR_POINT_Z:
1172 property = &node.mAnchorPoint;
1175 case Dali::Actor::Property::WORLD_POSITION: // FALLTHROUGH
1176 case Dali::Actor::Property::WORLD_POSITION_X: // FALLTHROUGH
1177 case Dali::Actor::Property::WORLD_POSITION_Y: // FALLTHROUGH
1178 case Dali::Actor::Property::WORLD_POSITION_Z:
1180 property = &node.mWorldPosition;
1183 case Dali::Actor::Property::WORLD_ORIENTATION:
1185 property = &node.mWorldOrientation;
1188 case Dali::Actor::Property::WORLD_SCALE:
1190 property = &node.mWorldScale;
1193 case Dali::Actor::Property::WORLD_COLOR:
1195 property = &node.mWorldColor;
1198 case Dali::Actor::Property::WORLD_MATRIX:
1200 property = &node.mWorldMatrix;
1203 case Dali::Actor::Property::CULLED:
1205 property = &node.mCulled;
1217 int32_t Actor::PropertyHandler::GetPropertyComponentIndex(Property::Index index)
1219 int32_t componentIndex = Property::INVALID_COMPONENT_INDEX;
1223 case Dali::Actor::Property::PARENT_ORIGIN_X:
1224 case Dali::Actor::Property::ANCHOR_POINT_X:
1225 case Dali::Actor::Property::SIZE_WIDTH:
1226 case Dali::Actor::Property::POSITION_X:
1227 case Dali::Actor::Property::WORLD_POSITION_X:
1228 case Dali::Actor::Property::SCALE_X:
1229 case Dali::Actor::Property::COLOR_RED:
1235 case Dali::Actor::Property::PARENT_ORIGIN_Y:
1236 case Dali::Actor::Property::ANCHOR_POINT_Y:
1237 case Dali::Actor::Property::SIZE_HEIGHT:
1238 case Dali::Actor::Property::POSITION_Y:
1239 case Dali::Actor::Property::WORLD_POSITION_Y:
1240 case Dali::Actor::Property::SCALE_Y:
1241 case Dali::Actor::Property::COLOR_GREEN:
1247 case Dali::Actor::Property::PARENT_ORIGIN_Z:
1248 case Dali::Actor::Property::ANCHOR_POINT_Z:
1249 case Dali::Actor::Property::SIZE_DEPTH:
1250 case Dali::Actor::Property::POSITION_Z:
1251 case Dali::Actor::Property::WORLD_POSITION_Z:
1252 case Dali::Actor::Property::SCALE_Z:
1253 case Dali::Actor::Property::COLOR_BLUE:
1259 case Dali::Actor::Property::COLOR_ALPHA:
1260 case Dali::Actor::Property::OPACITY:
1273 return componentIndex;
1276 bool Actor::PropertyHandler::GetCachedPropertyValue(const Internal::Actor& actor, Property::Index index, Property::Value& value)
1278 bool valueSet = true;
1282 case Dali::Actor::Property::PARENT_ORIGIN:
1284 value = actor.GetCurrentParentOrigin();
1288 case Dali::Actor::Property::PARENT_ORIGIN_X:
1290 value = actor.GetCurrentParentOrigin().x;
1294 case Dali::Actor::Property::PARENT_ORIGIN_Y:
1296 value = actor.GetCurrentParentOrigin().y;
1300 case Dali::Actor::Property::PARENT_ORIGIN_Z:
1302 value = actor.GetCurrentParentOrigin().z;
1306 case Dali::Actor::Property::ANCHOR_POINT:
1308 value = actor.GetCurrentAnchorPoint();
1312 case Dali::Actor::Property::ANCHOR_POINT_X:
1314 value = actor.GetCurrentAnchorPoint().x;
1318 case Dali::Actor::Property::ANCHOR_POINT_Y:
1320 value = actor.GetCurrentAnchorPoint().y;
1324 case Dali::Actor::Property::ANCHOR_POINT_Z:
1326 value = actor.GetCurrentAnchorPoint().z;
1330 case Dali::Actor::Property::SIZE:
1332 value = actor.GetTargetSize();
1336 case Dali::Actor::Property::SIZE_WIDTH:
1338 value = actor.GetTargetSize().width;
1342 case Dali::Actor::Property::SIZE_HEIGHT:
1344 value = actor.GetTargetSize().height;
1348 case Dali::Actor::Property::SIZE_DEPTH:
1350 value = actor.GetTargetSize().depth;
1354 case Dali::Actor::Property::POSITION:
1356 value = actor.GetTargetPosition();
1360 case Dali::Actor::Property::POSITION_X:
1362 value = actor.GetTargetPosition().x;
1366 case Dali::Actor::Property::POSITION_Y:
1368 value = actor.GetTargetPosition().y;
1372 case Dali::Actor::Property::POSITION_Z:
1374 value = actor.GetTargetPosition().z;
1378 case Dali::Actor::Property::ORIENTATION:
1380 value = actor.mTargetOrientation;
1384 case Dali::Actor::Property::SCALE:
1386 value = actor.mTargetScale;
1390 case Dali::Actor::Property::SCALE_X:
1392 value = actor.mTargetScale.x;
1396 case Dali::Actor::Property::SCALE_Y:
1398 value = actor.mTargetScale.y;
1402 case Dali::Actor::Property::SCALE_Z:
1404 value = actor.mTargetScale.z;
1408 case Dali::Actor::Property::VISIBLE:
1410 value = actor.mVisible;
1414 case Dali::Actor::Property::COLOR:
1416 value = actor.mTargetColor;
1420 case Dali::Actor::Property::COLOR_RED:
1422 value = actor.mTargetColor.r;
1426 case Dali::Actor::Property::COLOR_GREEN:
1428 value = actor.mTargetColor.g;
1432 case Dali::Actor::Property::COLOR_BLUE:
1434 value = actor.mTargetColor.b;
1438 case Dali::Actor::Property::COLOR_ALPHA:
1439 case Dali::Actor::Property::OPACITY:
1441 value = actor.mTargetColor.a;
1445 case Dali::Actor::Property::NAME:
1447 value = std::string(actor.GetName());
1451 case Dali::Actor::Property::SENSITIVE:
1453 value = actor.IsSensitive();
1457 case Dali::Actor::Property::LEAVE_REQUIRED:
1459 value = actor.GetLeaveRequired();
1463 case Dali::Actor::Property::INHERIT_POSITION:
1465 value = actor.IsPositionInherited();
1469 case Dali::Actor::Property::INHERIT_ORIENTATION:
1471 value = actor.IsOrientationInherited();
1475 case Dali::Actor::Property::INHERIT_SCALE:
1477 value = actor.IsScaleInherited();
1481 case Dali::Actor::Property::COLOR_MODE:
1483 value = actor.GetColorMode();
1487 case Dali::Actor::Property::DRAW_MODE:
1489 value = actor.GetDrawMode();
1493 case Dali::Actor::Property::SIZE_MODE_FACTOR:
1495 value = actor.GetSizeModeFactor();
1499 case Dali::Actor::Property::WIDTH_RESIZE_POLICY:
1501 value = Scripting::GetLinearEnumerationName<ResizePolicy::Type>(actor.mSizer.GetResizePolicy(Dimension::WIDTH), RESIZE_POLICY_TABLE, RESIZE_POLICY_TABLE_COUNT);
1505 case Dali::Actor::Property::HEIGHT_RESIZE_POLICY:
1507 value = Scripting::GetLinearEnumerationName<ResizePolicy::Type>(actor.mSizer.GetResizePolicy(Dimension::HEIGHT), RESIZE_POLICY_TABLE, RESIZE_POLICY_TABLE_COUNT);
1511 case Dali::Actor::Property::SIZE_SCALE_POLICY:
1513 value = actor.mSizer.GetSizeScalePolicy();
1517 case Dali::Actor::Property::WIDTH_FOR_HEIGHT:
1519 value = (actor.mSizer.GetResizePolicy(Dimension::WIDTH) == ResizePolicy::DIMENSION_DEPENDENCY) && (actor.mSizer.GetDimensionDependency(Dimension::WIDTH) == Dimension::HEIGHT);
1523 case Dali::Actor::Property::HEIGHT_FOR_WIDTH:
1525 value = (actor.mSizer.GetResizePolicy(Dimension::HEIGHT) == ResizePolicy::DIMENSION_DEPENDENCY) && (actor.mSizer.GetDimensionDependency(Dimension::HEIGHT) == Dimension::WIDTH);
1529 case Dali::Actor::Property::PADDING:
1531 Vector2 widthPadding = actor.GetPadding(Dimension::WIDTH);
1532 Vector2 heightPadding = actor.GetPadding(Dimension::HEIGHT);
1533 value = Vector4(widthPadding.x, widthPadding.y, heightPadding.x, heightPadding.y);
1537 case Dali::Actor::Property::MINIMUM_SIZE:
1539 value = Vector2(actor.GetMinimumSize(Dimension::WIDTH), actor.GetMinimumSize(Dimension::HEIGHT));
1543 case Dali::Actor::Property::MAXIMUM_SIZE:
1545 value = Vector2(actor.GetMaximumSize(Dimension::WIDTH), actor.GetMaximumSize(Dimension::HEIGHT));
1549 case Dali::Actor::Property::CLIPPING_MODE:
1551 value = actor.mClippingMode;
1555 case Dali::DevelActor::Property::SIBLING_ORDER:
1557 Actor* parent = actor.GetParent();
1560 value = static_cast<int>(parent->GetSiblingOrderOfChild(actor));
1569 case Dali::Actor::Property::SCREEN_POSITION:
1571 value = actor.GetCurrentScreenPosition();
1575 case Dali::Actor::Property::POSITION_USES_ANCHOR_POINT:
1577 value = actor.mPositionUsesAnchorPoint;
1581 case Dali::Actor::Property::LAYOUT_DIRECTION:
1583 value = actor.mLayoutDirection;
1587 case Dali::Actor::Property::INHERIT_LAYOUT_DIRECTION:
1589 value = actor.IsLayoutDirectionInherited();
1593 case Dali::Actor::Property::ID:
1595 value = static_cast<int>(actor.GetId());
1599 case Dali::Actor::Property::HIERARCHY_DEPTH:
1601 value = actor.GetHierarchyDepth();
1605 case Dali::Actor::Property::IS_ROOT:
1607 value = actor.IsRoot();
1611 case Dali::Actor::Property::IS_LAYER:
1613 value = actor.IsLayer();
1617 case Dali::Actor::Property::CONNECTED_TO_SCENE:
1619 value = actor.OnScene();
1623 case Dali::Actor::Property::KEYBOARD_FOCUSABLE:
1625 value = actor.IsKeyboardFocusable();
1629 case Dali::DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START:
1631 value = actor.mCaptureAllTouchAfterStart;
1635 case Dali::DevelActor::Property::TOUCH_AREA_OFFSET:
1637 value = actor.GetTouchAreaOffset();
1641 case Dali::DevelActor::Property::BLEND_EQUATION:
1643 value = actor.GetBlendEquation();
1647 case Dali::DevelActor::Property::TOUCH_FOCUSABLE:
1649 value = actor.IsTouchFocusable();
1653 case Dali::DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN:
1655 value = actor.AreChildrenKeyBoardFocusable();
1661 // Must be a scene-graph only property
1670 bool Actor::PropertyHandler::GetCurrentPropertyValue(const Internal::Actor& actor, Property::Index index, Property::Value& value)
1672 bool valueSet = true;
1676 case Dali::Actor::Property::SIZE:
1678 value = actor.GetCurrentSize();
1682 case Dali::Actor::Property::SIZE_WIDTH:
1684 value = actor.GetCurrentSize().width;
1688 case Dali::Actor::Property::SIZE_HEIGHT:
1690 value = actor.GetCurrentSize().height;
1694 case Dali::Actor::Property::SIZE_DEPTH:
1696 value = actor.GetCurrentSize().depth;
1700 case Dali::Actor::Property::POSITION:
1702 value = actor.GetCurrentPosition();
1706 case Dali::Actor::Property::POSITION_X:
1708 value = actor.GetCurrentPosition().x;
1712 case Dali::Actor::Property::POSITION_Y:
1714 value = actor.GetCurrentPosition().y;
1718 case Dali::Actor::Property::POSITION_Z:
1720 value = actor.GetCurrentPosition().z;
1724 case Dali::Actor::Property::WORLD_POSITION:
1726 value = actor.GetCurrentWorldPosition();
1730 case Dali::Actor::Property::WORLD_POSITION_X:
1732 value = actor.GetCurrentWorldPosition().x;
1736 case Dali::Actor::Property::WORLD_POSITION_Y:
1738 value = actor.GetCurrentWorldPosition().y;
1742 case Dali::Actor::Property::WORLD_POSITION_Z:
1744 value = actor.GetCurrentWorldPosition().z;
1748 case Dali::Actor::Property::ORIENTATION:
1750 value = actor.GetCurrentOrientation();
1754 case Dali::Actor::Property::WORLD_ORIENTATION:
1756 value = actor.GetCurrentWorldOrientation();
1760 case Dali::Actor::Property::SCALE:
1762 value = actor.GetCurrentScale();
1766 case Dali::Actor::Property::SCALE_X:
1768 value = actor.GetCurrentScale().x;
1772 case Dali::Actor::Property::SCALE_Y:
1774 value = actor.GetCurrentScale().y;
1778 case Dali::Actor::Property::SCALE_Z:
1780 value = actor.GetCurrentScale().z;
1784 case Dali::Actor::Property::WORLD_SCALE:
1786 value = actor.GetCurrentWorldScale();
1790 case Dali::Actor::Property::COLOR:
1792 value = actor.GetCurrentColor();
1796 case Dali::Actor::Property::COLOR_RED:
1798 value = actor.GetCurrentColor().r;
1802 case Dali::Actor::Property::COLOR_GREEN:
1804 value = actor.GetCurrentColor().g;
1808 case Dali::Actor::Property::COLOR_BLUE:
1810 value = actor.GetCurrentColor().b;
1814 case Dali::Actor::Property::COLOR_ALPHA:
1815 case Dali::Actor::Property::OPACITY:
1817 value = actor.GetCurrentColor().a;
1821 case Dali::Actor::Property::WORLD_COLOR:
1823 value = actor.GetCurrentWorldColor();
1827 case Dali::Actor::Property::WORLD_MATRIX:
1829 value = actor.GetCurrentWorldMatrix();
1833 case Dali::Actor::Property::VISIBLE:
1835 value = actor.IsVisible();
1839 case Dali::Actor::Property::CULLED:
1841 value = actor.GetNode().IsCulled(actor.GetEventThreadServices().GetEventBufferIndex());
1845 case Dali::DevelActor::Property::UPDATE_SIZE_HINT:
1847 // node is being used in a separate thread, the value from the previous update is the same, set by user
1848 value = Vector2(actor.GetNode().GetUpdateSizeHint());
1854 // Must be an event-side only property
1863 } // namespace Internal