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 <dali/devel-api/adaptor-framework/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.h>
39 int angle; ///< one of 0, 90, 180, 270
40 int winResize; ///< true if the window should be resized
41 int width; ///< new window width
42 int height; ///< new window height
46 * The RotationObserver can be overridden in order to listen to rotation events.
48 class RotationObserver
51 virtual void OnRotationPrepare( const RotationEvent& rotation ) = 0;
52 virtual void OnRotationRequest( ) = 0;
56 virtual ~RotationObserver(){}
59 class Orientation : public BaseObject, public RotationObserver
62 typedef Dali::Orientation::OrientationSignalType OrientationSignalType;
64 static Orientation* New(Window* window)
66 Orientation* orientation = new Orientation(window);
69 Orientation(Window* window)
74 virtual ~Orientation()
78 void SetAdaptor(Dali::Adaptor& adaptor)
81 int GetDegrees() const
85 float GetRadians() const
89 OrientationSignalType& ChangedSignal()
91 return mChangedSignal;
93 virtual void OnRotationPrepare( const RotationEvent& rotation )
96 virtual void OnRotationRequest( )
101 Orientation(const Orientation&);
102 Orientation& operator=(Orientation&);
103 OrientationSignalType mChangedSignal;
106 } // Adaptor namespace
107 } // Internal namespace
109 inline Internal::Adaptor::Orientation& GetImplementation (Dali::Orientation& orientation)
111 DALI_ASSERT_ALWAYS(orientation && "Orientation handle is empty");
112 BaseObject& handle = orientation.GetBaseObject();
113 return static_cast<Internal::Adaptor::Orientation&>(handle);
115 inline const Internal::Adaptor::Orientation& GetImplementation(const Dali::Orientation& orientation)
117 DALI_ASSERT_ALWAYS(orientation && "Orientation handle is empty");
118 const BaseObject& handle = orientation.GetBaseObject();
119 return static_cast<const Internal::Adaptor::Orientation&>(handle);
122 Orientation::Orientation()
125 Orientation::~Orientation()
128 Orientation::Orientation(const Orientation& handle)
133 Orientation& Orientation::operator=(const Orientation& rhs)
135 BaseHandle::operator=(rhs);
139 int Orientation::GetDegrees() const
141 return GetImplementation(*this).GetDegrees();
144 float Orientation::GetRadians() const
146 return GetImplementation(*this).GetRadians();
149 Orientation::OrientationSignalType& Orientation::ChangedSignal()
151 return GetImplementation(*this).ChangedSignal();
154 Orientation::Orientation( Internal::Adaptor::Orientation* orientation )
155 : BaseHandle(orientation)