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