[AT-SPI] Squashed implementation
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-orientation.cpp
1 /*
2  * Copyright (c) 2018 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 #include <dali/devel-api/adaptor-framework/orientation.h>
19
20 #include <dali-toolkit/public-api/dali-toolkit-common.h>
21 #include <dali/public-api/object/base-object.h>
22 #include <dali/public-api/signals/dali-signal.h>
23
24 using namespace Dali;
25
26 namespace Dali
27 {
28 class Adaptor;
29
30 namespace Internal
31 {
32 namespace Adaptor
33 {
34 class Window;
35
36
37 struct RotationEvent
38 {
39   int angle;     ///< one of 0, 90, 180, 270
40   int winResize; ///< true if the window should be resized
41   int width;     ///< new window width
42   int height;    ///< new window height
43 };
44
45 class Orientation : public BaseObject
46 {
47 public:
48   typedef Dali::Orientation::OrientationSignalType OrientationSignalType;
49
50   static Orientation* New(Window* window)
51   {
52     Orientation* orientation = new Orientation(window);
53     return orientation;
54   }
55   Orientation(Window* window)
56   {
57   }
58
59 protected:
60   virtual ~Orientation()
61   {
62   }
63 public:
64   int GetDegrees() const
65   {
66     return 0;
67   }
68   float GetRadians() const
69   {
70     return 0.0f;
71   }
72   void OnOrientationChanged( const RotationEvent& rotation )
73   {
74   }
75   OrientationSignalType& ChangedSignal()
76   {
77     return mChangedSignal;
78   }
79
80 private:
81   Orientation(const Orientation&);
82   Orientation& operator=(Orientation&);
83   OrientationSignalType mChangedSignal;
84 };
85
86 } // Adaptor namespace
87 } // Internal namespace
88
89 inline Internal::Adaptor::Orientation& GetImplementation (Dali::Orientation& orientation)
90 {
91   DALI_ASSERT_ALWAYS(orientation && "Orientation handle is empty");
92   BaseObject& handle = orientation.GetBaseObject();
93   return static_cast<Internal::Adaptor::Orientation&>(handle);
94 }
95 inline const Internal::Adaptor::Orientation& GetImplementation(const Dali::Orientation& orientation)
96 {
97   DALI_ASSERT_ALWAYS(orientation && "Orientation handle is empty");
98   const BaseObject& handle = orientation.GetBaseObject();
99   return static_cast<const Internal::Adaptor::Orientation&>(handle);
100 }
101
102 Orientation::Orientation()
103 {
104 }
105 Orientation::~Orientation()
106 {
107 }
108 Orientation::Orientation(const Orientation& handle)
109 : BaseHandle(handle)
110 {
111 }
112
113 Orientation& Orientation::operator=(const Orientation& rhs)
114 {
115   BaseHandle::operator=(rhs);
116   return *this;
117 }
118
119 int Orientation::GetDegrees() const
120 {
121   return GetImplementation(*this).GetDegrees();
122 }
123
124 float Orientation::GetRadians() const
125 {
126   return GetImplementation(*this).GetRadians();
127 }
128
129 Orientation::OrientationSignalType& Orientation::ChangedSignal()
130 {
131   return GetImplementation(*this).ChangedSignal();
132 }
133
134 Orientation::Orientation( Internal::Adaptor::Orientation* orientation )
135 : BaseHandle(orientation)
136 {
137 }
138
139 } // Dali