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);
622 case Dali::DevelActor::Property::USER_INTERACTION_ENABLED:
625 if(property.Get(value))
627 actor.SetUserInteractionEnabled(value);
634 // this can happen in the case of a non-animatable default property so just do nothing
640 void Actor::PropertyHandler::SetSceneGraphProperty(
641 Property::Index index,
642 const PropertyMetadata& entry,
643 const Property::Value& value,
644 EventThreadServices& eventThreadServices,
645 const SceneGraph::Node& node)
647 switch(entry.GetType())
649 case Property::BOOLEAN:
651 const AnimatableProperty<bool>* property = dynamic_cast<const AnimatableProperty<bool>*>(entry.GetSceneGraphProperty());
652 DALI_ASSERT_DEBUG(NULL != property);
654 // property is being used in a separate thread; queue a message to set the property
655 SceneGraph::NodePropertyMessage<bool>::Send(eventThreadServices, &node, property, &AnimatableProperty<bool>::Bake, value.Get<bool>());
660 case Property::INTEGER:
662 const AnimatableProperty<int>* property = dynamic_cast<const AnimatableProperty<int>*>(entry.GetSceneGraphProperty());
663 DALI_ASSERT_DEBUG(NULL != property);
665 // property is being used in a separate thread; queue a message to set the property
666 SceneGraph::NodePropertyMessage<int>::Send(eventThreadServices, &node, property, &AnimatableProperty<int>::Bake, value.Get<int>());
671 case Property::FLOAT:
673 const AnimatableProperty<float>* property = dynamic_cast<const AnimatableProperty<float>*>(entry.GetSceneGraphProperty());
674 DALI_ASSERT_DEBUG(NULL != property);
676 // property is being used in a separate thread; queue a message to set the property
677 SceneGraph::NodePropertyMessage<float>::Send(eventThreadServices, &node, property, &AnimatableProperty<float>::Bake, value.Get<float>());
682 case Property::VECTOR2:
684 const AnimatableProperty<Vector2>* property = dynamic_cast<const AnimatableProperty<Vector2>*>(entry.GetSceneGraphProperty());
685 DALI_ASSERT_DEBUG(NULL != property);
687 // property is being used in a separate thread; queue a message to set the property
688 if(entry.componentIndex == 0)
690 SceneGraph::NodePropertyComponentMessage<Vector2>::Send(eventThreadServices, &node, property, &AnimatableProperty<Vector2>::BakeX, value.Get<float>());
692 else if(entry.componentIndex == 1)
694 SceneGraph::NodePropertyComponentMessage<Vector2>::Send(eventThreadServices, &node, property, &AnimatableProperty<Vector2>::BakeY, value.Get<float>());
698 SceneGraph::NodePropertyMessage<Vector2>::Send(eventThreadServices, &node, property, &AnimatableProperty<Vector2>::Bake, value.Get<Vector2>());
704 case Property::VECTOR3:
706 const AnimatableProperty<Vector3>* property = dynamic_cast<const AnimatableProperty<Vector3>*>(entry.GetSceneGraphProperty());
707 DALI_ASSERT_DEBUG(NULL != property);
709 // property is being used in a separate thread; queue a message to set the property
710 if(entry.componentIndex == 0)
712 SceneGraph::NodePropertyComponentMessage<Vector3>::Send(eventThreadServices, &node, property, &AnimatableProperty<Vector3>::BakeX, value.Get<float>());
714 else if(entry.componentIndex == 1)
716 SceneGraph::NodePropertyComponentMessage<Vector3>::Send(eventThreadServices, &node, property, &AnimatableProperty<Vector3>::BakeY, value.Get<float>());
718 else if(entry.componentIndex == 2)
720 SceneGraph::NodePropertyComponentMessage<Vector3>::Send(eventThreadServices, &node, property, &AnimatableProperty<Vector3>::BakeZ, value.Get<float>());
724 SceneGraph::NodePropertyMessage<Vector3>::Send(eventThreadServices, &node, property, &AnimatableProperty<Vector3>::Bake, value.Get<Vector3>());
730 case Property::VECTOR4:
732 const AnimatableProperty<Vector4>* property = dynamic_cast<const AnimatableProperty<Vector4>*>(entry.GetSceneGraphProperty());
733 DALI_ASSERT_DEBUG(NULL != property);
735 // property is being used in a separate thread; queue a message to set the property
736 if(entry.componentIndex == 0)
738 SceneGraph::NodePropertyComponentMessage<Vector4>::Send(eventThreadServices, &node, property, &AnimatableProperty<Vector4>::BakeX, value.Get<float>());
740 else if(entry.componentIndex == 1)
742 SceneGraph::NodePropertyComponentMessage<Vector4>::Send(eventThreadServices, &node, property, &AnimatableProperty<Vector4>::BakeY, value.Get<float>());
744 else if(entry.componentIndex == 2)
746 SceneGraph::NodePropertyComponentMessage<Vector4>::Send(eventThreadServices, &node, property, &AnimatableProperty<Vector4>::BakeZ, value.Get<float>());
748 else if(entry.componentIndex == 3)
750 SceneGraph::NodePropertyComponentMessage<Vector4>::Send(eventThreadServices, &node, property, &AnimatableProperty<Vector4>::BakeW, value.Get<float>());
754 SceneGraph::NodePropertyMessage<Vector4>::Send(eventThreadServices, &node, property, &AnimatableProperty<Vector4>::Bake, value.Get<Vector4>());
760 case Property::ROTATION:
762 const AnimatableProperty<Quaternion>* property = dynamic_cast<const AnimatableProperty<Quaternion>*>(entry.GetSceneGraphProperty());
763 DALI_ASSERT_DEBUG(NULL != property);
765 // property is being used in a separate thread; queue a message to set the property
766 SceneGraph::NodePropertyMessage<Quaternion>::Send(eventThreadServices, &node, property, &AnimatableProperty<Quaternion>::Bake, value.Get<Quaternion>());
771 case Property::MATRIX:
773 const AnimatableProperty<Matrix>* property = dynamic_cast<const AnimatableProperty<Matrix>*>(entry.GetSceneGraphProperty());
774 DALI_ASSERT_DEBUG(NULL != property);
776 // property is being used in a separate thread; queue a message to set the property
777 SceneGraph::NodePropertyMessage<Matrix>::Send(eventThreadServices, &node, property, &AnimatableProperty<Matrix>::Bake, value.Get<Matrix>());
782 case Property::MATRIX3:
784 const AnimatableProperty<Matrix3>* property = dynamic_cast<const AnimatableProperty<Matrix3>*>(entry.GetSceneGraphProperty());
785 DALI_ASSERT_DEBUG(NULL != property);
787 // property is being used in a separate thread; queue a message to set the property
788 SceneGraph::NodePropertyMessage<Matrix3>::Send(eventThreadServices, &node, property, &AnimatableProperty<Matrix3>::Bake, value.Get<Matrix3>());
795 // nothing to do for other types
800 void Actor::PropertyHandler::OnNotifyDefaultPropertyAnimation(Internal::Actor& actor, Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType)
802 switch(animationType)
805 case Animation::BETWEEN:
809 case Dali::Actor::Property::SIZE:
812 if(value.Get(targetSize))
814 actor.mSizer.OnAnimateSize(animation, targetSize, false);
819 case Dali::Actor::Property::SIZE_WIDTH:
824 actor.mSizer.OnAnimateWidth(animation, width, false);
829 case Dali::Actor::Property::SIZE_HEIGHT:
832 if(value.Get(height))
834 actor.mSizer.OnAnimateHeight(animation, height, false);
839 case Dali::Actor::Property::SIZE_DEPTH:
844 actor.mSizer.OnAnimateDepth(animation, depth, false);
849 case Dali::Actor::Property::POSITION:
851 value.Get(actor.mTargetPosition);
855 case Dali::Actor::Property::POSITION_X:
857 value.Get(actor.mTargetPosition.x);
861 case Dali::Actor::Property::POSITION_Y:
863 value.Get(actor.mTargetPosition.y);
867 case Dali::Actor::Property::POSITION_Z:
869 value.Get(actor.mTargetPosition.z);
873 case Dali::Actor::Property::ORIENTATION:
875 value.Get(actor.mTargetOrientation);
879 case Dali::Actor::Property::SCALE:
881 value.Get(actor.mTargetScale);
885 case Dali::Actor::Property::SCALE_X:
887 value.Get(actor.mTargetScale.x);
891 case Dali::Actor::Property::SCALE_Y:
893 value.Get(actor.mTargetScale.y);
897 case Dali::Actor::Property::SCALE_Z:
899 value.Get(actor.mTargetScale.z);
903 case Dali::Actor::Property::VISIBLE:
905 actor.SetVisibleInternal(value.Get<bool>(), SendMessage::FALSE);
909 case Dali::Actor::Property::COLOR:
911 value.Get(actor.mTargetColor);
915 case Dali::Actor::Property::COLOR_RED:
917 value.Get(actor.mTargetColor.r);
921 case Dali::Actor::Property::COLOR_GREEN:
923 value.Get(actor.mTargetColor.g);
927 case Dali::Actor::Property::COLOR_BLUE:
929 value.Get(actor.mTargetColor.b);
933 case Dali::Actor::Property::COLOR_ALPHA:
934 case Dali::Actor::Property::OPACITY:
936 value.Get(actor.mTargetColor.a);
942 // Not an animatable property. Do nothing.
953 case Dali::Actor::Property::SIZE:
956 if(value.Get(targetSize))
958 actor.mSizer.OnAnimateSize(animation, targetSize, true);
963 case Dali::Actor::Property::SIZE_WIDTH:
968 actor.mSizer.OnAnimateWidth(animation, width, true);
973 case Dali::Actor::Property::SIZE_HEIGHT:
976 if(value.Get(height))
978 actor.mSizer.OnAnimateHeight(animation, height, true);
983 case Dali::Actor::Property::SIZE_DEPTH:
988 actor.mSizer.OnAnimateDepth(animation, depth, true);
993 case Dali::Actor::Property::POSITION:
995 AdjustValue<Vector3>(actor.mTargetPosition, value);
999 case Dali::Actor::Property::POSITION_X:
1001 AdjustValue<float>(actor.mTargetPosition.x, value);
1005 case Dali::Actor::Property::POSITION_Y:
1007 AdjustValue<float>(actor.mTargetPosition.y, value);
1011 case Dali::Actor::Property::POSITION_Z:
1013 AdjustValue<float>(actor.mTargetPosition.z, value);
1017 case Dali::Actor::Property::ORIENTATION:
1019 Quaternion relativeValue;
1020 if(value.Get(relativeValue))
1022 actor.mTargetOrientation *= relativeValue;
1027 case Dali::Actor::Property::SCALE:
1029 AdjustValue<Vector3>(actor.mTargetScale, value);
1033 case Dali::Actor::Property::SCALE_X:
1035 AdjustValue<float>(actor.mTargetScale.x, value);
1039 case Dali::Actor::Property::SCALE_Y:
1041 AdjustValue<float>(actor.mTargetScale.y, value);
1045 case Dali::Actor::Property::SCALE_Z:
1047 AdjustValue<float>(actor.mTargetScale.z, value);
1051 case Dali::Actor::Property::VISIBLE:
1053 bool relativeValue = false;
1054 if(value.Get(relativeValue))
1056 bool visible = actor.mVisible || relativeValue;
1057 actor.SetVisibleInternal(visible, SendMessage::FALSE);
1062 case Dali::Actor::Property::COLOR:
1064 AdjustValue<Vector4>(actor.mTargetColor, value);
1068 case Dali::Actor::Property::COLOR_RED:
1070 AdjustValue<float>(actor.mTargetColor.r, value);
1074 case Dali::Actor::Property::COLOR_GREEN:
1076 AdjustValue<float>(actor.mTargetColor.g, value);
1080 case Dali::Actor::Property::COLOR_BLUE:
1082 AdjustValue<float>(actor.mTargetColor.b, value);
1086 case Dali::Actor::Property::COLOR_ALPHA:
1087 case Dali::Actor::Property::OPACITY:
1089 AdjustValue<float>(actor.mTargetColor.a, value);
1095 // Not an animatable property. Do nothing.
1104 const PropertyBase* Actor::PropertyHandler::GetSceneObjectAnimatableProperty(Property::Index index, const SceneGraph::Node& node)
1106 const PropertyBase* property(nullptr);
1110 case Dali::Actor::Property::SIZE: // FALLTHROUGH
1111 case Dali::Actor::Property::SIZE_WIDTH: // FALLTHROUGH
1112 case Dali::Actor::Property::SIZE_HEIGHT: // FALLTHROUGH
1113 case Dali::Actor::Property::SIZE_DEPTH:
1115 property = &node.mSize;
1118 case Dali::Actor::Property::POSITION: // FALLTHROUGH
1119 case Dali::Actor::Property::POSITION_X: // FALLTHROUGH
1120 case Dali::Actor::Property::POSITION_Y: // FALLTHROUGH
1121 case Dali::Actor::Property::POSITION_Z:
1123 property = &node.mPosition;
1126 case Dali::Actor::Property::ORIENTATION:
1128 property = &node.mOrientation;
1131 case Dali::Actor::Property::SCALE: // FALLTHROUGH
1132 case Dali::Actor::Property::SCALE_X: // FALLTHROUGH
1133 case Dali::Actor::Property::SCALE_Y: // FALLTHROUGH
1134 case Dali::Actor::Property::SCALE_Z:
1136 property = &node.mScale;
1139 case Dali::Actor::Property::VISIBLE:
1141 property = &node.mVisible;
1144 case Dali::Actor::Property::COLOR: // FALLTHROUGH
1145 case Dali::Actor::Property::COLOR_RED: // FALLTHROUGH
1146 case Dali::Actor::Property::COLOR_GREEN: // FALLTHROUGH
1147 case Dali::Actor::Property::COLOR_BLUE: // FALLTHROUGH
1148 case Dali::Actor::Property::COLOR_ALPHA: // FALLTHROUGH
1149 case Dali::Actor::Property::OPACITY:
1151 property = &node.mColor;
1163 const PropertyInputImpl* Actor::PropertyHandler::GetSceneObjectInputProperty(Property::Index index, const SceneGraph::Node& node)
1165 const PropertyInputImpl* property(nullptr);
1169 case Dali::Actor::Property::PARENT_ORIGIN: // FALLTHROUGH
1170 case Dali::Actor::Property::PARENT_ORIGIN_X: // FALLTHROUGH
1171 case Dali::Actor::Property::PARENT_ORIGIN_Y: // FALLTHROUGH
1172 case Dali::Actor::Property::PARENT_ORIGIN_Z:
1174 property = &node.mParentOrigin;
1177 case Dali::Actor::Property::ANCHOR_POINT: // FALLTHROUGH
1178 case Dali::Actor::Property::ANCHOR_POINT_X: // FALLTHROUGH
1179 case Dali::Actor::Property::ANCHOR_POINT_Y: // FALLTHROUGH
1180 case Dali::Actor::Property::ANCHOR_POINT_Z:
1182 property = &node.mAnchorPoint;
1185 case Dali::Actor::Property::WORLD_POSITION: // FALLTHROUGH
1186 case Dali::Actor::Property::WORLD_POSITION_X: // FALLTHROUGH
1187 case Dali::Actor::Property::WORLD_POSITION_Y: // FALLTHROUGH
1188 case Dali::Actor::Property::WORLD_POSITION_Z:
1190 property = &node.mWorldPosition;
1193 case Dali::Actor::Property::WORLD_ORIENTATION:
1195 property = &node.mWorldOrientation;
1198 case Dali::Actor::Property::WORLD_SCALE:
1200 property = &node.mWorldScale;
1203 case Dali::Actor::Property::WORLD_COLOR:
1205 property = &node.mWorldColor;
1208 case Dali::Actor::Property::WORLD_MATRIX:
1210 property = &node.mWorldMatrix;
1213 case Dali::Actor::Property::CULLED:
1215 property = &node.mCulled;
1227 int32_t Actor::PropertyHandler::GetPropertyComponentIndex(Property::Index index)
1229 int32_t componentIndex = Property::INVALID_COMPONENT_INDEX;
1233 case Dali::Actor::Property::PARENT_ORIGIN_X:
1234 case Dali::Actor::Property::ANCHOR_POINT_X:
1235 case Dali::Actor::Property::SIZE_WIDTH:
1236 case Dali::Actor::Property::POSITION_X:
1237 case Dali::Actor::Property::WORLD_POSITION_X:
1238 case Dali::Actor::Property::SCALE_X:
1239 case Dali::Actor::Property::COLOR_RED:
1245 case Dali::Actor::Property::PARENT_ORIGIN_Y:
1246 case Dali::Actor::Property::ANCHOR_POINT_Y:
1247 case Dali::Actor::Property::SIZE_HEIGHT:
1248 case Dali::Actor::Property::POSITION_Y:
1249 case Dali::Actor::Property::WORLD_POSITION_Y:
1250 case Dali::Actor::Property::SCALE_Y:
1251 case Dali::Actor::Property::COLOR_GREEN:
1257 case Dali::Actor::Property::PARENT_ORIGIN_Z:
1258 case Dali::Actor::Property::ANCHOR_POINT_Z:
1259 case Dali::Actor::Property::SIZE_DEPTH:
1260 case Dali::Actor::Property::POSITION_Z:
1261 case Dali::Actor::Property::WORLD_POSITION_Z:
1262 case Dali::Actor::Property::SCALE_Z:
1263 case Dali::Actor::Property::COLOR_BLUE:
1269 case Dali::Actor::Property::COLOR_ALPHA:
1270 case Dali::Actor::Property::OPACITY:
1283 return componentIndex;
1286 bool Actor::PropertyHandler::GetCachedPropertyValue(const Internal::Actor& actor, Property::Index index, Property::Value& value)
1288 bool valueSet = true;
1292 case Dali::Actor::Property::PARENT_ORIGIN:
1294 value = actor.GetCurrentParentOrigin();
1298 case Dali::Actor::Property::PARENT_ORIGIN_X:
1300 value = actor.GetCurrentParentOrigin().x;
1304 case Dali::Actor::Property::PARENT_ORIGIN_Y:
1306 value = actor.GetCurrentParentOrigin().y;
1310 case Dali::Actor::Property::PARENT_ORIGIN_Z:
1312 value = actor.GetCurrentParentOrigin().z;
1316 case Dali::Actor::Property::ANCHOR_POINT:
1318 value = actor.GetCurrentAnchorPoint();
1322 case Dali::Actor::Property::ANCHOR_POINT_X:
1324 value = actor.GetCurrentAnchorPoint().x;
1328 case Dali::Actor::Property::ANCHOR_POINT_Y:
1330 value = actor.GetCurrentAnchorPoint().y;
1334 case Dali::Actor::Property::ANCHOR_POINT_Z:
1336 value = actor.GetCurrentAnchorPoint().z;
1340 case Dali::Actor::Property::SIZE:
1342 value = actor.GetTargetSize();
1346 case Dali::Actor::Property::SIZE_WIDTH:
1348 value = actor.GetTargetSize().width;
1352 case Dali::Actor::Property::SIZE_HEIGHT:
1354 value = actor.GetTargetSize().height;
1358 case Dali::Actor::Property::SIZE_DEPTH:
1360 value = actor.GetTargetSize().depth;
1364 case Dali::Actor::Property::POSITION:
1366 value = actor.GetTargetPosition();
1370 case Dali::Actor::Property::POSITION_X:
1372 value = actor.GetTargetPosition().x;
1376 case Dali::Actor::Property::POSITION_Y:
1378 value = actor.GetTargetPosition().y;
1382 case Dali::Actor::Property::POSITION_Z:
1384 value = actor.GetTargetPosition().z;
1388 case Dali::Actor::Property::ORIENTATION:
1390 value = actor.mTargetOrientation;
1394 case Dali::Actor::Property::SCALE:
1396 value = actor.mTargetScale;
1400 case Dali::Actor::Property::SCALE_X:
1402 value = actor.mTargetScale.x;
1406 case Dali::Actor::Property::SCALE_Y:
1408 value = actor.mTargetScale.y;
1412 case Dali::Actor::Property::SCALE_Z:
1414 value = actor.mTargetScale.z;
1418 case Dali::Actor::Property::VISIBLE:
1420 value = actor.mVisible;
1424 case Dali::Actor::Property::COLOR:
1426 value = actor.mTargetColor;
1430 case Dali::Actor::Property::COLOR_RED:
1432 value = actor.mTargetColor.r;
1436 case Dali::Actor::Property::COLOR_GREEN:
1438 value = actor.mTargetColor.g;
1442 case Dali::Actor::Property::COLOR_BLUE:
1444 value = actor.mTargetColor.b;
1448 case Dali::Actor::Property::COLOR_ALPHA:
1449 case Dali::Actor::Property::OPACITY:
1451 value = actor.mTargetColor.a;
1455 case Dali::Actor::Property::NAME:
1457 value = std::string(actor.GetName());
1461 case Dali::Actor::Property::SENSITIVE:
1463 value = actor.IsSensitive();
1467 case Dali::Actor::Property::LEAVE_REQUIRED:
1469 value = actor.GetLeaveRequired();
1473 case Dali::Actor::Property::INHERIT_POSITION:
1475 value = actor.IsPositionInherited();
1479 case Dali::Actor::Property::INHERIT_ORIENTATION:
1481 value = actor.IsOrientationInherited();
1485 case Dali::Actor::Property::INHERIT_SCALE:
1487 value = actor.IsScaleInherited();
1491 case Dali::Actor::Property::COLOR_MODE:
1493 value = actor.GetColorMode();
1497 case Dali::Actor::Property::DRAW_MODE:
1499 value = actor.GetDrawMode();
1503 case Dali::Actor::Property::SIZE_MODE_FACTOR:
1505 value = actor.GetSizeModeFactor();
1509 case Dali::Actor::Property::WIDTH_RESIZE_POLICY:
1511 value = Scripting::GetLinearEnumerationName<ResizePolicy::Type>(actor.mSizer.GetResizePolicy(Dimension::WIDTH), RESIZE_POLICY_TABLE, RESIZE_POLICY_TABLE_COUNT);
1515 case Dali::Actor::Property::HEIGHT_RESIZE_POLICY:
1517 value = Scripting::GetLinearEnumerationName<ResizePolicy::Type>(actor.mSizer.GetResizePolicy(Dimension::HEIGHT), RESIZE_POLICY_TABLE, RESIZE_POLICY_TABLE_COUNT);
1521 case Dali::Actor::Property::SIZE_SCALE_POLICY:
1523 value = actor.mSizer.GetSizeScalePolicy();
1527 case Dali::Actor::Property::WIDTH_FOR_HEIGHT:
1529 value = (actor.mSizer.GetResizePolicy(Dimension::WIDTH) == ResizePolicy::DIMENSION_DEPENDENCY) && (actor.mSizer.GetDimensionDependency(Dimension::WIDTH) == Dimension::HEIGHT);
1533 case Dali::Actor::Property::HEIGHT_FOR_WIDTH:
1535 value = (actor.mSizer.GetResizePolicy(Dimension::HEIGHT) == ResizePolicy::DIMENSION_DEPENDENCY) && (actor.mSizer.GetDimensionDependency(Dimension::HEIGHT) == Dimension::WIDTH);
1539 case Dali::Actor::Property::PADDING:
1541 Vector2 widthPadding = actor.GetPadding(Dimension::WIDTH);
1542 Vector2 heightPadding = actor.GetPadding(Dimension::HEIGHT);
1543 value = Vector4(widthPadding.x, widthPadding.y, heightPadding.x, heightPadding.y);
1547 case Dali::Actor::Property::MINIMUM_SIZE:
1549 value = Vector2(actor.GetMinimumSize(Dimension::WIDTH), actor.GetMinimumSize(Dimension::HEIGHT));
1553 case Dali::Actor::Property::MAXIMUM_SIZE:
1555 value = Vector2(actor.GetMaximumSize(Dimension::WIDTH), actor.GetMaximumSize(Dimension::HEIGHT));
1559 case Dali::Actor::Property::CLIPPING_MODE:
1561 value = actor.mClippingMode;
1565 case Dali::DevelActor::Property::SIBLING_ORDER:
1567 Actor* parent = actor.GetParent();
1570 value = static_cast<int>(parent->GetSiblingOrderOfChild(actor));
1579 case Dali::Actor::Property::SCREEN_POSITION:
1581 value = actor.GetCurrentScreenPosition();
1585 case Dali::Actor::Property::POSITION_USES_ANCHOR_POINT:
1587 value = actor.mPositionUsesAnchorPoint;
1591 case Dali::Actor::Property::LAYOUT_DIRECTION:
1593 value = actor.mLayoutDirection;
1597 case Dali::Actor::Property::INHERIT_LAYOUT_DIRECTION:
1599 value = actor.IsLayoutDirectionInherited();
1603 case Dali::Actor::Property::ID:
1605 value = static_cast<int>(actor.GetId());
1609 case Dali::Actor::Property::HIERARCHY_DEPTH:
1611 value = actor.GetHierarchyDepth();
1615 case Dali::Actor::Property::IS_ROOT:
1617 value = actor.IsRoot();
1621 case Dali::Actor::Property::IS_LAYER:
1623 value = actor.IsLayer();
1627 case Dali::Actor::Property::CONNECTED_TO_SCENE:
1629 value = actor.OnScene();
1633 case Dali::Actor::Property::KEYBOARD_FOCUSABLE:
1635 value = actor.IsKeyboardFocusable();
1639 case Dali::DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START:
1641 value = actor.mCaptureAllTouchAfterStart;
1645 case Dali::DevelActor::Property::TOUCH_AREA_OFFSET:
1647 value = actor.GetTouchAreaOffset();
1651 case Dali::DevelActor::Property::BLEND_EQUATION:
1653 value = actor.GetBlendEquation();
1657 case Dali::DevelActor::Property::TOUCH_FOCUSABLE:
1659 value = actor.IsTouchFocusable();
1663 case Dali::DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN:
1665 value = actor.AreChildrenKeyBoardFocusable();
1669 case Dali::DevelActor::Property::USER_INTERACTION_ENABLED:
1671 value = actor.IsUserInteractionEnabled();
1677 // Must be a scene-graph only property
1686 bool Actor::PropertyHandler::GetCurrentPropertyValue(const Internal::Actor& actor, Property::Index index, Property::Value& value)
1688 bool valueSet = true;
1692 case Dali::Actor::Property::SIZE:
1694 value = actor.GetCurrentSize();
1698 case Dali::Actor::Property::SIZE_WIDTH:
1700 value = actor.GetCurrentSize().width;
1704 case Dali::Actor::Property::SIZE_HEIGHT:
1706 value = actor.GetCurrentSize().height;
1710 case Dali::Actor::Property::SIZE_DEPTH:
1712 value = actor.GetCurrentSize().depth;
1716 case Dali::Actor::Property::POSITION:
1718 value = actor.GetCurrentPosition();
1722 case Dali::Actor::Property::POSITION_X:
1724 value = actor.GetCurrentPosition().x;
1728 case Dali::Actor::Property::POSITION_Y:
1730 value = actor.GetCurrentPosition().y;
1734 case Dali::Actor::Property::POSITION_Z:
1736 value = actor.GetCurrentPosition().z;
1740 case Dali::Actor::Property::WORLD_POSITION:
1742 value = actor.GetCurrentWorldPosition();
1746 case Dali::Actor::Property::WORLD_POSITION_X:
1748 value = actor.GetCurrentWorldPosition().x;
1752 case Dali::Actor::Property::WORLD_POSITION_Y:
1754 value = actor.GetCurrentWorldPosition().y;
1758 case Dali::Actor::Property::WORLD_POSITION_Z:
1760 value = actor.GetCurrentWorldPosition().z;
1764 case Dali::Actor::Property::ORIENTATION:
1766 value = actor.GetCurrentOrientation();
1770 case Dali::Actor::Property::WORLD_ORIENTATION:
1772 value = actor.GetCurrentWorldOrientation();
1776 case Dali::Actor::Property::SCALE:
1778 value = actor.GetCurrentScale();
1782 case Dali::Actor::Property::SCALE_X:
1784 value = actor.GetCurrentScale().x;
1788 case Dali::Actor::Property::SCALE_Y:
1790 value = actor.GetCurrentScale().y;
1794 case Dali::Actor::Property::SCALE_Z:
1796 value = actor.GetCurrentScale().z;
1800 case Dali::Actor::Property::WORLD_SCALE:
1802 value = actor.GetCurrentWorldScale();
1806 case Dali::Actor::Property::COLOR:
1808 value = actor.GetCurrentColor();
1812 case Dali::Actor::Property::COLOR_RED:
1814 value = actor.GetCurrentColor().r;
1818 case Dali::Actor::Property::COLOR_GREEN:
1820 value = actor.GetCurrentColor().g;
1824 case Dali::Actor::Property::COLOR_BLUE:
1826 value = actor.GetCurrentColor().b;
1830 case Dali::Actor::Property::COLOR_ALPHA:
1831 case Dali::Actor::Property::OPACITY:
1833 value = actor.GetCurrentColor().a;
1837 case Dali::Actor::Property::WORLD_COLOR:
1839 value = actor.GetCurrentWorldColor();
1843 case Dali::Actor::Property::WORLD_MATRIX:
1845 value = actor.GetCurrentWorldMatrix();
1849 case Dali::Actor::Property::VISIBLE:
1851 value = actor.IsVisible();
1855 case Dali::Actor::Property::CULLED:
1857 value = actor.GetNode().IsCulled(actor.GetEventThreadServices().GetEventBufferIndex());
1861 case Dali::DevelActor::Property::UPDATE_SIZE_HINT:
1863 // node is being used in a separate thread, the value from the previous update is the same, set by user
1864 value = Vector2(actor.GetNode().GetUpdateSizeHint());
1870 // Must be an event-side only property
1879 } // namespace Internal