Merge "Fixed indentation." into devel/master
[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-observer.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, public RotationObserver
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 public: // Signals
77
78   /**
79    * @copydoc Dali::Orientation::ChangedSignal()
80    */
81   OrientationSignalType& ChangedSignal();
82
83 private:
84   /**
85    * @copydoc Dali::Internal::Adaptor::RotationObserver::OnRotationPrepare()
86    */
87   virtual void OnRotationPrepare( const RotationEvent& rotation );
88
89   /**
90    * @copydoc Dali::Internal::Adaptor::RotationObserver::OnRotationRequest()
91    */
92   virtual void OnRotationRequest( );
93
94   // Undefined
95   Orientation(const Orientation&);
96   Orientation& operator=(Orientation&);
97
98 private:
99   /**
100    * Signals and sends event of orientation change.
101    */
102   void EmitOrientationChange();
103
104 private:
105
106   Window*                                  mWindow;
107
108   OrientationSignalType mChangedSignal;
109
110   int                                      mOrientation;
111   int                                      mWindowWidth;
112   int                                      mWindowHeight;
113 };
114
115 inline Orientation& GetImplementation (Dali::Orientation& orientation)
116 {
117   DALI_ASSERT_ALWAYS(orientation && "Orientation handle is empty");
118
119   BaseObject& handle = orientation.GetBaseObject();
120
121   return static_cast<Orientation&>(handle);
122 }
123
124 inline const Orientation& GetImplementation(const Dali::Orientation& orientation)
125 {
126   DALI_ASSERT_ALWAYS(orientation && "Orientation handle is empty");
127
128   const BaseObject& handle = orientation.GetBaseObject();
129
130   return static_cast<const Orientation&>(handle);
131 }
132
133 } // namespace Adaptor
134
135 } // namespace Internal
136
137 } // namespace Dali
138
139 #endif // DALI_INTERNAL_ORIENTATION_H