[AT-SPI] Make ProxyAccessible's parent settable
[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
28 namespace Dali::Accessibility
29 {
30 /**
31  * @brief The minimalistic, always empty Accessible object with settable address.
32  *
33  * To be used as a proxy object, in those situations where you want to return an address in
34  * a different bridge (embedding for example), but the object itself isn't planned to be used
35  * otherwise. This object has a settable parent, no children, an empty name and so on.
36  */
37 class DALI_ADAPTOR_API ProxyAccessible : public virtual Accessible
38 {
39 public:
40   ProxyAccessible()
41   : mAddress{},
42     mParent{nullptr}
43   {
44   }
45
46   void SetAddress(Address address)
47   {
48     mAddress = std::move(address);
49   }
50
51   void SetParent(Accessible* parent)
52   {
53     mParent = parent;
54   }
55
56   std::string GetName() const override
57   {
58     return "";
59   }
60
61   std::string GetDescription() const override
62   {
63     return "";
64   }
65
66   Accessible* GetParent() override
67   {
68     return mParent;
69   }
70
71   size_t GetChildCount() const override
72   {
73     return 0;
74   }
75
76   std::vector<Accessible*> GetChildren() override
77   {
78     return {};
79   }
80
81   Accessible* GetChildAtIndex(size_t index) override
82   {
83     throw std::domain_error{"out of bounds index (" + std::to_string(index) + ") - no children"};
84   }
85
86   size_t GetIndexInParent() override
87   {
88     return static_cast<size_t>(-1);
89   }
90
91   Role GetRole() const override
92   {
93     return {};
94   }
95
96   std::string GetRoleName() const override
97   {
98     return {};
99   }
100
101   States GetStates() override
102   {
103     return {};
104   }
105
106   Attributes GetAttributes() const override
107   {
108     return {};
109   }
110
111   bool IsProxy() const override
112   {
113     return true;
114   }
115
116   Address GetAddress() const override
117   {
118     return mAddress;
119   }
120
121   bool DoGesture(const GestureInfo& gestureInfo) override
122   {
123     return false;
124   }
125
126   std::vector<Relation> GetRelationSet() override
127   {
128     return {};
129   }
130
131   Dali::Actor GetInternalActor() override
132   {
133     return Dali::Actor{};
134   }
135
136 private:
137   Address     mAddress;
138   Accessible* mParent;
139 };
140
141 } // namespace Dali::Accessibility
142
143 #endif // DALI_ADAPTOR_PROXY_ACCESSIBLE_H