Dali 3D User Interface Engine
toolkit-orientation.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 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 "toolkit-orientation.h"
19 
23 
24 namespace Dali
25 {
26 
27 namespace
28 {
30 } // unnamed namespace
31 
32 namespace Internal
33 {
34 
35 namespace Adaptor
36 {
37 
41 class Orientation : public BaseObject
42 {
43 public: // Creation & Destruction
44 
45  Orientation();
46  Orientation(ToolkitOrientation *orientation);
47  ~Orientation();
48 
49 public: // Setters & Getters
50 
51  void SetDegrees( int degrees )
52  {
53  mOrientation = degrees;
54  }
55 
56  int GetDegrees() const;
57  float GetRadians() const;
58 
59 public: // Signals
60 
61  Dali::Orientation::OrientationSignalType& ChangedSignal();
62 
64  {
65  mChangedSignal.Emit(Dali::Orientation(this));
66  }
67 
68 private:
69 
70  Dali::Orientation::OrientationSignalType mChangedSignal;
71 
73 
74  int mOrientation;
75 };
76 
78 : mToolkitOrientation(NULL),
79  mOrientation(0)
80 {
81 }
82 
84 : mToolkitOrientation(orientation),
85  mOrientation(0)
86 {
87 }
88 
90 {
91 }
92 
93 int Orientation::GetDegrees() const
94 {
96  return mOrientation;
97 }
98 
99 float Orientation::GetRadians() const
100 {
102  return Math::PI * (float)mOrientation / 180.0f;
103 }
104 
105 Dali::Orientation::OrientationSignalType& Orientation::ChangedSignal()
106 {
108  return mChangedSignal;
109 }
110 
111 } // namespace Adaptor
112 
113 } // namespace Internal
114 
116 
118 : mOrientationStub(new Internal::Adaptor::Orientation(this)),
119  mOrientation( mOrientationStub )
120 {
121  gToolkitOrientation = this;
122 }
123 
125 {
126  gToolkitOrientation = NULL;
127 }
128 
130 {
131  return mOrientation;
132 }
133 
135 {
136  mOrientationStub->SetDegrees( degrees );
137 }
138 
140 {
142 }
143 
144 } // namespace Dali
Dali Docs Home
Read more about Dali