[Tizen][ATSPI] Accessibility initial implementation
[platform/core/uifw/dali-adaptor.git] / dali / dali-bridge / src / BridgeComponent.cpp
1 #include "BridgeComponent.hpp"
2 #include <iostream>
3
4 #define DBUS_INTERFACE_PROPERTIES "org.freedesktop.DBus.Properties"
5
6 using namespace Dali::Accessibility;
7
8 BridgeComponent::BridgeComponent()
9 {
10 }
11
12 void BridgeComponent::RegisterInterfaces()
13 {
14   DBus::DBusInterfaceDescription desc{ATSPI_DBUS_INTERFACE_COMPONENT};
15   AddFunctionToInterface( desc, "Contains", &BridgeComponent::Contains );
16   AddFunctionToInterface( desc, "GetAccessibleAtPoint", &BridgeComponent::GetAccessibleAtPoint );
17   AddFunctionToInterface( desc, "GetExtents", &BridgeComponent::GetExtents );
18   AddFunctionToInterface( desc, "GetPosition", &BridgeComponent::GetPosition );
19   AddFunctionToInterface( desc, "GetSize", &BridgeComponent::GetSize );
20   AddFunctionToInterface( desc, "GetLayer", &BridgeComponent::GetLayer );
21   AddFunctionToInterface( desc, "GetAlpha", &BridgeComponent::GetAlpha );
22   AddFunctionToInterface( desc, "GrabHighlight", &BridgeComponent::GrabHighlight );
23   AddFunctionToInterface( desc, "ClearHighlight", &BridgeComponent::ClearHighlight );
24   dbusServer.addInterface( "/", desc, true );
25 }
26
27 Component* BridgeComponent::FindSelf() const
28 {
29   auto s = BridgeBase::FindSelf();
30   assert( s );
31   auto s2 = dynamic_cast< Component* >( s );
32   if( !s2 )
33     throw AccessibleError{"object " + s->GetAddress().ToString() + " doesn't have Component interface"};
34   return s2;
35 }
36
37 DBus::ValueOrError< bool > BridgeComponent::Contains( int32_t x, int32_t y, uint32_t coordType )
38 {
39   return FindSelf()->Contains( {x, y}, static_cast< CoordType >( coordType ) );
40 }
41 DBus::ValueOrError< Accessible* > BridgeComponent::GetAccessibleAtPoint( int32_t x, int32_t y, uint32_t coordType )
42 {
43   return FindSelf()->GetAccessibleAtPoint( {x, y}, static_cast< CoordType >( coordType ) );
44 }
45 DBus::ValueOrError< std::tuple< int32_t, int32_t, int32_t, int32_t > > BridgeComponent::GetExtents( uint32_t coordType )
46 {
47   auto p = FindSelf()->GetExtents( static_cast< CoordType >( coordType ) );
48   return std::tuple< int32_t, int32_t, int32_t, int32_t >{p.position.x, p.position.y, p.size.width, p.size.height};
49 }
50 DBus::ValueOrError< int32_t, int32_t > BridgeComponent::GetPosition( uint32_t coordType )
51 {
52   auto p = FindSelf()->GetExtents( static_cast< CoordType >( coordType ) );
53   return {p.position.x, p.position.y};
54 }
55 DBus::ValueOrError< int32_t, int32_t > BridgeComponent::GetSize( uint32_t coordType )
56 {
57   auto p = FindSelf()->GetExtents( static_cast< CoordType >( coordType ) );
58   return {p.size.width, p.size.height};
59 }
60 DBus::ValueOrError< ComponentLayer > BridgeComponent::GetLayer()
61 {
62   return FindSelf()->GetLayer();
63 }
64 DBus::ValueOrError< double > BridgeComponent::GetAlpha()
65 {
66   return FindSelf()->GetAlpha();
67 }
68 DBus::ValueOrError< bool > BridgeComponent::GrabHighlight()
69 {
70   return FindSelf()->GrabHighlight();
71 }
72 DBus::ValueOrError< bool > BridgeComponent::ClearHighlight()
73 {
74   return FindSelf()->ClearHighlight();
75 }