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 MoveOuted event on at-spi bus.
223 * @param[in] obj Accessible object
224 * @param[in] type Direction type when an Accessible object moves out of screen
226 virtual void EmitMovedOutOfScreen(Accessible* obj, ScreenRelativeMoveType type) = 0;
229 * @brief Emits state-changed event on at-spi bus.
231 * @param[in] obj The accessible object
232 * @param[in] state The accessibility state (SHOWING, HIGHLIGHTED, etc)
233 * @param[in] newValue Whether the state value is changed to new value or not.
234 * @param[in] reserved Reserved. (Currently, this argument is not implemented in dali)
236 virtual void EmitStateChanged(Accessible* obj, State state, int newValue, int reserved = 0) = 0;
239 * @brief Emits window event on at-spi bus.
241 * @param[in] obj The accessible object
242 * @param[in] event The enumerated window event
243 * @param[in] detail The additional parameter which interpretation depends on chosen event
245 virtual void Emit(Accessible* obj, WindowEvent event, unsigned int detail = 0) = 0;
248 * @brief Emits property-changed event on at-spi bus.
250 * @param[in] obj The accessible object
251 * @param[in] event Property changed event
253 virtual void Emit(Accessible* obj, ObjectPropertyChangeEvent event) = 0;
256 * @brief Emits bounds-changed event on at-spi bus.
258 * @param[in] obj The accessible object
259 * @param[in] rect The rectangle for changed bounds
261 virtual void EmitBoundsChanged(Accessible* obj, Rect<> rect) = 0;
264 * @brief Emits key event on at-spi bus.
266 * Screen-reader might receive this event and reply, that given keycode is consumed. In that case
267 * further processing of the keycode should be ignored.
269 * @param[in] type Key event type
270 * @param[in] keyCode Key code
271 * @param[in] keyName Key name
272 * @param[in] timeStamp Time stamp
273 * @param[in] isText Whether it's text or not
274 * @return Whether this event is consumed or not
276 virtual Consumed Emit(KeyEventType type, unsigned int keyCode, const std::string& keyName, unsigned int timeStamp, bool isText) = 0;
279 * @brief Reads given text by screen reader
281 * @param[in] text The text to read
282 * @param[in] discardable If TRUE, reading can be discarded by subsequent reading requests,
283 * if FALSE the reading must finish before next reading request can be started
284 * @param[in] callback the callback function that is called on reading signals emitted
285 * during processing of this reading request.
286 * Callback can be one of the following signals:
287 * ReadingCancelled, ReadingStopped, ReadingSkipped
289 virtual void Say(const std::string& text, bool discardable, std::function<void(std::string)> callback) = 0;
292 * @brief Force accessibility client to pause.
294 virtual void Pause() = 0;
297 * @brief Force accessibility client to resume.
299 virtual void Resume() = 0;
302 * @brief Cancels anything screen-reader is reading / has queued to read
304 * @param[in] alsoNonDiscardable whether to cancel non-discardable readings as well
306 virtual void StopReading(bool alsoNonDiscardable) = 0;
309 * @brief Suppresses reading of screen-reader
311 * @param[in] suppress whether to suppress reading of screen-reader
313 virtual void SuppressScreenReader(bool suppress) = 0;
316 * @brief Gets screen reader status.
318 * @return True if screen reader is enabled
320 virtual bool GetScreenReaderEnabled() = 0;
323 * @brief Gets ATSPI status.
325 * @return True if ATSPI is enabled
327 virtual bool IsEnabled() = 0;
330 * @brief Returns instance of bridge singleton object.
332 * @return The current bridge object
334 static Bridge* GetCurrentBridge();
337 * @brief Blocks auto-initialization of AT-SPI bridge
339 * Use this only if your application starts before DBus does, and call it early in main()
340 * (before GetCurrentBridge() is called by anyone). GetCurrentBridge() will then return an
341 * instance of DummyBridge.
343 * When DBus is ready, call EnableAutoInit(). Please note that GetCurrentBridge() may still
344 * return an instance of DummyBridge if AT-SPI was disabled at compile time or using an
345 * environment variable, or if creating the real bridge failed.
347 * @see Dali::Accessibility::DummyBridge
348 * @see Dali::Accessibility::Bridge::EnableAutoInit
350 static void DisableAutoInit();
353 * @brief Re-enables auto-initialization of AT-SPI bridge
355 * Normal applications do not have to call this function. GetCurrentBridge() tries to
356 * initialize the AT-SPI bridge when it is called for the first time.
358 * @see Dali::Accessibility::Bridge::DisableAutoInit
359 * @see Dali::Accessibility::Bridge::AddTopLevelWindow
360 * @see Dali::Accessibility::Bridge::SetApplicationName
362 static void EnableAutoInit();
367 std::unordered_set<Accessible*> mKnownObjects;
368 std::string mBusName;
369 Bridge* mBridge = nullptr;
370 Actor mHighlightActor;
371 Actor mCurrentlyHighlightedActor;
373 std::shared_ptr<Data> mData;
374 friend class Accessible;
376 enum class AutoInitState
382 inline static AutoInitState autoInitState = AutoInitState::ENABLED;
385 * @brief Registers accessible object to be known in bridge object.
387 * Bridge must known about all currently alive accessible objects, as some requst
388 * might come and object will be identified by number id (it's memory address).
389 * To avoid memory corruption number id is checked against set of known objects.
391 * @param[in] object The accessible object
393 void RegisterOnBridge(Accessible* object);
396 * @brief Tells bridge, that given object is considered root (doesn't have any parents).
398 * All root objects will have the same parent - application object. Application object
399 * is controlled by bridge and private.
401 * @param[in] owner The accessible object
403 void SetIsOnRootLevel(Accessible* owner);
407 * @brief Checks if ATSPI is activated or not.
408 * @return True if ATSPI is activated.
412 if(Bridge::GetCurrentBridge() == nullptr)
417 if(Bridge::GetCurrentBridge()->IsEnabled() == false)
422 return Bridge::GetCurrentBridge()->IsUp();
426 * @brief Basic interface implemented by all accessibility objects.
431 virtual ~Accessible();
433 using utf8_t = unsigned char;
436 * @brief Calculates and finds word boundaries in given utf8 text.
438 * @param[in] string The source text to find
439 * @param[in] length The length of text to find
440 * @param[in] language The language to use
441 * @param[out] breaks The word boundaries in given text
443 * @note Word boundaries are returned as non-zero values in table breaks, which must be of size at least length.
445 void FindWordSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks);
448 * @brief Calculates and finds line boundaries in given utf8 text.
450 * @param[in] string The source text to find
451 * @param[in] length The length of text to find
452 * @param[in] language The language to use
453 * @param[out] breaks The line boundaries in given text
455 * @note Line boundaries are returned as non-zero values in table breaks, which must be of size at least length.
457 void FindLineSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks);
460 * @brief Helper function for emiting active-descendant-changed event.
462 * @param[in] obj The accessible object
463 * @param[in] child The child of the object
465 void EmitActiveDescendantChanged(Accessible* obj, Accessible* child);
468 * @brief Helper function for emiting state-changed event.
470 * @param[in] state The accessibility state (SHOWING, HIGHLIGHTED, etc)
471 * @param[in] newValue Whether the state value is changed to new value or not.
472 * @param[in] reserved Reserved. (TODO : Currently, this argument is not implemented in dali)
474 * @note The second argument determines which value is depending on State.
475 * For instance, if the state is PRESSED, newValue means isPressed or isSelected.
476 * If the state is SHOWING, newValue means isShowing.
478 void EmitStateChanged(State state, int newValue, int reserved = 0);
481 * @brief Helper function for emiting bounds-changed event.
483 * @param rect The rectangle for changed bounds
485 void EmitBoundsChanged(Rect<> rect);
488 * @brief Emits "showing" event.
489 * The method informs accessibility clients about "showing" state.
491 * @param[in] isShowing The flag pointing if object is showing
493 void EmitShowing(bool isShowing);
496 * @brief Emits "visible" event.
497 * The method informs accessibility clients about "visible" state.
499 * @param[in] isVisible The flag pointing if object is visible
501 void EmitVisible(bool isVisible);
504 * @brief Emits "highlighted" event.
505 * The method informs accessibility clients about "highlighted" state.
507 * @param[in] isHighlighted The flag pointing if object is highlighted
509 void EmitHighlighted(bool isHighlighted);
512 * @brief Emits "focused" event.
513 * The method informs accessibility clients about "focused" state.
515 * @param[in] isFocused The flag pointing if object is focused
517 void EmitFocused(bool isFocused);
520 * @brief Emits "text inserted" event.
522 * @param[in] position The cursor position
523 * @param[in] length The text length
524 * @param[in] content The inserted text
526 void EmitTextInserted(unsigned int position, unsigned int length, const std::string& content);
529 * @brief Emits "text deleted" event.
531 * @param[in] position The cursor position
532 * @param[in] length The text length
533 * @param[in] content The deleted text
535 void EmitTextDeleted(unsigned int position, unsigned int length, const std::string& content);
538 * @brief Emits "cursor moved" event.
540 * @param[in] cursorPosition The new cursor position
542 void EmitTextCursorMoved(unsigned int cursorPosition);
545 * @brief Emits "MoveOuted" event.
547 * @param[in] type moved out of screen type
549 void EmitMovedOutOfScreen(ScreenRelativeMoveType type);
552 * @brief Emits "highlighted" event.
554 * @param[in] event The enumerated window event
555 * @param[in] detail The additional parameter which interpretation depends on chosen event
557 void Emit(WindowEvent event, unsigned int detail = 0);
560 * @brief Emits property-changed event.
562 * @param[in] event Property changed event
564 void Emit(ObjectPropertyChangeEvent event);
567 * @brief Gets accessibility name.
569 * @return The string with name
571 virtual std::string GetName() = 0;
574 * @brief Gets accessibility description.
576 * @return The string with description
578 virtual std::string GetDescription() = 0;
581 * @brief Gets parent.
583 * @return The handler to accessibility object
585 virtual Accessible* GetParent() = 0;
588 * @brief Gets the number of children.
590 * @return The number of children
592 virtual size_t GetChildCount() = 0;
595 * @brief Gets collection with all children.
597 * @return The collection of accessibility objects
599 virtual std::vector<Accessible*> GetChildren();
602 * @brief Gets child of the index.
604 * @return The child object
606 virtual Accessible* GetChildAtIndex(size_t index) = 0;
609 * @brief Gets index that current object has in its parent's children collection.
611 * @return The index of the current object
613 virtual size_t GetIndexInParent() = 0;
616 * @brief Gets accessibility role.
618 * @return Role enumeration
620 * @see Dali::Accessibility::Role
622 virtual Role GetRole() = 0;
625 * @brief Gets name of accessibility role.
627 * @return The string with human readable role converted from enumeration
629 * @see Dali::Accessibility::Role
630 * @see Accessibility::Accessible::GetRole
632 virtual std::string GetRoleName();
635 * @brief Gets localized name of accessibility role.
637 * @return The string with human readable role translated according to current
640 * @see Dali::Accessibility::Role
641 * @see Accessibility::Accessible::GetRole
642 * @see Accessibility::Accessible::GetRoleName
644 * @note translation is not supported in this version
646 virtual std::string GetLocalizedRoleName();
649 * @brief Gets accessibility states.
651 * @return The collection of states
653 * @note States class is instatation of ArrayBitset template class
655 * @see Dali::Accessibility::State
656 * @see Dali::Accessibility::ArrayBitset
658 virtual States GetStates() = 0;
661 * @brief Gets accessibility attributes.
663 * @return The map of attributes and their values
665 virtual Attributes GetAttributes() = 0;
668 * @brief Checks if this is proxy.
670 * @return True if this is proxy
672 virtual bool IsProxy();
675 * @brief Gets unique address on accessibility bus.
677 * @return The Address class containing address
679 * @see Dali::Accessibility::Address
681 virtual Address GetAddress();
684 * @brief Gets accessibility object, which is "default label" for this object.
686 * @return The Accessible object
688 virtual Accessible* GetDefaultLabel();
691 * @brief Deputes an object to perform provided gesture.
693 * @param[in] gestureInfo The structure describing the gesture
695 * @return true on success, false otherwise
697 * @see Dali::Accessibility::GestureInfo
699 virtual bool DoGesture(const GestureInfo& gestureInfo) = 0;
702 * @brief Re-emits selected states of an Accessibility Object.
704 * @param[in] states The chosen states to re-emit
705 * @param[in] isRecursive If true, all children of the Accessibility object will also re-emit the states
707 void NotifyAccessibilityStateChange(Dali::Accessibility::States states, bool isRecursive);
710 * @brief Gets information about current object and all relations that connects
711 * it with other accessibility objects.
713 * @return The iterable collection of Relation objects
715 * @see Dali::Accessibility::Relation
717 virtual std::vector<Relation> GetRelationSet() = 0;
720 * @brief Gets all implemented interfaces.
722 * @return The collection of strings with implemented interfaces
724 std::vector<std::string> GetInterfaces();
727 * @brief Checks if object is on root level.
729 * @return Whether object is on root level or not
731 bool IsOnRootLevel() const
733 return mIsOnRootLevel;
737 * @brief The method registers functor resposible for converting Actor into Accessible.
738 * @param functor The returning Accessible handle from Actor object
740 static void RegisterControlAccessibilityGetter(std::function<Accessible*(Dali::Actor)> functor);
743 * @brief Acquires Accessible object from Actor object.
745 * @param[in] actor Actor object
746 * @param[in] isRoot True, if it's top level object (window)
748 * @return The handle to Accessible object
750 static Accessible* Get(Dali::Actor actor, bool isRoot = false);
754 Accessible(const Accessible&) = delete;
755 Accessible(Accessible&&) = delete;
756 Accessible& operator=(const Accessible&) = delete;
757 Accessible& operator=(Accessible&&) = delete;
758 std::shared_ptr<Bridge::Data> GetBridgeData();
762 * @brief Gets the highlight actor.
764 * This method is to get the highlight itself.
765 * @return The highlight actor
767 static Dali::Actor GetHighlightActor();
770 * @brief Sets the highlight actor.
772 * This method is to set the highlight itself.
773 * @param[in] actor The highlight actor
775 static void SetHighlightActor(Dali::Actor actor);
778 * @brief Gets the currently highlighted actor.
780 * @return The current highlighted actor
782 static Dali::Actor GetCurrentlyHighlightedActor();
785 * @brief Sets currently highlighted actor.
787 * @param[in] actor The highlight actor
789 static void SetCurrentlyHighlightedActor(Dali::Actor actor);
792 * @brief Sets ObjectRegistry.
794 * @param[in] registry ObjectRegistry instance
796 static void SetObjectRegistry(ObjectRegistry registry);
801 std::weak_ptr<Bridge::Data> mBridgeData;
802 bool mIsOnRootLevel = false;
806 * @brief Interface enabling to perform provided actions.
808 class Action : public virtual Accessible
812 * @brief Gets name of action with given index.
814 * @param[in] index The index of action
816 * @return The string with name of action
818 virtual std::string GetActionName(size_t index) = 0;
821 * @brief Gets translated name of action with given index.
823 * @param[in] index The index of action
825 * @return The string with name of action translated according to current translation domain
827 * @note The translation is not supported in this version
829 virtual std::string GetLocalizedActionName(size_t index) = 0;
832 * @brief Gets description of action with given index.
834 * @param[in] index The index of action
836 * @return The string with description of action
838 virtual std::string GetActionDescription(size_t index) = 0;
841 * @brief Gets key code binded to action with given index.
843 * @param[in] index The index of action
845 * @return The string with key name
847 virtual std::string GetActionKeyBinding(size_t index) = 0;
850 * @brief Gets number of provided actions.
852 * @return The number of actions
854 virtual size_t GetActionCount() = 0;
857 * @brief Performs an action with given index.
859 * @param index The index of action
861 * @return true on success, false otherwise
863 virtual bool DoAction(size_t index) = 0;
866 * @brief Performs an action with given name.
868 * @param name The name of action
870 * @return true on success, false otherwise
872 virtual bool DoAction(const std::string& name) = 0;
876 * @brief Interface enabling advanced quering of accessibility objects.
878 * @note since all mathods can be implemented inside bridge,
879 * none methods have to be overrided
881 class Collection : public virtual Accessible
887 * @brief Interface representing objects having screen coordinates.
889 class Component : public virtual Accessible
893 * @brief Gets rectangle describing size.
895 * @param[in] type The enumeration with type of coordinate systems
897 * @return Rect<> object
901 virtual Rect<> GetExtents(CoordinateType type) = 0;
904 * @brief Gets layer current object is localized on.
906 * @return The enumeration pointing layer
908 * @see Dali::Accessibility::ComponentLayer
910 virtual ComponentLayer GetLayer() = 0;
913 * @brief Gets value of z-order.
915 * @return The value of z-order
916 * @remarks MDI means "Multi Document Interface" (https://en.wikipedia.org/wiki/Multiple-document_interface)
917 * which in short means that many stacked windows can be displayed within a single application.
918 * In such model, the concept of z-order of UI element became important to deal with element overlapping.
920 virtual int16_t GetMdiZOrder() = 0;
923 * @brief Sets current object as "focused".
925 * @return true on success, false otherwise
927 virtual bool GrabFocus() = 0;
930 * @brief Gets value of alpha channel.
932 * @return The alpha channel value in range [0.0, 1.0]
934 virtual double GetAlpha() = 0;
937 * @brief Sets current object as "highlighted".
939 * The method assings "highlighted" state, simultaneously removing it
940 * from currently highlighted object.
942 * @return true on success, false otherwise
944 virtual bool GrabHighlight() = 0;
947 * @brief Sets current object as "unhighlighted".
949 * The method removes "highlighted" state from object.
951 * @return true on success, false otherwise
953 * @see Dali:Accessibility::State
955 virtual bool ClearHighlight() = 0;
958 * @brief Checks whether object can be scrolled.
960 * @return true if object is scrollable, false otherwise
962 * @see Dali:Accessibility::State
964 virtual bool IsScrollable();
967 * @brief Gets Accessible object containing given point.
969 * @param[in] point The two-dimensional point
970 * @param[in] type The enumeration with type of coordinate system
972 * @return The handle to last child of current object which contains given point
974 * @see Dali::Accessibility::Point
976 virtual Accessible* GetAccessibleAtPoint(Point point, CoordinateType type);
979 * @brief Checks if current object contains given point.
981 * @param[in] point The two-dimensional point
982 * @param[in] type The enumeration with type of coordinate system
984 * @return True if accessible contains in point, otherwise false.
986 * @remarks This method is `Contains` in DBus method.
987 * @see Dali::Accessibility::Point
989 virtual bool IsAccessibleContainedAtPoint(Point point, CoordinateType type);
993 * @brief Interface representing objects which can store numeric value.
995 class Value : public virtual Accessible
999 * @brief Gets the lowest possible value.
1001 * @return The minimum value
1003 virtual double GetMinimum() = 0;
1006 * @brief Gets the current value.
1008 * @return The current value
1010 virtual double GetCurrent() = 0;
1013 * @brief Gets the highest possible value.
1015 * @return The highest value.
1017 virtual double GetMaximum() = 0;
1020 * @brief Sets the current value.
1022 * @param[in] value The current value to set
1024 * @return true if value could have been assigned, false otherwise
1026 virtual bool SetCurrent(double value) = 0;
1029 * @brief Gets the lowest increment that can be distinguished.
1031 * @return The lowest increment
1033 virtual double GetMinimumIncrement() = 0;
1037 * @brief Interface representing objects which can store immutable texts.
1039 * @see Dali::Accessibility::EditableText
1041 class DALI_ADAPTOR_API Text : public virtual Accessible
1045 * @brief Gets stored text in given range.
1047 * @param[in] startOffset The index of first character
1048 * @param[in] endOffset The index of first character after the last one expected
1050 * @return The substring of stored text
1052 virtual std::string GetText(size_t startOffset, size_t endOffset) = 0;
1055 * @brief Gets number of all stored characters.
1057 * @return The number of characters
1058 * @remarks This method is `CharacterCount` in DBus method.
1060 virtual size_t GetCharacterCount() = 0;
1063 * @brief Gets the cursor offset.
1065 * @return Value of cursor offset
1066 * @remarks This method is `CaretOffset` in DBus method.
1068 virtual size_t GetCursorOffset() = 0;
1071 * @brief Sets the cursor offset.
1073 * @param[in] offset Cursor offset
1075 * @return True if successful
1076 * @remarks This method is `SetCaretOffset` in DBus method.
1078 virtual bool SetCursorOffset(size_t offset) = 0;
1081 * @brief Gets substring of stored text truncated in concrete gradation.
1083 * @param[in] offset The position in stored text
1084 * @param[in] boundary The enumeration describing text gradation
1086 * @return Range structure containing acquired text and offsets in original string
1088 * @see Dali::Accessibility::Range
1090 virtual Range GetTextAtOffset(size_t offset, TextBoundary boundary) = 0;
1093 * @brief Gets selected text.
1095 * @param[in] selectionIndex The selection index
1096 * @note Currently only one selection (i.e. with index = 0) is supported
1098 * @return Range structure containing acquired text and offsets in original string
1100 * @remarks This method is `GetSelection` in DBus method.
1101 * @see Dali::Accessibility::Range
1103 virtual Range GetRangeOfSelection(size_t selectionIndex) = 0;
1106 * @brief Removes the whole selection.
1108 * @param[in] selectionIndex The selection index
1109 * @note Currently only one selection (i.e. with index = 0) is supported
1111 * @return bool on success, false otherwise
1113 virtual bool RemoveSelection(size_t selectionIndex) = 0;
1116 * @brief Sets selected text.
1118 * @param[in] selectionIndex The selection index
1119 * @param[in] startOffset The index of first character
1120 * @param[in] endOffset The index of first character after the last one expected
1122 * @note Currently only one selection (i.e. with index = 0) is supported
1124 * @return true on success, false otherwise
1125 * @remarks This method is `SetSelection` in DBus method.
1127 virtual bool SetRangeOfSelection(size_t selectionIndex, size_t startOffset, size_t endOffset) = 0;
1131 * @brief Interface representing objects which can store editable texts.
1133 * @note Paste method is entirely implemented inside bridge
1135 * @see Dali::Accessibility::EditableText
1137 class DALI_ADAPTOR_API EditableText : public virtual Accessible
1141 * @brief Copies text in range to system clipboard.
1143 * @param[in] startPosition The index of first character
1144 * @param[in] endPosition The index of first character after the last one expected
1146 * @return true on success, false otherwise
1148 virtual bool CopyText(size_t startPosition, size_t endPosition) = 0;
1151 * @brief Cuts text in range to system clipboard.
1153 * @param[in] startPosition The index of first character
1154 * @param[in] endPosition The index of first character after the last one expected
1156 * @return true on success, false otherwise
1158 virtual bool CutText(size_t startPosition, size_t endPosition) = 0;
1161 * @brief Deletes text in range.
1163 * @param[in] startPosition The index of first character
1164 * @param[in] endPosition The index of first character after the last one expected
1166 * @return true on success, false otherwise
1168 virtual bool DeleteText(size_t startPosition, size_t endPosition) = 0;
1171 * @brief Inserts text at startPosition.
1173 * @param[in] startPosition The index of first character
1174 * @param[in] text The text content
1176 * @return true on success, false otherwise
1178 virtual bool InsertText(size_t startPosition, std::string text) = 0;
1181 * @brief Replaces text with content.
1183 * @param[in] newContents The text content
1185 * @return true on success, false otherwise
1187 virtual bool SetTextContents(std::string newContents) = 0;
1191 * @brief Interface representing objects which can store a set of selected items.
1193 class DALI_ADAPTOR_API Selection : public virtual Accessible
1197 * @brief Gets the number of selected children.
1199 * @return The number of selected children (zero if none)
1201 virtual int GetSelectedChildrenCount() = 0;
1204 * @brief Gets a specific selected child.
1206 * @param selectedChildIndex The index of the selected child
1208 * @note @p selectedChildIndex refers to the list of selected children,
1209 * not the list of all children
1211 * @return The selected child or nullptr if index is invalid
1213 virtual Accessible* GetSelectedChild(int selectedChildIndex) = 0;
1216 * @brief Selects a child.
1218 * @param childIndex The index of the child
1220 * @return true on success, false otherwise
1222 virtual bool SelectChild(int childIndex) = 0;
1225 * @brief Deselects a selected child.
1227 * @param selectedChildIndex The index of the selected child
1229 * @note @p selectedChildIndex refers to the list of selected children,
1230 * not the list of all children
1232 * @return true on success, false otherwise
1234 * @see Dali::Accessibility::Selection::DeselectChild
1236 virtual bool DeselectSelectedChild(int selectedChildIndex) = 0;
1239 * @brief Checks whether a child is selected.
1241 * @param childIndex The index of the child
1243 * @return true if given child is selected, false otherwise
1245 virtual bool IsChildSelected(int childIndex) = 0;
1248 * @brief Selects all children.
1250 * @return true on success, false otherwise
1252 virtual bool SelectAll() = 0;
1255 * @brief Deselects all children.
1257 * @return true on success, false otherwise
1259 virtual bool ClearSelection() = 0;
1262 * @brief Deselects a child.
1264 * @param childIndex The index of the child.
1266 * @return true on success, false otherwise
1268 * @see Dali::Accessibility::Selection::DeselectSelectedChild
1270 virtual bool DeselectChild(int childIndex) = 0;
1274 * @brief The minimalistic, always empty Accessible object with settable address.
1276 * For those situations, where you want to return address in different bridge
1277 * (embedding for example), but the object itself ain't planned to be used otherwise.
1278 * This object has null parent, no children, empty name and so on
1280 class DALI_ADAPTOR_API EmptyAccessibleWithAddress : public virtual Accessible
1283 EmptyAccessibleWithAddress() = default;
1285 EmptyAccessibleWithAddress(Address address)
1286 : mAddress(std::move(address))
1290 void SetAddress(Address address)
1292 this->mAddress = std::move(address);
1295 std::string GetName() override
1300 std::string GetDescription() override
1305 Accessible* GetParent() override
1310 size_t GetChildCount() override
1315 std::vector<Accessible*> GetChildren() override
1320 Accessible* GetChildAtIndex(size_t index) override
1322 throw std::domain_error{"out of bounds index (" + std::to_string(index) + ") - no children"};
1325 size_t GetIndexInParent() override
1327 return static_cast<size_t>(-1);
1330 Role GetRole() override
1335 std::string GetRoleName() override;
1337 States GetStates() override
1342 Attributes GetAttributes() override
1347 Address GetAddress() override
1352 bool DoGesture(const GestureInfo& gestureInfo) override
1357 std::vector<Relation> GetRelationSet() override
1366 } // namespace Accessibility
1369 #endif // DALI_INTERNAL_ATSPI_ACCESSIBILITY_IMPL_H