Fixed indentation.
[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 class Adaptor;
33
34 namespace Internal
35 {
36
37 namespace Adaptor
38 {
39 class Adaptor;
40 class Window;
41 class Orientation;
42
43 typedef IntrusivePtr<Orientation> OrientationPtr;
44
45 class Orientation : public BaseObject, public RotationObserver
46 {
47 public:
48
49   typedef Dali::Orientation::OrientationSignalType OrientationSignalType;
50
51   static Orientation* New(Window* window);
52
53   /**
54    * Constructor
55    */
56   Orientation(Window* window);
57
58 protected:
59   /**
60    * Destructor
61    */
62   virtual ~Orientation();
63
64 public:
65   /**
66    * Set the adaptor for basic setup
67    * @param[in] adaptor The adaptor
68    */
69   void SetAdaptor(Dali::Adaptor& adaptor);
70
71   /**
72    * Set the adaptor for basic setup
73    * @param[in] adaptor The adaptor
74    */
75   void SetAdaptor(Adaptor& adaptor);
76
77   /**
78    * Returns the actual orientation in degrees
79    * @return The device's orientation
80    */
81   int GetDegrees() const;
82
83   /**
84    * Returns the actual orientation in radians
85    * @return The device's orientation
86    */
87   float GetRadians() const;
88
89 public: // Signals
90
91   /**
92    * @copydoc Dali::Orientation::ChangedSignal()
93    */
94   OrientationSignalType& ChangedSignal();
95
96 private:
97   /**
98    * @copydoc Dali::Internal::Adaptor::RotationObserver::OnRotationPrepare()
99    */
100   virtual void OnRotationPrepare( const RotationEvent& rotation );
101
102   /**
103    * @copydoc Dali::Internal::Adaptor::RotationObserver::OnRotationRequest()
104    */
105   virtual void OnRotationRequest( );
106
107   // Undefined
108   Orientation(const Orientation&);
109   Orientation& operator=(Orientation&);
110
111 private:
112   /**
113    * Signals and sends event of orientation change.
114    */
115   void EmitOrientationChange();
116
117 private:
118
119   Window*                                  mWindow;
120
121   OrientationSignalType mChangedSignal;
122
123   int                                      mOrientation;
124   int                                      mWindowWidth;
125   int                                      mWindowHeight;
126 };
127
128 inline Orientation& GetImplementation (Dali::Orientation& orientation)
129 {
130   DALI_ASSERT_ALWAYS(orientation && "Orientation handle is empty");
131
132   BaseObject& handle = orientation.GetBaseObject();
133
134   return static_cast<Orientation&>(handle);
135 }
136
137 inline const Orientation& GetImplementation(const Dali::Orientation& orientation)
138 {
139   DALI_ASSERT_ALWAYS(orientation && "Orientation handle is empty");
140
141   const BaseObject& handle = orientation.GetBaseObject();
142
143   return static_cast<const Orientation&>(handle);
144 }
145
146 } // namespace Adaptor
147
148 } // namespace Internal
149
150 } // namespace Dali
151
152 #endif // DALI_INTERNAL_ORIENTATION_H