/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <dali/devel-api/scripting/scripting.h>
#include <dali/integration-api/adaptor-framework/adaptor.h>
#include <dali/integration-api/debug.h>
+#include <dali/public-api/math/math-utils.h>
#include <dali/public-api/object/object-registry.h>
#include <dali/public-api/object/type-registry-helper.h>
#include <cstring>
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/devel-api/controls/control-wrapper-impl.h>
+#include <dali-toolkit/devel-api/visuals/visual-actions-devel.h>
#include <dali-toolkit/internal/styling/style-manager-impl.h>
#include <dali-toolkit/internal/visuals/visual-base-impl.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
namespace
{
-const std::string READING_INFO_TYPE_NAME = "name";
-const std::string READING_INFO_TYPE_ROLE = "role";
-const std::string READING_INFO_TYPE_DESCRIPTION = "description";
-const std::string READING_INFO_TYPE_STATE = "state";
-const std::string READING_INFO_TYPE_ATTRIBUTE_NAME = "reading_info_type";
-const std::string READING_INFO_TYPE_SEPARATOR = "|";
+const char* READING_INFO_TYPE_NAME = "name";
+const char* READING_INFO_TYPE_ROLE = "role";
+const char* READING_INFO_TYPE_DESCRIPTION = "description";
+const char* READING_INFO_TYPE_STATE = "state";
+const char* READING_INFO_TYPE_ATTRIBUTE_NAME = "reading_info_type";
+const char* READING_INFO_TYPE_SEPARATOR = "|";
} // namespace
namespace Dali
return false;
}
+/**
+ * Finds visual in given array, returning true if found along with the iterator for that visual as a out parameter
+ */
+bool FindVisual(const Toolkit::Visual::Base findVisual, const RegisteredVisualContainer& visuals, RegisteredVisualContainer::Iterator& iter)
+{
+ for(iter = visuals.Begin(); iter != visuals.End(); iter++)
+ {
+ Toolkit::Visual::Base visual = (*iter)->visual;
+ if(visual && visual == findVisual)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+/**
+ * Finds internal visual in given array, returning true if found along with the iterator for that visual as a out parameter
+ */
+bool FindVisual(const Visual::Base& findInternalVisual, const RegisteredVisualContainer& visuals, RegisteredVisualContainer::Iterator& iter)
+{
+ for(iter = visuals.Begin(); iter != visuals.End(); iter++)
+ {
+ Visual::Base& visual = Toolkit::GetImplementation((*iter)->visual);
+ if((&visual == &findInternalVisual))
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
void FindChangableVisuals(Dictionary<Property::Map>& stateVisualsToAdd,
Dictionary<Property::Map>& stateVisualsToChange,
DictionaryKeys& stateVisualsToRemove)
}
/**
+ * Discard visual from source to visual factory.
+ */
+void DiscardVisual(RegisteredVisualContainer::Iterator sourceIter, RegisteredVisualContainer& source)
+{
+ Toolkit::Visual::Base visual = (*sourceIter)->visual;
+ if(visual)
+ {
+ if(Stage::IsInstalled())
+ {
+ Toolkit::VisualFactory::Get().DiscardVisual(visual);
+ }
+ }
+
+ source.Erase(sourceIter);
+}
+
+/**
* Performs actions as requested using the action name.
* @param[in] object The object on which to perform the action.
* @param[in] actionName The action to perform.
}
}
-Dali::Rect<> GetShowingGeometry(Dali::Rect<> rect, Dali::Toolkit::DevelControl::AccessibleImpl* accessibleImpl)
+Dali::Rect<> GetShowingGeometry(Dali::Rect<> rect, Dali::Toolkit::DevelControl::ControlAccessible* accessible)
{
Rect<> parentRect;
Vector2 currentPosition;
- auto parent = dynamic_cast<Toolkit::DevelControl::AccessibleImpl*>(accessibleImpl->GetParent());
+ auto parent = dynamic_cast<Toolkit::DevelControl::ControlAccessible*>(accessible->GetParent());
while(parent)
{
return rect;
}
- parent = dynamic_cast<Toolkit::DevelControl::AccessibleImpl*>(parent->GetParent());
+ parent = dynamic_cast<Toolkit::DevelControl::ControlAccessible*>(parent->GetParent());
}
return rect;
}
+static bool IsShowingGeometryOnScreen(Dali::Rect<> rect)
+{
+ return rect.width > 0 && rect.height > 0;
+}
+
+Dali::Accessibility::Accessible* ExternalAccessibleGetter(Dali::Actor actor)
+{
+ auto control = Toolkit::Control::DownCast(actor);
+ if(!control)
+ {
+ return nullptr;
+ }
+
+ auto& controlImpl = Toolkit::Internal::GetImplementation(control);
+
+ return controlImpl.GetAccessibleObject();
+}
+
} // unnamed namespace
// clang-format off
const PropertyRegistration Control::Impl::PROPERTY_19(typeRegistration, "accessibilityRole", Toolkit::DevelControl::Property::ACCESSIBILITY_ROLE, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
const PropertyRegistration Control::Impl::PROPERTY_20(typeRegistration, "accessibilityHighlightable", Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
const PropertyRegistration Control::Impl::PROPERTY_21(typeRegistration, "accessibilityAttributes", Toolkit::DevelControl::Property::ACCESSIBILITY_ATTRIBUTES, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
+const PropertyRegistration Control::Impl::PROPERTY_22(typeRegistration, "dispatchKeyEvents", Toolkit::DevelControl::Property::DISPATCH_KEY_EVENTS, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
+const PropertyRegistration Control::Impl::PROPERTY_23(typeRegistration, "accessibilityHidden", Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
+const PropertyRegistration Control::Impl::PROPERTY_24(typeRegistration, "clockwiseFocusableActorId", Toolkit::DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
+const PropertyRegistration Control::Impl::PROPERTY_25(typeRegistration, "counterClockwiseFocusableActorId", Toolkit::DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
+const PropertyRegistration Control::Impl::PROPERTY_26(typeRegistration, "automationId", Toolkit::DevelControl::Property::AUTOMATION_ID, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
+
// clang-format on
Control::Impl::Impl(Control& controlImpl)
mRightFocusableActorId(-1),
mUpFocusableActorId(-1),
mDownFocusableActorId(-1),
+ mClockwiseFocusableActorId(-1),
+ mCounterClockwiseFocusableActorId(-1),
mStyleName(""),
mBackgroundColor(Color::TRANSPARENT),
mStartingPinchScale(nullptr),
mIsKeyboardNavigationSupported(false),
mIsKeyboardFocusGroup(false),
mIsEmittingResourceReadySignal(false),
- mNeedToEmitResourceReady(false)
+ mIdleCallbackRegistered(false),
+ mDispatchKeyEvents(true)
{
- Dali::Accessibility::Accessible::RegisterControlAccessibilityGetter(
- [](Dali::Actor actor) -> Dali::Accessibility::Accessible* {
- return Control::Impl::GetAccessibilityObject(actor);
- });
-
- mAccessibilityConstructor = [](Dali::Actor actor) -> std::unique_ptr<Dali::Accessibility::Accessible> {
- return std::unique_ptr<Dali::Accessibility::Accessible>(new DevelControl::AccessibleImpl(actor, Dali::Accessibility::Role::UNKNOWN));
- };
-
- size_t length = static_cast<size_t>(Dali::Accessibility::RelationType::MAX_COUNT);
- mAccessibilityRelations.reserve(length);
- for(auto i = 0u; i < length; ++i)
- {
- mAccessibilityRelations.push_back({});
- }
+ Dali::Accessibility::Accessible::RegisterExternalAccessibleGetter(&ExternalAccessibleGetter);
}
Control::Impl::~Impl()
Control::Impl& Control::Impl::Get(Internal::Control& internalControl)
{
+ DALI_ASSERT_ALWAYS(Stage::IsCoreThread() && "Core is not installed. Might call this API from worker thread?");
+
return *internalControl.mImpl;
}
const Control::Impl& Control::Impl::Get(const Internal::Control& internalControl)
{
+ DALI_ASSERT_ALWAYS(Stage::IsCoreThread() && "Core is not installed. Might call this API from worker thread?");
+
return *internalControl.mImpl;
}
-void Control::Impl::CheckHighlightedObjectGeometry(PropertyNotification& propertyNotification)
+void Control::Impl::CheckHighlightedObjectGeometry()
{
- auto accessibleImpl = dynamic_cast<Dali::Toolkit::DevelControl::AccessibleImpl*>(mAccessibilityObject.get());
- auto lastPosition = accessibleImpl->GetLastPosition();
- auto accessibleRect = accessibleImpl->GetExtents(Dali::Accessibility::CoordinateType::WINDOW);
-
- if(lastPosition.x == accessibleRect.x && lastPosition.y == accessibleRect.y)
- {
- return;
- }
-
- auto rect = GetShowingGeometry(accessibleRect, accessibleImpl);
+ auto accessible = GetAccessibleObject();
+ auto lastPosition = accessible->GetLastPosition();
+ auto accessibleRect = accessible->GetExtents(Dali::Accessibility::CoordinateType::WINDOW);
+ auto rect = GetShowingGeometry(accessibleRect, accessible);
- // MoveOuted is sent already, no need to send it again
- if(mAccessibilityMovedOutOfScreenDirection != Dali::Accessibility::MovedOutOfScreenType::NONE)
+ switch(mAccessibilityLastScreenRelativeMoveType)
{
- if(rect.width > 0 && rect.height > 0)
+ case Dali::Accessibility::ScreenRelativeMoveType::OUTSIDE:
{
- // flick next does not use MoveOuted - ScrollToSelf makes object show, so reset for sending MoveOuted next
- mAccessibilityMovedOutOfScreenDirection = Dali::Accessibility::MovedOutOfScreenType::NONE;
+ if(IsShowingGeometryOnScreen(rect))
+ {
+ mAccessibilityLastScreenRelativeMoveType = Dali::Accessibility::ScreenRelativeMoveType::INSIDE;
+ }
+ break;
+ }
+ case Dali::Accessibility::ScreenRelativeMoveType::INSIDE:
+ {
+ if(rect.width < 0 && !Dali::Equals(accessibleRect.x, lastPosition.x))
+ {
+ mAccessibilityLastScreenRelativeMoveType = (accessibleRect.x < lastPosition.x) ? Dali::Accessibility::ScreenRelativeMoveType::OUTGOING_TOP_LEFT : Dali::Accessibility::ScreenRelativeMoveType::OUTGOING_BOTTOM_RIGHT;
+ }
+ if(rect.height < 0 && !Dali::Equals(accessibleRect.y, lastPosition.y))
+ {
+ mAccessibilityLastScreenRelativeMoveType = (accessibleRect.y < lastPosition.y) ? Dali::Accessibility::ScreenRelativeMoveType::OUTGOING_TOP_LEFT : Dali::Accessibility::ScreenRelativeMoveType::OUTGOING_BOTTOM_RIGHT;
+ }
+ // notify AT-clients on outgoing moves only
+ if(mAccessibilityLastScreenRelativeMoveType != Dali::Accessibility::ScreenRelativeMoveType::INSIDE)
+ {
+ accessible->EmitMovedOutOfScreen(mAccessibilityLastScreenRelativeMoveType);
+ }
+ break;
+ }
+ case Dali::Accessibility::ScreenRelativeMoveType::OUTGOING_TOP_LEFT:
+ case Dali::Accessibility::ScreenRelativeMoveType::OUTGOING_BOTTOM_RIGHT:
+ {
+ if(IsShowingGeometryOnScreen(rect))
+ {
+ mAccessibilityLastScreenRelativeMoveType = Dali::Accessibility::ScreenRelativeMoveType::INSIDE;
+ }
+ else
+ {
+ mAccessibilityLastScreenRelativeMoveType = Dali::Accessibility::ScreenRelativeMoveType::OUTSIDE;
+ }
+ break;
+ }
+ default:
+ {
+ break;
}
- return;
- }
-
- if(rect.width < 0)
- {
- mAccessibilityMovedOutOfScreenDirection = (accessibleRect.x < lastPosition.x) ? Dali::Accessibility::MovedOutOfScreenType::TOP_LEFT : Dali::Accessibility::MovedOutOfScreenType::BOTTOM_RIGHT;
- }
-
- if(rect.height < 0)
- {
- mAccessibilityMovedOutOfScreenDirection = (accessibleRect.y < lastPosition.y) ? Dali::Accessibility::MovedOutOfScreenType::TOP_LEFT : Dali::Accessibility::MovedOutOfScreenType::BOTTOM_RIGHT;
- }
-
- if(mAccessibilityMovedOutOfScreenDirection != Dali::Accessibility::MovedOutOfScreenType::NONE)
- {
- mAccessibilityObject.get()->EmitMovedOutOfScreen(mAccessibilityMovedOutOfScreenDirection);
- accessibleImpl->SetLastPosition(Vector2(0.0f, 0.0f));
- return;
}
- accessibleImpl->SetLastPosition(Vector2(accessibleRect.x, accessibleRect.y));
+ accessible->SetLastPosition(Vector2(accessibleRect.x, accessibleRect.y));
}
void Control::Impl::RegisterAccessibilityPositionPropertyNotification()
{
return;
}
-
- mAccessibilityMovedOutOfScreenDirection = Dali::Accessibility::MovedOutOfScreenType::NONE;
- mAccessibilityPositionNotification = mControlImpl.Self().AddPropertyNotification(Actor::Property::WORLD_POSITION, StepCondition(1.0f, 1.0f));
+ // set default value until first move of object is detected
+ mAccessibilityLastScreenRelativeMoveType = Dali::Accessibility::ScreenRelativeMoveType::OUTSIDE;
+ // recalculate mAccessibilityLastScreenRelativeMoveType accordingly to the initial position
+ CheckHighlightedObjectGeometry();
+ mAccessibilityPositionNotification = mControlImpl.Self().AddPropertyNotification(Actor::Property::WORLD_POSITION, StepCondition(1.0f, 1.0f));
mAccessibilityPositionNotification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
- mAccessibilityPositionNotification.NotifySignal().Connect(this, &Control::Impl::CheckHighlightedObjectGeometry);
+ mAccessibilityPositionNotification.NotifySignal().Connect(this, [this](PropertyNotification&) { CheckHighlightedObjectGeometry(); });
mIsAccessibilityPositionPropertyNotificationSet = true;
}
void Control::Impl::RegisterVisual(Property::Index index, Toolkit::Visual::Base& visual, VisualState::Type enabled, DepthIndexValue::Type depthIndexValueSet, int depthIndex)
{
+ DALI_ASSERT_ALWAYS(Stage::IsCoreThread() && "Core is not installed. Might call this API from worker thread?");
+
DALI_LOG_INFO(gLogFilter, Debug::Concise, "RegisterVisual:%d \n", index);
bool visualReplaced(false);
{
visualImpl.SetOnScene(self);
}
- else if(visualImpl.IsResourceReady()) // When not being staged, check if visual already 'ResourceReady' before it was Registered. ( Resource may have been loaded already )
+ else if(enabled && visualImpl.IsResourceReady()) // When not being staged, check if visual already 'ResourceReady' before it was Registered. ( Resource may have been loaded already )
{
ResourceReady(visualImpl);
}
void Control::Impl::UnregisterVisual(Property::Index index)
{
+ DALI_ASSERT_ALWAYS(Stage::IsCoreThread() && "Core is not installed. Might call this API from worker thread?");
+
RegisteredVisualContainer::Iterator iter;
if(FindVisual(index, mVisuals, iter))
{
Actor self(mControlImpl.Self());
Toolkit::GetImplementation((*iter)->visual).SetOffScene(self);
(*iter)->pending = false;
- (*iter)->visual.Reset();
- mRemoveVisuals.Erase(iter);
+
+ // Discard removed visual. It will be destroyed at next Idle time.
+ DiscardVisual(iter, mRemoveVisuals);
}
}
return false;
}
+void Control::Impl::EnableReadyTransitionOverriden(Toolkit::Visual::Base& visual, bool enable)
+{
+ DALI_LOG_INFO(gLogFilter, Debug::General, "Control::EnableReadyTransitionOverriden(%p, %s)\n", visual, enable ? "T" : "F");
+
+ RegisteredVisualContainer::Iterator iter;
+ if(FindVisual(visual, mVisuals, iter))
+ {
+ if((*iter)->overideReadyTransition == enable)
+ {
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Control::EnableReadyTransitionOverriden Visual %s(%p) already %s\n", (*iter)->visual.GetName().c_str(), visual, enable ? "enabled" : "disabled");
+ return;
+ }
+
+ (*iter)->overideReadyTransition = enable;
+ }
+}
+
void Control::Impl::StopObservingVisual(Toolkit::Visual::Base& visual)
{
Internal::Visual::Base& visualImpl = Toolkit::GetImplementation(visual);
visualImpl.AddEventObserver(*this);
}
+void Control::Impl::ResourceReady()
+{
+ DALI_ASSERT_ALWAYS(Stage::IsCoreThread() && "Core is not installed. Might call this API from worker thread?");
+
+ // Emit signal if all enabled visuals registered by the control are ready or there are no visuals.
+ if(IsResourceReady())
+ {
+ EmitResourceReadySignal();
+ }
+}
+
// Called by a Visual when it's resource is ready
void Control::Impl::ResourceReady(Visual::Base& object)
{
Actor self = mControlImpl.Self();
+ RegisteredVisualContainer::Iterator registeredIter;
+
// A resource is ready, find resource in the registered visuals container and get its index
- for(auto registeredIter = mVisuals.Begin(), end = mVisuals.End(); registeredIter != end; ++registeredIter)
+ if(!FindVisual(object, mVisuals, registeredIter))
{
- Internal::Visual::Base& registeredVisualImpl = Toolkit::GetImplementation((*registeredIter)->visual);
+ return;
+ }
- if(&object == ®isteredVisualImpl)
+ RegisteredVisualContainer::Iterator visualToRemoveIter;
+ // Find visual with the same index in the removal container
+ // Set if off stage as it's replacement is now ready.
+ // Remove if from removal list as now removed from stage.
+ // Set Pending flag on the ready visual to false as now ready.
+ if(FindVisual((*registeredIter)->index, mRemoveVisuals, visualToRemoveIter))
+ {
+ (*registeredIter)->pending = false;
+ if(!((*visualToRemoveIter)->overideReadyTransition))
{
- RegisteredVisualContainer::Iterator visualToRemoveIter;
- // Find visual with the same index in the removal container
- // Set if off stage as it's replacement is now ready.
- // Remove if from removal list as now removed from stage.
- // Set Pending flag on the ready visual to false as now ready.
- if(FindVisual((*registeredIter)->index, mRemoveVisuals, visualToRemoveIter))
- {
- (*registeredIter)->pending = false;
- Toolkit::GetImplementation((*visualToRemoveIter)->visual).SetOffScene(self);
- mRemoveVisuals.Erase(visualToRemoveIter);
- }
- break;
+ Toolkit::GetImplementation((*visualToRemoveIter)->visual).SetOffScene(self);
}
+
+ // Discard removed visual. It will be destroyed at next Idle time.
+ DiscardVisual(visualToRemoveIter, mRemoveVisuals);
}
// A visual is ready so control may need relayouting if staged
- if(self.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE))
- {
- mControlImpl.RelayoutRequest();
- }
+ RelayoutRequest(object);
- // Emit signal if all enabled visuals registered by the control are ready.
- if(IsResourceReady())
+ // Called by a Visual when it's resource is ready
+ if(((*registeredIter)->enabled))
{
- // Reset the flag
- mNeedToEmitResourceReady = false;
-
- EmitResourceReadySignal();
+ ResourceReady();
}
}
}
}
+void Control::Impl::RelayoutRequest(Visual::Base& object)
+{
+ if(mControlImpl.Self().GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE))
+ {
+ mControlImpl.RelayoutRequest();
+ }
+}
+
bool Control::Impl::IsResourceReady() const
{
// Iterate through and check all the enabled visuals are ready
}
}
+void Control::Impl::DoActionExtension(Dali::Property::Index visualIndex, Dali::Property::Index actionId, Dali::Any attributes)
+{
+ RegisteredVisualContainer::Iterator iter;
+ if(FindVisual(visualIndex, mVisuals, iter))
+ {
+ Toolkit::GetImplementation((*iter)->visual).DoActionExtension(actionId, attributes);
+ }
+}
+
void Control::Impl::AppendAccessibilityAttribute(const std::string& key, const std::string value)
{
Property::Value* checkedValue = mAccessibilityAttributes.Find(key);
void Control::Impl::SetProperty(BaseObject* object, Property::Index index, const Property::Value& value)
{
+ DALI_ASSERT_ALWAYS(Stage::IsCoreThread() && "Core is not installed. Might call this API from worker thread?");
+
Toolkit::Control control = Toolkit::Control::DownCast(BaseHandle(object));
if(control)
std::string name;
if(value.Get(name))
{
- controlImpl.mImpl->mAccessibilityName = name;
- controlImpl.mImpl->mAccessibilityNameSet = true;
- }
- else
- {
- controlImpl.mImpl->mAccessibilityNameSet = false;
+ controlImpl.mImpl->mAccessibilityName = name;
}
+ break;
}
- break;
case Toolkit::DevelControl::Property::ACCESSIBILITY_DESCRIPTION:
{
std::string text;
if(value.Get(text))
{
- controlImpl.mImpl->mAccessibilityDescription = text;
- controlImpl.mImpl->mAccessibilityDescriptionSet = true;
- }
- else
- {
- controlImpl.mImpl->mAccessibilityDescriptionSet = false;
+ controlImpl.mImpl->mAccessibilityDescription = text;
}
+ break;
}
- break;
case Toolkit::DevelControl::Property::ACCESSIBILITY_TRANSLATION_DOMAIN:
{
std::string text;
if(value.Get(text))
{
- controlImpl.mImpl->mAccessibilityTranslationDomain = text;
- controlImpl.mImpl->mAccessibilityTranslationDomainSet = true;
- }
- else
- {
- controlImpl.mImpl->mAccessibilityTranslationDomainSet = false;
+ controlImpl.mImpl->mAccessibilityTranslationDomain = text;
}
+ break;
}
- break;
case Toolkit::DevelControl::Property::ACCESSIBILITY_ROLE:
{
{
controlImpl.mImpl->mAccessibilityRole = role;
}
+ break;
}
- break;
case Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE:
{
bool highlightable;
if(value.Get(highlightable))
{
- controlImpl.mImpl->mAccessibilityHighlightable = highlightable;
- controlImpl.mImpl->mAccessibilityHighlightableSet = true;
- }
- else
- {
- controlImpl.mImpl->mAccessibilityHighlightableSet = false;
+ controlImpl.mImpl->mAccessibilityHighlightable = highlightable;
}
+ break;
}
- break;
case Toolkit::DevelControl::Property::ACCESSIBILITY_ATTRIBUTES:
{
}
break;
}
+
+ case Toolkit::DevelControl::Property::DISPATCH_KEY_EVENTS:
+ {
+ bool dispatch;
+ if(value.Get(dispatch))
+ {
+ controlImpl.mImpl->mDispatchKeyEvents = dispatch;
+ }
+ break;
+ }
+
+ case Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN:
+ {
+ bool hidden;
+ if(value.Get(hidden))
+ {
+ controlImpl.mImpl->mAccessibilityHidden = hidden;
+
+ auto* accessible = controlImpl.GetAccessibleObject();
+ auto* parent = dynamic_cast<Dali::Accessibility::ActorAccessible*>(accessible->GetParent());
+ if(parent)
+ {
+ parent->OnChildrenChanged();
+ }
+ }
+ break;
+ }
+ case Toolkit::DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID:
+ {
+ int focusId;
+ if(value.Get(focusId))
+ {
+ controlImpl.mImpl->mClockwiseFocusableActorId = focusId;
+ }
+ break;
+ }
+ case Toolkit::DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID:
+ {
+ int focusId;
+ if(value.Get(focusId))
+ {
+ controlImpl.mImpl->mCounterClockwiseFocusableActorId = focusId;
+ }
+ break;
+ }
+
+ case Toolkit::DevelControl::Property::AUTOMATION_ID:
+ {
+ std::string automationId;
+ if(value.Get(automationId))
+ {
+ controlImpl.mImpl->mAutomationId = automationId;
+ }
+ break;
+ }
}
}
}
Property::Value Control::Impl::GetProperty(BaseObject* object, Property::Index index)
{
+ DALI_ASSERT_ALWAYS(Stage::IsCoreThread() && "Core is not installed. Might call this API from worker thread?");
+
Property::Value value;
Toolkit::Control control = Toolkit::Control::DownCast(BaseHandle(object));
case Toolkit::DevelControl::Property::ACCESSIBILITY_NAME:
{
- if(controlImpl.mImpl->mAccessibilityNameSet)
- {
- value = controlImpl.mImpl->mAccessibilityName;
- }
+ value = controlImpl.mImpl->mAccessibilityName;
break;
}
case Toolkit::DevelControl::Property::ACCESSIBILITY_DESCRIPTION:
{
- if(controlImpl.mImpl->mAccessibilityDescriptionSet)
- {
- value = controlImpl.mImpl->mAccessibilityDescription;
- }
+ value = controlImpl.mImpl->mAccessibilityDescription;
break;
}
case Toolkit::DevelControl::Property::ACCESSIBILITY_TRANSLATION_DOMAIN:
{
- if(controlImpl.mImpl->mAccessibilityTranslationDomainSet)
- {
- value = controlImpl.mImpl->mAccessibilityTranslationDomain;
- }
+ value = controlImpl.mImpl->mAccessibilityTranslationDomain;
break;
}
case Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE:
{
- if(controlImpl.mImpl->mAccessibilityHighlightableSet)
- {
- value = controlImpl.mImpl->mAccessibilityHighlightable;
- }
+ value = controlImpl.mImpl->mAccessibilityHighlightable;
break;
}
value = controlImpl.mImpl->mAccessibilityAttributes;
break;
}
+
+ case Toolkit::DevelControl::Property::DISPATCH_KEY_EVENTS:
+ {
+ value = controlImpl.mImpl->mDispatchKeyEvents;
+ break;
+ }
+
+ case Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN:
+ {
+ value = controlImpl.mImpl->mAccessibilityHidden;
+ break;
+ }
+
+ case Toolkit::DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID:
+ {
+ value = controlImpl.mImpl->mClockwiseFocusableActorId;
+ break;
+ }
+
+ case Toolkit::DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID:
+ {
+ value = controlImpl.mImpl->mCounterClockwiseFocusableActorId;
+ break;
+ }
+
+ case Toolkit::DevelControl::Property::AUTOMATION_ID:
+ {
+ value = controlImpl.mImpl->mAutomationId;
+ break;
+ }
}
}
void Control::Impl::ReplaceStateVisualsAndProperties(const StylePtr oldState, const StylePtr newState, const std::string& subState)
{
+ DALI_ASSERT_ALWAYS(Stage::IsCoreThread() && "Core is not installed. Might call this API from worker thread?");
+
// Collect all old visual names
DictionaryKeys stateVisualsToRemove;
if(oldState)
// Visuals pending replacement can now be taken out of the removal list and set off scene
// Iterate through all replacement visuals and add to a move queue then set off scene
- for(auto removalIter = mRemoveVisuals.Begin(), end = mRemoveVisuals.End(); removalIter != end; removalIter++)
+
+ if(!mRemoveVisuals.Empty())
{
- Toolkit::GetImplementation((*removalIter)->visual).SetOffScene(self);
+ std::reverse(mRemoveVisuals.Begin(), mRemoveVisuals.End());
+
+ while(!mRemoveVisuals.Empty())
+ {
+ auto removalIter = mRemoveVisuals.End() - 1u;
+ Toolkit::GetImplementation((*removalIter)->visual).SetOffScene(self);
+
+ // Discard removed visual. It will be destroyed at next Idle time.
+ DiscardVisual(removalIter, mRemoveVisuals);
+ }
}
for(auto replacedIter = mVisuals.Begin(), end = mVisuals.End(); replacedIter != end; replacedIter++)
{
(*replacedIter)->pending = false;
}
-
- mRemoveVisuals.Clear();
}
void Control::Impl::SetMargin(Extents margin)
if(visual)
{
Internal::Visual::Base& visualImpl = Toolkit::GetImplementation(visual);
- return visualImpl.GetPropertyObject(visualPropertyKey);
+ return visualImpl.GetPropertyObject(std::move(visualPropertyKey));
}
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)
+void Control::Impl::CreateTransitions(std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& sourceProperties,
+ std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& destinationProperties,
+ Dali::Toolkit::Control source,
+ Dali::Toolkit::Control destination)
{
- 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())
+ // Retrieves background properties to be transitioned.
+ Dali::Property::Map backgroundSourcePropertyMap, backgroundDestinationPropertyMap;
+ mControlImpl.MakeVisualTransition(backgroundSourcePropertyMap, backgroundDestinationPropertyMap, source, destination, Toolkit::Control::Property::BACKGROUND);
+ if(backgroundSourcePropertyMap.Count() > 0)
{
- 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));
- }
+ sourceProperties.push_back(std::pair<Dali::Property::Index, Dali::Property::Map>(Toolkit::Control::Property::BACKGROUND, backgroundSourcePropertyMap));
+ destinationProperties.push_back(std::pair<Dali::Property::Index, Dali::Property::Map>(Toolkit::Control::Property::BACKGROUND, backgroundDestinationPropertyMap));
+ }
- if(sourceBorderlineWidth != borderlineWidth)
- {
- properties.push_back(GetVisualProperty(visualIndex, Dali::Toolkit::DevelVisual::Property::BORDERLINE_WIDTH));
- values.push_back(std::make_pair(sourceBorderlineWidth, borderlineWidth));
- }
+ // Retrieves shadow properties to be transitioned.
+ Dali::Property::Map shadowSourcePropertyMap, shadowDestinationPropertyMap;
+ mControlImpl.MakeVisualTransition(shadowSourcePropertyMap, shadowDestinationPropertyMap, source, destination, Toolkit::DevelControl::Property::SHADOW);
+ if(shadowSourcePropertyMap.Count() > 0)
+ {
+ sourceProperties.push_back(std::pair<Dali::Property::Index, Dali::Property::Map>(Toolkit::DevelControl::Property::SHADOW, shadowSourcePropertyMap));
+ destinationProperties.push_back(std::pair<Dali::Property::Index, Dali::Property::Map>(Toolkit::DevelControl::Property::SHADOW, shadowDestinationPropertyMap));
+ }
- if(sourceBorderlineColor != borderlineColor)
- {
- properties.push_back(GetVisualProperty(visualIndex, Dali::Toolkit::DevelVisual::Property::BORDERLINE_COLOR));
- values.push_back(std::make_pair(sourceBorderlineColor, borderlineColor));
- }
+ // Retrieves transition from inherited class.
+ mControlImpl.OnCreateTransitions(sourceProperties, destinationProperties, source, destination);
+}
- if(sourceBorderlineOffset != borderlineOffset)
+void Control::Impl::UpdateVisualProperties(const std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& properties)
+{
+ for(auto&& data : properties)
+ {
+ if(data.first == Toolkit::Control::Property::BACKGROUND)
{
- properties.push_back(GetVisualProperty(visualIndex, Dali::Toolkit::DevelVisual::Property::BORDERLINE_OFFSET));
- values.push_back(std::make_pair(sourceBorderlineOffset, borderlineOffset));
+ DoAction(Toolkit::Control::Property::BACKGROUND, DevelVisual::Action::UPDATE_PROPERTY, data.second);
}
-
- for(uint32_t i = 0; i < properties.size(); ++i)
+ else if(data.first == Toolkit::DevelControl::Property::SHADOW)
{
- 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);
+ DoAction(Toolkit::DevelControl::Property::SHADOW, DevelVisual::Action::UPDATE_PROPERTY, data.second);
}
}
+ mControlImpl.OnUpdateVisualProperties(properties);
}
void Control::Impl::EmitResourceReadySignal()
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
+ // get called again recursively. If so, mIdleCallbackRegistered 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)
+ mIsEmittingResourceReadySignal = false;
+ }
+ else
+ {
+ if(!mIdleCallbackRegistered)
{
+ mIdleCallbackRegistered = true;
+
// 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);
+ Adaptor::Get().AddIdle(mIdleCallback, true);
}
}
-
- mIsEmittingResourceReadySignal = false;
- }
- else
- {
- mNeedToEmitResourceReady = true;
}
}
-void Control::Impl::OnIdleCallback()
+bool Control::Impl::OnIdleCallback()
{
- if(mNeedToEmitResourceReady)
- {
- // Reset the flag
- mNeedToEmitResourceReady = false;
+ // Reset the flag
+ mIdleCallbackRegistered = 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();
+ // A visual is ready so control may need relayouting if staged
+ if(mControlImpl.Self().GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE))
+ {
+ mControlImpl.RelayoutRequest();
}
- // Set the pointer to null as the callback manager deletes the callback after execute it.
- mIdleCallback = nullptr;
-}
+ EmitResourceReadySignal();
-Dali::Accessibility::Accessible* Control::Impl::GetAccessibilityObject()
-{
- if(!mAccessibilityObject)
+ if(!mIdleCallbackRegistered)
{
- mAccessibilityObject = mAccessibilityConstructor(mControlImpl.Self());
+ // Set the pointer to null as the callback manager deletes the callback after execute it.
+ mIdleCallback = nullptr;
}
- return mAccessibilityObject.get();
+
+ // Repeat idle if mIdleCallbackRegistered become true one more time.
+ return mIdleCallbackRegistered;
}
-Dali::Accessibility::Accessible* Control::Impl::GetAccessibilityObject(Dali::Actor actor)
+Toolkit::DevelControl::ControlAccessible* Control::Impl::GetAccessibleObject()
{
- if(actor)
+ if(!mAccessibleObject)
{
- auto control = Dali::Toolkit::Control::DownCast(actor);
- if(control)
- {
- auto controlImpl = static_cast<Internal::Control*>(&control.GetImplementation());
- return controlImpl->mImpl->GetAccessibilityObject();
- }
+ mAccessibleObject.reset(mControlImpl.CreateAccessibleObject());
}
- return nullptr;
+
+ return mAccessibleObject.get();
}
} // namespace Internal