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 a relation between accessible objects
\r
46 * 1 to 0..N relation model is supported. By default relation is not symmetrical.
\r
47 * Symmetry must be explicitly maintained.
\r
49 enum class RelationType : uint32_t
\r
51 NULL_OF, ///< Null Relation.
\r
52 LABEL_FOR, ///< Label For.
\r
53 LABELLED_BY, ///< Labelled By.
\r
54 CONTROLLER_FOR, ///< Controller For.
\r
55 CONTROLLED_BY, ///< Controlled By.
\r
56 MEMBER_OF, ///< Member Of.
\r
57 TOOLTIP_FOR, ///< ToolTip For.
\r
58 NODE_CHILD_OF, ///< Node Child Of.
\r
59 NODE_PARENT_OF, ///< Node Parent Of.
\r
60 EXTENDED, ///< Extended.
\r
61 FLOWS_TO, ///< Flows To.
\r
62 FLOWS_FROM, ///< Flows From.
\r
63 SUBWINDOW_OF, ///< Sub Window Of.
\r
64 EMBEDS, ///< Embeds.
\r
65 EMBEDDED_BY, ///< Embedded By.
\r
66 POPUP_FOR, ///< Popup For
\r
67 PARENT_WINDOW_OF, ///< Parent Window Of.
\r
68 DESCRIPTION_FOR, ///< Description For.
\r
69 DESCRIBED_BY, ///< Described By.
\r
70 DETAILS, ///< Details.
\r
71 DETAILS_FOR, ///< Details For.
\r
72 ERROR_MESSAGE, ///< Error Message.
\r
73 ERROR_FOR, ///< Error For.
\r
78 * @brief Enumeration describing if coordinates are relative to screen or window
\r
79 * @see Accessibility::Component::GetExtents
\r
80 * @see Accessibility::Component::IsAccessibleContainedAtPoint
\r
82 enum class CoordinateType
\r
84 SCREEN, ///< Screen.
\r
89 * @brief Enumeration indicating relative stacking order
\r
90 * ComponentLayer allows to describe visibility of all parts of UI
\r
91 * basing on the concrete stacking order
\r
92 * @see Accessibility::Component::GetLayer
\r
93 * @note currently only ComponentLayer::Window is supported
\r
95 enum class ComponentLayer
\r
97 INVALID, ///< Invalid.
\r
98 BACKGROUND, ///< Background.
\r
99 CANVAS, ///< Canvas.
\r
100 WIDGET, ///< Widget.
\r
103 OVERLAY, ///< Overlay.
\r
104 WINDOW, ///< Window.
\r
109 * @brief Enumeration describing role of the Accessibility object
\r
110 * Object can be described by only one role.
\r
111 * @see Accessibility::Accessible::GetRole
\r
113 enum class Role : uint32_t
\r
172 TABLE_COLUMN_HEADER,
\r
204 INPUT_METHOD_WINDOW,
\r
207 DOCUMENT_SPREADSHEET,
\r
208 DOCUMENT_PRESENTATION,
\r
240 * @brief Enumeration describing states of the Accessibility object
\r
241 * Object can be in many states at the same time.
\r
242 * @see Accessibility::Accessible::GetStates
\r
244 enum class State : uint32_t
\r
277 MANAGES_DESCENDANTS,
\r
283 SUPPORTS_AUTOCOMPLETION,
\r
296 * @brief Enumeration describing change of text object
\r
298 enum class TextChangedState : uint32_t
\r
306 * @brief Enumeration describing change of object property
\r
308 enum class ObjectPropertyChangeEvent
\r
318 * @brief Enumeration describing change of window object
\r
319 * @see Accessibility::Accessible::Emit
\r
321 enum class WindowEvent
\r
345 * @brief Enumeration used to acquire bounded text from accessible object having textual content.
\r
346 * @see Accessibility::Text::GetTextAtOffset
\r
347 * @note Currently only TextBoundary::Character is supported
\r
349 enum class TextBoundary : uint32_t
\r
351 CHARACTER, ///> Only one character is acquired.
\r
352 WORD, ///> Not supported.
\r
353 SENTENCE, ///> Not supported.
\r
354 LINE, ///> Not supported.
\r
355 PARAGRAPH, ///> Not supported.
\r
360 * @brief Enumeration describing type of gesture
\r
361 * @see Accessibility::Accessible::DoGesture
\r
363 enum class Gesture : int32_t
\r
367 THREE_FINGER_HOVER,
\r
368 ONE_FINGER_FLICK_LEFT,
\r
369 ONE_FINGER_FLICK_RIGHT,
\r
370 ONE_FINGER_FLICK_UP,
\r
371 ONE_FINGER_FLICK_DOWN,
\r
372 TWO_FINGERS_FLICK_LEFT,
\r
373 TWO_FINGERS_FLICK_RIGHT,
\r
374 TWO_FINGERS_FLICK_UP,
\r
375 TWO_FINGERS_FLICK_DOWN,
\r
376 THREE_FINGERS_FLICK_LEFT,
\r
377 THREE_FINGERS_FLICK_RIGHT,
\r
378 THREE_FINGERS_FLICK_UP,
\r
379 THREE_FINGERS_FLICK_DOWN,
\r
380 ONE_FINGER_SINGLE_TAP,
\r
381 ONE_FINGER_DOUBLE_TAP,
\r
382 ONE_FINGER_TRIPLE_TAP,
\r
383 TWO_FINGERS_SINGLE_TAP,
\r
384 TWO_FINGERS_DOUBLE_TAP,
\r
385 TWO_FINGERS_TRIPLE_TAP,
\r
386 THREE_FINGERS_SINGLE_TAP,
\r
387 THREE_FINGERS_DOUBLE_TAP,
\r
388 THREE_FINGERS_TRIPLE_TAP,
\r
389 ONE_FINGER_FLICK_LEFT_RETURN,
\r
390 ONE_FINGER_FLICK_RIGHT_RETURN,
\r
391 ONE_FINGER_FLICK_UP_RETURN,
\r
392 ONE_FINGER_FLICK_DOWN_RETURN,
\r
393 TWO_FINGERS_FLICK_LEFT_RETURN,
\r
394 TWO_FINGERS_FLICK_RIGHT_RETURN,
\r
395 TWO_FINGERS_FLICK_UP_RETURN,
\r
396 TWO_FINGERS_FLICK_DOWN_RETURN,
\r
397 THREE_FINGERS_FLICK_LEFT_RETURN,
\r
398 THREE_FINGERS_FLICK_RIGHT_RETURN,
\r
399 THREE_FINGERS_FLICK_UP_RETURN,
\r
400 THREE_FINGERS_FLICK_DOWN_RETURN,
\r
401 ONE_FINGER_DOUBLE_TAP_N_HOLD,
\r
402 TWO_FINGERS_DOUBLE_TAP_N_HOLD,
\r
403 THREE_FINGERS_DOUBLE_TAP_N_HOLD,
\r
408 * @brief Enumeration indicating current state of gesture
\r
409 * @see Dali::Accessibility::GestureInfo
\r
411 enum class GestureState : int32_t
\r
420 * @brief Enumeration of ReadingInfoType
\r
422 enum class ReadingInfoType
\r
431 * @brief Helper class for storing values treated as bit sets
\r
432 * This class provides all bitset-like methods for bitset size larger, than long long int
\r
433 * @see Dali::Accessibility::Accessible::GetStates
\r
434 * @see Dali::Accessibility::Accessible::GetRoles
\r
436 template<size_t I, typename S>
\r
439 std::array<uint32_t, I> data;
\r
445 static constexpr bool Accepts()
\r
450 template<typename T>
\r
451 static constexpr bool Accepts()
\r
453 return std::is_enum<T>::value;
\r
456 template<typename T, typename T2, typename... ARGS>
\r
457 static constexpr bool Accepts()
\r
459 return std::is_enum<T>::value && Accepts<T2, ARGS...>();
\r
462 template<typename T, typename... ARGS>
\r
463 void Set(T t, ARGS... args)
\r
472 for(auto& u : data)
\r
477 BitSets(const BitSets&) = default;
\r
478 BitSets(BitSets&&) = default;
\r
480 template<typename T, typename... ARGS, typename std::enable_if<Accepts<T, ARGS...>()>::type* = nullptr>
\r
481 BitSets(T t, ARGS... args)
\r
483 for(auto& u : data)
\r
488 explicit BitSets(std::array<uint32_t, I> d)
\r
490 for(auto i = 0u; i < I; ++i)
\r
496 explicit BitSets(std::array<int32_t, I> d)
\r
498 for(auto i = 0u; i < I; ++i)
\r
500 data[i] = static_cast<uint32_t>(d[i]);
\r
504 BitSets& operator=(const BitSets&) = default;
\r
505 BitSets& operator=(BitSets&&) = default;
\r
509 std::array<uint32_t, I>& data;
\r
512 reference& operator=(reference r)
\r
514 (*this) = static_cast<bool>(r);
\r
518 reference& operator=(bool v)
\r
522 data[pos / 32] |= 1 << (pos & 31);
\r
526 data[pos / 32] &= ~(1 << (pos & 31));
\r
531 operator bool() const
\r
533 auto i = static_cast<size_t>(pos);
\r
534 return (data[i / 32] & (1 << (i & 31))) != 0;
\r
538 reference operator[](S index)
\r
540 return {data, static_cast<size_t>(index)};
\r
543 bool operator[](S index) const
\r
545 auto i = static_cast<size_t>(index);
\r
546 return (data[i / 32] & (1 << (i & 31))) != 0;
\r
549 std::array<uint32_t, I> GetRawData() const
\r
554 BitSets operator|(BitSets b) const
\r
557 for(auto i = 0u; i < I; ++i)
\r
559 r.data[i] = data[i] | b.data[i];
\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 bool operator==(BitSets b) const
\r
586 for(auto i = 0u; i < I; ++i)
\r
588 if(data[i] != b.data[i])
\r
596 bool operator!=(BitSets b) const
\r
598 return !((*this) == b);
\r
601 explicit operator bool() const
\r
603 for(auto& u : data)
\r
613 size_t size() const
\r
619 using ReadingInfoTypes = BitSets<1, ReadingInfoType>;
\r
620 using States = BitSets<2, State>;
\r
621 using Attributes = std::unordered_map<std::string, std::string>;
\r
624 * @brief Class representing unique object address on accessibility bus
\r
625 * @see Dali::Accessibility::Accessible::GetAddress
\r
627 class DALI_ADAPTOR_API Address
\r
630 Address() = default;
\r
632 Address(std::string bus, std::string path)
\r
633 : mBus(std::move(bus)),
\r
634 mPath(std::move(path))
\r
638 explicit operator bool() const
\r
640 return !mPath.empty();
\r
643 std::string ToString() const
\r
645 return *this ? mBus + ":" + mPath : "::null";
\r
648 const std::string& GetBus() const;
\r
650 const std::string& GetPath() const
\r
655 bool operator==(const Address& a) const
\r
657 return mBus == a.mBus && mPath == a.mPath;
\r
660 bool operator!=(const Address& a) const
\r
662 return !(*this == a);
\r
666 mutable std::string mBus, mPath;
\r
670 * @brief Enumeration describing type of key event
\r
671 * @see Adaptor::AccessibilityObserver::OnAccessibleKeyEvent
\r
673 enum class KeyEventType
\r
680 * @brief Enumeration with human readable values describing state of event
\r
681 * @see Dali::Accessibility::Bridge::Emit
\r
683 enum class Consumed
\r
690 * @brief Helper class representing two dimensional point with integer coordinates
\r
692 struct DALI_ADAPTOR_API Point
\r
699 Point(int x, int y)
\r
705 bool operator==(Point p) const
\r
707 return x == p.x && y == p.y;
\r
709 bool operator!=(Point p) const
\r
711 return !(*this == p);
\r
716 * @brief Helper class representing size of rectangle object with usage of two integer values
\r
718 struct DALI_ADAPTOR_API Size
\r
731 bool operator==(Size p) const
\r
733 return width == p.width && height == p.height;
\r
736 bool operator!=(Size p) const
\r
738 return !(*this == p);
\r
743 * @brief Helper class used to store data related with Accessibility::Text interface
\r
744 * @see Dali::Accessibility::Text::GetTextAtOffset
\r
745 * @see Dali::Accessibility::Text::GetRangeOfSelection
\r
747 struct DALI_ADAPTOR_API Range
\r
749 int32_t startOffset = 0;
\r
750 int32_t endOffset = 0;
\r
751 std::string content;
\r
755 Range(size_t start, size_t end)
\r
756 : startOffset(start),
\r
761 Range(size_t start, size_t end, std::string content)
\r
762 : startOffset(start),
\r
770 * @brief Structure containing all values needed to invoke Accessible::DoGesture
\r
771 * type : numerated gesture type
\r
772 * xBeg, yBeg : point where gesture begins
\r
773 * xEnd, yEnd : point where gesture ends
\r
774 * state : enumerated state of gesture
\r
775 * eventTime : time when event occured
\r
776 * @see Dali::Accessibility::Accessible::DoGesture
\r
778 struct DALI_ADAPTOR_API GestureInfo
\r
780 GestureInfo() = default;
\r
781 GestureInfo(Gesture type, int32_t xBeg, int32_t xEnd, int32_t yBeg, int32_t yEnd, GestureState state, uint32_t eventTime)
\r
788 eventTime(eventTime)
\r
797 GestureState state{};
\r
798 uint32_t eventTime{};
\r
802 * @brief Class representing accessibility relations
\r
803 * Class connecting one source object with multiple target objects with usage
\r
804 * of specific relation type.
\r
805 * @note std::string representing source and targets are string values of Accessibility::Address
\r
806 * @see Dali::Accessibility::Accessible::Address
\r
807 * @see Dali::Accessibility::Accessible::RelationType
\r
809 struct DALI_ADAPTOR_API Relation
\r
811 Relation(RelationType relationType, std::vector<Address> targets)
\r
812 : relationType(relationType),
\r
817 RelationType relationType;
\r
818 std::vector<Address> targets;
\r
821 } // namespace Accessibility
\r
822 } // namespace Dali
\r
824 #endif // DALI_ATSPI_ACCESSIBILITY_H
\r