Merge "Speedup image channel operation + alpha masking + etc" into devel/master
[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 #define DBUS_INTERFACE_PROPERTIES "org.freedesktop.DBus.Properties"
22
23 using namespace Dali::Accessibility;
24
25 BridgeComponent::BridgeComponent()
26 {
27 }
28
29 void BridgeComponent::RegisterInterfaces()
30 {
31   // The second arguments below are the names (or signatures) of DBus methods.
32   // Screen Reader will call the methods with the exact names as specified in the AT-SPI Component interface:
33   // https://gitlab.gnome.org/GNOME/at-spi2-core/-/blob/master/xml/Component.xml
34
35   DBus::DBusInterfaceDescription desc{Accessible::GetInterfaceName(AtspiInterface::COMPONENT)};
36   AddFunctionToInterface(desc, "Contains", &BridgeComponent::IsAccessibleContainingPoint);
37   AddFunctionToInterface(desc, "GetAccessibleAtPoint", &BridgeComponent::GetAccessibleAtPoint);
38   AddFunctionToInterface(desc, "GetExtents", &BridgeComponent::GetExtents);
39   AddFunctionToInterface(desc, "GetPosition", &BridgeComponent::GetPosition);
40   AddFunctionToInterface(desc, "GetSize", &BridgeComponent::GetSize);
41   AddFunctionToInterface(desc, "GetLayer", &BridgeComponent::GetLayer);
42   AddFunctionToInterface(desc, "GetAlpha", &BridgeComponent::GetAlpha);
43   AddFunctionToInterface(desc, "GetMDIZOrder", &BridgeComponent::GetMdiZOrder);
44   AddFunctionToInterface(desc, "GrabHighlight", &BridgeComponent::GrabHighlight);
45   AddFunctionToInterface(desc, "GrabFocus", &BridgeComponent::GrabFocus);
46   AddFunctionToInterface(desc, "ClearHighlight", &BridgeComponent::ClearHighlight);
47   mDbusServer.addInterface("/", desc, true);
48 }
49
50 Component* BridgeComponent::FindSelf() const
51 {
52   return FindCurrentObjectWithInterface<Dali::Accessibility::AtspiInterface::COMPONENT>();
53 }
54
55 DBus::ValueOrError<bool> BridgeComponent::IsAccessibleContainingPoint(int32_t x, int32_t y, uint32_t coordType)
56 {
57   return FindSelf()->IsAccessibleContainingPoint({x, y}, static_cast<CoordinateType>(coordType));
58 }
59
60 DBus::ValueOrError<Accessible*> BridgeComponent::GetAccessibleAtPoint(int32_t x, int32_t y, uint32_t coordType)
61 {
62   return FindSelf()->GetAccessibleAtPoint({x, y}, static_cast<CoordinateType>(coordType));
63 }
64
65 DBus::ValueOrError<std::tuple<int32_t, int32_t, int32_t, int32_t> > BridgeComponent::GetExtents(uint32_t coordType)
66 {
67   auto rect = FindSelf()->GetExtents(static_cast<CoordinateType>(coordType));
68   return std::tuple<int32_t, int32_t, int32_t, int32_t>{rect.x, rect.y, rect.width, rect.height};
69 }
70
71 DBus::ValueOrError<int32_t, int32_t> BridgeComponent::GetPosition(uint32_t coordType)
72 {
73   auto rect = FindSelf()->GetExtents(static_cast<CoordinateType>(coordType));
74   return {static_cast<int32_t>(rect.x), static_cast<int32_t>(rect.y)};
75 }
76
77 DBus::ValueOrError<int32_t, int32_t> BridgeComponent::GetSize(uint32_t coordType)
78 {
79   auto rect = FindSelf()->GetExtents(static_cast<CoordinateType>(coordType));
80   return {static_cast<int32_t>(rect.width), static_cast<int32_t>(rect.height)};
81 }
82
83 DBus::ValueOrError<ComponentLayer> BridgeComponent::GetLayer()
84 {
85   return FindSelf()->GetLayer();
86 }
87
88 DBus::ValueOrError<double> BridgeComponent::GetAlpha()
89 {
90   return FindSelf()->GetAlpha();
91 }
92
93 DBus::ValueOrError<bool> BridgeComponent::GrabFocus()
94 {
95   return FindSelf()->GrabFocus();
96 }
97
98 DBus::ValueOrError<bool> BridgeComponent::GrabHighlight()
99 {
100   return FindSelf()->GrabHighlight();
101 }
102
103 DBus::ValueOrError<bool> BridgeComponent::ClearHighlight()
104 {
105   return FindSelf()->ClearHighlight();
106 }
107
108 DBus::ValueOrError<int16_t> BridgeComponent::GetMdiZOrder()
109 {
110   return FindSelf()->GetMdiZOrder();
111 }