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