Update ATSPI code according to DALi coding rule
[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   bool suppressScreenReader = false;
37
38 public:
39   enum class GetNeighborSearchMode
40   {
41     normal                       = 0,
42     recurseFromRoot              = 1,
43     continueAfterFailedRecursion = 2,
44     recurseToOutside             = 3,
45   };
46   int                                                                                                          GetChildCount();
47   DBus::ValueOrError<Dali::Accessibility::Accessible*>                                                         GetChildAtIndex(int index);
48   Dali::Accessibility::Accessible*                                                                             GetParent();
49   DBus::ValueOrError<std::vector<Dali::Accessibility::Accessible*>>                                            GetChildren();
50   std::string                                                                                                  GetName();
51   std::string                                                                                                  GetDescription();
52   DBus::ValueOrError<uint32_t>                                                                                 GetRole();
53   DBus::ValueOrError<std::string>                                                                              GetRoleName();
54   DBus::ValueOrError<std::string>                                                                              GetLocalizedRoleName();
55   DBus::ValueOrError<int32_t>                                                                                  GetIndexInParent();
56   DBus::ValueOrError<std::array<uint32_t, 2>>                                                                  GetStates();
57   DBus::ValueOrError<std::unordered_map<std::string, std::string>>                                             GetAttributes();
58   DBus::ValueOrError<std::vector<std::string>>                                                                 GetInterfaces();
59   DBus::ValueOrError<Dali::Accessibility::Accessible*, uint8_t, Dali::Accessibility::Accessible*>              GetNavigableAtPoint(int32_t x, int32_t y, uint32_t coordinateType);
60   DBus::ValueOrError<Dali::Accessibility::Accessible*, uint8_t>                                                GetNeighbor(std::string root_path, int32_t direction, int32_t search_mode);
61   DBus::ValueOrError<Dali::Accessibility::Accessible*, uint32_t, std::unordered_map<std::string, std::string>> GetDefaultLabelInfo();
62   using ReadingMaterialType = DBus::ValueOrError<
63     std::unordered_map<std::string, std::string>, // attributes
64     std::string,                                  // name
65     std::string,                                  // labeledByName
66     std::string,                                  // textIfceName
67     uint32_t,
68     Dali::Accessibility::States,
69     std::string,                      // localized name
70     int32_t,                          // child count
71     double,                           // current value
72     double,                           // minimum increment
73     double,                           // maximum value
74     double,                           // minimum value
75     std::string,                      // description
76     int32_t,                          // index in parent
77     bool,                             // isSelectedInParent
78     bool,                             // hasCheckBoxChild
79     int32_t,                          // listChildrenCount
80     int32_t,                          // firstSelectedChildIndex
81     Dali::Accessibility::Accessible*, // parent
82     Dali::Accessibility::States,      // parentStateSet
83     int32_t,                          // parentChildCount
84     uint32_t,                         // parentRole
85     int32_t,                          // selectedChildCount,
86     Dali::Accessibility::Accessible*  // describedByObject
87     >;
88
89   ReadingMaterialType GetReadingMaterial();
90   void                SuppressScreenReader(bool) override;
91
92   DBus::ValueOrError<bool> DoGesture(Dali::Accessibility::Gesture type, int32_t xBeg, int32_t yBeg, int32_t xEnd, int32_t yEnd, Dali::Accessibility::GestureState state, uint32_t eventTime);
93
94   using Relation = std::tuple<uint32_t, std::vector<Dali::Accessibility::Address>>;
95   DBus::ValueOrError<std::vector<Relation>> GetRelationSet();
96
97 private:
98   Dali::Accessibility::Accessible*              CalculateNeighbor(Dali::Accessibility::Accessible* root, Dali::Accessibility::Accessible* start, unsigned char forward, GetNeighborSearchMode search_mode);
99   std::vector<Dali::Accessibility::Accessible*> ValidChildrenGet(const std::vector<Dali::Accessibility::Accessible*>& children, Dali::Accessibility::Accessible* start, Dali::Accessibility::Accessible* root);
100   Dali::Accessibility::Accessible*              GetCurrentlyHighlighted();
101   Dali::Accessibility::Accessible*              DirectionalDepthFirstSearchTryNonDefunctSibling(bool& all_children_visited, Dali::Accessibility::Accessible* node, Dali::Accessibility::Accessible* start, Dali::Accessibility::Accessible* root, unsigned char forward);
102   Dali::Accessibility::Accessible*              GetNextNonDefunctSibling(Dali::Accessibility::Accessible* obj, Dali::Accessibility::Accessible* start, Dali::Accessibility::Accessible* root, unsigned char forward);
103   Dali::Accessibility::Component*               CalculateNavigableAccessibleAtPoint(Dali::Accessibility::Accessible* root, Dali::Accessibility::Point p, Dali::Accessibility::CoordinateType type, unsigned int maxRecursionDepth);
104   Dali::Accessibility::Component*               GetObjectInRelation(Dali::Accessibility::Accessible* obj, Dali::Accessibility::RelationType ralationType);
105 };
106
107 #endif // DALI_INTERNAL_ACCESSIBILITY_BRIDGE_ACCESSIBLE_H