2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 // http://floralicense.org/license/
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.
17 #include "toolkit-orientation.h"
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>
28 ToolkitOrientation* gToolkitOrientation(NULL);
29 } // unnamed namespace
38 * Stub for the Orientation
40 class Orientation : public BaseObject
42 public: // Creation & Destruction
45 Orientation(ToolkitOrientation *orientation);
48 public: // Setters & Getters
50 void SetDegrees( int degrees )
52 mOrientation = degrees;
55 int GetDegrees() const;
56 float GetRadians() const;
60 Dali::Orientation::OrientationSignalV2& ChangedSignal();
62 void EmitChangedSignal()
64 mChangedSignal.Emit(Dali::Orientation(this));
69 Dali::Orientation::OrientationSignalV2 mChangedSignal;
71 ToolkitOrientation* mToolkitOrientation;
76 Orientation::Orientation()
77 : mToolkitOrientation(NULL),
82 Orientation::Orientation(ToolkitOrientation *orientation)
83 : mToolkitOrientation(orientation),
88 Orientation::~Orientation()
92 int Orientation::GetDegrees() const
94 mToolkitOrientation->mFunctionsCalled.GetDegrees = true;
98 float Orientation::GetRadians() const
100 mToolkitOrientation->mFunctionsCalled.GetRadians = true;
101 return Math::PI * (float)mOrientation / 180.0f;
104 Dali::Orientation::OrientationSignalV2& Orientation::ChangedSignal()
106 mToolkitOrientation->mFunctionsCalled.ChangedSignal = true;
107 return mChangedSignal;
110 } // namespace Adaptor
112 } // namespace Internal
114 ////////////////////////////////////////////////////////////////////////////////////////////////////
116 ToolkitOrientation::ToolkitOrientation()
117 : mOrientationStub(new Internal::Adaptor::Orientation(this)),
118 mOrientation( mOrientationStub )
120 gToolkitOrientation = this;
123 ToolkitOrientation::~ToolkitOrientation()
125 gToolkitOrientation = NULL;
128 Orientation ToolkitOrientation::GetHandle()
133 void ToolkitOrientation::SetDegrees( int degrees )
135 mOrientationStub->SetDegrees( degrees );
138 void ToolkitOrientation::EmitChangedSignal()
140 mOrientationStub->EmitChangedSignal();