[dali_2.3.19] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / controls / control-accessible.h
1 #ifndef DALI_TOOLKIT_CONTROL_ACCESSIBLE_H
2 #define DALI_TOOLKIT_CONTROL_ACCESSIBLE_H
3
4 /*
5  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
23 #include <dali/devel-api/adaptor-framework/accessibility.h>
24 #include <dali/devel-api/adaptor-framework/actor-accessible.h>
25 #include <dali/devel-api/atspi-interfaces/action.h>
26 #include <dali/public-api/object/weak-handle.h>
27
28 // INTERNAL INCLUDES
29 #include <dali-toolkit/public-api/dali-toolkit-common.h>
30
31 namespace Dali::Toolkit::DevelControl
32 {
33 /**
34  * @brief Represents the Accessible object for Dali::Toolkit::Control and derived classes
35  *
36  * You can create a derived class (and override Control::CreateAccessibleObject)
37  * in order to customize Accessibility for a given control.
38  *
39  * @see Dali::Accessibility::Accessible
40  * @see Dali::Accessibility::Component
41  * @see Dali::Accessibility::Collection
42  * @see Dali::Accessibility::Action
43  * @see Dali::Accessibility::Value
44  * @see Dali::Accessibility::Text
45  * @see Dali::Accessibility::EditableText
46  */
47 struct DALI_TOOLKIT_API ControlAccessible : public Dali::Accessibility::ActorAccessible,
48                                             public virtual Dali::Accessibility::Action
49 {
50 protected:
51   Vector2                       mLastPosition{0.0f, 0.0f};
52   Dali::WeakHandle<Dali::Actor> mCurrentHighlightActor;
53
54   void ScrollToSelf();
55
56   /**
57    * @brief Register property notification to check highlighted object position
58    */
59   void RegisterPositionPropertyNotification();
60
61   /**
62    * @brief Remove property notification added by RegisterPropertyNotification
63    */
64   void UnregisterPositionPropertyNotification();
65
66   /**
67    * @brief Registers PropertySet signal to notify when ACCESSIBILITY_NAME or ACCESSIBILITY_DESCRIPTION is changed.
68    * Note that those two signals only need for highlighted control. So, let us ensure to connect PropertySet signal
69    * only if control has been grabbed.
70    */
71   void RegisterPropertySetSignal();
72
73   /**
74    * @brief Unregisters PropertySet signal to notify when ACCESSIBILITY_NAME or ACCESSIBILITY_DESCRIPTION is changed.
75    */
76   void UnregisterPropertySetSignal();
77
78   /**
79    * @brief Check if the actor is showing
80    * @return True if the actor is showing
81    */
82   bool IsShowing();
83
84 public:
85   ControlAccessible(Dali::Actor self);
86
87   /**
88    * @copydoc Dali::Accessibility::Accessible::GetName()
89    */
90   std::string GetName() const override;
91
92   /**
93    * @brief Returns the actor's name in the absence of ACCESSIBILITY_NAME property
94    */
95   virtual std::string GetNameRaw() const;
96
97   /**
98    * @copydoc Dali::Accessibility::Accessible::GetDescription()
99    */
100   std::string GetDescription() const override;
101
102   /**
103    * @brief Returns the actor's description in the absence of ACCESSIBILITY_DESCRIPTION property
104    */
105   virtual std::string GetDescriptionRaw() const;
106
107   /**
108    * @copydoc Dali::Accessibility::Accessible::GetRole()
109    */
110   Dali::Accessibility::Role GetRole() const override;
111
112   /**
113    * @copydoc Dali::Accessibility::Accessible::GetLocalizedRoleName()
114    */
115   std::string GetLocalizedRoleName() const override;
116
117   /**
118    * @copydoc Dali::Accessibility::Accessible::GetStates()
119    */
120   Dali::Accessibility::States GetStates() override;
121
122   /**
123    * @copydoc Dali::Accessibility::Accessible::GetAttributes()
124    */
125   Dali::Accessibility::Attributes GetAttributes() const override;
126
127   /**
128    * @copydoc Dali::Accessibility::Accessible::IsHidden()
129    */
130   bool IsHidden() const override;
131
132   /**
133    * @copydoc Dali::Accessibility::Component::GrabFocus()
134    */
135   bool GrabFocus() override;
136
137   /**
138    * @copydoc Dali::Accessibility::Component::GrabHighlight()
139    */
140   bool GrabHighlight() override;
141
142   /**
143    * @copydoc Dali::Accessibility::Component::ClearHighlight()
144    */
145   bool ClearHighlight() override;
146
147   /**
148    * @copydoc Dali::Accessibility::Action::GetActionName()
149    */
150   std::string GetActionName(size_t index) const override;
151
152   /**
153    * @copydoc Dali::Accessibility::Action::GetLocalizedActionName()
154    */
155   std::string GetLocalizedActionName(size_t index) const override;
156
157   /**
158    * @copydoc Dali::Accessibility::Action::GetActionDescription()
159    */
160   std::string GetActionDescription(size_t index) const override;
161
162   /**
163    * @copydoc Dali::Accessibility::Action::GetActionCount()
164    */
165   size_t GetActionCount() const override;
166
167   /**
168    * @copydoc Dali::Accessibility::Action::GetActionKeyBinding()
169    */
170   std::string GetActionKeyBinding(size_t index) const override;
171
172   /**
173    * @copydoc Dali::Accessibility::Action::DoAction(std::size_t)
174    */
175   bool DoAction(size_t index) override;
176
177   /**
178    * @copydoc Dali::Accessibility::Action::DoAction(const std::string&)
179    */
180   bool DoAction(const std::string& name) override;
181
182   /**
183    * @copydoc Dali::Accessibility::Accessible::DoGesture()
184    */
185   bool DoGesture(const Dali::Accessibility::GestureInfo& gestureInfo) override;
186
187   /**
188    * @copydoc Dali::Accessibility::Accessible::GetRelationSet()
189    */
190   std::vector<Dali::Accessibility::Relation> GetRelationSet() override;
191
192   /**
193    * @copydoc Dali::Accessibility::Accessible::GetStates()
194    */
195   virtual Dali::Accessibility::States CalculateStates();
196
197   /**
198    * @brief Makes sure that a given child (descendant) of this container (e.g. ItemView) is visible
199    * @return false if scrolling is not supported or child is already visible
200    */
201   virtual bool ScrollToChild(Actor child);
202
203   /**
204    * @brief Returns the index of the property that represents this actor's name
205    */
206   virtual Dali::Property::Index GetNamePropertyIndex();
207
208   /**
209    * @brief Returns the index of the property that represents this actor's description
210    */
211   virtual Dali::Property::Index GetDescriptionPropertyIndex();
212
213   /**
214    * @brief Sets last object position
215    * @param[in] position Last object position
216    */
217   void SetLastPosition(Vector2 position);
218
219   /**
220    * @brief Gets last object position
221    * @return The Last object position
222    */
223   Vector2 GetLastPosition() const;
224 };
225
226 } // namespace Dali::Toolkit::DevelControl
227
228 #endif // DALI_TOOLKIT_CONTROL_ACCESSIBLE_H