Add class for encoded image buffer
[platform/core/uifw/dali-adaptor.git] / dali / internal / accessibility / bridge / bridge-component.cpp
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/accessibility/bridge/bridge-component.h>
20
21 // EXTERNAL INCLUDES
22 #include <iostream>
23
24 #define DBUS_INTERFACE_PROPERTIES "org.freedesktop.DBus.Properties"
25
26 using namespace Dali::Accessibility;
27
28 BridgeComponent::BridgeComponent()
29 {
30 }
31
32 void BridgeComponent::RegisterInterfaces()
33 {
34   DBus::DBusInterfaceDescription desc{AtspiDbusInterfaceComponent};
35   AddFunctionToInterface(desc, "Contains", &BridgeComponent::Contains);
36   AddFunctionToInterface(desc, "GetAccessibleAtPoint", &BridgeComponent::GetAccessibleAtPoint);
37   AddFunctionToInterface(desc, "GetExtents", &BridgeComponent::GetExtents);
38   AddFunctionToInterface(desc, "GetPosition", &BridgeComponent::GetPosition);
39   AddFunctionToInterface(desc, "GetSize", &BridgeComponent::GetSize);
40   AddFunctionToInterface(desc, "GetLayer", &BridgeComponent::GetLayer);
41   AddFunctionToInterface(desc, "GetAlpha", &BridgeComponent::GetAlpha);
42   AddFunctionToInterface(desc, "GetMDIZOrder", &BridgeComponent::GetMdiZOrder);
43   AddFunctionToInterface(desc, "GrabHighlight", &BridgeComponent::GrabHighlight);
44   AddFunctionToInterface(desc, "GrabFocus", &BridgeComponent::GrabFocus);
45   AddFunctionToInterface(desc, "ClearHighlight", &BridgeComponent::ClearHighlight);
46   dbusServer.addInterface("/", desc, true);
47 }
48
49 Component* BridgeComponent::FindSelf() const
50 {
51   auto s = BridgeBase::FindSelf();
52   assert(s);
53   auto s2 = dynamic_cast<Component*>(s);
54   if(!s2)
55     throw std::domain_error{"object " + s->GetAddress().ToString() + " doesn't have Component interface"};
56   return s2;
57 }
58
59 DBus::ValueOrError<bool> BridgeComponent::Contains(int32_t x, int32_t y, uint32_t coordType)
60 {
61   return FindSelf()->Contains({x, y}, static_cast<CoordType>(coordType));
62 }
63 DBus::ValueOrError<Accessible*> BridgeComponent::GetAccessibleAtPoint(int32_t x, int32_t y, uint32_t coordType)
64 {
65   return FindSelf()->GetAccessibleAtPoint({x, y}, static_cast<CoordType>(coordType));
66 }
67 DBus::ValueOrError<std::tuple<int32_t, int32_t, int32_t, int32_t> > BridgeComponent::GetExtents(uint32_t coordType)
68 {
69   auto p = FindSelf()->GetExtents(static_cast<CoordType>(coordType));
70   return std::tuple<int32_t, int32_t, int32_t, int32_t>{p.x, p.y, p.width, p.height};
71 }
72 DBus::ValueOrError<int32_t, int32_t> BridgeComponent::GetPosition(uint32_t coordType)
73 {
74   auto p = FindSelf()->GetExtents(static_cast<CoordType>(coordType));
75   return {static_cast<int32_t>(p.x), static_cast<int32_t>(p.y)};
76 }
77 DBus::ValueOrError<int32_t, int32_t> BridgeComponent::GetSize(uint32_t coordType)
78 {
79   auto p = FindSelf()->GetExtents(static_cast<CoordType>(coordType));
80   return {static_cast<int32_t>(p.width), static_cast<int32_t>(p.height)};
81 }
82 DBus::ValueOrError<ComponentLayer> BridgeComponent::GetLayer()
83 {
84   return FindSelf()->GetLayer();
85 }
86 DBus::ValueOrError<double> BridgeComponent::GetAlpha()
87 {
88   return FindSelf()->GetAlpha();
89 }
90 DBus::ValueOrError<bool> BridgeComponent::GrabFocus()
91 {
92   return FindSelf()->GrabFocus();
93 }
94 DBus::ValueOrError<bool> BridgeComponent::GrabHighlight()
95 {
96   return FindSelf()->GrabHighlight();
97 }
98 DBus::ValueOrError<bool> BridgeComponent::ClearHighlight()
99 {
100   return FindSelf()->ClearHighlight();
101 }
102 DBus::ValueOrError<int16_t> BridgeComponent::GetMdiZOrder()
103 {
104   return FindSelf()->GetMdiZOrder();
105 }