Revert "License conversion from Flora to Apache 2.0"
[platform/core/uifw/dali-toolkit.git] / automated-tests / TET / dali-toolkit-test-utils / toolkit-orientation.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 #include "toolkit-orientation.h"
18
19 #include <dali/public-api/common/dali-common.h>
20 #include <dali/public-api/object/base-object.h>
21 #include <dali/public-api/signals/dali-signal-v2.h>
22
23 namespace Dali
24 {
25
26 namespace
27 {
28 ToolkitOrientation* gToolkitOrientation(NULL);
29 } // unnamed namespace
30
31 namespace Internal
32 {
33
34 namespace Adaptor
35 {
36
37 /**
38  * Stub for the Orientation
39  */
40 class Orientation : public BaseObject
41 {
42 public: // Creation & Destruction
43
44   Orientation();
45   Orientation(ToolkitOrientation *orientation);
46   ~Orientation();
47
48 public: // Setters & Getters
49
50   void SetDegrees( int degrees )
51   {
52     mOrientation = degrees;
53   }
54
55   int GetDegrees() const;
56   float GetRadians() const;
57
58 public: // Signals
59
60   Dali::Orientation::OrientationSignalV2& ChangedSignal();
61
62   void EmitChangedSignal()
63   {
64     mChangedSignal.Emit(Dali::Orientation(this));
65   }
66
67 private:
68
69   Dali::Orientation::OrientationSignalV2 mChangedSignal;
70
71   ToolkitOrientation* mToolkitOrientation;
72
73   int mOrientation;
74 };
75
76 Orientation::Orientation()
77 : mToolkitOrientation(NULL),
78   mOrientation(0)
79 {
80 }
81
82 Orientation::Orientation(ToolkitOrientation *orientation)
83 : mToolkitOrientation(orientation),
84   mOrientation(0)
85 {
86 }
87
88 Orientation::~Orientation()
89 {
90 }
91
92 int Orientation::GetDegrees() const
93 {
94   mToolkitOrientation->mFunctionsCalled.GetDegrees = true;
95   return mOrientation;
96 }
97
98 float Orientation::GetRadians() const
99 {
100   mToolkitOrientation->mFunctionsCalled.GetRadians = true;
101   return Math::PI * (float)mOrientation / 180.0f;
102 }
103
104 Dali::Orientation::OrientationSignalV2& Orientation::ChangedSignal()
105 {
106   mToolkitOrientation->mFunctionsCalled.ChangedSignal = true;
107   return mChangedSignal;
108 }
109
110 } // namespace Adaptor
111
112 } // namespace Internal
113
114 ////////////////////////////////////////////////////////////////////////////////////////////////////
115
116 ToolkitOrientation::ToolkitOrientation()
117 : mOrientationStub(new Internal::Adaptor::Orientation(this)),
118   mOrientation( mOrientationStub )
119 {
120   gToolkitOrientation = this;
121 }
122
123 ToolkitOrientation::~ToolkitOrientation()
124 {
125   gToolkitOrientation = NULL;
126 }
127
128 Orientation ToolkitOrientation::GetHandle()
129 {
130   return mOrientation;
131 }
132
133 void ToolkitOrientation::SetDegrees( int degrees )
134 {
135   mOrientationStub->SetDegrees( degrees );
136 }
137
138 void ToolkitOrientation::EmitChangedSignal()
139 {
140   mOrientationStub->EmitChangedSignal();
141 }
142
143 } // namespace Dali