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;
54 * @brief Base class for different accessibility bridges.
56 * Bridge is resposible for initializing and managing connection on accessibility bus.
57 * Accessibility clients will not get any information about UI without initialized and upraised bridge.
58 * Concrete implementation depends on the accessibility technology available on the platform.
60 * @note This class is singleton.
62 struct DALI_ADAPTOR_API Bridge
64 enum class ForceUpResult
73 virtual ~Bridge() = default;
76 * @brief Gets bus name which bridge is initialized on.
78 * @return The bus name
80 virtual const std::string& GetBusName() const = 0;
83 * @brief Registers top level window.
85 * Hierarchy of objects visible for accessibility clients is based on tree-like
86 * structure created from Actors objects. This method allows to connect chosen
87 * object as direct ancestor of application and therefore make it visible for
88 * accessibility clients.
90 * @param[in] object The accessible object
92 virtual void AddTopLevelWindow(Accessible* object) = 0;
95 * @brief Removes top level window.
97 * Hierarchy of objects visible for accessibility clients is based on tree-like
98 * structure created from Actors objects. This method removes previously added
99 * window from visible accessibility objects.
101 * @param[in] object The accessible object
103 virtual void RemoveTopLevelWindow(Accessible* object) = 0;
106 * @brief Adds popup window.
108 * Hierarchy of objects visible for accessibility clients is based on tree-like
109 * structure created from Actors objects. This method adds new popup to the tree.
111 * @param[in] object The accessible object
113 virtual void AddPopup(Accessible* object) = 0;
116 * @brief Removes popup window.
118 * Hierarchy of objects visible for accessibility clients is based on tree-like
119 * structure created from Actors objects. This method removes previously added
122 * @param[in] object The accessible object
124 virtual void RemovePopup(Accessible* object) = 0;
127 * @brief Sets name of current application which will be visible on accessibility bus.
129 * @param[in] name The application name
131 virtual void SetApplicationName(std::string name) = 0;
134 * @brief Gets object being root of accessibility tree.
136 * @return handler to accessibility object
138 virtual Accessible* GetApplication() const = 0;
141 * @brief Finds an object in accessibility tree.
143 * @param[in] path The path to object
145 * @return The handler to accessibility object
147 virtual Accessible* FindByPath(const std::string& path) const = 0;
150 * @brief Notifies accessibility dbus that window has just been shown.
152 * @param[in] window The window to be shown
154 virtual void WindowShown(Window window) = 0;
157 * @brief Notifies accessibility dbus that window has just been hidden.
159 * @param[in] window The window to be hidden
161 virtual void WindowHidden(Window window) = 0;
164 * @brief Notifies accessibility dbus that window has just been focused.
166 * @param[in] window The window to be focused
168 virtual void WindowFocused(Window window) = 0;
171 * @brief Notifies accessibility dbus that window has just been out of focus.
173 * @param[in] window The window to be out of focus
175 virtual void WindowUnfocused(Window window) = 0;
178 * @brief Initializes accessibility bus.
180 virtual void Initialize() = 0;
183 * @brief Terminates accessibility bus.
185 virtual void Terminate() = 0;
188 * @brief This method is called, when bridge is being activated.
190 virtual ForceUpResult ForceUp()
194 return ForceUpResult::ALREADY_UP;
196 mData = std::make_shared<Data>();
197 mData->mBridge = this;
198 return ForceUpResult::JUST_STARTED;
202 * @brief This method is called, when bridge is being deactivated.
204 virtual void ForceDown() = 0;
207 * @brief Checks if bridge is activated or not.
208 * @return True if brige is activated.
216 * @brief Emits cursor-moved event on at-spi bus.
218 * @param[in] obj The accessible object
219 * @param[in] cursorPosition The new cursor position
221 virtual void EmitCursorMoved(Accessible* obj, unsigned int cursorPosition) = 0;
224 * @brief Emits active-descendant-changed event on at-spi bus.
226 * @param[in] obj The accessible object
227 * @param[in] child The child of the object
229 virtual void EmitActiveDescendantChanged(Accessible* obj, Accessible* child) = 0;
232 * @brief Emits text-changed event on at-spi bus.
234 * @param[in] obj The accessible object
235 * @param[in] state The changed state for text, such as Inserted or Deleted
236 * @param[in] position The cursor position
237 * @param[in] length The text length
238 * @param[in] content The changed text
240 virtual void EmitTextChanged(Accessible* obj, TextChangedState state, unsigned int position, unsigned int length, const std::string& content) = 0;
243 * @brief Emits MoveOuted event on at-spi bus.
245 * @param[in] obj Accessible object
246 * @param[in] type Direction type when an Accessible object moves out of screen
248 virtual void EmitMovedOutOfScreen(Accessible* obj, ScreenRelativeMoveType type) = 0;
251 * @brief Emits state-changed event on at-spi bus.
253 * @param[in] obj The accessible object
254 * @param[in] state The accessibility state (SHOWING, HIGHLIGHTED, etc)
255 * @param[in] newValue Whether the state value is changed to new value or not.
256 * @param[in] reserved Reserved. (Currently, this argument is not implemented in dali)
258 virtual void EmitStateChanged(Accessible* obj, State state, int newValue, int reserved = 0) = 0;
261 * @brief Emits window event on at-spi bus.
263 * @param[in] obj The accessible object
264 * @param[in] event The enumerated window event
265 * @param[in] detail The additional parameter which interpretation depends on chosen event
267 virtual void Emit(Accessible* obj, WindowEvent event, unsigned int detail = 0) = 0;
270 * @brief Emits property-changed event on at-spi bus.
272 * @param[in] obj The accessible object
273 * @param[in] event Property changed event
275 virtual void Emit(Accessible* obj, ObjectPropertyChangeEvent event) = 0;
278 * @brief Emits bounds-changed event on at-spi bus.
280 * @param[in] obj The accessible object
281 * @param[in] rect The rectangle for changed bounds
283 virtual void EmitBoundsChanged(Accessible* obj, Rect<> rect) = 0;
286 * @brief Emits key event on at-spi bus.
288 * Screen-reader might receive this event and reply, that given keycode is consumed. In that case
289 * further processing of the keycode should be ignored.
291 * @param[in] type Key event type
292 * @param[in] keyCode Key code
293 * @param[in] keyName Key name
294 * @param[in] timeStamp Time stamp
295 * @param[in] isText Whether it's text or not
296 * @return Whether this event is consumed or not
298 virtual Consumed Emit(KeyEventType type, unsigned int keyCode, const std::string& keyName, unsigned int timeStamp, bool isText) = 0;
301 * @brief Reads given text by screen reader
303 * @param[in] text The text to read
304 * @param[in] discardable If TRUE, reading can be discarded by subsequent reading requests,
305 * if FALSE the reading must finish before next reading request can be started
306 * @param[in] callback the callback function that is called on reading signals emitted
307 * during processing of this reading request.
308 * Callback can be one of the following signals:
309 * ReadingCancelled, ReadingStopped, ReadingSkipped
311 virtual void Say(const std::string& text, bool discardable, std::function<void(std::string)> callback) = 0;
314 * @brief Force accessibility client to pause.
316 virtual void Pause() = 0;
319 * @brief Force accessibility client to resume.
321 virtual void Resume() = 0;
324 * @brief Cancels anything screen-reader is reading / has queued to read
326 * @param[in] alsoNonDiscardable whether to cancel non-discardable readings as well
328 virtual void StopReading(bool alsoNonDiscardable) = 0;
331 * @brief Suppresses reading of screen-reader
333 * @param[in] suppress whether to suppress reading of screen-reader
335 virtual void SuppressScreenReader(bool suppress) = 0;
338 * @brief Gets screen reader status.
340 * @return True if screen reader is enabled
342 virtual bool GetScreenReaderEnabled() = 0;
345 * @brief Gets ATSPI status.
347 * @return True if ATSPI is enabled
349 virtual bool IsEnabled() = 0;
352 * @brief Returns instance of bridge singleton object.
354 * @return The current bridge object
356 static Bridge* GetCurrentBridge();
359 * @brief Blocks auto-initialization of AT-SPI bridge
361 * Use this only if your application starts before DBus does, and call it early in main()
362 * (before GetCurrentBridge() is called by anyone). GetCurrentBridge() will then return an
363 * instance of DummyBridge.
365 * When DBus is ready, call EnableAutoInit(). Please note that GetCurrentBridge() may still
366 * return an instance of DummyBridge if AT-SPI was disabled at compile time or using an
367 * environment variable, or if creating the real bridge failed.
369 * @see Dali::Accessibility::DummyBridge
370 * @see Dali::Accessibility::Bridge::EnableAutoInit
372 static void DisableAutoInit();
375 * @brief Re-enables auto-initialization of AT-SPI bridge
377 * Normal applications do not have to call this function. GetCurrentBridge() tries to
378 * initialize the AT-SPI bridge when it is called for the first time.
380 * @see Dali::Accessibility::Bridge::DisableAutoInit
381 * @see Dali::Accessibility::Bridge::AddTopLevelWindow
382 * @see Dali::Accessibility::Bridge::SetApplicationName
384 static void EnableAutoInit();
386 static Signal<void()>& EnabledSignal()
388 return mEnabledSignal;
391 static Signal<void()>& DisabledSignal()
393 return mDisabledSignal;
399 std::unordered_set<Accessible*> mKnownObjects;
400 std::string mBusName;
401 Bridge* mBridge = nullptr;
402 Actor mHighlightActor;
403 Actor mCurrentlyHighlightedActor;
405 std::shared_ptr<Data> mData;
406 friend class Accessible;
408 enum class AutoInitState
414 inline static AutoInitState mAutoInitState = AutoInitState::ENABLED;
416 inline static Signal<void()> mEnabledSignal;
417 inline static Signal<void()> mDisabledSignal;
420 * @brief Registers accessible object to be known in bridge object.
422 * Bridge must known about all currently alive accessible objects, as some requst
423 * might come and object will be identified by number id (it's memory address).
424 * To avoid memory corruption number id is checked against set of known objects.
426 * @param[in] object The accessible object
428 void RegisterOnBridge(Accessible* object);
431 * @brief Tells bridge, that given object is considered root (doesn't have any parents).
433 * All root objects will have the same parent - application object. Application object
434 * is controlled by bridge and private.
436 * @param[in] owner The accessible object
438 void SetIsOnRootLevel(Accessible* owner);
442 * @brief Checks if ATSPI is activated or not.
443 * @return True if ATSPI is activated.
447 if(Bridge::GetCurrentBridge() == nullptr)
452 if(Bridge::GetCurrentBridge()->IsEnabled() == false)
457 return Bridge::GetCurrentBridge()->IsUp();
461 * @brief Basic interface implemented by all accessibility objects.
466 virtual ~Accessible();
468 using utf8_t = unsigned char;
471 * @brief Calculates and finds word boundaries in given utf8 text.
473 * @param[in] string The source text to find
474 * @param[in] length The length of text to find
475 * @param[in] language The language to use
476 * @param[out] breaks The word boundaries in given text
478 * @note Word boundaries are returned as non-zero values in table breaks, which must be of size at least length.
480 void FindWordSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks);
483 * @brief Calculates and finds line boundaries in given utf8 text.
485 * @param[in] string The source text to find
486 * @param[in] length The length of text to find
487 * @param[in] language The language to use
488 * @param[out] breaks The line boundaries in given text
490 * @note Line boundaries are returned as non-zero values in table breaks, which must be of size at least length.
492 void FindLineSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks);
495 * @brief Helper function for emiting active-descendant-changed event.
497 * @param[in] obj The accessible object
498 * @param[in] child The child of the object
500 void EmitActiveDescendantChanged(Accessible* obj, Accessible* child);
503 * @brief Helper function for emiting state-changed event.
505 * @param[in] state The accessibility state (SHOWING, HIGHLIGHTED, etc)
506 * @param[in] newValue Whether the state value is changed to new value or not.
507 * @param[in] reserved Reserved. (TODO : Currently, this argument is not implemented in dali)
509 * @note The second argument determines which value is depending on State.
510 * For instance, if the state is PRESSED, newValue means isPressed or isSelected.
511 * If the state is SHOWING, newValue means isShowing.
513 void EmitStateChanged(State state, int newValue, int reserved = 0);
516 * @brief Helper function for emiting bounds-changed event.
518 * @param rect The rectangle for changed bounds
520 void EmitBoundsChanged(Rect<> rect);
523 * @brief Emits "showing" event.
524 * The method informs accessibility clients about "showing" state.
526 * @param[in] isShowing The flag pointing if object is showing
528 void EmitShowing(bool isShowing);
531 * @brief Emits "visible" event.
532 * The method informs accessibility clients about "visible" state.
534 * @param[in] isVisible The flag pointing if object is visible
536 void EmitVisible(bool isVisible);
539 * @brief Emits "highlighted" event.
540 * The method informs accessibility clients about "highlighted" state.
542 * @param[in] isHighlighted The flag pointing if object is highlighted
544 void EmitHighlighted(bool isHighlighted);
547 * @brief Emits "focused" event.
548 * The method informs accessibility clients about "focused" state.
550 * @param[in] isFocused The flag pointing if object is focused
552 void EmitFocused(bool isFocused);
555 * @brief Emits "text inserted" event.
557 * @param[in] position The cursor position
558 * @param[in] length The text length
559 * @param[in] content The inserted text
561 void EmitTextInserted(unsigned int position, unsigned int length, const std::string& content);
564 * @brief Emits "text deleted" event.
566 * @param[in] position The cursor position
567 * @param[in] length The text length
568 * @param[in] content The deleted text
570 void EmitTextDeleted(unsigned int position, unsigned int length, const std::string& content);
573 * @brief Emits "cursor moved" event.
575 * @param[in] cursorPosition The new cursor position
577 void EmitTextCursorMoved(unsigned int cursorPosition);
580 * @brief Emits "MoveOuted" event.
582 * @param[in] type moved out of screen type
584 void EmitMovedOutOfScreen(ScreenRelativeMoveType type);
587 * @brief Emits "highlighted" event.
589 * @param[in] event The enumerated window event
590 * @param[in] detail The additional parameter which interpretation depends on chosen event
592 void Emit(WindowEvent event, unsigned int detail = 0);
595 * @brief Emits property-changed event.
597 * @param[in] event Property changed event
599 void Emit(ObjectPropertyChangeEvent event);
602 * @brief Gets accessibility name.
604 * @return The string with name
606 virtual std::string GetName() = 0;
609 * @brief Gets accessibility description.
611 * @return The string with description
613 virtual std::string GetDescription() = 0;
616 * @brief Gets parent.
618 * @return The handler to accessibility object
620 virtual Accessible* GetParent() = 0;
623 * @brief Gets the number of children.
625 * @return The number of children
627 virtual size_t GetChildCount() = 0;
630 * @brief Gets collection with all children.
632 * @return The collection of accessibility objects
634 virtual std::vector<Accessible*> GetChildren();
637 * @brief Gets child of the index.
639 * @return The child object
641 virtual Accessible* GetChildAtIndex(size_t index) = 0;
644 * @brief Gets index that current object has in its parent's children collection.
646 * @return The index of the current object
648 virtual size_t GetIndexInParent() = 0;
651 * @brief Gets accessibility role.
653 * @return Role enumeration
655 * @see Dali::Accessibility::Role
657 virtual Role GetRole() = 0;
660 * @brief Gets name of accessibility role.
662 * @return The string with human readable role converted from enumeration
664 * @see Dali::Accessibility::Role
665 * @see Accessibility::Accessible::GetRole
667 virtual std::string GetRoleName();
670 * @brief Gets localized name of accessibility role.
672 * @return The string with human readable role translated according to current
675 * @see Dali::Accessibility::Role
676 * @see Accessibility::Accessible::GetRole
677 * @see Accessibility::Accessible::GetRoleName
679 * @note translation is not supported in this version
681 virtual std::string GetLocalizedRoleName();
684 * @brief Gets accessibility states.
686 * @return The collection of states
688 * @note States class is instatation of ArrayBitset template class
690 * @see Dali::Accessibility::State
691 * @see Dali::Accessibility::ArrayBitset
693 virtual States GetStates() = 0;
696 * @brief Gets accessibility attributes.
698 * @return The map of attributes and their values
700 virtual Attributes GetAttributes() = 0;
703 * @brief Checks if this is proxy.
705 * @return True if this is proxy
707 virtual bool IsProxy();
710 * @brief Gets unique address on accessibility bus.
712 * @return The Address class containing address
714 * @see Dali::Accessibility::Address
716 virtual Address GetAddress();
719 * @brief Gets accessibility object, which is "default label" for this object.
721 * @return The Accessible object
723 virtual Accessible* GetDefaultLabel();
726 * @brief Deputes an object to perform provided gesture.
728 * @param[in] gestureInfo The structure describing the gesture
730 * @return true on success, false otherwise
732 * @see Dali::Accessibility::GestureInfo
734 virtual bool DoGesture(const GestureInfo& gestureInfo) = 0;
737 * @brief Re-emits selected states of an Accessibility Object.
739 * @param[in] states The chosen states to re-emit
740 * @param[in] isRecursive If true, all children of the Accessibility object will also re-emit the states
742 void NotifyAccessibilityStateChange(Dali::Accessibility::States states, bool isRecursive);
745 * @brief Gets information about current object and all relations that connects
746 * it with other accessibility objects.
748 * @return The iterable collection of Relation objects
750 * @see Dali::Accessibility::Relation
752 virtual std::vector<Relation> GetRelationSet() = 0;
755 * @brief Gets internal Actor to be saved before.
757 * @return The internal Actor
759 virtual Dali::Actor GetInternalActor() = 0;
762 * @brief Gets all implemented interfaces.
764 * @return The collection of strings with implemented interfaces
766 std::vector<std::string> GetInterfaces();
769 * @brief Checks if object is on root level.
771 * @return Whether object is on root level or not
773 bool IsOnRootLevel() const
775 return mIsOnRootLevel;
780 Accessible(const Accessible&) = delete;
781 Accessible(Accessible&&) = delete;
782 Accessible& operator=(const Accessible&) = delete;
783 Accessible& operator=(Accessible&&) = delete;
784 std::shared_ptr<Bridge::Data> GetBridgeData();
788 * @brief Gets the highlight actor.
790 * This method is to get the highlight itself.
791 * @return The highlight actor
793 static Dali::Actor GetHighlightActor();
796 * @brief Sets the highlight actor.
798 * This method is to set the highlight itself.
799 * @param[in] actor The highlight actor
801 static void SetHighlightActor(Dali::Actor actor);
804 * @brief Gets the currently highlighted actor.
806 * @return The current highlighted actor
808 static Dali::Actor GetCurrentlyHighlightedActor();
811 * @brief Sets currently highlighted actor.
813 * @param[in] actor The highlight actor
815 static void SetCurrentlyHighlightedActor(Dali::Actor actor);
818 * @brief Sets ObjectRegistry.
820 * @param[in] registry ObjectRegistry instance
822 static void SetObjectRegistry(ObjectRegistry registry);
825 * @brief The method registers functor resposible for converting Actor into Accessible.
826 * @param functor The returning Accessible handle from Actor object
828 static void RegisterExternalAccessibleGetter(std::function<Accessible*(Dali::Actor)> functor);
831 * @brief Acquires Accessible object from Actor object.
833 * @param[in] actor Actor object
834 * @param[in] isRoot True, if it's top level object (window)
836 * @return The handle to Accessible object
838 static Accessible* Get(Dali::Actor actor, bool isRoot = false);
843 std::weak_ptr<Bridge::Data> mBridgeData;
844 bool mIsOnRootLevel = false;
846 }; // Accessible class
849 * @brief Interface enabling to perform provided actions.
851 class Action : public virtual Accessible
855 * @brief Gets name of action with given index.
857 * @param[in] index The index of action
859 * @return The string with name of action
861 virtual std::string GetActionName(size_t index) = 0;
864 * @brief Gets translated name of action with given index.
866 * @param[in] index The index of action
868 * @return The string with name of action translated according to current translation domain
870 * @note The translation is not supported in this version
872 virtual std::string GetLocalizedActionName(size_t index) = 0;
875 * @brief Gets description of action with given index.
877 * @param[in] index The index of action
879 * @return The string with description of action
881 virtual std::string GetActionDescription(size_t index) = 0;
884 * @brief Gets key code binded to action with given index.
886 * @param[in] index The index of action
888 * @return The string with key name
890 virtual std::string GetActionKeyBinding(size_t index) = 0;
893 * @brief Gets number of provided actions.
895 * @return The number of actions
897 virtual size_t GetActionCount() = 0;
900 * @brief Performs an action with given index.
902 * @param index The index of action
904 * @return true on success, false otherwise
906 virtual bool DoAction(size_t index) = 0;
909 * @brief Performs an action with given name.
911 * @param name The name of action
913 * @return true on success, false otherwise
915 virtual bool DoAction(const std::string& name) = 0;
919 * @brief An interface identifying the root object
920 * associated with a running application.
922 * @note Provides global properties describing
923 * application's runtime environment.
925 class Application : public virtual Accessible
929 * @brief Gets name of graphic user interface framework used by an application.
931 * @return String with name
933 virtual std::string GetToolkitName() = 0;
936 * @brief Gets version of graphic user interface framework used by an application.
938 * @return String with version
940 virtual std::string GetVersion() = 0;
944 * @brief Interface enabling advanced quering of accessibility objects.
946 * @note since all mathods can be implemented inside bridge,
947 * none methods have to be overrided
949 class Collection : public virtual Accessible
955 * @brief Interface representing objects having screen coordinates.
957 class Component : public virtual Accessible
961 * @brief Gets rectangle describing size.
963 * @param[in] type The enumeration with type of coordinate systems
965 * @return Rect<> object
969 virtual Rect<> GetExtents(CoordinateType type) = 0;
972 * @brief Gets layer current object is localized on.
974 * @return The enumeration pointing layer
976 * @see Dali::Accessibility::ComponentLayer
978 virtual ComponentLayer GetLayer() = 0;
981 * @brief Gets value of z-order.
983 * @return The value of z-order
984 * @remarks MDI means "Multi Document Interface" (https://en.wikipedia.org/wiki/Multiple-document_interface)
985 * which in short means that many stacked windows can be displayed within a single application.
986 * In such model, the concept of z-order of UI element became important to deal with element overlapping.
988 virtual int16_t GetMdiZOrder() = 0;
991 * @brief Sets current object as "focused".
993 * @return true on success, false otherwise
995 virtual bool GrabFocus() = 0;
998 * @brief Gets value of alpha channel.
1000 * @return The alpha channel value in range [0.0, 1.0]
1002 virtual double GetAlpha() = 0;
1005 * @brief Sets current object as "highlighted".
1007 * The method assings "highlighted" state, simultaneously removing it
1008 * from currently highlighted object.
1010 * @return true on success, false otherwise
1012 virtual bool GrabHighlight() = 0;
1015 * @brief Sets current object as "unhighlighted".
1017 * The method removes "highlighted" state from object.
1019 * @return true on success, false otherwise
1021 * @see Dali:Accessibility::State
1023 virtual bool ClearHighlight() = 0;
1026 * @brief Checks whether object can be scrolled.
1028 * @return true if object is scrollable, false otherwise
1030 * @see Dali:Accessibility::State
1032 virtual bool IsScrollable();
1035 * @brief Gets Accessible object containing given point.
1037 * @param[in] point The two-dimensional point
1038 * @param[in] type The enumeration with type of coordinate system
1040 * @return The handle to last child of current object which contains given point
1042 * @see Dali::Accessibility::Point
1044 virtual Accessible* GetAccessibleAtPoint(Point point, CoordinateType type);
1047 * @brief Checks if the current object contains the given point inside.
1049 * @param[in] point The two-dimensional point
1050 * @param[in] type The enumeration with type of coordinate system
1052 * @return True if accessible contains in point, otherwise false.
1054 * @remarks This method is `Contains` in DBus method.
1055 * @see Dali::Accessibility::Point
1057 virtual bool IsAccessibleContainingPoint(Point point, CoordinateType type);
1061 * @brief Interface representing objects which can store numeric value.
1063 class Value : public virtual Accessible
1067 * @brief Gets the lowest possible value.
1069 * @return The minimum value
1071 virtual double GetMinimum() = 0;
1074 * @brief Gets the current value.
1076 * @return The current value
1078 virtual double GetCurrent() = 0;
1081 * @brief Gets the highest possible value.
1083 * @return The highest value.
1085 virtual double GetMaximum() = 0;
1088 * @brief Sets the current value.
1090 * @param[in] value The current value to set
1092 * @return true if value could have been assigned, false otherwise
1094 virtual bool SetCurrent(double value) = 0;
1097 * @brief Gets the lowest increment that can be distinguished.
1099 * @return The lowest increment
1101 virtual double GetMinimumIncrement() = 0;
1105 * @brief Interface representing objects which can store immutable texts.
1107 * @see Dali::Accessibility::EditableText
1109 class DALI_ADAPTOR_API Text : public virtual Accessible
1113 * @brief Gets stored text in given range.
1115 * @param[in] startOffset The index of first character
1116 * @param[in] endOffset The index of first character after the last one expected
1118 * @return The substring of stored text
1120 virtual std::string GetText(size_t startOffset, size_t endOffset) = 0;
1123 * @brief Gets number of all stored characters.
1125 * @return The number of characters
1126 * @remarks This method is `CharacterCount` in DBus method.
1128 virtual size_t GetCharacterCount() = 0;
1131 * @brief Gets the cursor offset.
1133 * @return Value of cursor offset
1134 * @remarks This method is `CaretOffset` in DBus method.
1136 virtual size_t GetCursorOffset() = 0;
1139 * @brief Sets the cursor offset.
1141 * @param[in] offset Cursor offset
1143 * @return True if successful
1144 * @remarks This method is `SetCaretOffset` in DBus method.
1146 virtual bool SetCursorOffset(size_t offset) = 0;
1149 * @brief Gets substring of stored text truncated in concrete gradation.
1151 * @param[in] offset The position in stored text
1152 * @param[in] boundary The enumeration describing text gradation
1154 * @return Range structure containing acquired text and offsets in original string
1156 * @see Dali::Accessibility::Range
1158 virtual Range GetTextAtOffset(size_t offset, TextBoundary boundary) = 0;
1161 * @brief Gets selected text.
1163 * @param[in] selectionIndex The selection index
1164 * @note Currently only one selection (i.e. with index = 0) is supported
1166 * @return Range structure containing acquired text and offsets in original string
1168 * @remarks This method is `GetSelection` in DBus method.
1169 * @see Dali::Accessibility::Range
1171 virtual Range GetRangeOfSelection(size_t selectionIndex) = 0;
1174 * @brief Removes the whole selection.
1176 * @param[in] selectionIndex The selection index
1177 * @note Currently only one selection (i.e. with index = 0) is supported
1179 * @return bool on success, false otherwise
1181 virtual bool RemoveSelection(size_t selectionIndex) = 0;
1184 * @brief Sets selected text.
1186 * @param[in] selectionIndex The selection index
1187 * @param[in] startOffset The index of first character
1188 * @param[in] endOffset The index of first character after the last one expected
1190 * @note Currently only one selection (i.e. with index = 0) is supported
1192 * @return true on success, false otherwise
1193 * @remarks This method is `SetSelection` in DBus method.
1195 virtual bool SetRangeOfSelection(size_t selectionIndex, size_t startOffset, size_t endOffset) = 0;
1199 * @brief Interface representing objects which can store editable texts.
1201 * @note Paste method is entirely implemented inside bridge
1203 * @see Dali::Accessibility::EditableText
1205 class DALI_ADAPTOR_API EditableText : public virtual Accessible
1209 * @brief Copies text in range to system clipboard.
1211 * @param[in] startPosition The index of first character
1212 * @param[in] endPosition The index of first character after the last one expected
1214 * @return true on success, false otherwise
1216 virtual bool CopyText(size_t startPosition, size_t endPosition) = 0;
1219 * @brief Cuts text in range to system clipboard.
1221 * @param[in] startPosition The index of first character
1222 * @param[in] endPosition The index of first character after the last one expected
1224 * @return true on success, false otherwise
1226 virtual bool CutText(size_t startPosition, size_t endPosition) = 0;
1229 * @brief Deletes text in range.
1231 * @param[in] startPosition The index of first character
1232 * @param[in] endPosition The index of first character after the last one expected
1234 * @return true on success, false otherwise
1236 virtual bool DeleteText(size_t startPosition, size_t endPosition) = 0;
1239 * @brief Inserts text at startPosition.
1241 * @param[in] startPosition The index of first character
1242 * @param[in] text The text content
1244 * @return true on success, false otherwise
1246 virtual bool InsertText(size_t startPosition, std::string text) = 0;
1249 * @brief Replaces text with content.
1251 * @param[in] newContents The text content
1253 * @return true on success, false otherwise
1255 virtual bool SetTextContents(std::string newContents) = 0;
1259 * @brief Interface representing objects which can store a set of selected items.
1261 class DALI_ADAPTOR_API Selection : public virtual Accessible
1265 * @brief Gets the number of selected children.
1267 * @return The number of selected children (zero if none)
1269 virtual int GetSelectedChildrenCount() = 0;
1272 * @brief Gets a specific selected child.
1274 * @param selectedChildIndex The index of the selected child
1276 * @note @p selectedChildIndex refers to the list of selected children,
1277 * not the list of all children
1279 * @return The selected child or nullptr if index is invalid
1281 virtual Accessible* GetSelectedChild(int selectedChildIndex) = 0;
1284 * @brief Selects a child.
1286 * @param childIndex The index of the child
1288 * @return true on success, false otherwise
1290 virtual bool SelectChild(int childIndex) = 0;
1293 * @brief Deselects a selected child.
1295 * @param selectedChildIndex The index of the selected child
1297 * @note @p selectedChildIndex refers to the list of selected children,
1298 * not the list of all children
1300 * @return true on success, false otherwise
1302 * @see Dali::Accessibility::Selection::DeselectChild
1304 virtual bool DeselectSelectedChild(int selectedChildIndex) = 0;
1307 * @brief Checks whether a child is selected.
1309 * @param childIndex The index of the child
1311 * @return true if given child is selected, false otherwise
1313 virtual bool IsChildSelected(int childIndex) = 0;
1316 * @brief Selects all children.
1318 * @return true on success, false otherwise
1320 virtual bool SelectAll() = 0;
1323 * @brief Deselects all children.
1325 * @return true on success, false otherwise
1327 virtual bool ClearSelection() = 0;
1330 * @brief Deselects a child.
1332 * @param childIndex The index of the child.
1334 * @return true on success, false otherwise
1336 * @see Dali::Accessibility::Selection::DeselectSelectedChild
1338 virtual bool DeselectChild(int childIndex) = 0;
1342 * @brief The minimalistic, always empty Accessible object with settable address.
1344 * For those situations, where you want to return address in different bridge
1345 * (embedding for example), but the object itself ain't planned to be used otherwise.
1346 * This object has null parent, no children, empty name and so on
1348 class DALI_ADAPTOR_API EmptyAccessibleWithAddress : public virtual Accessible
1351 EmptyAccessibleWithAddress() = default;
1353 EmptyAccessibleWithAddress(Address address)
1354 : mAddress(std::move(address))
1358 void SetAddress(Address address)
1360 this->mAddress = std::move(address);
1363 std::string GetName() override
1368 std::string GetDescription() override
1373 Accessible* GetParent() override
1378 size_t GetChildCount() override
1383 std::vector<Accessible*> GetChildren() override
1388 Accessible* GetChildAtIndex(size_t index) override
1390 throw std::domain_error{"out of bounds index (" + std::to_string(index) + ") - no children"};
1393 size_t GetIndexInParent() override
1395 return static_cast<size_t>(-1);
1398 Role GetRole() override
1403 std::string GetRoleName() override;
1405 States GetStates() override
1410 Attributes GetAttributes() override
1415 Address GetAddress() override
1420 bool DoGesture(const GestureInfo& gestureInfo) override
1425 std::vector<Relation> GetRelationSet() override
1430 Dali::Actor GetInternalActor() override
1432 return Dali::Actor{};
1439 } // namespace Accessibility
1442 #endif // DALI_INTERNAL_ATSPI_ACCESSIBILITY_IMPL_H