2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include "toolkit-orientation.h"
20 #include <dali/public-api/common/dali-common.h>
21 #include <dali/public-api/object/base-object.h>
22 #include <dali/public-api/signals/dali-signal-v2.h>
29 ToolkitOrientation* gToolkitOrientation(NULL);
30 } // unnamed namespace
39 * Stub for the Orientation
41 class Orientation : public BaseObject
43 public: // Creation & Destruction
46 Orientation(ToolkitOrientation *orientation);
49 public: // Setters & Getters
51 void SetDegrees( int degrees )
53 mOrientation = degrees;
56 int GetDegrees() const;
57 float GetRadians() const;
61 Dali::Orientation::OrientationSignalV2& ChangedSignal();
63 void EmitChangedSignal()
65 mChangedSignal.Emit(Dali::Orientation(this));
70 Dali::Orientation::OrientationSignalV2 mChangedSignal;
72 ToolkitOrientation* mToolkitOrientation;
77 Orientation::Orientation()
78 : mToolkitOrientation(NULL),
83 Orientation::Orientation(ToolkitOrientation *orientation)
84 : mToolkitOrientation(orientation),
89 Orientation::~Orientation()
93 int Orientation::GetDegrees() const
95 mToolkitOrientation->mFunctionsCalled.GetDegrees = true;
99 float Orientation::GetRadians() const
101 mToolkitOrientation->mFunctionsCalled.GetRadians = true;
102 return Math::PI * (float)mOrientation / 180.0f;
105 Dali::Orientation::OrientationSignalV2& Orientation::ChangedSignal()
107 mToolkitOrientation->mFunctionsCalled.ChangedSignal = true;
108 return mChangedSignal;
111 } // namespace Adaptor
113 } // namespace Internal
115 ////////////////////////////////////////////////////////////////////////////////////////////////////
117 ToolkitOrientation::ToolkitOrientation()
118 : mOrientationStub(new Internal::Adaptor::Orientation(this)),
119 mOrientation( mOrientationStub )
121 gToolkitOrientation = this;
124 ToolkitOrientation::~ToolkitOrientation()
126 gToolkitOrientation = NULL;
129 Orientation ToolkitOrientation::GetHandle()
134 void ToolkitOrientation::SetDegrees( int degrees )
136 mOrientationStub->SetDegrees( degrees );
139 void ToolkitOrientation::EmitChangedSignal()
141 mOrientationStub->EmitChangedSignal();