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 signal that occurs when object moves out of screen.
\r
47 enum class MovedOutOfScreenType
\r
50 TOP_LEFT, ///< Object moves out of top(or left) side of screen
\r
51 BOTTOM_RIGHT ///< Object moves out of bottom(or right) side of screen
\r
55 * @brief Enumeration describing a relation between accessible objects
\r
56 * 1 to 0..N relation model is supported. By default relation is not symmetrical.
\r
57 * Symmetry must be explicitly maintained.
\r
59 enum class RelationType : uint32_t
\r
61 NULL_OF, ///< Null Relation.
\r
62 LABEL_FOR, ///< Label For.
\r
63 LABELLED_BY, ///< Labelled By.
\r
64 CONTROLLER_FOR, ///< Controller For.
\r
65 CONTROLLED_BY, ///< Controlled By.
\r
66 MEMBER_OF, ///< Member Of.
\r
67 TOOLTIP_FOR, ///< ToolTip For.
\r
68 NODE_CHILD_OF, ///< Node Child Of.
\r
69 NODE_PARENT_OF, ///< Node Parent Of.
\r
70 EXTENDED, ///< Extended.
\r
71 FLOWS_TO, ///< Flows To.
\r
72 FLOWS_FROM, ///< Flows From.
\r
73 SUBWINDOW_OF, ///< Sub Window Of.
\r
74 EMBEDS, ///< Embeds.
\r
75 EMBEDDED_BY, ///< Embedded By.
\r
76 POPUP_FOR, ///< Popup For
\r
77 PARENT_WINDOW_OF, ///< Parent Window Of.
\r
78 DESCRIPTION_FOR, ///< Description For.
\r
79 DESCRIBED_BY, ///< Described By.
\r
80 DETAILS, ///< Details.
\r
81 DETAILS_FOR, ///< Details For.
\r
82 ERROR_MESSAGE, ///< Error Message.
\r
83 ERROR_FOR, ///< Error For.
\r
88 * @brief Enumeration describing if coordinates are relative to screen or window
\r
89 * @see Accessibility::Component::GetExtents
\r
90 * @see Accessibility::Component::IsAccessibleContainedAtPoint
\r
92 enum class CoordinateType
\r
94 SCREEN, ///< Screen.
\r
99 * @brief Enumeration indicating relative stacking order
\r
100 * ComponentLayer allows to describe visibility of all parts of UI
\r
101 * basing on the concrete stacking order
\r
102 * @see Accessibility::Component::GetLayer
\r
103 * @note currently only ComponentLayer::Window is supported
\r
105 enum class ComponentLayer
\r
107 INVALID, ///< Invalid.
\r
108 BACKGROUND, ///< Background.
\r
109 CANVAS, ///< Canvas.
\r
110 WIDGET, ///< Widget.
\r
113 OVERLAY, ///< Overlay.
\r
114 WINDOW, ///< Window.
\r
119 * @brief Enumeration describing role of the Accessibility object
\r
120 * Object can be described by only one role.
\r
121 * @see Accessibility::Accessible::GetRole
\r
123 enum class Role : uint32_t
\r
182 TABLE_COLUMN_HEADER,
\r
214 INPUT_METHOD_WINDOW,
\r
217 DOCUMENT_SPREADSHEET,
\r
218 DOCUMENT_PRESENTATION,
\r
250 * @brief Enumeration describing states of the Accessibility object
\r
251 * Object can be in many states at the same time.
\r
252 * @see Accessibility::Accessible::GetStates
\r
254 enum class State : uint32_t
\r
287 MANAGES_DESCENDANTS,
\r
293 SUPPORTS_AUTOCOMPLETION,
\r
306 * @brief Enumeration describing change of text object
\r
308 enum class TextChangedState : uint32_t
\r
316 * @brief Enumeration describing change of object property
\r
318 enum class ObjectPropertyChangeEvent
\r
328 * @brief Enumeration describing change of window object
\r
329 * @see Accessibility::Accessible::Emit
\r
331 enum class WindowEvent
\r
355 * @brief Enumeration used to acquire bounded text from accessible object having textual content.
\r
356 * @see Accessibility::Text::GetTextAtOffset
\r
357 * @note Currently only TextBoundary::Character is supported
\r
359 enum class TextBoundary : uint32_t
\r
361 CHARACTER, ///> Only one character is acquired.
\r
362 WORD, ///> Not supported.
\r
363 SENTENCE, ///> Not supported.
\r
364 LINE, ///> Not supported.
\r
365 PARAGRAPH, ///> Not supported.
\r
370 * @brief Enumeration describing type of gesture
\r
371 * @see Accessibility::Accessible::DoGesture
\r
373 enum class Gesture : int32_t
\r
377 THREE_FINGER_HOVER,
\r
378 ONE_FINGER_FLICK_LEFT,
\r
379 ONE_FINGER_FLICK_RIGHT,
\r
380 ONE_FINGER_FLICK_UP,
\r
381 ONE_FINGER_FLICK_DOWN,
\r
382 TWO_FINGERS_FLICK_LEFT,
\r
383 TWO_FINGERS_FLICK_RIGHT,
\r
384 TWO_FINGERS_FLICK_UP,
\r
385 TWO_FINGERS_FLICK_DOWN,
\r
386 THREE_FINGERS_FLICK_LEFT,
\r
387 THREE_FINGERS_FLICK_RIGHT,
\r
388 THREE_FINGERS_FLICK_UP,
\r
389 THREE_FINGERS_FLICK_DOWN,
\r
390 ONE_FINGER_SINGLE_TAP,
\r
391 ONE_FINGER_DOUBLE_TAP,
\r
392 ONE_FINGER_TRIPLE_TAP,
\r
393 TWO_FINGERS_SINGLE_TAP,
\r
394 TWO_FINGERS_DOUBLE_TAP,
\r
395 TWO_FINGERS_TRIPLE_TAP,
\r
396 THREE_FINGERS_SINGLE_TAP,
\r
397 THREE_FINGERS_DOUBLE_TAP,
\r
398 THREE_FINGERS_TRIPLE_TAP,
\r
399 ONE_FINGER_FLICK_LEFT_RETURN,
\r
400 ONE_FINGER_FLICK_RIGHT_RETURN,
\r
401 ONE_FINGER_FLICK_UP_RETURN,
\r
402 ONE_FINGER_FLICK_DOWN_RETURN,
\r
403 TWO_FINGERS_FLICK_LEFT_RETURN,
\r
404 TWO_FINGERS_FLICK_RIGHT_RETURN,
\r
405 TWO_FINGERS_FLICK_UP_RETURN,
\r
406 TWO_FINGERS_FLICK_DOWN_RETURN,
\r
407 THREE_FINGERS_FLICK_LEFT_RETURN,
\r
408 THREE_FINGERS_FLICK_RIGHT_RETURN,
\r
409 THREE_FINGERS_FLICK_UP_RETURN,
\r
410 THREE_FINGERS_FLICK_DOWN_RETURN,
\r
411 ONE_FINGER_DOUBLE_TAP_N_HOLD,
\r
412 TWO_FINGERS_DOUBLE_TAP_N_HOLD,
\r
413 THREE_FINGERS_DOUBLE_TAP_N_HOLD,
\r
418 * @brief Enumeration indicating current state of gesture
\r
419 * @see Dali::Accessibility::GestureInfo
\r
421 enum class GestureState : int32_t
\r
430 * @brief Enumeration of ReadingInfoType
\r
432 enum class ReadingInfoType
\r
441 * @brief Helper class for storing values treated as bit sets
\r
442 * This class provides all bitset-like methods for bitset size larger, than long long int
\r
443 * @see Dali::Accessibility::Accessible::GetStates
\r
444 * @see Dali::Accessibility::Accessible::GetRoles
\r
446 template<size_t I, typename S>
\r
449 std::array<uint32_t, I> data;
\r
455 static constexpr bool Accepts()
\r
460 template<typename T>
\r
461 static constexpr bool Accepts()
\r
463 return std::is_enum<T>::value;
\r
466 template<typename T, typename T2, typename... ARGS>
\r
467 static constexpr bool Accepts()
\r
469 return std::is_enum<T>::value && Accepts<T2, ARGS...>();
\r
472 template<typename T, typename... ARGS>
\r
473 void Set(T t, ARGS... args)
\r
482 for(auto& u : data)
\r
487 BitSets(const BitSets&) = default;
\r
488 BitSets(BitSets&&) = default;
\r
490 template<typename T, typename... ARGS, typename std::enable_if<Accepts<T, ARGS...>()>::type* = nullptr>
\r
491 BitSets(T t, ARGS... args)
\r
493 for(auto& u : data)
\r
498 explicit BitSets(std::array<uint32_t, I> d)
\r
500 for(auto i = 0u; i < I; ++i)
\r
506 explicit BitSets(std::array<int32_t, I> d)
\r
508 for(auto i = 0u; i < I; ++i)
\r
510 data[i] = static_cast<uint32_t>(d[i]);
\r
514 BitSets& operator=(const BitSets&) = default;
\r
515 BitSets& operator=(BitSets&&) = default;
\r
519 std::array<uint32_t, I>& data;
\r
522 reference& operator=(reference r)
\r
524 (*this) = static_cast<bool>(r);
\r
528 reference& operator=(bool v)
\r
532 data[pos / 32] |= 1 << (pos & 31);
\r
536 data[pos / 32] &= ~(1 << (pos & 31));
\r
541 operator bool() const
\r
543 auto i = static_cast<size_t>(pos);
\r
544 return (data[i / 32] & (1 << (i & 31))) != 0;
\r
548 reference operator[](S index)
\r
550 return {data, static_cast<size_t>(index)};
\r
553 bool operator[](S index) const
\r
555 auto i = static_cast<size_t>(index);
\r
556 return (data[i / 32] & (1 << (i & 31))) != 0;
\r
559 std::array<uint32_t, I> GetRawData() const
\r
564 BitSets operator|(BitSets b) const
\r
567 for(auto i = 0u; i < I; ++i)
\r
569 r.data[i] = data[i] | b.data[i];
\r
574 BitSets operator^(BitSets b) const
\r
577 for(auto i = 0u; i < I; ++i)
\r
579 r.data[i] = data[i] ^ b.data[i];
\r
584 BitSets operator&(BitSets b) const
\r
587 for(auto i = 0u; i < I; ++i)
\r
589 r.data[i] = data[i] & b.data[i];
\r
594 bool operator==(BitSets b) const
\r
596 for(auto i = 0u; i < I; ++i)
\r
598 if(data[i] != b.data[i])
\r
606 bool operator!=(BitSets b) const
\r
608 return !((*this) == b);
\r
611 explicit operator bool() const
\r
613 for(auto& u : data)
\r
623 size_t size() const
\r
629 using ReadingInfoTypes = BitSets<1, ReadingInfoType>;
\r
630 using States = BitSets<2, State>;
\r
631 using Attributes = std::unordered_map<std::string, std::string>;
\r
634 * @brief Class representing unique object address on accessibility bus
\r
635 * @see Dali::Accessibility::Accessible::GetAddress
\r
637 class DALI_ADAPTOR_API Address
\r
640 Address() = default;
\r
642 Address(std::string bus, std::string path)
\r
643 : mBus(std::move(bus)),
\r
644 mPath(std::move(path))
\r
648 explicit operator bool() const
\r
650 return !mPath.empty();
\r
653 std::string ToString() const
\r
655 return *this ? mBus + ":" + mPath : "::null";
\r
658 const std::string& GetBus() const;
\r
660 const std::string& GetPath() const
\r
665 bool operator==(const Address& a) const
\r
667 return mBus == a.mBus && mPath == a.mPath;
\r
670 bool operator!=(const Address& a) const
\r
672 return !(*this == a);
\r
676 mutable std::string mBus, mPath;
\r
680 * @brief Enumeration describing type of key event
\r
681 * @see Adaptor::AccessibilityObserver::OnAccessibleKeyEvent
\r
683 enum class KeyEventType
\r
690 * @brief Enumeration with human readable values describing state of event
\r
691 * @see Dali::Accessibility::Bridge::Emit
\r
693 enum class Consumed
\r
700 * @brief Helper class representing two dimensional point with integer coordinates
\r
702 struct DALI_ADAPTOR_API Point
\r
709 Point(int x, int y)
\r
715 bool operator==(Point p) const
\r
717 return x == p.x && y == p.y;
\r
719 bool operator!=(Point p) const
\r
721 return !(*this == p);
\r
726 * @brief Helper class representing size of rectangle object with usage of two integer values
\r
728 struct DALI_ADAPTOR_API Size
\r
741 bool operator==(Size p) const
\r
743 return width == p.width && height == p.height;
\r
746 bool operator!=(Size p) const
\r
748 return !(*this == p);
\r
753 * @brief Helper class used to store data related with Accessibility::Text interface
\r
754 * @see Dali::Accessibility::Text::GetTextAtOffset
\r
755 * @see Dali::Accessibility::Text::GetRangeOfSelection
\r
757 struct DALI_ADAPTOR_API Range
\r
759 int32_t startOffset = 0;
\r
760 int32_t endOffset = 0;
\r
761 std::string content;
\r
765 Range(size_t start, size_t end)
\r
766 : startOffset(start),
\r
771 Range(size_t start, size_t end, std::string content)
\r
772 : startOffset(start),
\r
780 * @brief Structure containing all values needed to invoke Accessible::DoGesture
\r
781 * type : numerated gesture type
\r
782 * xBeg, yBeg : point where gesture begins
\r
783 * xEnd, yEnd : point where gesture ends
\r
784 * state : enumerated state of gesture
\r
785 * eventTime : time when event occured
\r
786 * @see Dali::Accessibility::Accessible::DoGesture
\r
788 struct DALI_ADAPTOR_API GestureInfo
\r
790 GestureInfo() = default;
\r
791 GestureInfo(Gesture type, int32_t xBeg, int32_t xEnd, int32_t yBeg, int32_t yEnd, GestureState state, uint32_t eventTime)
\r
798 eventTime(eventTime)
\r
807 GestureState state{};
\r
808 uint32_t eventTime{};
\r
812 * @brief Class representing accessibility relations
\r
813 * Class connecting one source object with multiple target objects with usage
\r
814 * of specific relation type.
\r
815 * @note std::string representing source and targets are string values of Accessibility::Address
\r
816 * @see Dali::Accessibility::Accessible::Address
\r
817 * @see Dali::Accessibility::Accessible::RelationType
\r
819 struct DALI_ADAPTOR_API Relation
\r
821 Relation(RelationType relationType, std::vector<Address> targets)
\r
822 : relationType(relationType),
\r
827 RelationType relationType;
\r
828 std::vector<Address> targets;
\r
831 } // namespace Accessibility
\r
832 } // namespace Dali
\r
834 #endif // DALI_ATSPI_ACCESSIBILITY_H
\r