1 #ifndef DALI_ATSPI_ACCESSIBILITY_H
\r
2 #define DALI_ATSPI_ACCESSIBILITY_H
\r
4 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
\r
6 * Licensed under the Apache License, Version 2.0 (the "License");
\r
7 * you may not use this file except in compliance with the License.
\r
8 * You may obtain a copy of the License at
\r
10 * http://www.apache.org/licenses/LICENSE-2.0
\r
12 * Unless required by applicable law or agreed to in writing, software
\r
13 * distributed under the License is distributed on an "AS IS" BASIS,
\r
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
15 * See the License for the specific language governing permissions and
\r
16 * limitations under the License.
\r
20 // EXTERNAL INCLUDES
\r
27 #include <exception>
\r
28 #include <functional>
\r
34 #include <unordered_map>
\r
37 // INTERNAL INCLUDES
\r
38 #include <dali/public-api/dali-adaptor-common.h>
\r
42 namespace Accessibility
\r
45 * @brief Enumeration describing type of object move relative to the screen. Only outgoing moves are signalled to AT-clients.
\r
47 enum class ScreenRelativeMoveType
\r
49 OUTSIDE = 0, ///< Object moves outside of the screen
\r
50 OUTGOING_TOP_LEFT = 1, ///< Object moves out through the top(or left) side of the screen. Maps to: ATSPI_MOVE_OUTED_TOP_LEFT
\r
51 OUTGOING_BOTTOM_RIGHT = 2, ///< Object moves out through the bottom(or right) side of the screen. Maps to: ATSPI_MOVE_OUTED_BOTTOM_RIGHT
\r
52 INSIDE ///< Object moves into the screen or moves inside the screen
\r
56 * @brief Enumeration describing a relation between accessible objects
\r
57 * 1 to 0..N relation model is supported. By default relation is not symmetrical.
\r
58 * Symmetry must be explicitly maintained.
\r
60 enum class RelationType : uint32_t
\r
62 NULL_OF, ///< Null Relation.
\r
63 LABEL_FOR, ///< Label For.
\r
64 LABELLED_BY, ///< Labelled By.
\r
65 CONTROLLER_FOR, ///< Controller For.
\r
66 CONTROLLED_BY, ///< Controlled By.
\r
67 MEMBER_OF, ///< Member Of.
\r
68 TOOLTIP_FOR, ///< ToolTip For.
\r
69 NODE_CHILD_OF, ///< Node Child Of.
\r
70 NODE_PARENT_OF, ///< Node Parent Of.
\r
71 EXTENDED, ///< Extended.
\r
72 FLOWS_TO, ///< Flows To.
\r
73 FLOWS_FROM, ///< Flows From.
\r
74 SUBWINDOW_OF, ///< Sub Window Of.
\r
75 EMBEDS, ///< Embeds.
\r
76 EMBEDDED_BY, ///< Embedded By.
\r
77 POPUP_FOR, ///< Popup For
\r
78 PARENT_WINDOW_OF, ///< Parent Window Of.
\r
79 DESCRIPTION_FOR, ///< Description For.
\r
80 DESCRIBED_BY, ///< Described By.
\r
81 DETAILS, ///< Details.
\r
82 DETAILS_FOR, ///< Details For.
\r
83 ERROR_MESSAGE, ///< Error Message.
\r
84 ERROR_FOR, ///< Error For.
\r
89 * @brief Enumeration describing if coordinates are relative to screen or window
\r
90 * @see Accessibility::Component::GetExtents
\r
91 * @see Accessibility::Component::IsAccessibleContainingPoint
\r
93 enum class CoordinateType
\r
95 SCREEN, ///< Screen.
\r
100 * @brief Enumeration indicating relative stacking order
\r
101 * ComponentLayer allows to describe visibility of all parts of UI
\r
102 * basing on the concrete stacking order
\r
103 * @see Accessibility::Component::GetLayer
\r
104 * @note currently only ComponentLayer::Window is supported
\r
106 enum class ComponentLayer
\r
108 INVALID, ///< Invalid.
\r
109 BACKGROUND, ///< Background.
\r
110 CANVAS, ///< Canvas.
\r
111 WIDGET, ///< Widget.
\r
114 OVERLAY, ///< Overlay.
\r
115 WINDOW, ///< Window.
\r
120 * @brief Enumeration describing role of the Accessibility object
\r
121 * Object can be described by only one role.
\r
122 * @see Accessibility::Accessible::GetRole
\r
124 enum class Role : uint32_t
\r
183 TABLE_COLUMN_HEADER,
\r
215 INPUT_METHOD_WINDOW,
\r
218 DOCUMENT_SPREADSHEET,
\r
219 DOCUMENT_PRESENTATION,
\r
251 * @brief Enumeration describing states of the Accessibility object
\r
252 * Object can be in many states at the same time.
\r
253 * @see Accessibility::Accessible::GetStates
\r
255 enum class State : uint32_t
\r
288 MANAGES_DESCENDANTS,
\r
294 SUPPORTS_AUTOCOMPLETION,
\r
307 * @brief Enumeration describing change of text object
\r
309 enum class TextChangedState : uint32_t
\r
317 * @brief Enumeration describing change of object property
\r
319 enum class ObjectPropertyChangeEvent
\r
329 * @brief Enumeration describing change of window object
\r
330 * @see Accessibility::Accessible::Emit
\r
332 enum class WindowEvent
\r
356 * @brief Enumeration used to acquire bounded text from accessible object having textual content.
\r
357 * @see Accessibility::Text::GetTextAtOffset
\r
358 * @note Currently only TextBoundary::Character is supported
\r
360 enum class TextBoundary : uint32_t
\r
362 CHARACTER, ///> Only one character is acquired.
\r
363 WORD, ///> Not supported.
\r
364 SENTENCE, ///> Not supported.
\r
365 LINE, ///> Not supported.
\r
366 PARAGRAPH, ///> Not supported.
\r
371 * @brief Enumeration describing type of gesture
\r
372 * @see Accessibility::Accessible::DoGesture
\r
374 enum class Gesture : int32_t
\r
378 THREE_FINGER_HOVER,
\r
379 ONE_FINGER_FLICK_LEFT,
\r
380 ONE_FINGER_FLICK_RIGHT,
\r
381 ONE_FINGER_FLICK_UP,
\r
382 ONE_FINGER_FLICK_DOWN,
\r
383 TWO_FINGERS_FLICK_LEFT,
\r
384 TWO_FINGERS_FLICK_RIGHT,
\r
385 TWO_FINGERS_FLICK_UP,
\r
386 TWO_FINGERS_FLICK_DOWN,
\r
387 THREE_FINGERS_FLICK_LEFT,
\r
388 THREE_FINGERS_FLICK_RIGHT,
\r
389 THREE_FINGERS_FLICK_UP,
\r
390 THREE_FINGERS_FLICK_DOWN,
\r
391 ONE_FINGER_SINGLE_TAP,
\r
392 ONE_FINGER_DOUBLE_TAP,
\r
393 ONE_FINGER_TRIPLE_TAP,
\r
394 TWO_FINGERS_SINGLE_TAP,
\r
395 TWO_FINGERS_DOUBLE_TAP,
\r
396 TWO_FINGERS_TRIPLE_TAP,
\r
397 THREE_FINGERS_SINGLE_TAP,
\r
398 THREE_FINGERS_DOUBLE_TAP,
\r
399 THREE_FINGERS_TRIPLE_TAP,
\r
400 ONE_FINGER_FLICK_LEFT_RETURN,
\r
401 ONE_FINGER_FLICK_RIGHT_RETURN,
\r
402 ONE_FINGER_FLICK_UP_RETURN,
\r
403 ONE_FINGER_FLICK_DOWN_RETURN,
\r
404 TWO_FINGERS_FLICK_LEFT_RETURN,
\r
405 TWO_FINGERS_FLICK_RIGHT_RETURN,
\r
406 TWO_FINGERS_FLICK_UP_RETURN,
\r
407 TWO_FINGERS_FLICK_DOWN_RETURN,
\r
408 THREE_FINGERS_FLICK_LEFT_RETURN,
\r
409 THREE_FINGERS_FLICK_RIGHT_RETURN,
\r
410 THREE_FINGERS_FLICK_UP_RETURN,
\r
411 THREE_FINGERS_FLICK_DOWN_RETURN,
\r
412 ONE_FINGER_DOUBLE_TAP_N_HOLD,
\r
413 TWO_FINGERS_DOUBLE_TAP_N_HOLD,
\r
414 THREE_FINGERS_DOUBLE_TAP_N_HOLD,
\r
419 * @brief Enumeration indicating current state of gesture
\r
420 * @see Dali::Accessibility::GestureInfo
\r
422 enum class GestureState : int32_t
\r
431 * @brief Enumeration of ReadingInfoType
\r
433 enum class ReadingInfoType
\r
442 * @brief Helper class for storing values treated as bit sets
\r
443 * This class provides all bitset-like methods for bitset size larger, than long long int
\r
444 * @see Dali::Accessibility::Accessible::GetStates
\r
445 * @see Dali::Accessibility::Accessible::GetRoles
\r
447 template<size_t I, typename S>
\r
450 std::array<uint32_t, I> mData;
\r
456 static constexpr bool Accepts()
\r
461 template<typename T>
\r
462 static constexpr bool Accepts()
\r
464 return std::is_enum<T>::value;
\r
467 template<typename T, typename T2, typename... ARGS>
\r
468 static constexpr bool Accepts()
\r
470 return std::is_enum<T>::value && Accepts<T2, ARGS...>();
\r
473 template<typename T, typename... ARGS>
\r
474 void Set(T t, ARGS... args)
\r
483 for(auto& u : mData)
\r
488 BitSets(const BitSets&) = default;
\r
489 BitSets(BitSets&&) = default;
\r
491 template<typename T, typename... ARGS, typename std::enable_if<Accepts<T, ARGS...>()>::type* = nullptr>
\r
492 BitSets(T t, ARGS... args)
\r
494 for(auto& u : mData)
\r
501 explicit BitSets(std::array<uint32_t, I> d)
\r
503 for(auto i = 0u; i < I; ++i)
\r
509 explicit BitSets(std::array<int32_t, I> d)
\r
511 for(auto i = 0u; i < I; ++i)
\r
513 mData[i] = static_cast<uint32_t>(d[i]);
\r
517 BitSets& operator=(const BitSets&) = default;
\r
518 BitSets& operator=(BitSets&&) = default;
\r
522 std::array<uint32_t, I>& data;
\r
525 Reference& operator=(Reference r)
\r
527 (*this) = static_cast<bool>(r);
\r
531 Reference& operator=(bool v)
\r
535 data[pos / 32] |= 1 << (pos & 31);
\r
539 data[pos / 32] &= ~(1 << (pos & 31));
\r
544 operator bool() const
\r
546 auto i = static_cast<size_t>(pos);
\r
547 return (data[i / 32] & (1 << (i & 31))) != 0;
\r
549 }; // Reference struct
\r
551 Reference operator[](S index)
\r
553 return {mData, static_cast<size_t>(index)};
\r
556 bool operator[](S index) const
\r
558 auto i = static_cast<size_t>(index);
\r
559 return (mData[i / 32] & (1 << (i & 31))) != 0;
\r
562 std::array<uint32_t, I> GetRawData() const
\r
567 BitSets operator|(BitSets b) const
\r
570 for(auto i = 0u; i < I; ++i)
\r
572 r.mData[i] = mData[i] | b.mData[i];
\r
577 BitSets operator^(BitSets b) const
\r
580 for(auto i = 0u; i < I; ++i)
\r
582 r.mData[i] = mData[i] ^ b.mData[i];
\r
587 BitSets operator&(BitSets b) const
\r
590 for(auto i = 0u; i < I; ++i)
\r
592 r.mData[i] = mData[i] & b.mData[i];
\r
597 bool operator==(BitSets b) const
\r
599 for(auto i = 0u; i < I; ++i)
\r
601 if(mData[i] != b.mData[i])
\r
609 bool operator!=(BitSets b) const
\r
611 return !((*this) == b);
\r
614 explicit operator bool() const
\r
616 for(auto& u : mData)
\r
626 size_t size() const
\r
630 }; // BitSets class
\r
632 using ReadingInfoTypes = BitSets<1, ReadingInfoType>;
\r
633 using States = BitSets<2, State>;
\r
634 using Attributes = std::unordered_map<std::string, std::string>;
\r
637 * @brief Class representing unique object address on accessibility bus
\r
638 * @see Dali::Accessibility::Accessible::GetAddress
\r
640 class DALI_ADAPTOR_API Address
\r
643 Address() = default;
\r
645 Address(std::string bus, std::string path)
\r
646 : mBus(std::move(bus)),
\r
647 mPath(std::move(path))
\r
651 explicit operator bool() const
\r
653 return !mPath.empty();
\r
656 std::string ToString() const
\r
658 return *this ? mBus + ":" + mPath : "::null";
\r
661 const std::string& GetBus() const;
\r
663 const std::string& GetPath() const
\r
668 bool operator==(const Address& a) const
\r
670 return mBus == a.mBus && mPath == a.mPath;
\r
673 bool operator!=(const Address& a) const
\r
675 return !(*this == a);
\r
679 mutable std::string mBus, mPath;
\r
683 * @brief Enumeration describing type of key event
\r
684 * @see Adaptor::AccessibilityObserver::OnAccessibleKeyEvent
\r
686 enum class KeyEventType
\r
693 * @brief Enumeration with human readable values describing state of event
\r
694 * @see Dali::Accessibility::Bridge::Emit
\r
696 enum class Consumed
\r
703 * @brief Helper class representing two dimensional point with integer coordinates
\r
705 struct DALI_ADAPTOR_API Point
\r
712 Point(int x, int y)
\r
718 bool operator==(Point p) const
\r
720 return x == p.x && y == p.y;
\r
722 bool operator!=(Point p) const
\r
724 return !(*this == p);
\r
729 * @brief Helper class representing size of rectangle object with usage of two integer values
\r
731 struct DALI_ADAPTOR_API Size
\r
744 bool operator==(Size p) const
\r
746 return width == p.width && height == p.height;
\r
749 bool operator!=(Size p) const
\r
751 return !(*this == p);
\r
756 * @brief Helper class used to store data related with Accessibility::Text interface
\r
757 * @see Dali::Accessibility::Text::GetTextAtOffset
\r
758 * @see Dali::Accessibility::Text::GetRangeOfSelection
\r
760 struct DALI_ADAPTOR_API Range
\r
762 int32_t startOffset = 0;
\r
763 int32_t endOffset = 0;
\r
764 std::string content;
\r
768 Range(size_t start, size_t end)
\r
769 : startOffset(start),
\r
774 Range(size_t start, size_t end, std::string content)
\r
775 : startOffset(start),
\r
783 * @brief Structure containing all values needed to invoke Accessible::DoGesture
\r
784 * type : numerated gesture type
\r
785 * startPositionX, startPositionY : point where gesture begins
\r
786 * endPositionX, endPositionY : point where gesture ends
\r
787 * state : enumerated state of gesture
\r
788 * eventTime : time when event occured
\r
789 * @see Dali::Accessibility::Accessible::DoGesture
\r
791 struct DALI_ADAPTOR_API GestureInfo
\r
793 GestureInfo() = default;
\r
794 GestureInfo(Gesture type, int32_t startPositionX, int32_t endPositionX, int32_t startPositionY, int32_t endPositionY, GestureState state, uint32_t eventTime)
\r
796 startPointX(startPositionX),
\r
797 endPointX(endPositionX),
\r
798 startPointY(startPositionY),
\r
799 endPointY(endPositionY),
\r
801 eventTime(eventTime)
\r
806 int32_t startPointX{};
\r
807 int32_t endPointX{};
\r
808 int32_t startPointY{};
\r
809 int32_t endPointY{};
\r
810 GestureState state{};
\r
811 uint32_t eventTime{};
\r
815 * @brief Class representing accessibility relations
\r
816 * Class connecting one source object with multiple target objects with usage
\r
817 * of specific relation type.
\r
818 * @note std::string representing source and targets are string values of Accessibility::Address
\r
819 * @see Dali::Accessibility::Accessible::Address
\r
820 * @see Dali::Accessibility::Accessible::RelationType
\r
822 struct DALI_ADAPTOR_API Relation
\r
824 Relation(RelationType relationType, std::vector<Address> targets)
\r
825 : relationType(relationType),
\r
830 RelationType relationType;
\r
831 std::vector<Address> targets;
\r
834 } // namespace Accessibility
\r
835 } // namespace Dali
\r
837 #endif // DALI_ATSPI_ACCESSIBILITY_H
\r