1 #ifndef __DALI_INTERNAL_WINDOW_H__
2 #define __DALI_INTERNAL_WINDOW_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/object/ref-object.h>
23 #include <dali/public-api/object/base-object.h>
25 #include <orientation.h>
26 #include <render-surface.h>
27 #include <drag-and-drop-detector.h>
30 #include <base/lifecycle-observer.h>
31 #include <adaptor-impl.h>
32 #include <indicator-impl.h>
53 typedef IntrusivePtr<Window> WindowPtr;
54 typedef IntrusivePtr<Orientation> OrientationPtr;
57 * Window provides a surface to render onto with orientation & indicator properties.
59 class Window : public Dali::BaseObject, public Indicator::Observer, public LifeCycleObserver
63 * Create a new Window. This should only be called once by the Application class
64 * @param[in] windowPosition The position and size of the window
65 * @param[in] name The window title
66 * @param[in] isTransparent Whether window is transparent
67 * @return A newly allocated Window
69 static Window* New(const PositionSize& posSize, const std::string& name, bool isTransparent = false);
72 * Pass the adaptor back to the overlay. This allows the window to access Core's overlay.
73 * @param[in] adaptor An initialized adaptor
75 void SetAdaptor(Dali::Adaptor& adaptor);
78 * Get the window surface
79 * @return The render surface
81 RenderSurface* GetSurface();
84 * @copydoc Dali::Window::SetIndicatorStyle()
86 void SetIndicatorStyle( Dali::Window::IndicatorStyle style );
89 * @copydoc Dali::Window::ShowIndicator()
91 void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
94 * @copydoc Dali::Window::SetIndicatorBgOpacity()
96 void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
99 * @copydoc Dali::Window::RotateIndicator()
101 void RotateIndicator( Dali::Window::WindowOrientation orientation );
104 * @copydoc Dali::Window::SetClass()
106 void SetClass( std::string name, std::string klass );
109 * @copydoc Dali::Window::Raise()
114 * @copydoc Dali::Window::Lower()
119 * @copydoc Dali::Window::Activate()
124 * @copydoc Dali::Window::GetOrientation()
126 OrientationPtr GetOrientation();
129 * @copydoc Dali::Window::AddAvailableOrientation()
131 void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
134 * @copydoc Dali::Window::RemoveAvailableOrientation()
136 void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
139 * @copydoc Dali::Window::SetAvailableOrientations()
141 void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
144 * @copydoc Dali::Window::GetAvailableOrientations()
146 const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
149 * @copydoc Dali::Window::SetPreferredOrientation()
151 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
154 * @copydoc Dali::Window::GetPreferredOrientation()
156 Dali::Window::WindowOrientation GetPreferredOrientation();
159 * @copydoc Dali::Window::GetDragAndDropDetector() const
161 Dali::DragAndDropDetector GetDragAndDropDetector() const;
164 * @copydoc Dali::Window::GetNativeHandle() const
166 Dali::Any GetNativeHandle() const;
169 * Called from Orientation after the Change signal has been sent
171 void RotationDone( int orientation, int width, int height );
176 * Private constructor.
187 * Second stage initialization
189 void Initialize(const PositionSize& posSize, const std::string& name);
192 * Shows / hides the indicator bar.
193 * Handles close/open if rotation changes whilst hidden
195 void DoShowIndicator( Dali::Window::WindowOrientation lastOrientation );
198 * Close current indicator and open a connection onto the new indicator service.
199 * Effect may not be synchronous if waiting for an indicator update on existing connection.
201 void DoRotateIndicator( Dali::Window::WindowOrientation orientation );
204 * Change the indicator actor's rotation to match the current orientation
206 void SetIndicatorActorRotation();
209 * Set the indicator properties on the window
211 void SetIndicatorProperties( bool isShown, Dali::Window::WindowOrientation lastOrientation );
213 private: // Indicator::Observer interface
216 * @copydoc Dali::Internal::Adaptor::Indicator::Observer::IndicatorTypeChanged()
218 virtual void IndicatorTypeChanged( Indicator::Type type );
221 * @copydoc Dali::Internal::Adaptor::Indicator::Observer::IndicatorClosed()
223 virtual void IndicatorClosed(Indicator* indicator);
225 private: // Adaptor::Observer interface
228 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
230 virtual void OnStart();
233 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
235 virtual void OnPause();
238 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
240 virtual void OnResume();
243 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
245 virtual void OnStop();
248 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
250 virtual void OnDestroy();
254 typedef std::vector<Indicator*> DiscardedIndicators;
256 RenderSurface* mSurface;
257 Dali::Window::IndicatorStyle mIndicatorStyle; ///< indicator style
258 Dali::Window::IndicatorVisibleMode mIndicatorVisible; ///< public state
259 bool mIndicatorIsShown:1; ///< private state
260 bool mShowRotatedIndicatorOnClose:1;
262 bool mIsTransparent:1;
263 bool mWMRotationAppSet:1;
264 Indicator* mIndicator;
265 Dali::Window::WindowOrientation mIndicatorOrientation;
266 Dali::Window::WindowOrientation mNextIndicatorOrientation;
267 Dali::Window::IndicatorBgOpacity mIndicatorOpacityMode;
268 Integration::SystemOverlay* mOverlay;
270 Dali::DragAndDropDetector mDragAndDropDetector;
273 EventHandler* mEventHandler;
275 OrientationPtr mOrientation;
276 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
277 Dali::Window::WindowOrientation mPreferredOrientation;
280 } // namespace Adaptor
281 } // namepsace Internal
283 // Helpers for public-api forwarding methods
285 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
287 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
288 BaseObject& object = window.GetBaseObject();
289 return static_cast<Internal::Adaptor::Window&>(object);
292 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
294 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
295 const BaseObject& object = window.GetBaseObject();
296 return static_cast<const Internal::Adaptor::Window&>(object);
302 #endif // __DALI_INTERNAL_WINDOW_H__