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