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