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/public-api/adaptor-framework/window.h>
39 #include <dali/integration-api/debug.h>
43 namespace Accessibility
45 class DALI_ADAPTOR_API Accessible;
46 class DALI_ADAPTOR_API Text;
47 class DALI_ADAPTOR_API Value;
48 class DALI_ADAPTOR_API Component;
49 class DALI_ADAPTOR_API Collection;
50 class DALI_ADAPTOR_API Action;
51 class DALI_ADAPTOR_API Application;
52 class DALI_ADAPTOR_API Hypertext;
53 class DALI_ADAPTOR_API Hyperlink;
56 * @brief Base class for different accessibility bridges.
58 * Bridge is resposible for initializing and managing connection on accessibility bus.
59 * Accessibility clients will not get any information about UI without initialized and upraised bridge.
60 * Concrete implementation depends on the accessibility technology available on the platform.
62 * @note This class is singleton.
64 struct DALI_ADAPTOR_API Bridge
66 enum class ForceUpResult
75 virtual ~Bridge() = default;
78 * @brief Gets bus name which bridge is initialized on.
80 * @return The bus name
82 virtual const std::string& GetBusName() const = 0;
85 * @brief Registers top level window.
87 * Hierarchy of objects visible for accessibility clients is based on tree-like
88 * structure created from Actors objects. This method allows to connect chosen
89 * object as direct ancestor of application and therefore make it visible for
90 * accessibility clients.
92 * @param[in] object The accessible object
94 virtual void AddTopLevelWindow(Accessible* object) = 0;
97 * @brief Removes top level window.
99 * Hierarchy of objects visible for accessibility clients is based on tree-like
100 * structure created from Actors objects. This method removes previously added
101 * window from visible accessibility objects.
103 * @param[in] object The accessible object
105 virtual void RemoveTopLevelWindow(Accessible* object) = 0;
108 * @brief Adds popup window.
110 * Hierarchy of objects visible for accessibility clients is based on tree-like
111 * structure created from Actors objects. This method adds new popup to the tree.
113 * @param[in] object The accessible object
115 virtual void AddPopup(Accessible* object) = 0;
118 * @brief Removes popup window.
120 * Hierarchy of objects visible for accessibility clients is based on tree-like
121 * structure created from Actors objects. This method removes previously added
124 * @param[in] object The accessible object
126 virtual void RemovePopup(Accessible* object) = 0;
129 * @brief Sets name of current application which will be visible on accessibility bus.
131 * @param[in] name The application name
133 virtual void SetApplicationName(std::string name) = 0;
136 * @brief Gets object being root of accessibility tree.
138 * @return handler to accessibility object
140 virtual Accessible* GetApplication() const = 0;
143 * @brief Finds an object in accessibility tree.
145 * @param[in] path The path to object
147 * @return The handler to accessibility object
149 virtual Accessible* FindByPath(const std::string& path) const = 0;
152 * @brief Notifies accessibility dbus that window has just been shown.
154 * @param[in] window The window to be shown
156 virtual void WindowShown(Window window) = 0;
159 * @brief Notifies accessibility dbus that window has just been hidden.
161 * @param[in] window The window to be hidden
163 virtual void WindowHidden(Window window) = 0;
166 * @brief Notifies accessibility dbus that window has just been focused.
168 * @param[in] window The window to be focused
170 virtual void WindowFocused(Window window) = 0;
173 * @brief Notifies accessibility dbus that window has just been out of focus.
175 * @param[in] window The window to be out of focus
177 virtual void WindowUnfocused(Window window) = 0;
180 * @brief Initializes accessibility bus.
182 virtual void Initialize() = 0;
185 * @brief Terminates accessibility bus.
187 virtual void Terminate() = 0;
190 * @brief This method is called, when bridge is being activated.
192 virtual ForceUpResult ForceUp()
196 return ForceUpResult::ALREADY_UP;
198 mData = std::make_shared<Data>();
199 mData->mBridge = this;
200 return ForceUpResult::JUST_STARTED;
204 * @brief This method is called, when bridge is being deactivated.
206 virtual void ForceDown() = 0;
209 * @brief Checks if bridge is activated or not.
210 * @return True if brige is activated.
218 * @brief Emits cursor-moved event on at-spi bus.
220 * @param[in] obj The accessible object
221 * @param[in] cursorPosition The new cursor position
223 virtual void EmitCursorMoved(Accessible* obj, unsigned int cursorPosition) = 0;
226 * @brief Emits active-descendant-changed event on at-spi bus.
228 * @param[in] obj The accessible object
229 * @param[in] child The child of the object
231 virtual void EmitActiveDescendantChanged(Accessible* obj, Accessible* child) = 0;
234 * @brief Emits text-changed event on at-spi bus.
236 * @param[in] obj The accessible object
237 * @param[in] state The changed state for text, such as Inserted or Deleted
238 * @param[in] position The cursor position
239 * @param[in] length The text length
240 * @param[in] content The changed text
242 virtual void EmitTextChanged(Accessible* obj, TextChangedState state, unsigned int position, unsigned int length, const std::string& content) = 0;
245 * @brief Emits MoveOuted event on at-spi bus.
247 * @param[in] obj Accessible object
248 * @param[in] type Direction type when an Accessible object moves out of screen
250 virtual void EmitMovedOutOfScreen(Accessible* obj, ScreenRelativeMoveType type) = 0;
253 * @brief Emits state-changed event on at-spi bus.
255 * @param[in] obj The accessible object
256 * @param[in] state The accessibility state (SHOWING, HIGHLIGHTED, etc)
257 * @param[in] newValue Whether the state value is changed to new value or not.
258 * @param[in] reserved Reserved. (Currently, this argument is not implemented in dali)
260 virtual void EmitStateChanged(Accessible* obj, State state, int newValue, int reserved = 0) = 0;
263 * @brief Emits window event on at-spi bus.
265 * @param[in] obj The accessible object
266 * @param[in] event The enumerated window event
267 * @param[in] detail The additional parameter which interpretation depends on chosen event
269 virtual void Emit(Accessible* obj, WindowEvent event, unsigned int detail = 0) = 0;
272 * @brief Emits property-changed event on at-spi bus.
274 * @param[in] obj The accessible object
275 * @param[in] event Property changed event
277 virtual void Emit(Accessible* obj, ObjectPropertyChangeEvent event) = 0;
280 * @brief Emits bounds-changed event on at-spi bus.
282 * @param[in] obj The accessible object
283 * @param[in] rect The rectangle for changed bounds
285 virtual void EmitBoundsChanged(Accessible* obj, Rect<> rect) = 0;
288 * @brief Emits key event on at-spi bus.
290 * Screen-reader might receive this event and reply, that given keycode is consumed. In that case
291 * further processing of the keycode should be ignored.
293 * @param[in] type Key event type
294 * @param[in] keyCode Key code
295 * @param[in] keyName Key name
296 * @param[in] timeStamp Time stamp
297 * @param[in] isText Whether it's text or not
298 * @return Whether this event is consumed or not
300 virtual Consumed Emit(KeyEventType type, unsigned int keyCode, const std::string& keyName, unsigned int timeStamp, bool isText) = 0;
303 * @brief Reads given text by screen reader
305 * @param[in] text The text to read
306 * @param[in] discardable If TRUE, reading can be discarded by subsequent reading requests,
307 * if FALSE the reading must finish before next reading request can be started
308 * @param[in] callback the callback function that is called on reading signals emitted
309 * during processing of this reading request.
310 * Callback can be one of the following signals:
311 * ReadingCancelled, ReadingStopped, ReadingSkipped
313 virtual void Say(const std::string& text, bool discardable, std::function<void(std::string)> callback) = 0;
316 * @brief Force accessibility client to pause.
318 virtual void Pause() = 0;
321 * @brief Force accessibility client to resume.
323 virtual void Resume() = 0;
326 * @brief Cancels anything screen-reader is reading / has queued to read
328 * @param[in] alsoNonDiscardable whether to cancel non-discardable readings as well
330 virtual void StopReading(bool alsoNonDiscardable) = 0;
333 * @brief Suppresses reading of screen-reader
335 * @param[in] suppress whether to suppress reading of screen-reader
337 virtual void SuppressScreenReader(bool suppress) = 0;
340 * @brief Gets screen reader status.
342 * @return True if screen reader is enabled
344 virtual bool GetScreenReaderEnabled() = 0;
347 * @brief Gets ATSPI status.
349 * @return True if ATSPI is enabled
351 virtual bool IsEnabled() = 0;
354 * @brief Returns instance of bridge singleton object.
356 * @return The current bridge object
358 static Bridge* GetCurrentBridge();
361 * @brief Blocks auto-initialization of AT-SPI bridge
363 * Use this only if your application starts before DBus does, and call it early in main()
364 * (before GetCurrentBridge() is called by anyone). GetCurrentBridge() will then return an
365 * instance of DummyBridge.
367 * When DBus is ready, call EnableAutoInit(). Please note that GetCurrentBridge() may still
368 * return an instance of DummyBridge if AT-SPI was disabled at compile time or using an
369 * environment variable, or if creating the real bridge failed.
371 * @see Dali::Accessibility::DummyBridge
372 * @see Dali::Accessibility::Bridge::EnableAutoInit
374 static void DisableAutoInit();
377 * @brief Re-enables auto-initialization of AT-SPI bridge
379 * Normal applications do not have to call this function. GetCurrentBridge() tries to
380 * initialize the AT-SPI bridge when it is called for the first time.
382 * @see Dali::Accessibility::Bridge::DisableAutoInit
383 * @see Dali::Accessibility::Bridge::AddTopLevelWindow
384 * @see Dali::Accessibility::Bridge::SetApplicationName
386 static void EnableAutoInit();
388 static Signal<void()>& EnabledSignal()
390 return mEnabledSignal;
393 static Signal<void()>& DisabledSignal()
395 return mDisabledSignal;
401 std::unordered_set<Accessible*> mKnownObjects;
402 std::string mBusName;
403 Bridge* mBridge = nullptr;
404 Actor mHighlightActor;
405 Actor mCurrentlyHighlightedActor;
407 std::shared_ptr<Data> mData;
408 friend class Accessible;
410 enum class AutoInitState
416 inline static AutoInitState mAutoInitState = AutoInitState::ENABLED;
418 inline static Signal<void()> mEnabledSignal;
419 inline static Signal<void()> mDisabledSignal;
422 * @brief Registers accessible object to be known in bridge object.
424 * Bridge must known about all currently alive accessible objects, as some requst
425 * might come and object will be identified by number id (it's memory address).
426 * To avoid memory corruption number id is checked against set of known objects.
428 * @param[in] object The accessible object
430 void RegisterOnBridge(Accessible* object);
433 * @brief Tells bridge, that given object is considered root (doesn't have any parents).
435 * All root objects will have the same parent - application object. Application object
436 * is controlled by bridge and private.
438 * @param[in] owner The accessible object
440 void SetIsOnRootLevel(Accessible* owner);
444 * @brief Checks if ATSPI is activated or not.
445 * @return True if ATSPI is activated.
449 if(Bridge::GetCurrentBridge() == nullptr)
454 if(Bridge::GetCurrentBridge()->IsEnabled() == false)
459 return Bridge::GetCurrentBridge()->IsUp();
463 * @brief Basic interface implemented by all accessibility objects.
468 virtual ~Accessible();
470 using utf8_t = unsigned char;
473 * @brief Calculates and finds word boundaries in given utf8 text.
475 * @param[in] string The source text to find
476 * @param[in] length The length of text to find
477 * @param[in] language The language to use
478 * @param[out] breaks The word boundaries in given text
480 * @note Word boundaries are returned as non-zero values in table breaks, which must be of size at least length.
482 void FindWordSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks);
485 * @brief Calculates and finds line boundaries in given utf8 text.
487 * @param[in] string The source text to find
488 * @param[in] length The length of text to find
489 * @param[in] language The language to use
490 * @param[out] breaks The line boundaries in given text
492 * @note Line boundaries are returned as non-zero values in table breaks, which must be of size at least length.
494 void FindLineSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks);
497 * @brief Helper function for emiting active-descendant-changed event.
499 * @param[in] obj The accessible object
500 * @param[in] child The child of the object
502 void EmitActiveDescendantChanged(Accessible* obj, Accessible* child);
505 * @brief Helper function for emiting state-changed event.
507 * @param[in] state The accessibility state (SHOWING, HIGHLIGHTED, etc)
508 * @param[in] newValue Whether the state value is changed to new value or not.
509 * @param[in] reserved Reserved. (TODO : Currently, this argument is not implemented in dali)
511 * @note The second argument determines which value is depending on State.
512 * For instance, if the state is PRESSED, newValue means isPressed or isSelected.
513 * If the state is SHOWING, newValue means isShowing.
515 void EmitStateChanged(State state, int newValue, int reserved = 0);
518 * @brief Helper function for emiting bounds-changed event.
520 * @param rect The rectangle for changed bounds
522 void EmitBoundsChanged(Rect<> rect);
525 * @brief Emits "showing" event.
526 * The method informs accessibility clients about "showing" state.
528 * @param[in] isShowing The flag pointing if object is showing
530 void EmitShowing(bool isShowing);
533 * @brief Emits "visible" event.
534 * The method informs accessibility clients about "visible" state.
536 * @param[in] isVisible The flag pointing if object is visible
538 void EmitVisible(bool isVisible);
541 * @brief Emits "highlighted" event.
542 * The method informs accessibility clients about "highlighted" state.
544 * @param[in] isHighlighted The flag pointing if object is highlighted
546 void EmitHighlighted(bool isHighlighted);
549 * @brief Emits "focused" event.
550 * The method informs accessibility clients about "focused" state.
552 * @param[in] isFocused The flag pointing if object is focused
554 void EmitFocused(bool isFocused);
557 * @brief Emits "text inserted" event.
559 * @param[in] position The cursor position
560 * @param[in] length The text length
561 * @param[in] content The inserted text
563 void EmitTextInserted(unsigned int position, unsigned int length, const std::string& content);
566 * @brief Emits "text deleted" event.
568 * @param[in] position The cursor position
569 * @param[in] length The text length
570 * @param[in] content The deleted text
572 void EmitTextDeleted(unsigned int position, unsigned int length, const std::string& content);
575 * @brief Emits "cursor moved" event.
577 * @param[in] cursorPosition The new cursor position
579 void EmitTextCursorMoved(unsigned int cursorPosition);
582 * @brief Emits "MoveOuted" event.
584 * @param[in] type moved out of screen type
586 void EmitMovedOutOfScreen(ScreenRelativeMoveType type);
589 * @brief Emits "highlighted" event.
591 * @param[in] event The enumerated window event
592 * @param[in] detail The additional parameter which interpretation depends on chosen event
594 void Emit(WindowEvent event, unsigned int detail = 0);
597 * @brief Emits property-changed event.
599 * @param[in] event Property changed event
601 void Emit(ObjectPropertyChangeEvent event);
604 * @brief Gets accessibility name.
606 * @return The string with name
608 virtual std::string GetName() = 0;
611 * @brief Gets accessibility description.
613 * @return The string with description
615 virtual std::string GetDescription() = 0;
618 * @brief Gets parent.
620 * @return The handler to accessibility object
622 virtual Accessible* GetParent() = 0;
625 * @brief Gets the number of children.
627 * @return The number of children
629 virtual size_t GetChildCount() = 0;
632 * @brief Gets collection with all children.
634 * @return The collection of accessibility objects
636 virtual std::vector<Accessible*> GetChildren();
639 * @brief Gets child of the index.
641 * @return The child object
643 virtual Accessible* GetChildAtIndex(size_t index) = 0;
646 * @brief Gets index that current object has in its parent's children collection.
648 * @return The index of the current object
650 virtual size_t GetIndexInParent() = 0;
653 * @brief Gets accessibility role.
655 * @return Role enumeration
657 * @see Dali::Accessibility::Role
659 virtual Role GetRole() = 0;
662 * @brief Gets name of accessibility role.
664 * @return The string with human readable role converted from enumeration
666 * @see Dali::Accessibility::Role
667 * @see Accessibility::Accessible::GetRole
669 virtual std::string GetRoleName();
672 * @brief Gets localized name of accessibility role.
674 * @return The string with human readable role translated according to current
677 * @see Dali::Accessibility::Role
678 * @see Accessibility::Accessible::GetRole
679 * @see Accessibility::Accessible::GetRoleName
681 * @note translation is not supported in this version
683 virtual std::string GetLocalizedRoleName();
686 * @brief Gets accessibility states.
688 * @return The collection of states
690 * @note States class is instatation of ArrayBitset template class
692 * @see Dali::Accessibility::State
693 * @see Dali::Accessibility::ArrayBitset
695 virtual States GetStates() = 0;
698 * @brief Gets accessibility attributes.
700 * @return The map of attributes and their values
702 virtual Attributes GetAttributes() = 0;
705 * @brief Checks if this is proxy.
707 * @return True if this is proxy
709 virtual bool IsProxy();
712 * @brief Gets unique address on accessibility bus.
714 * @return The Address class containing address
716 * @see Dali::Accessibility::Address
718 virtual Address GetAddress();
721 * @brief Gets accessibility object, which is "default label" for this object.
723 * @return The Accessible object
725 virtual Accessible* GetDefaultLabel();
728 * @brief Deputes an object to perform provided gesture.
730 * @param[in] gestureInfo The structure describing the gesture
732 * @return true on success, false otherwise
734 * @see Dali::Accessibility::GestureInfo
736 virtual bool DoGesture(const GestureInfo& gestureInfo) = 0;
739 * @brief Re-emits selected states of an Accessibility Object.
741 * @param[in] states The chosen states to re-emit
742 * @param[in] isRecursive If true, all children of the Accessibility object will also re-emit the states
744 void NotifyAccessibilityStateChange(Dali::Accessibility::States states, bool isRecursive);
747 * @brief Gets information about current object and all relations that connects
748 * it with other accessibility objects.
750 * @return The iterable collection of Relation objects
752 * @see Dali::Accessibility::Relation
754 virtual std::vector<Relation> GetRelationSet() = 0;
757 * @brief Gets internal Actor to be saved before.
759 * @return The internal Actor
761 virtual Dali::Actor GetInternalActor() = 0;
764 * @brief Gets all implemented interfaces.
766 * @return The collection of strings with implemented interfaces
768 std::vector<std::string> GetInterfaces();
771 * @brief Checks if object is on root level.
773 * @return Whether object is on root level or not
775 bool IsOnRootLevel() const
777 return mIsOnRootLevel;
782 Accessible(const Accessible&) = delete;
783 Accessible(Accessible&&) = delete;
784 Accessible& operator=(const Accessible&) = delete;
785 Accessible& operator=(Accessible&&) = delete;
786 std::shared_ptr<Bridge::Data> GetBridgeData();
790 * @brief Gets the highlight actor.
792 * This method is to get the highlight itself.
793 * @return The highlight actor
795 static Dali::Actor GetHighlightActor();
798 * @brief Sets the highlight actor.
800 * This method is to set the highlight itself.
801 * @param[in] actor The highlight actor
803 static void SetHighlightActor(Dali::Actor actor);
806 * @brief Gets the currently highlighted actor.
808 * @return The current highlighted actor
810 static Dali::Actor GetCurrentlyHighlightedActor();
813 * @brief Sets currently highlighted actor.
815 * @param[in] actor The highlight actor
817 static void SetCurrentlyHighlightedActor(Dali::Actor actor);
820 * @brief Sets ObjectRegistry.
822 * @param[in] registry ObjectRegistry instance
824 static void SetObjectRegistry(ObjectRegistry registry);
827 * @brief The method registers functor resposible for converting Actor into Accessible.
828 * @param functor The returning Accessible handle from Actor object
830 static void RegisterExternalAccessibleGetter(std::function<Accessible*(Dali::Actor)> functor);
833 * @brief Acquires Accessible object from Actor object.
835 * @param[in] actor Actor object
836 * @param[in] isRoot True, if it's top level object (window)
838 * @return The handle to Accessible object
840 static Accessible* Get(Dali::Actor actor, bool isRoot = false);
845 std::weak_ptr<Bridge::Data> mBridgeData;
846 bool mIsOnRootLevel = false;
848 }; // Accessible class
851 * @brief Interface enabling to perform provided actions.
853 class Action : public virtual Accessible
857 * @brief Gets name of action with given index.
859 * @param[in] index The index of action
861 * @return The string with name of action
863 virtual std::string GetActionName(size_t index) = 0;
866 * @brief Gets translated name of action with given index.
868 * @param[in] index The index of action
870 * @return The string with name of action translated according to current translation domain
872 * @note The translation is not supported in this version
874 virtual std::string GetLocalizedActionName(size_t index) = 0;
877 * @brief Gets description of action with given index.
879 * @param[in] index The index of action
881 * @return The string with description of action
883 virtual std::string GetActionDescription(size_t index) = 0;
886 * @brief Gets key code binded to action with given index.
888 * @param[in] index The index of action
890 * @return The string with key name
892 virtual std::string GetActionKeyBinding(size_t index) = 0;
895 * @brief Gets number of provided actions.
897 * @return The number of actions
899 virtual size_t GetActionCount() = 0;
902 * @brief Performs an action with given index.
904 * @param index The index of action
906 * @return true on success, false otherwise
908 virtual bool DoAction(size_t index) = 0;
911 * @brief Performs an action with given name.
913 * @param name The name of action
915 * @return true on success, false otherwise
917 virtual bool DoAction(const std::string& name) = 0;
921 * @brief An interface identifying the root object
922 * associated with a running application.
924 * @note Provides global properties describing
925 * application's runtime environment.
927 class Application : public virtual Accessible
931 * @brief Gets name of graphic user interface framework used by an application.
933 * @return String with name
935 virtual std::string GetToolkitName() = 0;
938 * @brief Gets version of graphic user interface framework used by an application.
940 * @return String with version
942 virtual std::string GetVersion() = 0;
946 * @brief Interface enabling advanced quering of accessibility objects.
948 * @note since all mathods can be implemented inside bridge,
949 * none methods have to be overrided
951 class Collection : public virtual Accessible
957 * @brief Interface representing objects having screen coordinates.
959 class Component : public virtual Accessible
963 * @brief Gets rectangle describing size.
965 * @param[in] type The enumeration with type of coordinate systems
967 * @return Rect<> object
971 virtual Rect<> GetExtents(CoordinateType type) = 0;
974 * @brief Gets layer current object is localized on.
976 * @return The enumeration pointing layer
978 * @see Dali::Accessibility::ComponentLayer
980 virtual ComponentLayer GetLayer() = 0;
983 * @brief Gets value of z-order.
985 * @return The value of z-order
986 * @remarks MDI means "Multi Document Interface" (https://en.wikipedia.org/wiki/Multiple-document_interface)
987 * which in short means that many stacked windows can be displayed within a single application.
988 * In such model, the concept of z-order of UI element became important to deal with element overlapping.
990 virtual int16_t GetMdiZOrder() = 0;
993 * @brief Sets current object as "focused".
995 * @return true on success, false otherwise
997 virtual bool GrabFocus() = 0;
1000 * @brief Gets value of alpha channel.
1002 * @return The alpha channel value in range [0.0, 1.0]
1004 virtual double GetAlpha() = 0;
1007 * @brief Sets current object as "highlighted".
1009 * The method assings "highlighted" state, simultaneously removing it
1010 * from currently highlighted object.
1012 * @return true on success, false otherwise
1014 virtual bool GrabHighlight() = 0;
1017 * @brief Sets current object as "unhighlighted".
1019 * The method removes "highlighted" state from object.
1021 * @return true on success, false otherwise
1023 * @see Dali:Accessibility::State
1025 virtual bool ClearHighlight() = 0;
1028 * @brief Checks whether object can be scrolled.
1030 * @return true if object is scrollable, false otherwise
1032 * @see Dali:Accessibility::State
1034 virtual bool IsScrollable();
1037 * @brief Gets Accessible object containing given point.
1039 * @param[in] point The two-dimensional point
1040 * @param[in] type The enumeration with type of coordinate system
1042 * @return The handle to last child of current object which contains given point
1044 * @see Dali::Accessibility::Point
1046 virtual Accessible* GetAccessibleAtPoint(Point point, CoordinateType type);
1049 * @brief Checks if the current object contains the given point inside.
1051 * @param[in] point The two-dimensional point
1052 * @param[in] type The enumeration with type of coordinate system
1054 * @return True if accessible contains in point, otherwise false.
1056 * @remarks This method is `Contains` in DBus method.
1057 * @see Dali::Accessibility::Point
1059 virtual bool IsAccessibleContainingPoint(Point point, CoordinateType type);
1063 * @brief Interface representing objects which can store numeric value.
1065 class Value : public virtual Accessible
1069 * @brief Gets the lowest possible value.
1071 * @return The minimum value
1073 virtual double GetMinimum() = 0;
1076 * @brief Gets the current value.
1078 * @return The current value
1080 virtual double GetCurrent() = 0;
1083 * @brief Gets the highest possible value.
1085 * @return The highest value.
1087 virtual double GetMaximum() = 0;
1090 * @brief Sets the current value.
1092 * @param[in] value The current value to set
1094 * @return true if value could have been assigned, false otherwise
1096 virtual bool SetCurrent(double value) = 0;
1099 * @brief Gets the lowest increment that can be distinguished.
1101 * @return The lowest increment
1103 virtual double GetMinimumIncrement() = 0;
1107 * @brief Interface representing objects which can store immutable texts.
1109 * @see Dali::Accessibility::EditableText
1111 class DALI_ADAPTOR_API Text : public virtual Accessible
1115 * @brief Gets stored text in given range.
1117 * @param[in] startOffset The index of first character
1118 * @param[in] endOffset The index of first character after the last one expected
1120 * @return The substring of stored text
1122 virtual std::string GetText(size_t startOffset, size_t endOffset) = 0;
1125 * @brief Gets number of all stored characters.
1127 * @return The number of characters
1128 * @remarks This method is `CharacterCount` in DBus method.
1130 virtual size_t GetCharacterCount() = 0;
1133 * @brief Gets the cursor offset.
1135 * @return Value of cursor offset
1136 * @remarks This method is `CaretOffset` in DBus method.
1138 virtual size_t GetCursorOffset() = 0;
1141 * @brief Sets the cursor offset.
1143 * @param[in] offset Cursor offset
1145 * @return True if successful
1146 * @remarks This method is `SetCaretOffset` in DBus method.
1148 virtual bool SetCursorOffset(size_t offset) = 0;
1151 * @brief Gets substring of stored text truncated in concrete gradation.
1153 * @param[in] offset The position in stored text
1154 * @param[in] boundary The enumeration describing text gradation
1156 * @return Range structure containing acquired text and offsets in original string
1158 * @see Dali::Accessibility::Range
1160 virtual Range GetTextAtOffset(size_t offset, TextBoundary boundary) = 0;
1163 * @brief Gets selected text.
1165 * @param[in] selectionIndex The selection index
1166 * @note Currently only one selection (i.e. with index = 0) is supported
1168 * @return Range structure containing acquired text and offsets in original string
1170 * @remarks This method is `GetSelection` in DBus method.
1171 * @see Dali::Accessibility::Range
1173 virtual Range GetRangeOfSelection(size_t selectionIndex) = 0;
1176 * @brief Removes the whole selection.
1178 * @param[in] selectionIndex The selection index
1179 * @note Currently only one selection (i.e. with index = 0) is supported
1181 * @return bool on success, false otherwise
1183 virtual bool RemoveSelection(size_t selectionIndex) = 0;
1186 * @brief Sets selected text.
1188 * @param[in] selectionIndex The selection index
1189 * @param[in] startOffset The index of first character
1190 * @param[in] endOffset The index of first character after the last one expected
1192 * @note Currently only one selection (i.e. with index = 0) is supported
1194 * @return true on success, false otherwise
1195 * @remarks This method is `SetSelection` in DBus method.
1197 virtual bool SetRangeOfSelection(size_t selectionIndex, size_t startOffset, size_t endOffset) = 0;
1201 * @brief Interface representing objects which can store editable texts.
1203 * @note Paste method is entirely implemented inside bridge
1205 * @see Dali::Accessibility::EditableText
1207 class DALI_ADAPTOR_API EditableText : public virtual Accessible
1211 * @brief Copies text in range to system clipboard.
1213 * @param[in] startPosition The index of first character
1214 * @param[in] endPosition The index of first character after the last one expected
1216 * @return true on success, false otherwise
1218 virtual bool CopyText(size_t startPosition, size_t endPosition) = 0;
1221 * @brief Cuts text in range to system clipboard.
1223 * @param[in] startPosition The index of first character
1224 * @param[in] endPosition The index of first character after the last one expected
1226 * @return true on success, false otherwise
1228 virtual bool CutText(size_t startPosition, size_t endPosition) = 0;
1231 * @brief Deletes text in range.
1233 * @param[in] startPosition The index of first character
1234 * @param[in] endPosition The index of first character after the last one expected
1236 * @return true on success, false otherwise
1238 virtual bool DeleteText(size_t startPosition, size_t endPosition) = 0;
1241 * @brief Inserts text at startPosition.
1243 * @param[in] startPosition The index of first character
1244 * @param[in] text The text content
1246 * @return true on success, false otherwise
1248 virtual bool InsertText(size_t startPosition, std::string text) = 0;
1251 * @brief Replaces text with content.
1253 * @param[in] newContents The text content
1255 * @return true on success, false otherwise
1257 virtual bool SetTextContents(std::string newContents) = 0;
1261 * @brief Interface representing hypertext that can store a collection of hyperlinks.
1263 class Hypertext : public virtual Accessible
1267 * @brief Gets the handle to hyperlink object from a specified index in hyperlink collection of this hypertext.
1269 * @param[in] linkIndex The 0-based index in hyperlink collection.
1271 * @return Handle to hyperlink object at a specified index in hyperlink collection of hypertext.
1273 virtual Hyperlink* GetLink(int32_t linkIndex) const = 0;
1276 * @brief Gets the index in hyperlink collection occupied by hyperlink which spans over a specified character offset in this hypertext.
1278 * @param[in] characterOffset The 0-based index of character in hypertext.
1280 * @return The value of 0-based index in hyperlink collection (-1 if there is no hyperlink at the specified character offset).
1282 virtual int32_t GetLinkIndex(int32_t characterOffset) const = 0;
1285 * @brief Gets number of hyperlinks stored in this hypertext.
1287 * @return The number of hyperlinks (zero if none or -1 if the number cannot be determined)
1289 virtual int32_t GetLinkCount() const = 0;
1293 * @brief Interface representing a hyperlink in hypertext .
1295 class Hyperlink : public virtual Accessible
1299 * @brief Gets the index of character in originating hypertext at which this hyperlink ends.
1301 * @return The 0-based index of hyperlink's last character + 1, in its originating hypertext.
1303 virtual int32_t GetEndIndex() const = 0;
1306 * @brief Gets the index of character in originating hypertext at which this hyperlink starts.
1308 * @return The 0-based index of hyperlink's first character, in its originating hypertext.
1310 virtual int32_t GetStartIndex() const = 0;
1313 * @brief Gets the total number of anchors which this hyperlink has. Though, typical hyperlinks will have only one anchor.
1315 * @return The number of anchors.
1317 virtual int32_t GetAnchorCount() const = 0;
1320 * @brief Gets the object associated with a particular hyperlink's anchor.
1322 * @param[in] anchorIndex The 0-based index in anchor collection.
1324 * @return The handle to accessible object.
1326 virtual Accessible* GetAnchorAccessible(int32_t anchorIndex) const = 0;
1329 * @brief Gets the URI associated with a particular hyperlink's anchor.
1331 * @param[in] anchorIndex The 0-based index in anchor collection.
1333 * @return The string containing URI.
1335 virtual std::string GetAnchorUri(int32_t anchorIndex) const = 0;
1338 * @brief Tells whether this hyperlink object is still valid with respect to its originating hypertext object.
1340 * @return True if hyperlink object is valid, false otherwise
1342 virtual bool IsValid() const = 0;
1346 * @brief Interface representing objects which can store a set of selected items.
1348 class DALI_ADAPTOR_API Selection : public virtual Accessible
1352 * @brief Gets the number of selected children.
1354 * @return The number of selected children (zero if none)
1356 virtual int GetSelectedChildrenCount() = 0;
1359 * @brief Gets a specific selected child.
1361 * @param selectedChildIndex The index of the selected child
1363 * @note @p selectedChildIndex refers to the list of selected children,
1364 * not the list of all children
1366 * @return The selected child or nullptr if index is invalid
1368 virtual Accessible* GetSelectedChild(int selectedChildIndex) = 0;
1371 * @brief Selects a child.
1373 * @param childIndex The index of the child
1375 * @return true on success, false otherwise
1377 virtual bool SelectChild(int childIndex) = 0;
1380 * @brief Deselects a selected child.
1382 * @param selectedChildIndex The index of the selected child
1384 * @note @p selectedChildIndex refers to the list of selected children,
1385 * not the list of all children
1387 * @return true on success, false otherwise
1389 * @see Dali::Accessibility::Selection::DeselectChild
1391 virtual bool DeselectSelectedChild(int selectedChildIndex) = 0;
1394 * @brief Checks whether a child is selected.
1396 * @param childIndex The index of the child
1398 * @return true if given child is selected, false otherwise
1400 virtual bool IsChildSelected(int childIndex) = 0;
1403 * @brief Selects all children.
1405 * @return true on success, false otherwise
1407 virtual bool SelectAll() = 0;
1410 * @brief Deselects all children.
1412 * @return true on success, false otherwise
1414 virtual bool ClearSelection() = 0;
1417 * @brief Deselects a child.
1419 * @param childIndex The index of the child.
1421 * @return true on success, false otherwise
1423 * @see Dali::Accessibility::Selection::DeselectSelectedChild
1425 virtual bool DeselectChild(int childIndex) = 0;
1429 * @brief The minimalistic, always empty Accessible object with settable address.
1431 * For those situations, where you want to return address in different bridge
1432 * (embedding for example), but the object itself ain't planned to be used otherwise.
1433 * This object has null parent, no children, empty name and so on
1435 class DALI_ADAPTOR_API EmptyAccessibleWithAddress : public virtual Accessible
1438 EmptyAccessibleWithAddress() = default;
1440 EmptyAccessibleWithAddress(Address address)
1441 : mAddress(std::move(address))
1445 void SetAddress(Address address)
1447 this->mAddress = std::move(address);
1450 std::string GetName() override
1455 std::string GetDescription() override
1460 Accessible* GetParent() override
1465 size_t GetChildCount() override
1470 std::vector<Accessible*> GetChildren() override
1475 Accessible* GetChildAtIndex(size_t index) override
1477 throw std::domain_error{"out of bounds index (" + std::to_string(index) + ") - no children"};
1480 size_t GetIndexInParent() override
1482 return static_cast<size_t>(-1);
1485 Role GetRole() override
1490 std::string GetRoleName() override;
1492 States GetStates() override
1497 Attributes GetAttributes() override
1502 Address GetAddress() override
1507 bool DoGesture(const GestureInfo& gestureInfo) override
1512 std::vector<Relation> GetRelationSet() override
1517 Dali::Actor GetInternalActor() override
1519 return Dali::Actor{};
1526 } // namespace Accessibility
1529 #endif // DALI_INTERNAL_ATSPI_ACCESSIBILITY_IMPL_H