1 #ifndef DALI_ADAPTOR_ACTOR_ACCESSIBLE_H
2 #define DALI_ADAPTOR_ACTOR_ACCESSIBLE_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 #include <dali/public-api/actors/actor.h>
22 #include <dali/public-api/object/weak-handle.h>
23 #include <dali/public-api/signals/connection-tracker.h>
26 #include <dali/devel-api/atspi-interfaces/accessible.h>
27 #include <dali/devel-api/atspi-interfaces/collection.h>
28 #include <dali/devel-api/atspi-interfaces/component.h>
30 namespace Dali::Accessibility
32 class DALI_ADAPTOR_API ActorAccessible : public virtual Accessible,
33 public virtual Collection,
34 public virtual Component,
35 public Dali::ConnectionTracker
38 ActorAccessible() = delete;
40 ActorAccessible(Actor actor);
43 * @copydoc Dali::Accessibility::Accessible::GetName()
45 std::string GetName() const override;
48 * @copydoc Dali::Accessibility::Accessible::GetDescription()
50 std::string GetDescription() const override;
53 * @copydoc Dali::Accessibility::Accessible::GetParent()
55 Accessible* GetParent() final;
58 * @copydoc Dali::Accessibility::Accessible::GetChildCount()
60 std::size_t GetChildCount() const final;
63 * @copydoc Dali::Accessibility::Accessible::GetChildren()
65 std::vector<Accessible*> GetChildren() final;
68 * @copydoc Dali::Accessibility::Accessible::GetChildAtIndex()
70 Accessible* GetChildAtIndex(std::size_t index) final;
73 * @copydoc Dali::Accessibility::Accessible::GetIndexInParent()
75 std::size_t GetIndexInParent() final;
78 * @copydoc Dali::Accessibility::Accessible::GetInternalActor()
80 Dali::Actor GetInternalActor() final;
83 * @copydoc Dali::Accessibility::Component::GetLayer()
85 ComponentLayer GetLayer() const override;
88 * @copydoc Dali::Accessibility::Component::GetMdiZOrder()
90 std::int16_t GetMdiZOrder() const override;
93 * @copydoc Dali::Accessibility::Component::GetAlpha()
95 double GetAlpha() const override;
98 * @copydoc Dali::Accessibility::Component::IsScrollable()
100 bool IsScrollable() const override;
103 * @copydoc Dali::Accessibility::Component::GetExtents()
105 Dali::Rect<> GetExtents(CoordinateType type) const override;
108 * @brief Notifies this object that its children have changed.
110 * This is useful if you maintain a custom collection of children that are not derived from
111 * ActorAccessible and the contents or order of elements in that collection change.
113 * @see DoGetChildren()
115 void OnChildrenChanged();
118 Dali::Actor Self() const
120 auto handle = mSelf.GetHandle();
122 // It is a bug if the Accessible outlives its Actor
123 DALI_ASSERT_ALWAYS(handle);
129 * @brief Populates the collection of children of this Accessible.
131 * The default implementation retrieves the children from the Actor hierarchy. Override this if
132 * you want to report other objects as children, either instead of, or together with the
133 * dependent Actor-derived Accessibles. Remember to call OnChildrenChanged() if you want your
134 * implementation of DoGetChildren() to be called again (in case your custom collection of
137 * @param[out] children The initially empty vector to insert children into
139 * @note GetChildCound(), GetChildren() and GetChildAtIndex() are not available for overriding,
140 * but they respect the children collection reported by this method.
142 * @see OnChildrenChanged()
143 * @see GetChildCount()
145 * @see GetChildAtIndex()
147 virtual void DoGetChildren(std::vector<Accessible*>& children);
150 // Extra overload for OnChildrenChanged() to connect to signals directly
151 void OnChildrenChanged(Dali::Actor);
153 // Ensures children are up to date (calls DoGetChildren() if necessary)
154 void UpdateChildren();
156 Dali::WeakHandle<Dali::Actor> mSelf;
157 std::vector<Accessible*> mChildren;
161 } // namespace Dali::Accessibility
163 #endif // DALI_ADAPTOR_ACTOR_ACCESSIBLE_H