[3.0] Fix build error
[platform/core/uifw/dali-adaptor.git] / adaptors / common / window-impl.h
1 #ifndef __DALI_INTERNAL_WINDOW_H__
2 #define __DALI_INTERNAL_WINDOW_H__
3
4 /*
5  * Copyright (c) 2017 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/ref-object.h>
23 #include <dali/public-api/object/base-object.h>
24
25 // INTERNAL INCLUDES
26 #include <base/lifecycle-observer.h>
27 #include <base/interfaces/indicator-interface.h>
28 #include <adaptor-impl.h>
29 #include <window.h>
30 #include <orientation.h>
31 #include <render-surface.h>
32 #include <drag-and-drop-detector.h>
33
34 namespace Dali
35 {
36 class Adaptor;
37 class RenderSurface;
38
39 namespace Integration
40 {
41 class SystemOverlay;
42 }
43
44 namespace Internal
45 {
46 namespace Adaptor
47 {
48 class Orientation;
49
50 class Window;
51 typedef IntrusivePtr<Window> WindowPtr;
52 typedef IntrusivePtr<Orientation> OrientationPtr;
53
54 /**
55  * Window provides a surface to render onto with orientation & indicator properties.
56  */
57 class Window : public Dali::BaseObject, public IndicatorInterface::Observer, public LifeCycleObserver
58 {
59 public:
60   typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
61   typedef Signal< void () > SignalType;
62
63   /**
64    * Create a new Window. This should only be called once by the Application class
65    * @param[in] positionSize The position and size of the window
66    * @param[in] name The window title
67    * @param[in] className The window class name
68    * @param[in] isTransparent Whether window is transparent
69    * @return A newly allocated Window
70    */
71   static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false);
72
73   /**
74    * Pass the adaptor back to the overlay. This allows the window to access Core's overlay.
75    * @param[in] adaptor An initialized adaptor
76    */
77   void SetAdaptor(Dali::Adaptor& adaptor);
78
79   /**
80    * Get the window surface
81    * @return The render surface
82    */
83   RenderSurface* GetSurface();
84
85   /**
86    * @copydoc Dali::Window::ShowIndicator()
87    */
88   void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
89
90   /**
91    * @copydoc Dali::Window::SetIndicatorBgOpacity()
92    */
93   void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
94
95   /**
96    * @copydoc Dali::Window::RotateIndicator()
97    */
98   void RotateIndicator( Dali::Window::WindowOrientation orientation );
99
100   /**
101    * @copydoc Dali::Window::SetClass()
102    */
103   void SetClass( std::string name, std::string klass );
104
105   /**
106    * @copydoc Dali::Window::Raise()
107    */
108   void Raise();
109
110   /**
111    * @copydoc Dali::Window::Lower()
112    */
113   void Lower();
114
115   /**
116    * @copydoc Dali::Window::Activate()
117    */
118   void Activate();
119
120   /**
121    * @copydoc Dali::Window::AddAvailableOrientation()
122    */
123   void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
124
125   /**
126    * @copydoc Dali::Window::RemoveAvailableOrientation()
127    */
128   void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
129
130   /**
131    * @copydoc Dali::Window::SetAvailableOrientations()
132    */
133   void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
134
135   /**
136    * @copydoc Dali::Window::GetAvailableOrientations()
137    */
138   const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
139
140   /**
141    * @copydoc Dali::Window::SetPreferredOrientation()
142    */
143   void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
144
145   /**
146    * @copydoc Dali::Window::GetPreferredOrientation()
147    */
148   Dali::Window::WindowOrientation GetPreferredOrientation();
149
150   /**
151    * @copydoc Dali::Window::GetDragAndDropDetector() const
152    */
153   Dali::DragAndDropDetector GetDragAndDropDetector() const;
154
155   /**
156    * @copydoc Dali::Window::GetNativeHandle() const
157    */
158   Dali::Any GetNativeHandle() const;
159
160   unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
161
162   /**
163    * Called from Orientation after the Change signal has been sent
164    */
165   void RotationDone( int orientation, int width, int height );
166
167 private:
168   /**
169    * Private constructor.
170    * @sa Window::New()
171    */
172   Window();
173
174   /**
175    * Destructor
176    */
177   virtual ~Window();
178
179   /**
180    * Second stage initialization
181    */
182   void Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className);
183
184   /**
185    * Shows / hides the indicator bar.
186    * Handles close/open if rotation changes whilst hidden
187    */
188   void DoShowIndicator( Dali::Window::WindowOrientation lastOrientation );
189
190   /**
191    * Close current indicator and open a connection onto the new indicator service.
192    * Effect may not be synchronous if waiting for an indicator update on existing connection.
193    */
194   void DoRotateIndicator( Dali::Window::WindowOrientation orientation );
195
196   /**
197    * Change the indicator actor's rotation to match the current orientation
198    */
199   void SetIndicatorActorRotation();
200
201   /**
202    * Set the indicator properties on the window
203    */
204   void SetIndicatorProperties( bool isShown, Dali::Window::WindowOrientation lastOrientation );
205
206 private: // IndicatorInterface::Observer interface
207
208   /**
209    * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorTypeChanged()
210    */
211   virtual void IndicatorTypeChanged( IndicatorInterface::Type type );
212
213   /**
214    * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorClosed()
215    */
216   virtual void IndicatorClosed( IndicatorInterface* indicator);
217
218   /**
219    * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorVisibilityChanged()
220    */
221   virtual void IndicatorVisibilityChanged( bool isVisible );
222
223 private: // Adaptor::Observer interface
224
225   /**
226    * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
227    */
228   virtual void OnStart();
229
230   /**
231    * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
232    */
233   virtual void OnPause();
234
235   /**
236    * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
237    */
238   virtual void OnResume();
239
240   /**
241    * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
242    */
243   virtual void OnStop();
244
245   /**
246    * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
247    */
248   virtual void OnDestroy();
249
250 public: // Signals
251
252   /**
253    * The user should connect to this signal to get a timing when indicator was shown / hidden.
254    */
255   IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
256
257   /**
258    * This signal is emitted when the window is requesting to be deleted
259    */
260   SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
261
262 private:
263
264   typedef std::vector< std::pair< std::string, std::string > > AuxiliaryHints;
265
266   RenderSurface*                   mSurface;
267   Dali::Window::IndicatorVisibleMode mIndicatorVisible; ///< public state
268   bool                             mIndicatorIsShown:1; ///< private state
269   bool                             mShowRotatedIndicatorOnClose:1;
270   bool                             mStarted:1;
271   bool                             mIsTransparent:1;
272   bool                             mWMRotationAppSet:1;
273   bool                             mEcoreEventHander:1;
274   bool                             mResizeEnabled:1;
275   IndicatorInterface*              mIndicator;
276   Dali::Window::WindowOrientation  mIndicatorOrientation;
277   Dali::Window::WindowOrientation  mNextIndicatorOrientation;
278   Dali::Window::IndicatorBgOpacity mIndicatorOpacityMode;
279   Integration::SystemOverlay*      mOverlay;
280   Adaptor*                         mAdaptor;
281   Dali::DragAndDropDetector        mDragAndDropDetector;
282
283   struct EventHandler;
284   EventHandler*                    mEventHandler;
285
286   OrientationPtr                               mOrientation;
287   std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
288   Dali::Window::WindowOrientation              mPreferredOrientation;
289
290   std::vector< std::string >        mSupportedAuxiliaryHints;
291   AuxiliaryHints                    mAuxiliaryHints;
292
293   // Signals
294   IndicatorSignalType mIndicatorVisibilityChangedSignal;
295   SignalType          mDeleteRequestSignal;
296 };
297
298 } // namespace Adaptor
299 } // namepsace Internal
300
301 // Helpers for public-api forwarding methods
302
303 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
304 {
305   DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
306   BaseObject& object = window.GetBaseObject();
307   return static_cast<Internal::Adaptor::Window&>(object);
308 }
309
310 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
311 {
312   DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
313   const BaseObject& object = window.GetBaseObject();
314   return static_cast<const Internal::Adaptor::Window&>(object);
315 }
316
317 } // namespace Dali
318
319
320 #endif // __DALI_INTERNAL_WINDOW_H__