1681440f9daec1a43bdbceb3bd46f22e0bd569ad
[platform/core/uifw/dali-adaptor.git] / adaptors / public-api / adaptor-framework / orientation.h
1 #ifndef __DALI_ORIENTATION_H__
2 #define __DALI_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 <boost/function.hpp>
23
24 #include <dali/public-api/signals/dali-signal-v2.h>
25 #include <dali/public-api/object/base-handle.h>
26
27 namespace Dali DALI_IMPORT_API
28 {
29
30 namespace Internal DALI_INTERNAL
31 {
32 namespace Adaptor
33 {
34 class Orientation;
35 }
36 }
37
38 /**
39  * @brief Orientation allows the user to determine the orientation of the device.
40  *
41  * A signal is emitted whenever the orientation changes.
42  * Dali applications have full control over visual layout when the device is rotated
43  * i.e. the application developer decides which UI controls to rotate, if any.
44  */
45 class Orientation : public BaseHandle
46 {
47 public:
48
49   typedef SignalV2< void (Orientation) > OrientationSignalV2; ///< Orientation changed signal type
50
51   /**
52    * @brief Create an unintialized handle.
53    *
54    * This can be initialized by calling Dali::Application::GetOrientation()
55    */
56   Orientation();
57
58   /**
59    * @brief Destructor
60    *
61    * This is non-virtual since derived Handle types must not contain data or virtual methods.
62    */
63   ~Orientation();
64
65   /**
66    * @brief This copy constructor is required for (smart) pointer semantics.
67    *
68    * @param [in] handle A reference to the copied handle
69    */
70   Orientation(const Orientation& handle);
71
72   /**
73    * @brief This assignment operator is required for (smart) pointer semantics.
74    *
75    * @param [in] rhs  A reference to the copied handle
76    * @return A reference to this
77    */
78   Orientation& operator=(const Orientation& rhs);
79
80   /**
81    * @brief This method is defined to allow assignment of the NULL value,
82    * and will throw an exception if passed any other value.
83    *
84    * Assigning to NULL is an alias for Reset().
85    * @param [in] rhs  A NULL pointer
86    * @return A reference to this handle
87    */
88   Orientation& operator=(BaseHandle::NullType* rhs);
89
90   /**
91    * @brief Returns the orientation of the device in degrees.
92    *
93    * This is one of four discrete values, in degrees clockwise: 0, 90, 180, & 270
94    * For a device with a portrait form-factor:
95    *   0 indicates that the device is in the "normal" portrait orientation.
96    *   90 indicates that device has been rotated clockwise, into a landscape orientation.
97    * @return The orientation in degrees clockwise.
98    */
99   int GetDegrees() const;
100
101   /**
102    * @brief Returns the orientation of the device in radians.
103    *
104    * This is one of four discrete values, in radians clockwise: 0, PI/2, PI, & 3xPI/2
105    * For a device with a portrait form-factor:
106    *   0 indicates that the device is in the "normal" portrait orientation.
107    *   PI/2 indicates that device has been rotated clockwise, into a landscape orientation.
108    * @return The orientation in radians clockwise.
109    */
110   float GetRadians() const;
111
112   /**
113    * @brief The user should connect to this signal so that they can be notified whenever
114    * the orientation of the device changes.
115    *
116    * @return The orientation change signal.
117    */
118   OrientationSignalV2& ChangedSignal();
119
120 public: // Not intended for application developers
121   /**
122    * @brief This constructor is used by Dali::Application::GetOrientation().
123    *
124    * @param[in] orientation A pointer to the orientation object
125    */
126   explicit DALI_INTERNAL Orientation( Internal::Adaptor::Orientation* orientation );
127 };
128
129 } // namespace Dali
130
131 #endif // __DALI_ORIENTATION_H__