+ Handle handle;
+ return Dali::Property(handle, Property::INVALID_INDEX);
+}
+
+void Control::Impl::MakeVisualTransition(Dali::Animation& animation, Dali::Toolkit::Control source, Dali::Property::Index visualIndex, AlphaFunction alphaFunction, TimePeriod timePeriod)
+{
+ Dali::Toolkit::Control sourceHandle = Dali::Toolkit::Control::DownCast(source);
+ Property::Map sourceMap = sourceHandle.GetProperty<Property::Map>(visualIndex);
+ Dali::Toolkit::Control destinationHandle = Dali::Toolkit::Control::DownCast(mControlImpl.Self());
+ Property::Map destinationMap = destinationHandle.GetProperty<Property::Map>(visualIndex);
+
+ Vector4 mixColor(1.0f, 1.0f, 1.0f, 1.0f);
+ Vector4 cornerRadius(0.0f, 0.0f, 0.0f, 0.0f);
+ float borderlineWidth(0.0f);
+ Vector4 borderlineColor(0.0f, 0.0f, 0.0f, 1.0f);
+ float borderlineOffset(0.0f);
+
+ if(!destinationMap.Empty())
+ {
+ static auto findValueVector4 = [](const Property::Map& map, Property::Index index, const Vector4& defaultValue = Vector4()) -> Vector4 {
+ Property::Value* propertyValue = map.Find(index);
+ if(propertyValue)
+ {
+ return propertyValue->Get<Vector4>();
+ }
+ return defaultValue;
+ };
+
+ static auto findValueFloat = [](const Property::Map& map, Property::Index index, const float& defaultValue = 0.0f) -> float {
+ Property::Value* propertyValue = map.Find(index);
+ if(propertyValue)
+ {
+ return propertyValue->Get<float>();
+ }
+ return defaultValue;
+ };
+
+ mixColor = findValueVector4(destinationMap, Dali::Toolkit::Visual::Property::MIX_COLOR, mixColor);
+ cornerRadius = findValueVector4(destinationMap, Toolkit::DevelVisual::Property::CORNER_RADIUS, cornerRadius);
+ borderlineWidth = findValueFloat(destinationMap, Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, borderlineWidth);
+ borderlineColor = findValueVector4(destinationMap, Toolkit::DevelVisual::Property::BORDERLINE_COLOR, borderlineColor);
+ borderlineOffset = findValueFloat(destinationMap, Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, borderlineOffset);
+
+ if(sourceMap.Empty())
+ {
+ sourceMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
+ sourceMap.Insert(Dali::Toolkit::Visual::Property::MIX_COLOR, Color::TRANSPARENT);
+ sourceMap.Insert(Toolkit::DevelVisual::Property::CORNER_RADIUS, cornerRadius);
+ sourceMap.Insert(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, borderlineWidth);
+ sourceMap.Insert(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, borderlineColor);
+ sourceMap.Insert(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, borderlineOffset);
+ }
+
+ Vector4 sourceMixColor = findValueVector4(sourceMap, Dali::Toolkit::Visual::Property::MIX_COLOR, mixColor);
+ Vector4 sourceCornerRadius = findValueVector4(sourceMap, Toolkit::DevelVisual::Property::CORNER_RADIUS, cornerRadius);
+ float sourceBorderlineWidth = findValueFloat(sourceMap, Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, borderlineWidth);
+ Vector4 sourceBorderlineColor = findValueVector4(sourceMap, Toolkit::DevelVisual::Property::BORDERLINE_COLOR, borderlineColor);
+ float sourceBorderlineOffset = findValueFloat(sourceMap, Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, borderlineOffset);
+
+ std::vector<Dali::Property> properties;
+ std::vector<std::pair<Property::Value, Property::Value>> values;
+
+ if(Vector3(sourceMixColor) != Vector3(mixColor))
+ {
+ properties.push_back(GetVisualProperty(visualIndex, Dali::Toolkit::Visual::Property::MIX_COLOR));
+ values.push_back(std::make_pair(Vector3(sourceMixColor), Vector3(mixColor)));
+ }
+
+ if(std::abs(sourceMixColor.a - mixColor.a) > Math::MACHINE_EPSILON_1)
+ {
+ properties.push_back(GetVisualProperty(visualIndex, Dali::Toolkit::Visual::Property::OPACITY));
+ values.push_back(std::make_pair(sourceMixColor.a, mixColor.a));
+ }
+
+ if(sourceCornerRadius != cornerRadius)
+ {
+ properties.push_back(GetVisualProperty(visualIndex, Dali::Toolkit::DevelVisual::Property::CORNER_RADIUS));
+ values.push_back(std::make_pair(sourceCornerRadius, cornerRadius));
+ }
+
+ if(sourceBorderlineWidth != borderlineWidth)
+ {
+ properties.push_back(GetVisualProperty(visualIndex, Dali::Toolkit::DevelVisual::Property::BORDERLINE_WIDTH));
+ values.push_back(std::make_pair(sourceBorderlineWidth, borderlineWidth));
+ }
+
+ if(sourceBorderlineColor != borderlineColor)
+ {
+ properties.push_back(GetVisualProperty(visualIndex, Dali::Toolkit::DevelVisual::Property::BORDERLINE_COLOR));
+ values.push_back(std::make_pair(sourceBorderlineColor, borderlineColor));
+ }
+
+ if(sourceBorderlineOffset != borderlineOffset)
+ {
+ properties.push_back(GetVisualProperty(visualIndex, Dali::Toolkit::DevelVisual::Property::BORDERLINE_OFFSET));
+ values.push_back(std::make_pair(sourceBorderlineOffset, borderlineOffset));
+ }
+
+ for(uint32_t i = 0; i < properties.size(); ++i)
+ {
+ if(timePeriod.delaySeconds > 0.0f)
+ {
+ Dali::KeyFrames initialKeyframes = Dali::KeyFrames::New();
+ initialKeyframes.Add(0.0f, values[i].first);
+ initialKeyframes.Add(1.0f, values[i].first);
+ animation.AnimateBetween(properties[i], initialKeyframes, TimePeriod(timePeriod.delaySeconds));
+ }
+ Dali::KeyFrames keyframes = Dali::KeyFrames::New();
+ keyframes.Add(0.0f, values[i].first);
+ keyframes.Add(1.0f, values[i].second);
+ animation.AnimateBetween(properties[i], keyframes, alphaFunction, timePeriod);
+ }
+ }
+}
+
+void Control::Impl::EmitResourceReadySignal()
+{
+ if(!mIsEmittingResourceReadySignal)
+ {
+ // Guard against calls to emit the signal during the callback
+ mIsEmittingResourceReadySignal = true;
+
+ // If the signal handler changes visual, it may become ready during this call & therefore this method will
+ // get called again recursively. If so, mNeedToEmitResourceReady is set below, and we act on it after that secondary
+ // invocation has completed by notifying in an Idle callback to prevent further recursion.
+ Dali::Toolkit::Control handle(mControlImpl.GetOwner());
+ mResourceReadySignal.Emit(handle);
+
+ if(mNeedToEmitResourceReady)
+ {
+ // Add idler to emit the signal again
+ if(!mIdleCallback)
+ {
+ // The callback manager takes the ownership of the callback object.
+ mIdleCallback = MakeCallback(this, &Control::Impl::OnIdleCallback);
+ Adaptor::Get().AddIdle(mIdleCallback, false);
+ }
+ }
+
+ mIsEmittingResourceReadySignal = false;
+ }
+ else
+ {
+ mNeedToEmitResourceReady = true;
+ }
+}
+
+void Control::Impl::OnIdleCallback()
+{
+ if(mNeedToEmitResourceReady)
+ {
+ // Reset the flag
+ mNeedToEmitResourceReady = false;
+
+ // A visual is ready so control may need relayouting if staged
+ if(mControlImpl.Self().GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE))
+ {
+ mControlImpl.RelayoutRequest();
+ }
+
+ EmitResourceReadySignal();
+ }
+
+ // Set the pointer to null as the callback manager deletes the callback after execute it.
+ mIdleCallback = nullptr;
+}
+
+Dali::Accessibility::Accessible* Control::Impl::GetAccessibilityObject()
+{
+ if(!mAccessibilityObject)
+ {
+ mAccessibilityObject = mAccessibilityConstructor(mControlImpl.Self());
+ }
+ return mAccessibilityObject.get();
+}
+
+Dali::Accessibility::Accessible* Control::Impl::GetAccessibilityObject(Dali::Actor actor)
+{
+ if(actor)
+ {
+ auto control = Dali::Toolkit::Control::DownCast(actor);
+ if(control)
+ {
+ auto controlImpl = static_cast<Internal::Control*>(&control.GetImplementation());
+ return controlImpl->mImpl->GetAccessibilityObject();
+ }
+ }
+ return nullptr;