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;
50 class DALI_ADAPTOR_API Application;
53 * @brief Base class for different accessibility bridges.
55 * Bridge is resposible for initializing and managing connection on accessibility bus.
56 * Accessibility clients will not get any information about UI without initialized and upraised bridge.
57 * Concrete implementation depends on the accessibility technology available on the platform.
59 * @note This class is singleton.
61 struct DALI_ADAPTOR_API Bridge
63 enum class ForceUpResult
72 virtual ~Bridge() = default;
75 * @brief Gets bus name which bridge is initialized on.
77 virtual const std::string& GetBusName() const = 0;
80 * @brief Registers top level window.
82 * Hierarchy of objects visible for accessibility clients is based on tree-like
83 * structure created from Actors objects. This method allows to connect chosen
84 * object as direct ancestor of application and therefore make it visible for
85 * accessibility clients.
87 * @param[in] object The accessible object
89 virtual void AddTopLevelWindow(Accessible* object) = 0;
92 * @brief Removes top level window.
94 * Hierarchy of objects visible for accessibility clients is based on tree-like
95 * structure created from Actors objects. This method removes previously added
96 * window from visible accessibility objects.
98 * @param[in] object The accessible object
100 virtual void RemoveTopLevelWindow(Accessible* object) = 0;
103 * @brief Adds popup window.
105 * Hierarchy of objects visible for accessibility clients is based on tree-like
106 * structure created from Actors objects. This method adds new popup to the tree.
108 * @param[in] object The accessible object
110 virtual void AddPopup(Accessible* object) = 0;
113 * @brief Removes popup window.
115 * Hierarchy of objects visible for accessibility clients is based on tree-like
116 * structure created from Actors objects. This method removes previously added
119 * @param[in] object The accessible object
121 virtual void RemovePopup(Accessible* object) = 0;
124 * @brief Sets name of current application which will be visible on accessibility bus.
126 * @param[in] name The application name
128 virtual void SetApplicationName(std::string name) = 0;
131 * @brief Gets object being root of accessibility tree.
133 * @return handler to accessibility object
135 virtual Accessible* GetApplication() const = 0;
138 * @brief Finds an object in accessibility tree.
140 * @param[in] path The path to object
142 * @return The handler to accessibility object
144 virtual Accessible* FindByPath(const std::string& path) const = 0;
147 * @brief Shows application on accessibility bus.
149 virtual void ApplicationShown() = 0;
152 * @brief Hides application on accessibility bus.
154 virtual void ApplicationHidden() = 0;
157 * @brief Initializes accessibility bus.
159 virtual void Initialize() = 0;
162 * @brief Terminates accessibility bus.
164 virtual void Terminate() = 0;
167 * @brief This method is called, when bridge is being activated.
169 virtual ForceUpResult ForceUp()
173 return ForceUpResult::ALREADY_UP;
175 mData = std::make_shared<Data>();
176 mData->mBridge = this;
177 return ForceUpResult::JUST_STARTED;
181 * @brief This method is called, when bridge is being deactivated.
183 virtual void ForceDown() = 0;
186 * @brief Checks if bridge is activated or not.
187 * @return True if brige is activated.
195 * @brief Emits cursor-moved event on at-spi bus.
197 * @param[in] obj The accessible object
198 * @param[in] cursorPosition The new cursor position
200 virtual void EmitCursorMoved(Accessible* obj, unsigned int cursorPosition) = 0;
203 * @brief Emits active-descendant-changed event on at-spi bus.
205 * @param[in] obj The accessible object
206 * @param[in] child The child of the object
208 virtual void EmitActiveDescendantChanged(Accessible* obj, Accessible* child) = 0;
211 * @brief Emits text-changed event on at-spi bus.
213 * @param[in] obj The accessible object
214 * @param[in] state The changed state for text, such as Inserted or Deleted
215 * @param[in] position The cursor position
216 * @param[in] length The text length
217 * @param[in] content The changed text
219 virtual void EmitTextChanged(Accessible* obj, TextChangedState state, unsigned int position, unsigned int length, const std::string& content) = 0;
222 * @brief Emits MoveOuted event on at-spi bus.
224 * @param[in] obj Accessible object
225 * @param[in] type Direction type when an Accessible object moves out of screen
227 virtual void EmitMovedOutOfScreen(Accessible* obj, ScreenRelativeMoveType type) = 0;
230 * @brief Emits state-changed event on at-spi bus.
232 * @param[in] obj The accessible object
233 * @param[in] state The accessibility state (SHOWING, HIGHLIGHTED, etc)
234 * @param[in] newValue Whether the state value is changed to new value or not.
235 * @param[in] reserved Reserved. (Currently, this argument is not implemented in dali)
237 virtual void EmitStateChanged(Accessible* obj, State state, int newValue, int reserved = 0) = 0;
240 * @brief Emits window event on at-spi bus.
242 * @param[in] obj The accessible object
243 * @param[in] event The enumerated window event
244 * @param[in] detail The additional parameter which interpretation depends on chosen event
246 virtual void Emit(Accessible* obj, WindowEvent event, unsigned int detail = 0) = 0;
249 * @brief Emits property-changed event on at-spi bus.
251 * @param[in] obj The accessible object
252 * @param[in] event Property changed event
254 virtual void Emit(Accessible* obj, ObjectPropertyChangeEvent event) = 0;
257 * @brief Emits bounds-changed event on at-spi bus.
259 * @param[in] obj The accessible object
260 * @param[in] rect The rectangle for changed bounds
262 virtual void EmitBoundsChanged(Accessible* obj, Rect<> rect) = 0;
265 * @brief Emits key event on at-spi bus.
267 * Screen-reader might receive this event and reply, that given keycode is consumed. In that case
268 * further processing of the keycode should be ignored.
270 * @param[in] type Key event type
271 * @param[in] keyCode Key code
272 * @param[in] keyName Key name
273 * @param[in] timeStamp Time stamp
274 * @param[in] isText Whether it's text or not
275 * @return Whether this event is consumed or not
277 virtual Consumed Emit(KeyEventType type, unsigned int keyCode, const std::string& keyName, unsigned int timeStamp, bool isText) = 0;
280 * @brief Reads given text by screen reader
282 * @param[in] text The text to read
283 * @param[in] discardable If TRUE, reading can be discarded by subsequent reading requests,
284 * if FALSE the reading must finish before next reading request can be started
285 * @param[in] callback the callback function that is called on reading signals emitted
286 * during processing of this reading request.
287 * Callback can be one of the following signals:
288 * ReadingCancelled, ReadingStopped, ReadingSkipped
290 virtual void Say(const std::string& text, bool discardable, std::function<void(std::string)> callback) = 0;
293 * @brief Force accessibility client to pause.
295 virtual void Pause() = 0;
298 * @brief Force accessibility client to resume.
300 virtual void Resume() = 0;
303 * @brief Cancels anything screen-reader is reading / has queued to read
305 * @param[in] alsoNonDiscardable whether to cancel non-discardable readings as well
307 virtual void StopReading(bool alsoNonDiscardable) = 0;
310 * @brief Suppresses reading of screen-reader
312 * @param[in] suppress whether to suppress reading of screen-reader
314 virtual void SuppressScreenReader(bool suppress) = 0;
317 * @brief Gets screen reader status.
319 * @return True if screen reader is enabled
321 virtual bool GetScreenReaderEnabled() = 0;
324 * @brief Gets ATSPI status.
326 * @return True if ATSPI is enabled
328 virtual bool IsEnabled() = 0;
331 * @brief Returns instance of bridge singleton object.
333 * @return The current bridge object
335 static Bridge* GetCurrentBridge();
338 * @brief Blocks auto-initialization of AT-SPI bridge
340 * Use this only if your application starts before DBus does, and call it early in main()
341 * (before GetCurrentBridge() is called by anyone). GetCurrentBridge() will then return an
342 * instance of DummyBridge.
344 * When DBus is ready, call EnableAutoInit(). Please note that GetCurrentBridge() may still
345 * return an instance of DummyBridge if AT-SPI was disabled at compile time or using an
346 * environment variable, or if creating the real bridge failed.
348 * @see Dali::Accessibility::DummyBridge
349 * @see Dali::Accessibility::Bridge::EnableAutoInit
351 static void DisableAutoInit();
354 * @brief Re-enables auto-initialization of AT-SPI bridge
356 * Normal applications do not have to call this function. GetCurrentBridge() tries to
357 * initialize the AT-SPI bridge when it is called for the first time.
359 * @see Dali::Accessibility::Bridge::DisableAutoInit
360 * @see Dali::Accessibility::Bridge::AddTopLevelWindow
361 * @see Dali::Accessibility::Bridge::SetApplicationName
363 static void EnableAutoInit();
368 std::unordered_set<Accessible*> mKnownObjects;
369 std::string mBusName;
370 Bridge* mBridge = nullptr;
371 Actor mHighlightActor;
372 Actor mCurrentlyHighlightedActor;
374 std::shared_ptr<Data> mData;
375 friend class Accessible;
377 enum class AutoInitState
383 inline static AutoInitState autoInitState = AutoInitState::ENABLED;
386 * @brief Registers accessible object to be known in bridge object.
388 * Bridge must known about all currently alive accessible objects, as some requst
389 * might come and object will be identified by number id (it's memory address).
390 * To avoid memory corruption number id is checked against set of known objects.
392 * @param[in] object The accessible object
394 void RegisterOnBridge(Accessible* object);
397 * @brief Tells bridge, that given object is considered root (doesn't have any parents).
399 * All root objects will have the same parent - application object. Application object
400 * is controlled by bridge and private.
402 * @param[in] owner The accessible object
404 void SetIsOnRootLevel(Accessible* owner);
408 * @brief Checks if ATSPI is activated or not.
409 * @return True if ATSPI is activated.
413 if(Bridge::GetCurrentBridge() == nullptr)
418 if(Bridge::GetCurrentBridge()->IsEnabled() == false)
423 return Bridge::GetCurrentBridge()->IsUp();
427 * @brief Basic interface implemented by all accessibility objects.
432 virtual ~Accessible();
434 using utf8_t = unsigned char;
437 * @brief Calculates and finds word boundaries in given utf8 text.
439 * @param[in] string The source text to find
440 * @param[in] length The length of text to find
441 * @param[in] language The language to use
442 * @param[out] breaks The word boundaries in given text
444 * @note Word boundaries are returned as non-zero values in table breaks, which must be of size at least length.
446 void FindWordSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks);
449 * @brief Calculates and finds line boundaries in given utf8 text.
451 * @param[in] string The source text to find
452 * @param[in] length The length of text to find
453 * @param[in] language The language to use
454 * @param[out] breaks The line boundaries in given text
456 * @note Line boundaries are returned as non-zero values in table breaks, which must be of size at least length.
458 void FindLineSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks);
461 * @brief Helper function for emiting active-descendant-changed event.
463 * @param[in] obj The accessible object
464 * @param[in] child The child of the object
466 void EmitActiveDescendantChanged(Accessible* obj, Accessible* child);
469 * @brief Helper function for emiting state-changed event.
471 * @param[in] state The accessibility state (SHOWING, HIGHLIGHTED, etc)
472 * @param[in] newValue Whether the state value is changed to new value or not.
473 * @param[in] reserved Reserved. (TODO : Currently, this argument is not implemented in dali)
475 * @note The second argument determines which value is depending on State.
476 * For instance, if the state is PRESSED, newValue means isPressed or isSelected.
477 * If the state is SHOWING, newValue means isShowing.
479 void EmitStateChanged(State state, int newValue, int reserved = 0);
482 * @brief Helper function for emiting bounds-changed event.
484 * @param rect The rectangle for changed bounds
486 void EmitBoundsChanged(Rect<> rect);
489 * @brief Emits "showing" event.
490 * The method informs accessibility clients about "showing" state.
492 * @param[in] isShowing The flag pointing if object is showing
494 void EmitShowing(bool isShowing);
497 * @brief Emits "visible" event.
498 * The method informs accessibility clients about "visible" state.
500 * @param[in] isVisible The flag pointing if object is visible
502 void EmitVisible(bool isVisible);
505 * @brief Emits "highlighted" event.
506 * The method informs accessibility clients about "highlighted" state.
508 * @param[in] isHighlighted The flag pointing if object is highlighted
510 void EmitHighlighted(bool isHighlighted);
513 * @brief Emits "focused" event.
514 * The method informs accessibility clients about "focused" state.
516 * @param[in] isFocused The flag pointing if object is focused
518 void EmitFocused(bool isFocused);
521 * @brief Emits "text inserted" event.
523 * @param[in] position The cursor position
524 * @param[in] length The text length
525 * @param[in] content The inserted text
527 void EmitTextInserted(unsigned int position, unsigned int length, const std::string& content);
530 * @brief Emits "text deleted" event.
532 * @param[in] position The cursor position
533 * @param[in] length The text length
534 * @param[in] content The deleted text
536 void EmitTextDeleted(unsigned int position, unsigned int length, const std::string& content);
539 * @brief Emits "cursor moved" event.
541 * @param[in] cursorPosition The new cursor position
543 void EmitTextCursorMoved(unsigned int cursorPosition);
546 * @brief Emits "MoveOuted" event.
548 * @param[in] type moved out of screen type
550 void EmitMovedOutOfScreen(ScreenRelativeMoveType type);
553 * @brief Emits "highlighted" event.
555 * @param[in] event The enumerated window event
556 * @param[in] detail The additional parameter which interpretation depends on chosen event
558 void Emit(WindowEvent event, unsigned int detail = 0);
561 * @brief Emits property-changed event.
563 * @param[in] event Property changed event
565 void Emit(ObjectPropertyChangeEvent event);
568 * @brief Gets accessibility name.
570 * @return The string with name
572 virtual std::string GetName() = 0;
575 * @brief Gets accessibility description.
577 * @return The string with description
579 virtual std::string GetDescription() = 0;
582 * @brief Gets parent.
584 * @return The handler to accessibility object
586 virtual Accessible* GetParent() = 0;
589 * @brief Gets the number of children.
591 * @return The number of children
593 virtual size_t GetChildCount() = 0;
596 * @brief Gets collection with all children.
598 * @return The collection of accessibility objects
600 virtual std::vector<Accessible*> GetChildren();
603 * @brief Gets child of the index.
605 * @return The child object
607 virtual Accessible* GetChildAtIndex(size_t index) = 0;
610 * @brief Gets index that current object has in its parent's children collection.
612 * @return The index of the current object
614 virtual size_t GetIndexInParent() = 0;
617 * @brief Gets accessibility role.
619 * @return Role enumeration
621 * @see Dali::Accessibility::Role
623 virtual Role GetRole() = 0;
626 * @brief Gets name of accessibility role.
628 * @return The string with human readable role converted from enumeration
630 * @see Dali::Accessibility::Role
631 * @see Accessibility::Accessible::GetRole
633 virtual std::string GetRoleName();
636 * @brief Gets localized name of accessibility role.
638 * @return The string with human readable role translated according to current
641 * @see Dali::Accessibility::Role
642 * @see Accessibility::Accessible::GetRole
643 * @see Accessibility::Accessible::GetRoleName
645 * @note translation is not supported in this version
647 virtual std::string GetLocalizedRoleName();
650 * @brief Gets accessibility states.
652 * @return The collection of states
654 * @note States class is instatation of ArrayBitset template class
656 * @see Dali::Accessibility::State
657 * @see Dali::Accessibility::ArrayBitset
659 virtual States GetStates() = 0;
662 * @brief Gets accessibility attributes.
664 * @return The map of attributes and their values
666 virtual Attributes GetAttributes() = 0;
669 * @brief Checks if this is proxy.
671 * @return True if this is proxy
673 virtual bool IsProxy();
676 * @brief Gets unique address on accessibility bus.
678 * @return The Address class containing address
680 * @see Dali::Accessibility::Address
682 virtual Address GetAddress();
685 * @brief Gets accessibility object, which is "default label" for this object.
687 * @return The Accessible object
689 virtual Accessible* GetDefaultLabel();
692 * @brief Deputes an object to perform provided gesture.
694 * @param[in] gestureInfo The structure describing the gesture
696 * @return true on success, false otherwise
698 * @see Dali::Accessibility::GestureInfo
700 virtual bool DoGesture(const GestureInfo& gestureInfo) = 0;
703 * @brief Re-emits selected states of an Accessibility Object.
705 * @param[in] states The chosen states to re-emit
706 * @param[in] isRecursive If true, all children of the Accessibility object will also re-emit the states
708 void NotifyAccessibilityStateChange(Dali::Accessibility::States states, bool isRecursive);
711 * @brief Gets information about current object and all relations that connects
712 * it with other accessibility objects.
714 * @return The iterable collection of Relation objects
716 * @see Dali::Accessibility::Relation
718 virtual std::vector<Relation> GetRelationSet() = 0;
721 * @brief Gets all implemented interfaces.
723 * @return The collection of strings with implemented interfaces
725 std::vector<std::string> GetInterfaces();
728 * @brief Checks if object is on root level.
730 * @return Whether object is on root level or not
732 bool IsOnRootLevel() const
734 return mIsOnRootLevel;
738 * @brief The method registers functor resposible for converting Actor into Accessible.
739 * @param functor The returning Accessible handle from Actor object
741 static void RegisterControlAccessibilityGetter(std::function<Accessible*(Dali::Actor)> functor);
744 * @brief Acquires Accessible object from Actor object.
746 * @param[in] actor Actor object
747 * @param[in] isRoot True, if it's top level object (window)
749 * @return The handle to Accessible object
751 static Accessible* Get(Dali::Actor actor, bool isRoot = false);
755 Accessible(const Accessible&) = delete;
756 Accessible(Accessible&&) = delete;
757 Accessible& operator=(const Accessible&) = delete;
758 Accessible& operator=(Accessible&&) = delete;
759 std::shared_ptr<Bridge::Data> GetBridgeData();
763 * @brief Gets the highlight actor.
765 * This method is to get the highlight itself.
766 * @return The highlight actor
768 static Dali::Actor GetHighlightActor();
771 * @brief Sets the highlight actor.
773 * This method is to set the highlight itself.
774 * @param[in] actor The highlight actor
776 static void SetHighlightActor(Dali::Actor actor);
779 * @brief Gets the currently highlighted actor.
781 * @return The current highlighted actor
783 static Dali::Actor GetCurrentlyHighlightedActor();
786 * @brief Sets currently highlighted actor.
788 * @param[in] actor The highlight actor
790 static void SetCurrentlyHighlightedActor(Dali::Actor actor);
793 * @brief Sets ObjectRegistry.
795 * @param[in] registry ObjectRegistry instance
797 static void SetObjectRegistry(ObjectRegistry registry);
802 std::weak_ptr<Bridge::Data> mBridgeData;
803 bool mIsOnRootLevel = false;
807 * @brief Interface enabling to perform provided actions.
809 class Action : public virtual Accessible
813 * @brief Gets name of action with given index.
815 * @param[in] index The index of action
817 * @return The string with name of action
819 virtual std::string GetActionName(size_t index) = 0;
822 * @brief Gets translated name of action with given index.
824 * @param[in] index The index of action
826 * @return The string with name of action translated according to current translation domain
828 * @note The translation is not supported in this version
830 virtual std::string GetLocalizedActionName(size_t index) = 0;
833 * @brief Gets description of action with given index.
835 * @param[in] index The index of action
837 * @return The string with description of action
839 virtual std::string GetActionDescription(size_t index) = 0;
842 * @brief Gets key code binded to action with given index.
844 * @param[in] index The index of action
846 * @return The string with key name
848 virtual std::string GetActionKeyBinding(size_t index) = 0;
851 * @brief Gets number of provided actions.
853 * @return The number of actions
855 virtual size_t GetActionCount() = 0;
858 * @brief Performs an action with given index.
860 * @param index The index of action
862 * @return true on success, false otherwise
864 virtual bool DoAction(size_t index) = 0;
867 * @brief Performs an action with given name.
869 * @param name The name of action
871 * @return true on success, false otherwise
873 virtual bool DoAction(const std::string& name) = 0;
877 * @brief An interface identifying the root object
878 * associated with a running application.
880 * @note Provides global properties describing
881 * application's runtime environment.
883 class Application : public virtual Accessible
887 * @brief Gets name of graphic user interface framework used by an application.
889 * @return String with name
891 virtual std::string GetToolkitName() = 0;
894 * @brief Gets version of graphic user interface framework used by an application.
896 * @return String with version
898 virtual std::string GetVersion() = 0;
902 * @brief Interface enabling advanced quering of accessibility objects.
904 * @note since all mathods can be implemented inside bridge,
905 * none methods have to be overrided
907 class Collection : public virtual Accessible
913 * @brief Interface representing objects having screen coordinates.
915 class Component : public virtual Accessible
919 * @brief Gets rectangle describing size.
921 * @param[in] type The enumeration with type of coordinate systems
923 * @return Rect<> object
927 virtual Rect<> GetExtents(CoordinateType type) = 0;
930 * @brief Gets layer current object is localized on.
932 * @return The enumeration pointing layer
934 * @see Dali::Accessibility::ComponentLayer
936 virtual ComponentLayer GetLayer() = 0;
939 * @brief Gets value of z-order.
941 * @return The value of z-order
942 * @remarks MDI means "Multi Document Interface" (https://en.wikipedia.org/wiki/Multiple-document_interface)
943 * which in short means that many stacked windows can be displayed within a single application.
944 * In such model, the concept of z-order of UI element became important to deal with element overlapping.
946 virtual int16_t GetMdiZOrder() = 0;
949 * @brief Sets current object as "focused".
951 * @return true on success, false otherwise
953 virtual bool GrabFocus() = 0;
956 * @brief Gets value of alpha channel.
958 * @return The alpha channel value in range [0.0, 1.0]
960 virtual double GetAlpha() = 0;
963 * @brief Sets current object as "highlighted".
965 * The method assings "highlighted" state, simultaneously removing it
966 * from currently highlighted object.
968 * @return true on success, false otherwise
970 virtual bool GrabHighlight() = 0;
973 * @brief Sets current object as "unhighlighted".
975 * The method removes "highlighted" state from object.
977 * @return true on success, false otherwise
979 * @see Dali:Accessibility::State
981 virtual bool ClearHighlight() = 0;
984 * @brief Checks whether object can be scrolled.
986 * @return true if object is scrollable, false otherwise
988 * @see Dali:Accessibility::State
990 virtual bool IsScrollable();
993 * @brief Gets Accessible object containing given point.
995 * @param[in] point The two-dimensional point
996 * @param[in] type The enumeration with type of coordinate system
998 * @return The handle to last child of current object which contains given point
1000 * @see Dali::Accessibility::Point
1002 virtual Accessible* GetAccessibleAtPoint(Point point, CoordinateType type);
1005 * @brief Checks if current object contains given point.
1007 * @param[in] point The two-dimensional point
1008 * @param[in] type The enumeration with type of coordinate system
1010 * @return True if accessible contains in point, otherwise false.
1012 * @remarks This method is `Contains` in DBus method.
1013 * @see Dali::Accessibility::Point
1015 virtual bool IsAccessibleContainedAtPoint(Point point, CoordinateType type);
1019 * @brief Interface representing objects which can store numeric value.
1021 class Value : public virtual Accessible
1025 * @brief Gets the lowest possible value.
1027 * @return The minimum value
1029 virtual double GetMinimum() = 0;
1032 * @brief Gets the current value.
1034 * @return The current value
1036 virtual double GetCurrent() = 0;
1039 * @brief Gets the highest possible value.
1041 * @return The highest value.
1043 virtual double GetMaximum() = 0;
1046 * @brief Sets the current value.
1048 * @param[in] value The current value to set
1050 * @return true if value could have been assigned, false otherwise
1052 virtual bool SetCurrent(double value) = 0;
1055 * @brief Gets the lowest increment that can be distinguished.
1057 * @return The lowest increment
1059 virtual double GetMinimumIncrement() = 0;
1063 * @brief Interface representing objects which can store immutable texts.
1065 * @see Dali::Accessibility::EditableText
1067 class DALI_ADAPTOR_API Text : public virtual Accessible
1071 * @brief Gets stored text in given range.
1073 * @param[in] startOffset The index of first character
1074 * @param[in] endOffset The index of first character after the last one expected
1076 * @return The substring of stored text
1078 virtual std::string GetText(size_t startOffset, size_t endOffset) = 0;
1081 * @brief Gets number of all stored characters.
1083 * @return The number of characters
1084 * @remarks This method is `CharacterCount` in DBus method.
1086 virtual size_t GetCharacterCount() = 0;
1089 * @brief Gets the cursor offset.
1091 * @return Value of cursor offset
1092 * @remarks This method is `CaretOffset` in DBus method.
1094 virtual size_t GetCursorOffset() = 0;
1097 * @brief Sets the cursor offset.
1099 * @param[in] offset Cursor offset
1101 * @return True if successful
1102 * @remarks This method is `SetCaretOffset` in DBus method.
1104 virtual bool SetCursorOffset(size_t offset) = 0;
1107 * @brief Gets substring of stored text truncated in concrete gradation.
1109 * @param[in] offset The position in stored text
1110 * @param[in] boundary The enumeration describing text gradation
1112 * @return Range structure containing acquired text and offsets in original string
1114 * @see Dali::Accessibility::Range
1116 virtual Range GetTextAtOffset(size_t offset, TextBoundary boundary) = 0;
1119 * @brief Gets selected text.
1121 * @param[in] selectionIndex The selection index
1122 * @note Currently only one selection (i.e. with index = 0) is supported
1124 * @return Range structure containing acquired text and offsets in original string
1126 * @remarks This method is `GetSelection` in DBus method.
1127 * @see Dali::Accessibility::Range
1129 virtual Range GetRangeOfSelection(size_t selectionIndex) = 0;
1132 * @brief Removes the whole selection.
1134 * @param[in] selectionIndex The selection index
1135 * @note Currently only one selection (i.e. with index = 0) is supported
1137 * @return bool on success, false otherwise
1139 virtual bool RemoveSelection(size_t selectionIndex) = 0;
1142 * @brief Sets selected text.
1144 * @param[in] selectionIndex The selection index
1145 * @param[in] startOffset The index of first character
1146 * @param[in] endOffset The index of first character after the last one expected
1148 * @note Currently only one selection (i.e. with index = 0) is supported
1150 * @return true on success, false otherwise
1151 * @remarks This method is `SetSelection` in DBus method.
1153 virtual bool SetRangeOfSelection(size_t selectionIndex, size_t startOffset, size_t endOffset) = 0;
1157 * @brief Interface representing objects which can store editable texts.
1159 * @note Paste method is entirely implemented inside bridge
1161 * @see Dali::Accessibility::EditableText
1163 class DALI_ADAPTOR_API EditableText : public virtual Accessible
1167 * @brief Copies text in range to system clipboard.
1169 * @param[in] startPosition The index of first character
1170 * @param[in] endPosition The index of first character after the last one expected
1172 * @return true on success, false otherwise
1174 virtual bool CopyText(size_t startPosition, size_t endPosition) = 0;
1177 * @brief Cuts text in range to system clipboard.
1179 * @param[in] startPosition The index of first character
1180 * @param[in] endPosition The index of first character after the last one expected
1182 * @return true on success, false otherwise
1184 virtual bool CutText(size_t startPosition, size_t endPosition) = 0;
1187 * @brief Deletes text in range.
1189 * @param[in] startPosition The index of first character
1190 * @param[in] endPosition The index of first character after the last one expected
1192 * @return true on success, false otherwise
1194 virtual bool DeleteText(size_t startPosition, size_t endPosition) = 0;
1197 * @brief Inserts text at startPosition.
1199 * @param[in] startPosition The index of first character
1200 * @param[in] text The text content
1202 * @return true on success, false otherwise
1204 virtual bool InsertText(size_t startPosition, std::string text) = 0;
1207 * @brief Replaces text with content.
1209 * @param[in] newContents The text content
1211 * @return true on success, false otherwise
1213 virtual bool SetTextContents(std::string newContents) = 0;
1217 * @brief Interface representing objects which can store a set of selected items.
1219 class DALI_ADAPTOR_API Selection : public virtual Accessible
1223 * @brief Gets the number of selected children.
1225 * @return The number of selected children (zero if none)
1227 virtual int GetSelectedChildrenCount() = 0;
1230 * @brief Gets a specific selected child.
1232 * @param selectedChildIndex The index of the selected child
1234 * @note @p selectedChildIndex refers to the list of selected children,
1235 * not the list of all children
1237 * @return The selected child or nullptr if index is invalid
1239 virtual Accessible* GetSelectedChild(int selectedChildIndex) = 0;
1242 * @brief Selects a child.
1244 * @param childIndex The index of the child
1246 * @return true on success, false otherwise
1248 virtual bool SelectChild(int childIndex) = 0;
1251 * @brief Deselects a selected child.
1253 * @param selectedChildIndex The index of the selected child
1255 * @note @p selectedChildIndex refers to the list of selected children,
1256 * not the list of all children
1258 * @return true on success, false otherwise
1260 * @see Dali::Accessibility::Selection::DeselectChild
1262 virtual bool DeselectSelectedChild(int selectedChildIndex) = 0;
1265 * @brief Checks whether a child is selected.
1267 * @param childIndex The index of the child
1269 * @return true if given child is selected, false otherwise
1271 virtual bool IsChildSelected(int childIndex) = 0;
1274 * @brief Selects all children.
1276 * @return true on success, false otherwise
1278 virtual bool SelectAll() = 0;
1281 * @brief Deselects all children.
1283 * @return true on success, false otherwise
1285 virtual bool ClearSelection() = 0;
1288 * @brief Deselects a child.
1290 * @param childIndex The index of the child.
1292 * @return true on success, false otherwise
1294 * @see Dali::Accessibility::Selection::DeselectSelectedChild
1296 virtual bool DeselectChild(int childIndex) = 0;
1300 * @brief The minimalistic, always empty Accessible object with settable address.
1302 * For those situations, where you want to return address in different bridge
1303 * (embedding for example), but the object itself ain't planned to be used otherwise.
1304 * This object has null parent, no children, empty name and so on
1306 class DALI_ADAPTOR_API EmptyAccessibleWithAddress : public virtual Accessible
1309 EmptyAccessibleWithAddress() = default;
1311 EmptyAccessibleWithAddress(Address address)
1312 : mAddress(std::move(address))
1316 void SetAddress(Address address)
1318 this->mAddress = std::move(address);
1321 std::string GetName() override
1326 std::string GetDescription() override
1331 Accessible* GetParent() override
1336 size_t GetChildCount() override
1341 std::vector<Accessible*> GetChildren() override
1346 Accessible* GetChildAtIndex(size_t index) override
1348 throw std::domain_error{"out of bounds index (" + std::to_string(index) + ") - no children"};
1351 size_t GetIndexInParent() override
1353 return static_cast<size_t>(-1);
1356 Role GetRole() override
1361 std::string GetRoleName() override;
1363 States GetStates() override
1368 Attributes GetAttributes() override
1373 Address GetAddress() override
1378 bool DoGesture(const GestureInfo& gestureInfo) override
1383 std::vector<Relation> GetRelationSet() override
1392 } // namespace Accessibility
1395 #endif // DALI_INTERNAL_ATSPI_ACCESSIBILITY_IMPL_H