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.
19 #include "orientation-impl.h"
23 #include <dali/integration-api/debug.h>
26 #include <window-impl.h>
27 #include <adaptor-impl.h>
36 Orientation* Orientation::New(Window* window)
38 Orientation* orientation = new Orientation(window);
43 Orientation::Orientation(Window* window)
51 Orientation::~Orientation()
53 // Note, there is only one orientation object that's owned by window,
54 // so it will live longer than adaptor. (hence, no need to remove rotation observer)
57 void Orientation::SetAdaptor(Dali::Adaptor& adaptor)
59 Adaptor& adaptorImpl = Adaptor::GetImplementation(adaptor);
60 adaptorImpl.SetRotationObserver(this);
63 int Orientation::GetDegrees() const
68 float Orientation::GetRadians() const
70 return Math::PI * (float)mOrientation / 180.0f;
73 Orientation::OrientationSignalV2& Orientation::ChangedSignal()
75 return mChangedSignal;
78 void Orientation::OnRotationPrepare( const RotationEvent& rotation )
80 mOrientation = rotation.angle;
81 mWindowWidth = rotation.width;
82 mWindowHeight = rotation.height;
85 void Orientation::OnRotationRequest()
88 if( !mChangedSignal.Empty() )
90 Dali::Orientation handle( this );
91 mChangedSignal.Emit( handle );
96 mWindow->RotationDone( mOrientation, mWindowWidth, mWindowHeight );
100 } // namespace Adaptor
102 } // namespace Internal