1 #ifndef DALI_INTERNAL_ATSPI_ACCESSIBILITY_IMPL_H
2 #define DALI_INTERNAL_ATSPI_ACCESSIBILITY_IMPL_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.
22 #include <dali/public-api/actors/actor.h>
23 #include <dali/public-api/math/rect.h>
24 #include <dali/public-api/object/object-registry.h>
32 #include <unordered_map>
33 #include <unordered_set>
37 #include <dali/devel-api/adaptor-framework/accessibility.h>
38 #include <dali/integration-api/debug.h>
42 namespace Accessibility
44 class DALI_ADAPTOR_API Accessible;
45 class DALI_ADAPTOR_API Text;
46 class DALI_ADAPTOR_API Value;
47 class DALI_ADAPTOR_API Component;
48 class DALI_ADAPTOR_API Collection;
49 class DALI_ADAPTOR_API Action;
52 * @brief Base class for different accessibility bridges.
54 * Bridge is resposible for initializing and managing connection on accessibility bus.
55 * Accessibility clients will not get any information about UI without initialized and upraised bridge.
56 * Concrete implementation depends on the accessibility technology available on the platform.
58 * @note This class is singleton.
60 struct DALI_ADAPTOR_API Bridge
62 enum class ForceUpResult
71 virtual ~Bridge() = default;
74 * @brief Gets bus name which bridge is initialized on.
76 virtual const std::string& GetBusName() const = 0;
79 * @brief Registers top level window.
81 * Hierarchy of objects visible for accessibility clients is based on tree-like
82 * structure created from Actors objects. This method allows to connect chosen
83 * object as direct ancestor of application and therefore make it visible for
84 * accessibility clients.
86 * @param[in] object The accessible object
88 virtual void AddTopLevelWindow(Accessible* object) = 0;
91 * @brief Removes top level window.
93 * Hierarchy of objects visible for accessibility clients is based on tree-like
94 * structure created from Actors objects. This method removes previously added
95 * window from visible accessibility objects.
97 * @param[in] object The accessible object
99 virtual void RemoveTopLevelWindow(Accessible* object) = 0;
102 * @brief Adds popup window.
104 * Hierarchy of objects visible for accessibility clients is based on tree-like
105 * structure created from Actors objects. This method adds new popup to the tree.
107 * @param[in] object The accessible object
109 virtual void AddPopup(Accessible* object) = 0;
112 * @brief Removes popup window.
114 * Hierarchy of objects visible for accessibility clients is based on tree-like
115 * structure created from Actors objects. This method removes previously added
118 * @param[in] object The accessible object
120 virtual void RemovePopup(Accessible* object) = 0;
123 * @brief Sets name of current application which will be visible on accessibility bus.
125 * @param[in] name The application name
127 virtual void SetApplicationName(std::string name) = 0;
130 * @brief Gets object being root of accessibility tree.
132 * @return handler to accessibility object
134 virtual Accessible* GetApplication() const = 0;
137 * @brief Finds an object in accessibility tree.
139 * @param[in] path The path to object
141 * @return The handler to accessibility object
143 virtual Accessible* FindByPath(const std::string& path) const = 0;
146 * @brief Shows application on accessibility bus.
148 virtual void ApplicationShown() = 0;
151 * @brief Hides application on accessibility bus.
153 virtual void ApplicationHidden() = 0;
156 * @brief Initializes accessibility bus.
158 virtual void Initialize() = 0;
161 * @brief Terminates accessibility bus.
163 virtual void Terminate() = 0;
166 * @brief This method is called, when bridge is being activated.
168 virtual ForceUpResult ForceUp()
172 return ForceUpResult::ALREADY_UP;
174 mData = std::make_shared<Data>();
175 mData->mBridge = this;
176 return ForceUpResult::JUST_STARTED;
180 * @brief This method is called, when bridge is being deactivated.
182 virtual void ForceDown() = 0;
185 * @brief Checks if bridge is activated or not.
186 * @return True if brige is activated.
194 * @brief Emits cursor-moved event on at-spi bus.
196 * @param[in] obj The accessible object
197 * @param[in] cursorPosition The new cursor position
199 virtual void EmitCursorMoved(Accessible* obj, unsigned int cursorPosition) = 0;
202 * @brief Emits active-descendant-changed event on at-spi bus.
204 * @param[in] obj The accessible object
205 * @param[in] child The child of the object
207 virtual void EmitActiveDescendantChanged(Accessible* obj, Accessible* child) = 0;
210 * @brief Emits text-changed event on at-spi bus.
212 * @param[in] obj The accessible object
213 * @param[in] state The changed state for text, such as Inserted or Deleted
214 * @param[in] position The cursor position
215 * @param[in] length The text length
216 * @param[in] content The changed text
218 virtual void EmitTextChanged(Accessible* obj, TextChangedState state, unsigned int position, unsigned int length, const std::string& content) = 0;
221 * @brief Emits state-changed event on at-spi bus.
223 * @param[in] obj The accessible object
224 * @param[in] state The accessibility state (SHOWING, HIGHLIGHTED, etc)
225 * @param[in] newValue Whether the state value is changed to new value or not.
226 * @param[in] reserved Reserved. (Currently, this argument is not implemented in dali)
228 virtual void EmitStateChanged(Accessible* obj, State state, int newValue, int reserved = 0) = 0;
231 * @brief Emits window event on at-spi bus.
233 * @param[in] obj The accessible object
234 * @param[in] event The enumerated window event
235 * @param[in] detail The additional parameter which interpretation depends on chosen event
237 virtual void Emit(Accessible* obj, WindowEvent event, unsigned int detail = 0) = 0;
240 * @brief Emits property-changed event on at-spi bus.
242 * @param[in] obj The accessible object
243 * @param[in] event Property changed event
245 virtual void Emit(Accessible* obj, ObjectPropertyChangeEvent event) = 0;
248 * @brief Emits bounds-changed event on at-spi bus.
250 * @param[in] obj The accessible object
251 * @param[in] rect The rectangle for changed bounds
253 virtual void EmitBoundsChanged(Accessible* obj, Rect<> rect) = 0;
256 * @brief Emits key event on at-spi bus.
258 * Screen-reader might receive this event and reply, that given keycode is consumed. In that case
259 * further processing of the keycode should be ignored.
261 * @param[in] type Key event type
262 * @param[in] keyCode Key code
263 * @param[in] keyName Key name
264 * @param[in] timeStamp Time stamp
265 * @param[in] isText Whether it's text or not
266 * @return Whether this event is consumed or not
268 virtual Consumed Emit(KeyEventType type, unsigned int keyCode, const std::string& keyName, unsigned int timeStamp, bool isText) = 0;
271 * @brief Reads given text by screen reader
273 * @param[in] text The text to read
274 * @param[in] discardable If TRUE, reading can be discarded by subsequent reading requests,
275 * if FALSE the reading must finish before next reading request can be started
276 * @param[in] callback the callback function that is called on reading signals emitted
277 * during processing of this reading request.
278 * Callback can be one of the following signals:
279 * ReadingCancelled, ReadingStopped, ReadingSkipped
281 virtual void Say(const std::string& text, bool discardable, std::function<void(std::string)> callback) = 0;
284 * @brief Force accessibility client to pause.
286 virtual void Pause() = 0;
289 * @brief Force accessibility client to resume.
291 virtual void Resume() = 0;
294 * @brief Cancels anything screen-reader is reading / has queued to read
296 * @param[in] alsoNonDiscardable whether to cancel non-discardable readings as well
298 virtual void StopReading(bool alsoNonDiscardable) = 0;
301 * @brief Suppresses reading of screen-reader
303 * @param[in] suppress whether to suppress reading of screen-reader
305 virtual void SuppressScreenReader(bool suppress) = 0;
308 * @brief Gets screen reader status.
310 * @return True if screen reader is enabled
312 virtual bool GetScreenReaderEnabled() = 0;
315 * @brief Gets ATSPI status.
317 * @return True if ATSPI is enabled
319 virtual bool IsEnabled() = 0;
322 * @brief Returns instance of bridge singleton object.
324 * @return The current bridge object
326 static Bridge* GetCurrentBridge();
329 * @brief Blocks auto-initialization of AT-SPI bridge
331 * Use this only if your application starts before DBus does, and call it early in main()
332 * (before GetCurrentBridge() is called by anyone). GetCurrentBridge() will then return an
333 * instance of DummyBridge.
335 * When DBus is ready, call EnableAutoInit(). Please note that GetCurrentBridge() may still
336 * return an instance of DummyBridge if AT-SPI was disabled at compile time or using an
337 * environment variable, or if creating the real bridge failed.
339 * @see Dali::Accessibility::DummyBridge
340 * @see Dali::Accessibility::Bridge::EnableAutoInit
342 static void DisableAutoInit();
345 * @brief Re-enables auto-initialization of AT-SPI bridge
347 * Normal applications do not have to call this function. GetCurrentBridge() tries to
348 * initialize the AT-SPI bridge when it is called for the first time.
350 * @see Dali::Accessibility::Bridge::DisableAutoInit
351 * @see Dali::Accessibility::Bridge::AddTopLevelWindow
352 * @see Dali::Accessibility::Bridge::SetApplicationName
354 static void EnableAutoInit();
359 std::unordered_set<Accessible*> mKnownObjects;
360 std::string mBusName;
361 Bridge* mBridge = nullptr;
362 Actor mHighlightActor;
363 Actor mCurrentlyHighlightedActor;
365 std::shared_ptr<Data> mData;
366 friend class Accessible;
368 enum class AutoInitState
374 inline static AutoInitState autoInitState = AutoInitState::ENABLED;
377 * @brief Registers accessible object to be known in bridge object.
379 * Bridge must known about all currently alive accessible objects, as some requst
380 * might come and object will be identified by number id (it's memory address).
381 * To avoid memory corruption number id is checked against set of known objects.
383 * @param[in] object The accessible object
385 void RegisterOnBridge(Accessible* object);
388 * @brief Tells bridge, that given object is considered root (doesn't have any parents).
390 * All root objects will have the same parent - application object. Application object
391 * is controlled by bridge and private.
393 * @param[in] owner The accessible object
395 void SetIsOnRootLevel(Accessible* owner);
399 * @brief Checks if ATSPI is activated or not.
400 * @return True if ATSPI is activated.
404 if(Bridge::GetCurrentBridge() == nullptr)
409 if(Bridge::GetCurrentBridge()->IsEnabled() == false)
414 return Bridge::GetCurrentBridge()->IsUp();
418 * @brief Basic interface implemented by all accessibility objects.
423 virtual ~Accessible();
425 using utf8_t = unsigned char;
428 * @brief Calculates and finds word boundaries in given utf8 text.
430 * @param[in] string The source text to find
431 * @param[in] length The length of text to find
432 * @param[in] language The language to use
433 * @param[out] breaks The word boundaries in given text
435 * @note Word boundaries are returned as non-zero values in table breaks, which must be of size at least length.
437 void FindWordSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks);
440 * @brief Calculates and finds line boundaries in given utf8 text.
442 * @param[in] string The source text to find
443 * @param[in] length The length of text to find
444 * @param[in] language The language to use
445 * @param[out] breaks The line boundaries in given text
447 * @note Line boundaries are returned as non-zero values in table breaks, which must be of size at least length.
449 void FindLineSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks);
452 * @brief Helper function for emiting active-descendant-changed event.
454 * @param[in] obj The accessible object
455 * @param[in] child The child of the object
457 void EmitActiveDescendantChanged(Accessible* obj, Accessible* child);
460 * @brief Helper function for emiting state-changed event.
462 * @param[in] state The accessibility state (SHOWING, HIGHLIGHTED, etc)
463 * @param[in] newValue Whether the state value is changed to new value or not.
464 * @param[in] reserved Reserved. (TODO : Currently, this argument is not implemented in dali)
466 * @note The second argument determines which value is depending on State.
467 * For instance, if the state is PRESSED, newValue means isPressed or isSelected.
468 * If the state is SHOWING, newValue means isShowing.
470 void EmitStateChanged(State state, int newValue, int reserved = 0);
473 * @brief Helper function for emiting bounds-changed event.
475 * @param rect The rectangle for changed bounds
477 void EmitBoundsChanged(Rect<> rect);
480 * @brief Emits "showing" event.
481 * The method informs accessibility clients about "showing" state.
483 * @param[in] isShowing The flag pointing if object is showing
485 void EmitShowing(bool isShowing);
488 * @brief Emits "visible" event.
489 * The method informs accessibility clients about "visible" state.
491 * @param[in] isVisible The flag pointing if object is visible
493 void EmitVisible(bool isVisible);
496 * @brief Emits "highlighted" event.
497 * The method informs accessibility clients about "highlighted" state.
499 * @param[in] isHighlighted The flag pointing if object is highlighted
501 void EmitHighlighted(bool isHighlighted);
504 * @brief Emits "focused" event.
505 * The method informs accessibility clients about "focused" state.
507 * @param[in] isFocused The flag pointing if object is focused
509 void EmitFocused(bool isFocused);
512 * @brief Emits "text inserted" event.
514 * @param[in] position The cursor position
515 * @param[in] length The text length
516 * @param[in] content The inserted text
518 void EmitTextInserted(unsigned int position, unsigned int length, const std::string& content);
521 * @brief Emits "text deleted" event.
523 * @param[in] position The cursor position
524 * @param[in] length The text length
525 * @param[in] content The deleted text
527 void EmitTextDeleted(unsigned int position, unsigned int length, const std::string& content);
530 * @brief Emits "cursor moved" event.
532 * @param[in] cursorPosition The new cursor position
534 void EmitTextCursorMoved(unsigned int cursorPosition);
537 * @brief Emits "highlighted" event.
539 * @param[in] event The enumerated window event
540 * @param[in] detail The additional parameter which interpretation depends on chosen event
542 void Emit(WindowEvent event, unsigned int detail = 0);
545 * @brief Emits property-changed event.
547 * @param[in] event Property changed event
549 void Emit(ObjectPropertyChangeEvent event);
552 * @brief Gets accessibility name.
554 * @return The string with name
556 virtual std::string GetName() = 0;
559 * @brief Gets accessibility description.
561 * @return The string with description
563 virtual std::string GetDescription() = 0;
566 * @brief Gets parent.
568 * @return The handler to accessibility object
570 virtual Accessible* GetParent() = 0;
573 * @brief Gets the number of children.
575 * @return The number of children
577 virtual size_t GetChildCount() = 0;
580 * @brief Gets collection with all children.
582 * @return The collection of accessibility objects
584 virtual std::vector<Accessible*> GetChildren();
587 * @brief Gets child of the index.
589 * @return The child object
591 virtual Accessible* GetChildAtIndex(size_t index) = 0;
594 * @brief Gets index that current object has in its parent's children collection.
596 * @return The index of the current object
598 virtual size_t GetIndexInParent() = 0;
601 * @brief Gets accessibility role.
603 * @return Role enumeration
605 * @see Dali::Accessibility::Role
607 virtual Role GetRole() = 0;
610 * @brief Gets name of accessibility role.
612 * @return The string with human readable role converted from enumeration
614 * @see Dali::Accessibility::Role
615 * @see Accessibility::Accessible::GetRole
617 virtual std::string GetRoleName();
620 * @brief Gets localized name of accessibility role.
622 * @return The string with human readable role translated according to current
625 * @see Dali::Accessibility::Role
626 * @see Accessibility::Accessible::GetRole
627 * @see Accessibility::Accessible::GetRoleName
629 * @note translation is not supported in this version
631 virtual std::string GetLocalizedRoleName();
634 * @brief Gets accessibility states.
636 * @return The collection of states
638 * @note States class is instatation of ArrayBitset template class
640 * @see Dali::Accessibility::State
641 * @see Dali::Accessibility::ArrayBitset
643 virtual States GetStates() = 0;
646 * @brief Gets accessibility attributes.
648 * @return The map of attributes and their values
650 virtual Attributes GetAttributes() = 0;
653 * @brief Checks if this is proxy.
655 * @return True if this is proxy
657 virtual bool IsProxy();
660 * @brief Gets unique address on accessibility bus.
662 * @return The Address class containing address
664 * @see Dali::Accessibility::Address
666 virtual Address GetAddress();
669 * @brief Gets accessibility object, which is "default label" for this object.
671 * @return The Accessible object
673 virtual Accessible* GetDefaultLabel();
676 * @brief Deputes an object to perform provided gesture.
678 * @param[in] gestureInfo The structure describing the gesture
680 * @return true on success, false otherwise
682 * @see Dali::Accessibility::GestureInfo
684 virtual bool DoGesture(const GestureInfo& gestureInfo) = 0;
687 * @brief Re-emits selected states of an Accessibility Object.
689 * @param[in] states The chosen states to re-emit
690 * @param[in] isRecursive If true, all children of the Accessibility object will also re-emit the states
692 void NotifyAccessibilityStateChange(Dali::Accessibility::States states, bool isRecursive);
695 * @brief Gets information about current object and all relations that connects
696 * it with other accessibility objects.
698 * @return The iterable collection of Relation objects
700 * @see Dali::Accessibility::Relation
702 virtual std::vector<Relation> GetRelationSet() = 0;
705 * @brief Gets all implemented interfaces.
707 * @return The collection of strings with implemented interfaces
709 std::vector<std::string> GetInterfaces();
712 * @brief Checks if object is on root level.
714 * @return Whether object is on root level or not
716 bool IsOnRootLevel() const
718 return mIsOnRootLevel;
722 * @brief The method registers functor resposible for converting Actor into Accessible.
723 * @param functor The returning Accessible handle from Actor object
725 static void RegisterControlAccessibilityGetter(std::function<Accessible*(Dali::Actor)> functor);
728 * @brief Acquires Accessible object from Actor object.
730 * @param[in] actor Actor object
731 * @param[in] isRoot True, if it's top level object (window)
733 * @return The handle to Accessible object
735 static Accessible* Get(Dali::Actor actor, bool isRoot = false);
739 Accessible(const Accessible&) = delete;
740 Accessible(Accessible&&) = delete;
741 Accessible& operator=(const Accessible&) = delete;
742 Accessible& operator=(Accessible&&) = delete;
743 std::shared_ptr<Bridge::Data> GetBridgeData();
747 * @brief Gets the highlight actor.
749 * This method is to get the highlight itself.
750 * @return The highlight actor
752 static Dali::Actor GetHighlightActor();
755 * @brief Sets the highlight actor.
757 * This method is to set the highlight itself.
758 * @param[in] actor The highlight actor
760 static void SetHighlightActor(Dali::Actor actor);
763 * @brief Gets the currently highlighted actor.
765 * @return The current highlighted actor
767 static Dali::Actor GetCurrentlyHighlightedActor();
770 * @brief Sets currently highlighted actor.
772 * @param[in] actor The highlight actor
774 static void SetCurrentlyHighlightedActor(Dali::Actor actor);
777 * @brief Sets ObjectRegistry.
779 * @param[in] registry ObjectRegistry instance
781 static void SetObjectRegistry(ObjectRegistry registry);
786 std::weak_ptr<Bridge::Data> mBridgeData;
787 bool mIsOnRootLevel = false;
791 * @brief Interface enabling to perform provided actions.
793 class Action : public virtual Accessible
797 * @brief Gets name of action with given index.
799 * @param[in] index The index of action
801 * @return The string with name of action
803 virtual std::string GetActionName(size_t index) = 0;
806 * @brief Gets translated name of action with given index.
808 * @param[in] index The index of action
810 * @return The string with name of action translated according to current translation domain
812 * @note The translation is not supported in this version
814 virtual std::string GetLocalizedActionName(size_t index) = 0;
817 * @brief Gets description of action with given index.
819 * @param[in] index The index of action
821 * @return The string with description of action
823 virtual std::string GetActionDescription(size_t index) = 0;
826 * @brief Gets key code binded to action with given index.
828 * @param[in] index The index of action
830 * @return The string with key name
832 virtual std::string GetActionKeyBinding(size_t index) = 0;
835 * @brief Gets number of provided actions.
837 * @return The number of actions
839 virtual size_t GetActionCount() = 0;
842 * @brief Performs an action with given index.
844 * @param index The index of action
846 * @return true on success, false otherwise
848 virtual bool DoAction(size_t index) = 0;
851 * @brief Performs an action with given name.
853 * @param name The name of action
855 * @return true on success, false otherwise
857 virtual bool DoAction(const std::string& name) = 0;
861 * @brief Interface enabling advanced quering of accessibility objects.
863 * @note since all mathods can be implemented inside bridge,
864 * none methods have to be overrided
866 class Collection : public virtual Accessible
872 * @brief Interface representing objects having screen coordinates.
874 class Component : public virtual Accessible
878 * @brief Gets rectangle describing size.
880 * @param[in] type The enumeration with type of coordinate systems
882 * @return Rect<> object
886 virtual Rect<> GetExtents(CoordinateType type) = 0;
889 * @brief Gets layer current object is localized on.
891 * @return The enumeration pointing layer
893 * @see Dali::Accessibility::ComponentLayer
895 virtual ComponentLayer GetLayer() = 0;
898 * @brief Gets value of z-order.
900 * @return The value of z-order
901 * @remarks MDI means "Multi Document Interface" (https://en.wikipedia.org/wiki/Multiple-document_interface)
902 * which in short means that many stacked windows can be displayed within a single application.
903 * In such model, the concept of z-order of UI element became important to deal with element overlapping.
905 virtual int16_t GetMdiZOrder() = 0;
908 * @brief Sets current object as "focused".
910 * @return true on success, false otherwise
912 virtual bool GrabFocus() = 0;
915 * @brief Gets value of alpha channel.
917 * @return The alpha channel value in range [0.0, 1.0]
919 virtual double GetAlpha() = 0;
922 * @brief Sets current object as "highlighted".
924 * The method assings "highlighted" state, simultaneously removing it
925 * from currently highlighted object.
927 * @return true on success, false otherwise
929 virtual bool GrabHighlight() = 0;
932 * @brief Sets current object as "unhighlighted".
934 * The method removes "highlighted" state from object.
936 * @return true on success, false otherwise
938 * @see Dali:Accessibility::State
940 virtual bool ClearHighlight() = 0;
943 * @brief Checks whether object can be scrolled.
945 * @return true if object is scrollable, false otherwise
947 * @see Dali:Accessibility::State
949 virtual bool IsScrollable();
952 * @brief Gets Accessible object containing given point.
954 * @param[in] point The two-dimensional point
955 * @param[in] type The enumeration with type of coordinate system
957 * @return The handle to last child of current object which contains given point
959 * @see Dali::Accessibility::Point
961 virtual Accessible* GetAccessibleAtPoint(Point point, CoordinateType type);
964 * @brief Checks if current object contains given point.
966 * @param[in] point The two-dimensional point
967 * @param[in] type The enumeration with type of coordinate system
969 * @return True if accessible contains in point, otherwise false.
971 * @remarks This method is `Contains` in DBus method.
972 * @see Dali::Accessibility::Point
974 virtual bool IsAccessibleContainedAtPoint(Point point, CoordinateType type);
978 * @brief Interface representing objects which can store numeric value.
980 class Value : public virtual Accessible
984 * @brief Gets the lowest possible value.
986 * @return The minimum value
988 virtual double GetMinimum() = 0;
991 * @brief Gets the current value.
993 * @return The current value
995 virtual double GetCurrent() = 0;
998 * @brief Gets the highest possible value.
1000 * @return The highest value.
1002 virtual double GetMaximum() = 0;
1005 * @brief Sets the current value.
1007 * @param[in] value The current value to set
1009 * @return true if value could have been assigned, false otherwise
1011 virtual bool SetCurrent(double value) = 0;
1014 * @brief Gets the lowest increment that can be distinguished.
1016 * @return The lowest increment
1018 virtual double GetMinimumIncrement() = 0;
1022 * @brief Interface representing objects which can store immutable texts.
1024 * @see Dali::Accessibility::EditableText
1026 class DALI_ADAPTOR_API Text : public virtual Accessible
1030 * @brief Gets stored text in given range.
1032 * @param[in] startOffset The index of first character
1033 * @param[in] endOffset The index of first character after the last one expected
1035 * @return The substring of stored text
1037 virtual std::string GetText(size_t startOffset, size_t endOffset) = 0;
1040 * @brief Gets number of all stored characters.
1042 * @return The number of characters
1043 * @remarks This method is `CharacterCount` in DBus method.
1045 virtual size_t GetCharacterCount() = 0;
1048 * @brief Gets the cursor offset.
1050 * @return Value of cursor offset
1051 * @remarks This method is `CaretOffset` in DBus method.
1053 virtual size_t GetCursorOffset() = 0;
1056 * @brief Sets the cursor offset.
1058 * @param[in] offset Cursor offset
1060 * @return True if successful
1061 * @remarks This method is `SetCaretOffset` in DBus method.
1063 virtual bool SetCursorOffset(size_t offset) = 0;
1066 * @brief Gets substring of stored text truncated in concrete gradation.
1068 * @param[in] offset The position in stored text
1069 * @param[in] boundary The enumeration describing text gradation
1071 * @return Range structure containing acquired text and offsets in original string
1073 * @see Dali::Accessibility::Range
1075 virtual Range GetTextAtOffset(size_t offset, TextBoundary boundary) = 0;
1078 * @brief Gets selected text.
1080 * @param[in] selectionIndex The selection index
1081 * @note Currently only one selection (i.e. with index = 0) is supported
1083 * @return Range structure containing acquired text and offsets in original string
1085 * @remarks This method is `GetSelection` in DBus method.
1086 * @see Dali::Accessibility::Range
1088 virtual Range GetRangeOfSelection(size_t selectionIndex) = 0;
1091 * @brief Removes the whole selection.
1093 * @param[in] selectionIndex The selection index
1094 * @note Currently only one selection (i.e. with index = 0) is supported
1096 * @return bool on success, false otherwise
1098 virtual bool RemoveSelection(size_t selectionIndex) = 0;
1101 * @brief Sets selected text.
1103 * @param[in] selectionIndex The selection index
1104 * @param[in] startOffset The index of first character
1105 * @param[in] endOffset The index of first character after the last one expected
1107 * @note Currently only one selection (i.e. with index = 0) is supported
1109 * @return true on success, false otherwise
1110 * @remarks This method is `SetSelection` in DBus method.
1112 virtual bool SetRangeOfSelection(size_t selectionIndex, size_t startOffset, size_t endOffset) = 0;
1116 * @brief Interface representing objects which can store editable texts.
1118 * @note Paste method is entirely implemented inside bridge
1120 * @see Dali::Accessibility::EditableText
1122 class DALI_ADAPTOR_API EditableText : public virtual Accessible
1126 * @brief Copies text in range to system clipboard.
1128 * @param[in] startPosition The index of first character
1129 * @param[in] endPosition The index of first character after the last one expected
1131 * @return true on success, false otherwise
1133 virtual bool CopyText(size_t startPosition, size_t endPosition) = 0;
1136 * @brief Cuts text in range to system clipboard.
1138 * @param[in] startPosition The index of first character
1139 * @param[in] endPosition The index of first character after the last one expected
1141 * @return true on success, false otherwise
1143 virtual bool CutText(size_t startPosition, size_t endPosition) = 0;
1146 * @brief Deletes text in range.
1148 * @param[in] startPosition The index of first character
1149 * @param[in] endPosition The index of first character after the last one expected
1151 * @return true on success, false otherwise
1153 virtual bool DeleteText(size_t startPosition, size_t endPosition) = 0;
1156 * @brief Inserts text at startPosition.
1158 * @param[in] startPosition The index of first character
1159 * @param[in] text The text content
1161 * @return true on success, false otherwise
1163 virtual bool InsertText(size_t startPosition, std::string text) = 0;
1166 * @brief Replaces text with content.
1168 * @param[in] newContents The text content
1170 * @return true on success, false otherwise
1172 virtual bool SetTextContents(std::string newContents) = 0;
1176 * @brief Interface representing objects which can store a set of selected items.
1178 class DALI_ADAPTOR_API Selection : public virtual Accessible
1182 * @brief Gets the number of selected children.
1184 * @return The number of selected children (zero if none)
1186 virtual int GetSelectedChildrenCount() = 0;
1189 * @brief Gets a specific selected child.
1191 * @param selectedChildIndex The index of the selected child
1193 * @note @p selectedChildIndex refers to the list of selected children,
1194 * not the list of all children
1196 * @return The selected child or nullptr if index is invalid
1198 virtual Accessible* GetSelectedChild(int selectedChildIndex) = 0;
1201 * @brief Selects a child.
1203 * @param childIndex The index of the child
1205 * @return true on success, false otherwise
1207 virtual bool SelectChild(int childIndex) = 0;
1210 * @brief Deselects a selected child.
1212 * @param selectedChildIndex The index of the selected child
1214 * @note @p selectedChildIndex refers to the list of selected children,
1215 * not the list of all children
1217 * @return true on success, false otherwise
1219 * @see Dali::Accessibility::Selection::DeselectChild
1221 virtual bool DeselectSelectedChild(int selectedChildIndex) = 0;
1224 * @brief Checks whether a child is selected.
1226 * @param childIndex The index of the child
1228 * @return true if given child is selected, false otherwise
1230 virtual bool IsChildSelected(int childIndex) = 0;
1233 * @brief Selects all children.
1235 * @return true on success, false otherwise
1237 virtual bool SelectAll() = 0;
1240 * @brief Deselects all children.
1242 * @return true on success, false otherwise
1244 virtual bool ClearSelection() = 0;
1247 * @brief Deselects a child.
1249 * @param childIndex The index of the child.
1251 * @return true on success, false otherwise
1253 * @see Dali::Accessibility::Selection::DeselectSelectedChild
1255 virtual bool DeselectChild(int childIndex) = 0;
1259 * @brief The minimalistic, always empty Accessible object with settable address.
1261 * For those situations, where you want to return address in different bridge
1262 * (embedding for example), but the object itself ain't planned to be used otherwise.
1263 * This object has null parent, no children, empty name and so on
1265 class DALI_ADAPTOR_API EmptyAccessibleWithAddress : public virtual Accessible
1268 EmptyAccessibleWithAddress() = default;
1270 EmptyAccessibleWithAddress(Address address)
1271 : mAddress(std::move(address))
1275 void SetAddress(Address address)
1277 this->mAddress = std::move(address);
1280 std::string GetName() override
1285 std::string GetDescription() override
1290 Accessible* GetParent() override
1295 size_t GetChildCount() override
1300 std::vector<Accessible*> GetChildren() override
1305 Accessible* GetChildAtIndex(size_t index) override
1307 throw std::domain_error{"out of bounds index (" + std::to_string(index) + ") - no children"};
1310 size_t GetIndexInParent() override
1312 return static_cast<size_t>(-1);
1315 Role GetRole() override
1320 std::string GetRoleName() override;
1322 States GetStates() override
1327 Attributes GetAttributes() override
1332 Address GetAddress() override
1337 bool DoGesture(const GestureInfo& gestureInfo) override
1342 std::vector<Relation> GetRelationSet() override
1351 } // namespace Accessibility
1354 #endif // DALI_INTERNAL_ATSPI_ACCESSIBILITY_IMPL_H