/*
- * Copyright (c) 2017 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 "control-devel.h"
// EXTERNAL INCLUDES
+#include <dali/public-api/actors/actor.h>
#include <dali/public-api/animation/animation.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/visual-factory/transition-data.h>
#include <dali-toolkit/internal/controls/control/control-data-impl.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
-#include <dali-toolkit/devel-api/visual-factory/transition-data.h>
+#include <dali-toolkit/public-api/controls/control.h>
-namespace Dali
+namespace
+{
+Dali::Toolkit::Internal::Control::Impl& GetControlImplementation(Dali::Toolkit::Control control)
{
+ auto& internalControl = Dali::Toolkit::Internal::GetImplementation(control);
+
+ return Dali::Toolkit::Internal::Control::Impl::Get(internalControl);
+}
+
+} // unnamed namespace
+namespace Dali
+{
namespace Toolkit
{
-
namespace DevelControl
{
+void RegisterVisual(Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual)
+{
+ Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(control);
+ controlDataImpl.RegisterVisual(index, visual);
+}
+
+void RegisterVisual(Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, int depthIndex)
+{
+ Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(control);
+ controlDataImpl.RegisterVisual(index, visual, depthIndex);
+}
+
+void RegisterVisual(Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled)
+{
+ Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(control);
+ controlDataImpl.RegisterVisual(index, visual, enabled);
+}
+
+void RegisterVisual(Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled, int depthIndex)
+{
+ Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(control);
+ controlDataImpl.RegisterVisual(index, visual, enabled, depthIndex);
+}
+
+void UnregisterVisual(Internal::Control& control, Dali::Property::Index index)
+{
+ Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(control);
+ controlDataImpl.UnregisterVisual(index);
+}
+
+Toolkit::Visual::Base GetVisual(const Internal::Control& control, Dali::Property::Index index)
+{
+ const Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(control);
+ return controlDataImpl.GetVisual(index);
+}
+
+void EnableVisual(Internal::Control& control, Dali::Property::Index index, bool enable)
+{
+ Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(control);
+ controlDataImpl.EnableVisual(index, enable);
+}
+
+bool IsVisualEnabled(const Internal::Control& control, Dali::Property::Index index)
+{
+ const Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(control);
+ return controlDataImpl.IsVisualEnabled(index);
+}
+
+Dali::Animation CreateTransition(Internal::Control& control, const Toolkit::TransitionData& handle)
+{
+ Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(control);
+ return controlDataImpl.CreateTransition(handle);
+}
+
+void AddTransitions(Internal::Control& control,
+ Dali::Animation animation,
+ const Toolkit::TransitionData& transitionData)
+{
+ Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(control);
+ controlDataImpl.AddTransitions(animation, transitionData);
+}
+
+void DoAction(Control& control, Dali::Property::Index visualIndex, Dali::Property::Index actionId, const Dali::Property::Value attributes)
+{
+ Internal::Control& controlInternal = Toolkit::Internal::GetImplementation(control);
+ Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(controlInternal);
+ controlDataImpl.DoAction(visualIndex, actionId, attributes);
+}
+
+void DoActionExtension(Control& control, Dali::Property::Index visualIndex, Dali::Property::Index actionId, Dali::Any attributes)
+{
+ Internal::Control& controlInternal = Toolkit::Internal::GetImplementation(control);
+ Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(controlInternal);
+ controlDataImpl.DoActionExtension(visualIndex, actionId, attributes);
+}
+
+void SetInputMethodContext(Internal::Control& control, InputMethodContext& inputMethodContext)
+{
+ Internal::Control::Impl::Get(control).SetInputMethodContext(inputMethodContext);
+}
+
+VisualEventSignalType& VisualEventSignal(Control control)
+{
+ Internal::Control& internalControl = Toolkit::Internal::GetImplementation(control);
+ Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(internalControl);
+ return controlDataImpl.VisualEventSignal();
+}
-ResourceReadySignalType& ResourceReadySignal( Control& control )
+Dali::Property GetVisualProperty(Control control, Dali::Property::Index index, Dali::Property::Key visualPropertyKey)
{
- Internal::Control& internalControl = Toolkit::Internal::GetImplementation(control);
- Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( internalControl );
+ Internal::Control& internalControl = Toolkit::Internal::GetImplementation(control);
+ Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(internalControl);
+ return controlDataImpl.GetVisualProperty(index, visualPropertyKey);
+}
- return controlImpl.mResourceReadySignal;
+Toolkit::DevelControl::AccessibilityActivateSignalType& AccessibilityActivateSignal(Toolkit::Control control)
+{
+ return GetControlImplementation(control).mAccessibilityActivateSignal;
}
-bool IsResourceReady( const Control& control )
+Toolkit::DevelControl::AccessibilityReadingSkippedSignalType& AccessibilityReadingSkippedSignal(Toolkit::Control control)
{
- const Internal::Control& internalControl = Toolkit::Internal::GetImplementation(control);
- const Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( internalControl );
+ return GetControlImplementation(control).mAccessibilityReadingSkippedSignal;
+}
- return controlImpl.IsResourceReady();
+Toolkit::DevelControl::AccessibilityReadingPausedSignalType& AccessibilityReadingPausedSignal(Toolkit::Control control)
+{
+ return GetControlImplementation(control).mAccessibilityReadingPausedSignal;
}
-void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual )
+Toolkit::DevelControl::AccessibilityReadingResumedSignalType& AccessibilityReadingResumedSignal(Toolkit::Control control)
{
- Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
- controlImpl.RegisterVisual( index, visual );
+ return GetControlImplementation(control).mAccessibilityReadingResumedSignal;
}
-void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, float depthIndex )
+Toolkit::DevelControl::AccessibilityReadingCancelledSignalType& AccessibilityReadingCancelledSignal(Toolkit::Control control)
{
- Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
- controlImpl.RegisterVisual( index, visual, depthIndex );
+ return GetControlImplementation(control).mAccessibilityReadingCancelledSignal;
}
-void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled )
+Toolkit::DevelControl::AccessibilityReadingStoppedSignalType& AccessibilityReadingStoppedSignal(Toolkit::Control control)
{
- Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
- controlImpl.RegisterVisual( index, visual, enabled );
+ return GetControlImplementation(control).mAccessibilityReadingStoppedSignal;
}
-void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled, float depthIndex )
+Toolkit::DevelControl::AccessibilityGetNameSignalType& AccessibilityGetNameSignal(Toolkit::Control control)
{
- Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
- controlImpl.RegisterVisual( index, visual, enabled, depthIndex );
+ return GetControlImplementation(control).mAccessibilityGetNameSignal;
}
-void UnregisterVisual( Internal::Control& control, Dali::Property::Index index )
+Toolkit::DevelControl::AccessibilityGetDescriptionSignalType& AccessibilityGetDescriptionSignal(Toolkit::Control control)
{
- Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
- controlImpl.UnregisterVisual( index );
+ return GetControlImplementation(control).mAccessibilityGetDescriptionSignal;
}
-Toolkit::Visual::Base GetVisual( const Internal::Control& control, Dali::Property::Index index )
+Toolkit::DevelControl::AccessibilityDoGestureSignalType& AccessibilityDoGestureSignal(Toolkit::Control control)
{
- const Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
- return controlImpl.GetVisual( index );
+ return GetControlImplementation(control).mAccessibilityDoGestureSignal;
}
-void EnableVisual( Internal::Control& control, Dali::Property::Index index, bool enable )
+void AppendAccessibilityRelation(Toolkit::Control control, Dali::Actor destination, Dali::Accessibility::RelationType relation)
{
- Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
- controlImpl.EnableVisual( index, enable );
+ if(auto destinationAccessible = Accessibility::Accessible::Get(destination))
+ {
+ GetControlImplementation(control).mAccessibilityRelations[relation].insert(destinationAccessible);
+ }
}
-bool IsVisualEnabled( const Internal::Control& control, Dali::Property::Index index )
+void RemoveAccessibilityRelation(Toolkit::Control control, Dali::Actor destination, Dali::Accessibility::RelationType relation)
{
- const Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
- return controlImpl.IsVisualEnabled( index );
+ if(auto destinationAccessible = Accessibility::Accessible::Get(destination))
+ {
+ auto& relations = GetControlImplementation(control).mAccessibilityRelations;
+
+ relations[relation].erase(destinationAccessible);
+
+ if(relations[relation].empty())
+ {
+ relations.erase(relation);
+ }
+ }
}
-Dali::Animation CreateTransition( Internal::Control& control, const Toolkit::TransitionData& handle )
+std::vector<Accessibility::Relation> GetAccessibilityRelations(Toolkit::Control control)
{
- Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
- return controlImpl.CreateTransition( handle );
+ const auto& relations = GetControlImplementation(control).mAccessibilityRelations;
+ std::vector<Accessibility::Relation> result;
+
+ for(auto& relation : relations)
+ {
+ auto& targets = relation.second;
+
+ result.emplace_back(Accessibility::Relation{relation.first, {}});
+ std::copy(targets.begin(), targets.end(), std::back_inserter(result.back().mTargets));
+ }
+
+ return result;
}
+void ClearAccessibilityRelations(Toolkit::Control control)
+{
+ GetControlImplementation(control).mAccessibilityRelations.clear();
+}
+
+void AppendAccessibilityAttribute(Toolkit::Control control, const std::string& key, const std::string& value)
+{
+ GetControlImplementation(control).AppendAccessibilityAttribute(key, value);
+}
+
+void RemoveAccessibilityAttribute(Toolkit::Control control, const std::string& key)
+{
+ GetControlImplementation(control).RemoveAccessibilityAttribute(key);
+}
+
+void ClearAccessibilityAttributes(Toolkit::Control control)
+{
+ GetControlImplementation(control).ClearAccessibilityAttributes();
+}
+
+void SetAccessibilityReadingInfoType(Toolkit::Control control, const Dali::Accessibility::ReadingInfoTypes types)
+{
+ GetControlImplementation(control).SetAccessibilityReadingInfoType(types);
+}
+
+Dali::Accessibility::ReadingInfoTypes GetAccessibilityReadingInfoType(Toolkit::Control control)
+{
+ return GetControlImplementation(control).GetAccessibilityReadingInfoType();
+}
+
+bool ClearAccessibilityHighlight(Toolkit::Control control)
+{
+ auto* controlAccessible = GetControlImplementation(control).GetAccessibleObject();
+ if(DALI_LIKELY(controlAccessible))
+ {
+ return controlAccessible->ClearHighlight();
+ }
+ return false;
+}
+
+bool GrabAccessibilityHighlight(Toolkit::Control control)
+{
+ auto* controlAccessible = GetControlImplementation(control).GetAccessibleObject();
+ if(DALI_LIKELY(controlAccessible))
+ {
+ return controlAccessible->GrabHighlight();
+ }
+ return false;
+}
+
+Dali::Accessibility::States GetAccessibilityStates(Toolkit::Control control)
+{
+ auto* controlAccessible = GetControlImplementation(control).GetAccessibleObject();
+ if(DALI_LIKELY(controlAccessible))
+ {
+ return controlAccessible->GetStates();
+ }
+ return Dali::Accessibility::States{};
+}
+
+void NotifyAccessibilityStateChange(Toolkit::Control control, Dali::Accessibility::States states, bool recurse)
+{
+ auto* controlAccessible = GetControlImplementation(control).GetAccessibleObject();
+ if(DALI_LIKELY(controlAccessible))
+ {
+ controlAccessible->NotifyAccessibilityStateChange(std::move(states), recurse);
+ }
+}
+
+bool IsAccessibleCreated(Toolkit::Control control)
+{
+ return GetControlImplementation(control).IsAccessibleCreated();
+}
+
+void EnableCreateAccessible(Toolkit::Control control, bool enable)
+{
+ GetControlImplementation(control).EnableCreateAccessible(enable);
+}
+
+bool IsCreateAccessibleEnabled(Toolkit::Control control)
+{
+ return GetControlImplementation(control).IsCreateAccessibleEnabled();
+}
} // namespace DevelControl