Merge branch 'devel/master' into devel/graphics
[platform/core/uifw/dali-adaptor.git] / dali / internal / accessibility / bridge / bridge-accessible.h
1 #ifndef DALI_INTERNAL_ACCESSIBILITY_BRIDGE_ACCESSIBLE_H
2 #define DALI_INTERNAL_ACCESSIBILITY_BRIDGE_ACCESSIBLE_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <array>
23 #include <string>
24 #include <unordered_map>
25 #include <vector>
26
27 // INTERNAL INCLUDES
28 #include "bridge-base.h"
29
30 class BridgeAccessible : public virtual BridgeBase
31 {
32 protected:
33   BridgeAccessible();
34
35   void RegisterInterfaces();
36
37 public:
38   enum class GetNeighborSearchMode
39   {
40     normal                       = 0,
41     recurseFromRoot              = 1,
42     continueAfterFailedRecursion = 2,
43     recurseToOutside             = 3,
44   };
45   int                                                                                                          GetChildCount();
46   DBus::ValueOrError<Dali::Accessibility::Accessible*>                                                         GetChildAtIndex(int index);
47   Dali::Accessibility::Accessible*                                                                             GetParent();
48   DBus::ValueOrError<std::vector<Dali::Accessibility::Accessible*>>                                            GetChildren();
49   std::string                                                                                                  GetName();
50   std::string                                                                                                  GetDescription();
51   DBus::ValueOrError<uint32_t>                                                                                 GetRole();
52   DBus::ValueOrError<std::string>                                                                              GetRoleName();
53   DBus::ValueOrError<std::string>                                                                              GetLocalizedRoleName();
54   DBus::ValueOrError<int32_t>                                                                                  GetIndexInParent();
55   DBus::ValueOrError<std::array<uint32_t, 2>>                                                                  GetStates();
56   DBus::ValueOrError<std::unordered_map<std::string, std::string>>                                             GetAttributes();
57   DBus::ValueOrError<std::vector<std::string>>                                                                 GetInterfaces();
58   DBus::ValueOrError<Dali::Accessibility::Accessible*, uint8_t, Dali::Accessibility::Accessible*>              GetNavigableAtPoint(int32_t x, int32_t y, uint32_t coordType);
59   DBus::ValueOrError<Dali::Accessibility::Accessible*, uint8_t>                                                GetNeighbor(std::string root_path, int32_t direction, int32_t search_mode);
60   DBus::ValueOrError<Dali::Accessibility::Accessible*, uint32_t, std::unordered_map<std::string, std::string>> GetDefaultLabelInfo();
61   using ReadingMaterialType = DBus::ValueOrError<
62     std::unordered_map<std::string, std::string>, // attributes
63     std::string,                                  // name
64     std::string,                                  // labeledByName
65     std::string,                                  // textIfceName
66     uint32_t,
67     Dali::Accessibility::States,
68     std::string,                      // localized name
69     int32_t,                          // child count
70     double,                           // current value
71     double,                           // minimum increment
72     double,                           // maximum value
73     double,                           // minimum value
74     std::string,                      // description
75     int32_t,                          // index in parent
76     bool,                             // isSelectedInParent
77     bool,                             // hasCheckBoxChild
78     int32_t,                          // listChildrenCount
79     int32_t,                          // firstSelectedChildIndex
80     Dali::Accessibility::Accessible*, // parent
81     Dali::Accessibility::States,      // parentStateSet
82     int32_t,                          // parentChildCount
83     uint32_t,                         // parentRole
84     int32_t,                          // selectedChildCount,
85     Dali::Accessibility::Accessible*  // describedByObject
86     >;
87
88   ReadingMaterialType GetReadingMaterial();
89
90   DBus::ValueOrError<bool> DoGesture(Dali::Accessibility::Gesture type, int32_t xBeg, int32_t xEnd, int32_t yBeg, int32_t yEnd, Dali::Accessibility::GestureState state, uint32_t eventTime);
91
92   using Relation = std::tuple<uint32_t, std::vector<Dali::Accessibility::Address>>;
93   DBus::ValueOrError<std::vector<Relation>> GetRelationSet();
94
95 private:
96   Dali::Accessibility::Accessible*              CalculateNeighbor(Dali::Accessibility::Accessible* root, Dali::Accessibility::Accessible* start, unsigned char forward, GetNeighborSearchMode search_mode);
97   std::vector<Dali::Accessibility::Accessible*> ValidChildrenGet(const std::vector<Dali::Accessibility::Accessible*>& children, Dali::Accessibility::Accessible* start, Dali::Accessibility::Accessible* root);
98   Dali::Accessibility::Accessible*              GetCurrentlyHighlighted();
99   Dali::Accessibility::Accessible*              DirectionalDepthFirstSearchTryNonDefunctSibling(bool& all_children_visited, Dali::Accessibility::Accessible* node, Dali::Accessibility::Accessible* start, Dali::Accessibility::Accessible* root, unsigned char forward);
100   Dali::Accessibility::Accessible*              GetNextNonDefunctSibling(Dali::Accessibility::Accessible* obj, Dali::Accessibility::Accessible* start, Dali::Accessibility::Accessible* root, unsigned char forward);
101   Dali::Accessibility::Component*               CalculateNavigableAccessibleAtPoint(Dali::Accessibility::Accessible* root, Dali::Accessibility::Point p, Dali::Accessibility::CoordType cType, unsigned int maxRecursionDepth);
102   Dali::Accessibility::Component*               GetObjectInRelation(Dali::Accessibility::Accessible* obj, Dali::Accessibility::RelationType ralationType);
103 };
104
105 #endif // DALI_INTERNAL_ACCESSIBILITY_BRIDGE_ACCESSIBLE_H