[Tizen][AT-SPI] Move AccessibilityAttributes to Accessible
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / proxy-accessible.h
1 #ifndef DALI_ADAPTOR_PROXY_ACCESSIBLE_H
2 #define DALI_ADAPTOR_PROXY_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 // EXTERNAL INCLUDES
21 #include <string>
22 #include <vector>
23
24 // INTERNAL INCLUDES
25 #include <dali/devel-api/adaptor-framework/accessibility.h>
26 #include <dali/devel-api/atspi-interfaces/accessible.h>
27 #include <dali/devel-api/atspi-interfaces/component.h>
28
29 namespace Dali::Accessibility
30 {
31 /**
32  * @brief The minimalistic, always empty Accessible object with settable address.
33  *
34  * To be used as a proxy object, in those situations where you want to return an address in
35  * a different bridge (embedding for example), but the object itself isn't planned to be used
36  * otherwise. This object has a settable parent, no children, an empty name and so on.
37  */
38 class DALI_ADAPTOR_API ProxyAccessible : public virtual Accessible, public virtual Component
39 {
40 public:
41   ProxyAccessible()
42   : mAddress{},
43     mParent{nullptr}
44   {
45   }
46
47   void SetAddress(Address address)
48   {
49     mAddress = std::move(address);
50   }
51
52   void SetParent(Accessible* parent)
53   {
54     mParent = parent;
55   }
56
57   std::string GetName() const override
58   {
59     return "";
60   }
61
62   std::string GetDescription() const override
63   {
64     return "";
65   }
66
67   Accessible* GetParent() override
68   {
69     return mParent;
70   }
71
72   size_t GetChildCount() const override
73   {
74     return 0;
75   }
76
77   std::vector<Accessible*> GetChildren() override
78   {
79     return {};
80   }
81
82   Accessible* GetChildAtIndex(size_t index) override
83   {
84     throw std::domain_error{"out of bounds index (" + std::to_string(index) + ") - no children"};
85   }
86
87   size_t GetIndexInParent() override
88   {
89     return static_cast<size_t>(-1);
90   }
91
92   Role GetRole() const override
93   {
94     return {};
95   }
96
97   std::string GetRoleName() const override
98   {
99     return {};
100   }
101
102   States GetStates() override
103   {
104     return {};
105   }
106
107   bool IsProxy() const override
108   {
109     return true;
110   }
111
112   Address GetAddress() const override
113   {
114     return mAddress;
115   }
116
117   bool DoGesture(const GestureInfo& gestureInfo) override
118   {
119     return false;
120   }
121
122   std::vector<Relation> GetRelationSet() override
123   {
124     return {};
125   }
126
127   Dali::Actor GetInternalActor() override
128   {
129     return Dali::Actor{};
130   }
131
132   Rect<> GetExtents(CoordinateType type) const override
133   {
134     auto* parent = Component::DownCast(mParent);
135
136     return parent ? parent->GetExtents(type) : Rect<>{};
137   }
138
139   ComponentLayer GetLayer() const override
140   {
141     return ComponentLayer::WINDOW;
142   }
143
144   int16_t GetMdiZOrder() const override
145   {
146     return false;
147   }
148
149   bool GrabFocus() override
150   {
151     return false;
152   }
153
154   double GetAlpha() const override
155   {
156     return 0.0;
157   }
158
159   bool GrabHighlight() override
160   {
161     return false;
162   }
163
164   bool ClearHighlight() override
165   {
166     return false;
167   }
168
169   bool IsScrollable() const override
170   {
171     return false;
172   }
173
174 private:
175   Address     mAddress;
176   Accessible* mParent;
177 };
178
179 } // namespace Dali::Accessibility
180
181 #endif // DALI_ADAPTOR_PROXY_ACCESSIBLE_H