Merge "Support to get the rect value to recalulate with the default system coordinate...
[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) 2021 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 <dali/public-api/common/constants.h>
23 #include <dali/public-api/object/base-object.h>
24 #include <cmath>
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 namespace Internal
33 {
34 namespace Adaptor
35 {
36 class Window;
37 class Orientation;
38
39 typedef IntrusivePtr<Orientation> OrientationPtr;
40
41 class Orientation : public BaseObject
42 {
43 public:
44   typedef Dali::Orientation::OrientationSignalType OrientationSignalType;
45
46   static Orientation* New(Window* window);
47
48   /**
49    * Constructor
50    */
51   Orientation(Window* window);
52
53 protected:
54   /**
55    * Destructor
56    */
57   ~Orientation() override;
58
59 public:
60   /**
61    * Returns the actual orientation in degrees
62    * @return The device's orientation
63    */
64   int GetDegrees() const;
65
66   /**
67    * Returns the actual orientation in radians
68    * @return The device's orientation
69    */
70   float GetRadians() const;
71
72   /**
73    * Called by the Window when orientation is changed
74    * @param[in] rotation The rotation event
75    */
76   void OnOrientationChange(const RotationEvent& rotation);
77
78 public: // Signals
79   /**
80    * @copydoc Dali::Orientation::ChangedSignal()
81    */
82   OrientationSignalType& ChangedSignal();
83
84 private:
85   // Undefined
86   Orientation(const Orientation&);
87   Orientation& operator=(Orientation&);
88
89 private:
90   Window* mWindow;
91
92   OrientationSignalType mChangedSignal;
93
94   int mOrientation;
95   int mWindowWidth;
96   int mWindowHeight;
97 };
98
99 inline Orientation& GetImplementation(Dali::Orientation& orientation)
100 {
101   DALI_ASSERT_ALWAYS(orientation && "Orientation handle is empty");
102
103   BaseObject& handle = orientation.GetBaseObject();
104
105   return static_cast<Orientation&>(handle);
106 }
107
108 inline const Orientation& GetImplementation(const Dali::Orientation& orientation)
109 {
110   DALI_ASSERT_ALWAYS(orientation && "Orientation handle is empty");
111
112   const BaseObject& handle = orientation.GetBaseObject();
113
114   return static_cast<const Orientation&>(handle);
115 }
116
117 } // namespace Adaptor
118
119 } // namespace Internal
120
121 } // namespace Dali
122
123 #endif // DALI_INTERNAL_ORIENTATION_H