Event handling refactoring to support EvasPlugin
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / orientation-impl.h
1 #ifndef DALI_INTERNAL_ORIENTATION_H
2 #define DALI_INTERNAL_ORIENTATION_H
3
4 /*
5  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <cmath>
23 #include <dali/public-api/common/constants.h>
24 #include <dali/public-api/object/base-object.h>
25
26 // INTERNAL INCLUDES
27 #include <dali/devel-api/adaptor-framework/orientation.h>
28 #include <dali/internal/window-system/common/rotation-event.h>
29
30 namespace Dali
31 {
32
33 namespace Internal
34 {
35
36 namespace Adaptor
37 {
38 class Window;
39 class Orientation;
40
41 typedef IntrusivePtr<Orientation> OrientationPtr;
42
43 class Orientation : public BaseObject
44 {
45 public:
46
47   typedef Dali::Orientation::OrientationSignalType OrientationSignalType;
48
49   static Orientation* New(Window* window);
50
51   /**
52    * Constructor
53    */
54   Orientation(Window* window);
55
56 protected:
57   /**
58    * Destructor
59    */
60   virtual ~Orientation();
61
62 public:
63
64   /**
65    * Returns the actual orientation in degrees
66    * @return The device's orientation
67    */
68   int GetDegrees() const;
69
70   /**
71    * Returns the actual orientation in radians
72    * @return The device's orientation
73    */
74   float GetRadians() const;
75
76   /**
77    * Called by the Window when orientation is changed
78    * @param[in] rotation The rotation event
79    */
80   void OnOrientationChange( const RotationEvent& rotation );
81
82 public: // Signals
83
84   /**
85    * @copydoc Dali::Orientation::ChangedSignal()
86    */
87   OrientationSignalType& ChangedSignal();
88
89 private:
90
91   // Undefined
92   Orientation(const Orientation&);
93   Orientation& operator=(Orientation&);
94
95 private:
96
97   Window*                                  mWindow;
98
99   OrientationSignalType mChangedSignal;
100
101   int                                      mOrientation;
102   int                                      mWindowWidth;
103   int                                      mWindowHeight;
104 };
105
106 inline Orientation& GetImplementation (Dali::Orientation& orientation)
107 {
108   DALI_ASSERT_ALWAYS(orientation && "Orientation handle is empty");
109
110   BaseObject& handle = orientation.GetBaseObject();
111
112   return static_cast<Orientation&>(handle);
113 }
114
115 inline const Orientation& GetImplementation(const Dali::Orientation& orientation)
116 {
117   DALI_ASSERT_ALWAYS(orientation && "Orientation handle is empty");
118
119   const BaseObject& handle = orientation.GetBaseObject();
120
121   return static_cast<const Orientation&>(handle);
122 }
123
124 } // namespace Adaptor
125
126 } // namespace Internal
127
128 } // namespace Dali
129
130 #endif // DALI_INTERNAL_ORIENTATION_H