1 #ifndef DALI_ADAPTOR_ATSPI_ACCESSIBLE_H
2 #define DALI_ADAPTOR_ATSPI_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/math/rect.h>
23 #include <dali/public-api/object/object-registry.h>
28 #include <dali/devel-api/adaptor-framework/accessibility.h>
29 #include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
31 namespace Dali::Accessibility
34 * @brief Basic interface implemented by all accessibility objects.
36 class DALI_ADAPTOR_API Accessible
39 virtual ~Accessible();
41 using utf8_t = unsigned char;
44 * @brief Calculates and finds word boundaries in given utf8 text.
46 * @param[in] string The source text to find
47 * @param[in] length The length of text to find
48 * @param[in] language The language to use
49 * @param[out] breaks The word boundaries in given text
51 * @note Word boundaries are returned as non-zero values in table breaks, which must be of size at least length.
53 void FindWordSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks);
56 * @brief Calculates and finds line boundaries in given utf8 text.
58 * @param[in] string The source text to find
59 * @param[in] length The length of text to find
60 * @param[in] language The language to use
61 * @param[out] breaks The line boundaries in given text
63 * @note Line boundaries are returned as non-zero values in table breaks, which must be of size at least length.
65 void FindLineSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks);
68 * @brief Helper function for emiting active-descendant-changed event.
70 * @param[in] obj The accessible object
71 * @param[in] child The child of the object
73 void EmitActiveDescendantChanged(Accessible* obj, Accessible* child);
76 * @brief Helper function for emiting state-changed event.
78 * @param[in] state The accessibility state (SHOWING, HIGHLIGHTED, etc)
79 * @param[in] newValue Whether the state value is changed to new value or not.
80 * @param[in] reserved Reserved. (TODO : Currently, this argument is not implemented in dali)
82 * @note The second argument determines which value is depending on State.
83 * For instance, if the state is PRESSED, newValue means isPressed or isSelected.
84 * If the state is SHOWING, newValue means isShowing.
86 void EmitStateChanged(State state, int newValue, int reserved = 0);
89 * @brief Helper function for emiting bounds-changed event.
91 * @param rect The rectangle for changed bounds
93 void EmitBoundsChanged(Rect<> rect);
96 * @brief Emits "showing" event.
97 * The method informs accessibility clients about "showing" state.
99 * @param[in] isShowing The flag pointing if object is showing
101 void EmitShowing(bool isShowing);
104 * @brief Emits "visible" event.
105 * The method informs accessibility clients about "visible" state.
107 * @param[in] isVisible The flag pointing if object is visible
109 void EmitVisible(bool isVisible);
112 * @brief Emits "highlighted" event.
113 * The method informs accessibility clients about "highlighted" state.
115 * @param[in] isHighlighted The flag pointing if object is highlighted
117 void EmitHighlighted(bool isHighlighted);
120 * @brief Emits "focused" event.
121 * The method informs accessibility clients about "focused" state.
123 * @param[in] isFocused The flag pointing if object is focused
125 void EmitFocused(bool isFocused);
128 * @brief Emits "text inserted" event.
130 * @param[in] position The cursor position
131 * @param[in] length The text length
132 * @param[in] content The inserted text
134 void EmitTextInserted(unsigned int position, unsigned int length, const std::string& content);
137 * @brief Emits "text deleted" event.
139 * @param[in] position The cursor position
140 * @param[in] length The text length
141 * @param[in] content The deleted text
143 void EmitTextDeleted(unsigned int position, unsigned int length, const std::string& content);
146 * @brief Emits "cursor moved" event.
148 * @param[in] cursorPosition The new cursor position
150 void EmitTextCursorMoved(unsigned int cursorPosition);
153 * @brief Emits "MoveOuted" event.
155 * @param[in] type moved out of screen type
157 void EmitMovedOutOfScreen(ScreenRelativeMoveType type);
160 * @brief Emits "highlighted" event.
162 * @param[in] event The enumerated window event
163 * @param[in] detail The additional parameter which interpretation depends on chosen event
165 void Emit(WindowEvent event, unsigned int detail = 0);
168 * @brief Emits property-changed event.
170 * @param[in] event Property changed event
172 void Emit(ObjectPropertyChangeEvent event);
175 * @brief Gets accessibility name.
177 * @return The string with name
179 virtual std::string GetName() = 0;
182 * @brief Gets accessibility description.
184 * @return The string with description
186 virtual std::string GetDescription() = 0;
189 * @brief Gets parent.
191 * @return The handler to accessibility object
193 virtual Accessible* GetParent() = 0;
196 * @brief Gets the number of children.
198 * @return The number of children
200 virtual size_t GetChildCount() = 0;
203 * @brief Gets collection with all children.
205 * @return The collection of accessibility objects
207 virtual std::vector<Accessible*> GetChildren();
210 * @brief Gets child of the index.
212 * @return The child object
214 virtual Accessible* GetChildAtIndex(size_t index) = 0;
217 * @brief Gets index that current object has in its parent's children collection.
219 * @return The index of the current object
221 virtual size_t GetIndexInParent() = 0;
224 * @brief Gets accessibility role.
226 * @return Role enumeration
228 * @see Dali::Accessibility::Role
230 virtual Role GetRole() = 0;
233 * @brief Gets name of accessibility role.
235 * @return The string with human readable role converted from enumeration
237 * @see Dali::Accessibility::Role
238 * @see Accessibility::Accessible::GetRole
240 virtual std::string GetRoleName();
243 * @brief Gets localized name of accessibility role.
245 * @return The string with human readable role translated according to current
248 * @see Dali::Accessibility::Role
249 * @see Accessibility::Accessible::GetRole
250 * @see Accessibility::Accessible::GetRoleName
252 * @note translation is not supported in this version
254 virtual std::string GetLocalizedRoleName();
257 * @brief Gets accessibility states.
259 * @return The collection of states
261 * @note States class is instatation of ArrayBitset template class
263 * @see Dali::Accessibility::State
264 * @see Dali::Accessibility::ArrayBitset
266 virtual States GetStates() = 0;
269 * @brief Gets accessibility attributes.
271 * @return The map of attributes and their values
273 virtual Attributes GetAttributes() = 0;
276 * @brief Checks if this is proxy.
278 * @return True if this is proxy
280 virtual bool IsProxy();
283 * @brief Gets unique address on accessibility bus.
285 * @return The Address class containing address
287 * @see Dali::Accessibility::Address
289 virtual Address GetAddress();
292 * @brief Deputes an object to perform provided gesture.
294 * @param[in] gestureInfo The structure describing the gesture
296 * @return true on success, false otherwise
298 * @see Dali::Accessibility::GestureInfo
300 virtual bool DoGesture(const GestureInfo& gestureInfo) = 0;
303 * @brief Re-emits selected states of an Accessibility Object.
305 * @param[in] states The chosen states to re-emit
306 * @param[in] isRecursive If true, all children of the Accessibility object will also re-emit the states
308 void NotifyAccessibilityStateChange(Dali::Accessibility::States states, bool isRecursive);
311 * @brief Gets information about current object and all relations that connects
312 * it with other accessibility objects.
314 * @return The iterable collection of Relation objects
316 * @see Dali::Accessibility::Relation
318 virtual std::vector<Relation> GetRelationSet() = 0;
321 * @brief Gets internal Actor to be saved before.
323 * @return The internal Actor
325 virtual Dali::Actor GetInternalActor() = 0;
328 * @brief Gets all implemented interfaces.
330 * @return The collection of strings with implemented interfaces
332 std::vector<std::string> GetInterfaces();
335 * @brief Checks if object is on root level.
337 * @return Whether object is on root level or not
339 bool IsOnRootLevel() const
341 return mIsOnRootLevel;
346 Accessible(const Accessible&) = delete;
347 Accessible(Accessible&&) = delete;
348 Accessible& operator=(const Accessible&) = delete;
349 Accessible& operator=(Accessible&&) = delete;
350 std::shared_ptr<Bridge::Data> GetBridgeData();
354 * @brief Gets the highlight actor.
356 * This method is to get the highlight itself.
357 * @return The highlight actor
359 static Dali::Actor GetHighlightActor();
362 * @brief Sets the highlight actor.
364 * This method is to set the highlight itself.
365 * @param[in] actor The highlight actor
367 static void SetHighlightActor(Dali::Actor actor);
370 * @brief Gets the currently highlighted actor.
372 * @return The current highlighted actor
374 static Dali::Actor GetCurrentlyHighlightedActor();
377 * @brief Sets currently highlighted actor.
379 * @param[in] actor The highlight actor
381 static void SetCurrentlyHighlightedActor(Dali::Actor actor);
384 * @brief Sets ObjectRegistry.
386 * @param[in] registry ObjectRegistry instance
388 static void SetObjectRegistry(ObjectRegistry registry);
391 * @brief The method registers functor resposible for converting Actor into Accessible.
392 * @param functor The returning Accessible handle from Actor object
394 static void RegisterExternalAccessibleGetter(std::function<Accessible*(Dali::Actor)> functor);
397 * @brief Acquires Accessible object from Actor object.
399 * @param[in] actor Actor object
400 * @param[in] isRoot True, if it's top level object (window)
402 * @return The handle to Accessible object
404 static Accessible* Get(Dali::Actor actor, bool isRoot = false);
409 std::weak_ptr<Bridge::Data> mBridgeData;
410 bool mIsOnRootLevel = false;
412 }; // Accessible class
414 } // namespace Dali::Accessibility
416 #endif // DALI_ADAPTOR_ATSPI_ACCESSIBLE_H