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 * @return The bus name
79 virtual const std::string& GetBusName() const = 0;
82 * @brief Registers top level window.
84 * Hierarchy of objects visible for accessibility clients is based on tree-like
85 * structure created from Actors objects. This method allows to connect chosen
86 * object as direct ancestor of application and therefore make it visible for
87 * accessibility clients.
89 * @param[in] object The accessible object
91 virtual void AddTopLevelWindow(Accessible* object) = 0;
94 * @brief Removes top level window.
96 * Hierarchy of objects visible for accessibility clients is based on tree-like
97 * structure created from Actors objects. This method removes previously added
98 * window from visible accessibility objects.
100 * @param[in] object The accessible object
102 virtual void RemoveTopLevelWindow(Accessible* object) = 0;
105 * @brief Adds popup window.
107 * Hierarchy of objects visible for accessibility clients is based on tree-like
108 * structure created from Actors objects. This method adds new popup to the tree.
110 * @param[in] object The accessible object
112 virtual void AddPopup(Accessible* object) = 0;
115 * @brief Removes popup window.
117 * Hierarchy of objects visible for accessibility clients is based on tree-like
118 * structure created from Actors objects. This method removes previously added
121 * @param[in] object The accessible object
123 virtual void RemovePopup(Accessible* object) = 0;
126 * @brief Sets name of current application which will be visible on accessibility bus.
128 * @param[in] name The application name
130 virtual void SetApplicationName(std::string name) = 0;
133 * @brief Gets object being root of accessibility tree.
135 * @return handler to accessibility object
137 virtual Accessible* GetApplication() const = 0;
140 * @brief Finds an object in accessibility tree.
142 * @param[in] path The path to object
144 * @return The handler to accessibility object
146 virtual Accessible* FindByPath(const std::string& path) const = 0;
149 * @brief Notifies accessibility dbus that window has just been shown.
151 virtual void WindowShown() = 0;
154 * @brief Notifies accessibility dbus that window has just been hidden.
156 virtual void WindowHidden() = 0;
159 * @brief Initializes accessibility bus.
161 virtual void Initialize() = 0;
164 * @brief Terminates accessibility bus.
166 virtual void Terminate() = 0;
169 * @brief This method is called, when bridge is being activated.
171 virtual ForceUpResult ForceUp()
175 return ForceUpResult::ALREADY_UP;
177 mData = std::make_shared<Data>();
178 mData->mBridge = this;
179 return ForceUpResult::JUST_STARTED;
183 * @brief This method is called, when bridge is being deactivated.
185 virtual void ForceDown() = 0;
188 * @brief Checks if bridge is activated or not.
189 * @return True if brige is activated.
197 * @brief Emits cursor-moved event on at-spi bus.
199 * @param[in] obj The accessible object
200 * @param[in] cursorPosition The new cursor position
202 virtual void EmitCursorMoved(Accessible* obj, unsigned int cursorPosition) = 0;
205 * @brief Emits active-descendant-changed event on at-spi bus.
207 * @param[in] obj The accessible object
208 * @param[in] child The child of the object
210 virtual void EmitActiveDescendantChanged(Accessible* obj, Accessible* child) = 0;
213 * @brief Emits text-changed event on at-spi bus.
215 * @param[in] obj The accessible object
216 * @param[in] state The changed state for text, such as Inserted or Deleted
217 * @param[in] position The cursor position
218 * @param[in] length The text length
219 * @param[in] content The changed text
221 virtual void EmitTextChanged(Accessible* obj, TextChangedState state, unsigned int position, unsigned int length, const std::string& content) = 0;
224 * @brief Emits MoveOuted event on at-spi bus.
226 * @param[in] obj Accessible object
227 * @param[in] type Direction type when an Accessible object moves out of screen
229 virtual void EmitMovedOutOfScreen(Accessible* obj, ScreenRelativeMoveType type) = 0;
232 * @brief Emits state-changed event on at-spi bus.
234 * @param[in] obj The accessible object
235 * @param[in] state The accessibility state (SHOWING, HIGHLIGHTED, etc)
236 * @param[in] newValue Whether the state value is changed to new value or not.
237 * @param[in] reserved Reserved. (Currently, this argument is not implemented in dali)
239 virtual void EmitStateChanged(Accessible* obj, State state, int newValue, int reserved = 0) = 0;
242 * @brief Emits window event on at-spi bus.
244 * @param[in] obj The accessible object
245 * @param[in] event The enumerated window event
246 * @param[in] detail The additional parameter which interpretation depends on chosen event
248 virtual void Emit(Accessible* obj, WindowEvent event, unsigned int detail = 0) = 0;
251 * @brief Emits property-changed event on at-spi bus.
253 * @param[in] obj The accessible object
254 * @param[in] event Property changed event
256 virtual void Emit(Accessible* obj, ObjectPropertyChangeEvent event) = 0;
259 * @brief Emits bounds-changed event on at-spi bus.
261 * @param[in] obj The accessible object
262 * @param[in] rect The rectangle for changed bounds
264 virtual void EmitBoundsChanged(Accessible* obj, Rect<> rect) = 0;
267 * @brief Emits key event on at-spi bus.
269 * Screen-reader might receive this event and reply, that given keycode is consumed. In that case
270 * further processing of the keycode should be ignored.
272 * @param[in] type Key event type
273 * @param[in] keyCode Key code
274 * @param[in] keyName Key name
275 * @param[in] timeStamp Time stamp
276 * @param[in] isText Whether it's text or not
277 * @return Whether this event is consumed or not
279 virtual Consumed Emit(KeyEventType type, unsigned int keyCode, const std::string& keyName, unsigned int timeStamp, bool isText) = 0;
282 * @brief Reads given text by screen reader
284 * @param[in] text The text to read
285 * @param[in] discardable If TRUE, reading can be discarded by subsequent reading requests,
286 * if FALSE the reading must finish before next reading request can be started
287 * @param[in] callback the callback function that is called on reading signals emitted
288 * during processing of this reading request.
289 * Callback can be one of the following signals:
290 * ReadingCancelled, ReadingStopped, ReadingSkipped
292 virtual void Say(const std::string& text, bool discardable, std::function<void(std::string)> callback) = 0;
295 * @brief Force accessibility client to pause.
297 virtual void Pause() = 0;
300 * @brief Force accessibility client to resume.
302 virtual void Resume() = 0;
305 * @brief Cancels anything screen-reader is reading / has queued to read
307 * @param[in] alsoNonDiscardable whether to cancel non-discardable readings as well
309 virtual void StopReading(bool alsoNonDiscardable) = 0;
312 * @brief Suppresses reading of screen-reader
314 * @param[in] suppress whether to suppress reading of screen-reader
316 virtual void SuppressScreenReader(bool suppress) = 0;
319 * @brief Gets screen reader status.
321 * @return True if screen reader is enabled
323 virtual bool GetScreenReaderEnabled() = 0;
326 * @brief Gets ATSPI status.
328 * @return True if ATSPI is enabled
330 virtual bool IsEnabled() = 0;
333 * @brief Returns instance of bridge singleton object.
335 * @return The current bridge object
337 static Bridge* GetCurrentBridge();
340 * @brief Blocks auto-initialization of AT-SPI bridge
342 * Use this only if your application starts before DBus does, and call it early in main()
343 * (before GetCurrentBridge() is called by anyone). GetCurrentBridge() will then return an
344 * instance of DummyBridge.
346 * When DBus is ready, call EnableAutoInit(). Please note that GetCurrentBridge() may still
347 * return an instance of DummyBridge if AT-SPI was disabled at compile time or using an
348 * environment variable, or if creating the real bridge failed.
350 * @see Dali::Accessibility::DummyBridge
351 * @see Dali::Accessibility::Bridge::EnableAutoInit
353 static void DisableAutoInit();
356 * @brief Re-enables auto-initialization of AT-SPI bridge
358 * Normal applications do not have to call this function. GetCurrentBridge() tries to
359 * initialize the AT-SPI bridge when it is called for the first time.
361 * @see Dali::Accessibility::Bridge::DisableAutoInit
362 * @see Dali::Accessibility::Bridge::AddTopLevelWindow
363 * @see Dali::Accessibility::Bridge::SetApplicationName
365 static void EnableAutoInit();
370 std::unordered_set<Accessible*> mKnownObjects;
371 std::string mBusName;
372 Bridge* mBridge = nullptr;
373 Actor mHighlightActor;
374 Actor mCurrentlyHighlightedActor;
376 std::shared_ptr<Data> mData;
377 friend class Accessible;
379 enum class AutoInitState
385 inline static AutoInitState mAutoInitState = AutoInitState::ENABLED;
388 * @brief Registers accessible object to be known in bridge object.
390 * Bridge must known about all currently alive accessible objects, as some requst
391 * might come and object will be identified by number id (it's memory address).
392 * To avoid memory corruption number id is checked against set of known objects.
394 * @param[in] object The accessible object
396 void RegisterOnBridge(Accessible* object);
399 * @brief Tells bridge, that given object is considered root (doesn't have any parents).
401 * All root objects will have the same parent - application object. Application object
402 * is controlled by bridge and private.
404 * @param[in] owner The accessible object
406 void SetIsOnRootLevel(Accessible* owner);
410 * @brief Checks if ATSPI is activated or not.
411 * @return True if ATSPI is activated.
415 if(Bridge::GetCurrentBridge() == nullptr)
420 if(Bridge::GetCurrentBridge()->IsEnabled() == false)
425 return Bridge::GetCurrentBridge()->IsUp();
429 * @brief Basic interface implemented by all accessibility objects.
434 virtual ~Accessible();
436 using utf8_t = unsigned char;
439 * @brief Calculates and finds word boundaries in given utf8 text.
441 * @param[in] string The source text to find
442 * @param[in] length The length of text to find
443 * @param[in] language The language to use
444 * @param[out] breaks The word boundaries in given text
446 * @note Word boundaries are returned as non-zero values in table breaks, which must be of size at least length.
448 void FindWordSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks);
451 * @brief Calculates and finds line boundaries in given utf8 text.
453 * @param[in] string The source text to find
454 * @param[in] length The length of text to find
455 * @param[in] language The language to use
456 * @param[out] breaks The line boundaries in given text
458 * @note Line boundaries are returned as non-zero values in table breaks, which must be of size at least length.
460 void FindLineSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks);
463 * @brief Helper function for emiting active-descendant-changed event.
465 * @param[in] obj The accessible object
466 * @param[in] child The child of the object
468 void EmitActiveDescendantChanged(Accessible* obj, Accessible* child);
471 * @brief Helper function for emiting state-changed event.
473 * @param[in] state The accessibility state (SHOWING, HIGHLIGHTED, etc)
474 * @param[in] newValue Whether the state value is changed to new value or not.
475 * @param[in] reserved Reserved. (TODO : Currently, this argument is not implemented in dali)
477 * @note The second argument determines which value is depending on State.
478 * For instance, if the state is PRESSED, newValue means isPressed or isSelected.
479 * If the state is SHOWING, newValue means isShowing.
481 void EmitStateChanged(State state, int newValue, int reserved = 0);
484 * @brief Helper function for emiting bounds-changed event.
486 * @param rect The rectangle for changed bounds
488 void EmitBoundsChanged(Rect<> rect);
491 * @brief Emits "showing" event.
492 * The method informs accessibility clients about "showing" state.
494 * @param[in] isShowing The flag pointing if object is showing
496 void EmitShowing(bool isShowing);
499 * @brief Emits "visible" event.
500 * The method informs accessibility clients about "visible" state.
502 * @param[in] isVisible The flag pointing if object is visible
504 void EmitVisible(bool isVisible);
507 * @brief Emits "highlighted" event.
508 * The method informs accessibility clients about "highlighted" state.
510 * @param[in] isHighlighted The flag pointing if object is highlighted
512 void EmitHighlighted(bool isHighlighted);
515 * @brief Emits "focused" event.
516 * The method informs accessibility clients about "focused" state.
518 * @param[in] isFocused The flag pointing if object is focused
520 void EmitFocused(bool isFocused);
523 * @brief Emits "text inserted" event.
525 * @param[in] position The cursor position
526 * @param[in] length The text length
527 * @param[in] content The inserted text
529 void EmitTextInserted(unsigned int position, unsigned int length, const std::string& content);
532 * @brief Emits "text deleted" event.
534 * @param[in] position The cursor position
535 * @param[in] length The text length
536 * @param[in] content The deleted text
538 void EmitTextDeleted(unsigned int position, unsigned int length, const std::string& content);
541 * @brief Emits "cursor moved" event.
543 * @param[in] cursorPosition The new cursor position
545 void EmitTextCursorMoved(unsigned int cursorPosition);
548 * @brief Emits "MoveOuted" event.
550 * @param[in] type moved out of screen type
552 void EmitMovedOutOfScreen(ScreenRelativeMoveType type);
555 * @brief Emits "highlighted" event.
557 * @param[in] event The enumerated window event
558 * @param[in] detail The additional parameter which interpretation depends on chosen event
560 void Emit(WindowEvent event, unsigned int detail = 0);
563 * @brief Emits property-changed event.
565 * @param[in] event Property changed event
567 void Emit(ObjectPropertyChangeEvent event);
570 * @brief Gets accessibility name.
572 * @return The string with name
574 virtual std::string GetName() = 0;
577 * @brief Gets accessibility description.
579 * @return The string with description
581 virtual std::string GetDescription() = 0;
584 * @brief Gets parent.
586 * @return The handler to accessibility object
588 virtual Accessible* GetParent() = 0;
591 * @brief Gets the number of children.
593 * @return The number of children
595 virtual size_t GetChildCount() = 0;
598 * @brief Gets collection with all children.
600 * @return The collection of accessibility objects
602 virtual std::vector<Accessible*> GetChildren();
605 * @brief Gets child of the index.
607 * @return The child object
609 virtual Accessible* GetChildAtIndex(size_t index) = 0;
612 * @brief Gets index that current object has in its parent's children collection.
614 * @return The index of the current object
616 virtual size_t GetIndexInParent() = 0;
619 * @brief Gets accessibility role.
621 * @return Role enumeration
623 * @see Dali::Accessibility::Role
625 virtual Role GetRole() = 0;
628 * @brief Gets name of accessibility role.
630 * @return The string with human readable role converted from enumeration
632 * @see Dali::Accessibility::Role
633 * @see Accessibility::Accessible::GetRole
635 virtual std::string GetRoleName();
638 * @brief Gets localized name of accessibility role.
640 * @return The string with human readable role translated according to current
643 * @see Dali::Accessibility::Role
644 * @see Accessibility::Accessible::GetRole
645 * @see Accessibility::Accessible::GetRoleName
647 * @note translation is not supported in this version
649 virtual std::string GetLocalizedRoleName();
652 * @brief Gets accessibility states.
654 * @return The collection of states
656 * @note States class is instatation of ArrayBitset template class
658 * @see Dali::Accessibility::State
659 * @see Dali::Accessibility::ArrayBitset
661 virtual States GetStates() = 0;
664 * @brief Gets accessibility attributes.
666 * @return The map of attributes and their values
668 virtual Attributes GetAttributes() = 0;
671 * @brief Checks if this is proxy.
673 * @return True if this is proxy
675 virtual bool IsProxy();
678 * @brief Gets unique address on accessibility bus.
680 * @return The Address class containing address
682 * @see Dali::Accessibility::Address
684 virtual Address GetAddress();
687 * @brief Gets accessibility object, which is "default label" for this object.
689 * @return The Accessible object
691 virtual Accessible* GetDefaultLabel();
694 * @brief Deputes an object to perform provided gesture.
696 * @param[in] gestureInfo The structure describing the gesture
698 * @return true on success, false otherwise
700 * @see Dali::Accessibility::GestureInfo
702 virtual bool DoGesture(const GestureInfo& gestureInfo) = 0;
705 * @brief Re-emits selected states of an Accessibility Object.
707 * @param[in] states The chosen states to re-emit
708 * @param[in] isRecursive If true, all children of the Accessibility object will also re-emit the states
710 void NotifyAccessibilityStateChange(Dali::Accessibility::States states, bool isRecursive);
713 * @brief Gets information about current object and all relations that connects
714 * it with other accessibility objects.
716 * @return The iterable collection of Relation objects
718 * @see Dali::Accessibility::Relation
720 virtual std::vector<Relation> GetRelationSet() = 0;
723 * @brief Gets all implemented interfaces.
725 * @return The collection of strings with implemented interfaces
727 std::vector<std::string> GetInterfaces();
730 * @brief Checks if object is on root level.
732 * @return Whether object is on root level or not
734 bool IsOnRootLevel() const
736 return mIsOnRootLevel;
740 * @brief The method registers functor resposible for converting Actor into Accessible.
741 * @param functor The returning Accessible handle from Actor object
743 static void RegisterControlAccessibilityGetter(std::function<Accessible*(Dali::Actor)> functor);
746 * @brief Acquires Accessible object from Actor object.
748 * @param[in] actor Actor object
749 * @param[in] isRoot True, if it's top level object (window)
751 * @return The handle to Accessible object
753 static Accessible* Get(Dali::Actor actor, bool isRoot = false);
757 Accessible(const Accessible&) = delete;
758 Accessible(Accessible&&) = delete;
759 Accessible& operator=(const Accessible&) = delete;
760 Accessible& operator=(Accessible&&) = delete;
761 std::shared_ptr<Bridge::Data> GetBridgeData();
765 * @brief Gets the highlight actor.
767 * This method is to get the highlight itself.
768 * @return The highlight actor
770 static Dali::Actor GetHighlightActor();
773 * @brief Sets the highlight actor.
775 * This method is to set the highlight itself.
776 * @param[in] actor The highlight actor
778 static void SetHighlightActor(Dali::Actor actor);
781 * @brief Gets the currently highlighted actor.
783 * @return The current highlighted actor
785 static Dali::Actor GetCurrentlyHighlightedActor();
788 * @brief Sets currently highlighted actor.
790 * @param[in] actor The highlight actor
792 static void SetCurrentlyHighlightedActor(Dali::Actor actor);
795 * @brief Sets ObjectRegistry.
797 * @param[in] registry ObjectRegistry instance
799 static void SetObjectRegistry(ObjectRegistry registry);
804 std::weak_ptr<Bridge::Data> mBridgeData;
805 bool mIsOnRootLevel = false;
809 * @brief Interface enabling to perform provided actions.
811 class Action : public virtual Accessible
815 * @brief Gets name of action with given index.
817 * @param[in] index The index of action
819 * @return The string with name of action
821 virtual std::string GetActionName(size_t index) = 0;
824 * @brief Gets translated name of action with given index.
826 * @param[in] index The index of action
828 * @return The string with name of action translated according to current translation domain
830 * @note The translation is not supported in this version
832 virtual std::string GetLocalizedActionName(size_t index) = 0;
835 * @brief Gets description of action with given index.
837 * @param[in] index The index of action
839 * @return The string with description of action
841 virtual std::string GetActionDescription(size_t index) = 0;
844 * @brief Gets key code binded to action with given index.
846 * @param[in] index The index of action
848 * @return The string with key name
850 virtual std::string GetActionKeyBinding(size_t index) = 0;
853 * @brief Gets number of provided actions.
855 * @return The number of actions
857 virtual size_t GetActionCount() = 0;
860 * @brief Performs an action with given index.
862 * @param index The index of action
864 * @return true on success, false otherwise
866 virtual bool DoAction(size_t index) = 0;
869 * @brief Performs an action with given name.
871 * @param name The name of action
873 * @return true on success, false otherwise
875 virtual bool DoAction(const std::string& name) = 0;
879 * @brief An interface identifying the root object
880 * associated with a running application.
882 * @note Provides global properties describing
883 * application's runtime environment.
885 class Application : public virtual Accessible
889 * @brief Gets name of graphic user interface framework used by an application.
891 * @return String with name
893 virtual std::string GetToolkitName() = 0;
896 * @brief Gets version of graphic user interface framework used by an application.
898 * @return String with version
900 virtual std::string GetVersion() = 0;
904 * @brief Interface enabling advanced quering of accessibility objects.
906 * @note since all mathods can be implemented inside bridge,
907 * none methods have to be overrided
909 class Collection : public virtual Accessible
915 * @brief Interface representing objects having screen coordinates.
917 class Component : public virtual Accessible
921 * @brief Gets rectangle describing size.
923 * @param[in] type The enumeration with type of coordinate systems
925 * @return Rect<> object
929 virtual Rect<> GetExtents(CoordinateType type) = 0;
932 * @brief Gets layer current object is localized on.
934 * @return The enumeration pointing layer
936 * @see Dali::Accessibility::ComponentLayer
938 virtual ComponentLayer GetLayer() = 0;
941 * @brief Gets value of z-order.
943 * @return The value of z-order
944 * @remarks MDI means "Multi Document Interface" (https://en.wikipedia.org/wiki/Multiple-document_interface)
945 * which in short means that many stacked windows can be displayed within a single application.
946 * In such model, the concept of z-order of UI element became important to deal with element overlapping.
948 virtual int16_t GetMdiZOrder() = 0;
951 * @brief Sets current object as "focused".
953 * @return true on success, false otherwise
955 virtual bool GrabFocus() = 0;
958 * @brief Gets value of alpha channel.
960 * @return The alpha channel value in range [0.0, 1.0]
962 virtual double GetAlpha() = 0;
965 * @brief Sets current object as "highlighted".
967 * The method assings "highlighted" state, simultaneously removing it
968 * from currently highlighted object.
970 * @return true on success, false otherwise
972 virtual bool GrabHighlight() = 0;
975 * @brief Sets current object as "unhighlighted".
977 * The method removes "highlighted" state from object.
979 * @return true on success, false otherwise
981 * @see Dali:Accessibility::State
983 virtual bool ClearHighlight() = 0;
986 * @brief Checks whether object can be scrolled.
988 * @return true if object is scrollable, false otherwise
990 * @see Dali:Accessibility::State
992 virtual bool IsScrollable();
995 * @brief Gets Accessible object containing given point.
997 * @param[in] point The two-dimensional point
998 * @param[in] type The enumeration with type of coordinate system
1000 * @return The handle to last child of current object which contains given point
1002 * @see Dali::Accessibility::Point
1004 virtual Accessible* GetAccessibleAtPoint(Point point, CoordinateType type);
1007 * @brief Checks if the current object contains the given point inside.
1009 * @param[in] point The two-dimensional point
1010 * @param[in] type The enumeration with type of coordinate system
1012 * @return True if accessible contains in point, otherwise false.
1014 * @remarks This method is `Contains` in DBus method.
1015 * @see Dali::Accessibility::Point
1017 virtual bool IsAccessibleContainingPoint(Point point, CoordinateType type);
1021 * @brief Interface representing objects which can store numeric value.
1023 class Value : public virtual Accessible
1027 * @brief Gets the lowest possible value.
1029 * @return The minimum value
1031 virtual double GetMinimum() = 0;
1034 * @brief Gets the current value.
1036 * @return The current value
1038 virtual double GetCurrent() = 0;
1041 * @brief Gets the highest possible value.
1043 * @return The highest value.
1045 virtual double GetMaximum() = 0;
1048 * @brief Sets the current value.
1050 * @param[in] value The current value to set
1052 * @return true if value could have been assigned, false otherwise
1054 virtual bool SetCurrent(double value) = 0;
1057 * @brief Gets the lowest increment that can be distinguished.
1059 * @return The lowest increment
1061 virtual double GetMinimumIncrement() = 0;
1065 * @brief Interface representing objects which can store immutable texts.
1067 * @see Dali::Accessibility::EditableText
1069 class DALI_ADAPTOR_API Text : public virtual Accessible
1073 * @brief Gets stored text in given range.
1075 * @param[in] startOffset The index of first character
1076 * @param[in] endOffset The index of first character after the last one expected
1078 * @return The substring of stored text
1080 virtual std::string GetText(size_t startOffset, size_t endOffset) = 0;
1083 * @brief Gets number of all stored characters.
1085 * @return The number of characters
1086 * @remarks This method is `CharacterCount` in DBus method.
1088 virtual size_t GetCharacterCount() = 0;
1091 * @brief Gets the cursor offset.
1093 * @return Value of cursor offset
1094 * @remarks This method is `CaretOffset` in DBus method.
1096 virtual size_t GetCursorOffset() = 0;
1099 * @brief Sets the cursor offset.
1101 * @param[in] offset Cursor offset
1103 * @return True if successful
1104 * @remarks This method is `SetCaretOffset` in DBus method.
1106 virtual bool SetCursorOffset(size_t offset) = 0;
1109 * @brief Gets substring of stored text truncated in concrete gradation.
1111 * @param[in] offset The position in stored text
1112 * @param[in] boundary The enumeration describing text gradation
1114 * @return Range structure containing acquired text and offsets in original string
1116 * @see Dali::Accessibility::Range
1118 virtual Range GetTextAtOffset(size_t offset, TextBoundary boundary) = 0;
1121 * @brief Gets selected text.
1123 * @param[in] selectionIndex The selection index
1124 * @note Currently only one selection (i.e. with index = 0) is supported
1126 * @return Range structure containing acquired text and offsets in original string
1128 * @remarks This method is `GetSelection` in DBus method.
1129 * @see Dali::Accessibility::Range
1131 virtual Range GetRangeOfSelection(size_t selectionIndex) = 0;
1134 * @brief Removes the whole selection.
1136 * @param[in] selectionIndex The selection index
1137 * @note Currently only one selection (i.e. with index = 0) is supported
1139 * @return bool on success, false otherwise
1141 virtual bool RemoveSelection(size_t selectionIndex) = 0;
1144 * @brief Sets selected text.
1146 * @param[in] selectionIndex The selection index
1147 * @param[in] startOffset The index of first character
1148 * @param[in] endOffset The index of first character after the last one expected
1150 * @note Currently only one selection (i.e. with index = 0) is supported
1152 * @return true on success, false otherwise
1153 * @remarks This method is `SetSelection` in DBus method.
1155 virtual bool SetRangeOfSelection(size_t selectionIndex, size_t startOffset, size_t endOffset) = 0;
1159 * @brief Interface representing objects which can store editable texts.
1161 * @note Paste method is entirely implemented inside bridge
1163 * @see Dali::Accessibility::EditableText
1165 class DALI_ADAPTOR_API EditableText : public virtual Accessible
1169 * @brief Copies text in range to system clipboard.
1171 * @param[in] startPosition The index of first character
1172 * @param[in] endPosition The index of first character after the last one expected
1174 * @return true on success, false otherwise
1176 virtual bool CopyText(size_t startPosition, size_t endPosition) = 0;
1179 * @brief Cuts text in range to system clipboard.
1181 * @param[in] startPosition The index of first character
1182 * @param[in] endPosition The index of first character after the last one expected
1184 * @return true on success, false otherwise
1186 virtual bool CutText(size_t startPosition, size_t endPosition) = 0;
1189 * @brief Deletes text in range.
1191 * @param[in] startPosition The index of first character
1192 * @param[in] endPosition The index of first character after the last one expected
1194 * @return true on success, false otherwise
1196 virtual bool DeleteText(size_t startPosition, size_t endPosition) = 0;
1199 * @brief Inserts text at startPosition.
1201 * @param[in] startPosition The index of first character
1202 * @param[in] text The text content
1204 * @return true on success, false otherwise
1206 virtual bool InsertText(size_t startPosition, std::string text) = 0;
1209 * @brief Replaces text with content.
1211 * @param[in] newContents The text content
1213 * @return true on success, false otherwise
1215 virtual bool SetTextContents(std::string newContents) = 0;
1219 * @brief Interface representing objects which can store a set of selected items.
1221 class DALI_ADAPTOR_API Selection : public virtual Accessible
1225 * @brief Gets the number of selected children.
1227 * @return The number of selected children (zero if none)
1229 virtual int GetSelectedChildrenCount() = 0;
1232 * @brief Gets a specific selected child.
1234 * @param selectedChildIndex The index of the selected child
1236 * @note @p selectedChildIndex refers to the list of selected children,
1237 * not the list of all children
1239 * @return The selected child or nullptr if index is invalid
1241 virtual Accessible* GetSelectedChild(int selectedChildIndex) = 0;
1244 * @brief Selects a child.
1246 * @param childIndex The index of the child
1248 * @return true on success, false otherwise
1250 virtual bool SelectChild(int childIndex) = 0;
1253 * @brief Deselects a selected child.
1255 * @param selectedChildIndex The index of the selected child
1257 * @note @p selectedChildIndex refers to the list of selected children,
1258 * not the list of all children
1260 * @return true on success, false otherwise
1262 * @see Dali::Accessibility::Selection::DeselectChild
1264 virtual bool DeselectSelectedChild(int selectedChildIndex) = 0;
1267 * @brief Checks whether a child is selected.
1269 * @param childIndex The index of the child
1271 * @return true if given child is selected, false otherwise
1273 virtual bool IsChildSelected(int childIndex) = 0;
1276 * @brief Selects all children.
1278 * @return true on success, false otherwise
1280 virtual bool SelectAll() = 0;
1283 * @brief Deselects all children.
1285 * @return true on success, false otherwise
1287 virtual bool ClearSelection() = 0;
1290 * @brief Deselects a child.
1292 * @param childIndex The index of the child.
1294 * @return true on success, false otherwise
1296 * @see Dali::Accessibility::Selection::DeselectSelectedChild
1298 virtual bool DeselectChild(int childIndex) = 0;
1302 * @brief The minimalistic, always empty Accessible object with settable address.
1304 * For those situations, where you want to return address in different bridge
1305 * (embedding for example), but the object itself ain't planned to be used otherwise.
1306 * This object has null parent, no children, empty name and so on
1308 class DALI_ADAPTOR_API EmptyAccessibleWithAddress : public virtual Accessible
1311 EmptyAccessibleWithAddress() = default;
1313 EmptyAccessibleWithAddress(Address address)
1314 : mAddress(std::move(address))
1318 void SetAddress(Address address)
1320 this->mAddress = std::move(address);
1323 std::string GetName() override
1328 std::string GetDescription() override
1333 Accessible* GetParent() override
1338 size_t GetChildCount() override
1343 std::vector<Accessible*> GetChildren() override
1348 Accessible* GetChildAtIndex(size_t index) override
1350 throw std::domain_error{"out of bounds index (" + std::to_string(index) + ") - no children"};
1353 size_t GetIndexInParent() override
1355 return static_cast<size_t>(-1);
1358 Role GetRole() override
1363 std::string GetRoleName() override;
1365 States GetStates() override
1370 Attributes GetAttributes() override
1375 Address GetAddress() override
1380 bool DoGesture(const GestureInfo& gestureInfo) override
1385 std::vector<Relation> GetRelationSet() override
1394 } // namespace Accessibility
1397 #endif // DALI_INTERNAL_ATSPI_ACCESSIBILITY_IMPL_H