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>
26 #include <base/lifecycle-observer.h>
27 #include <adaptor-impl.h>
28 #include <indicator-impl.h>
30 #include <orientation.h>
31 #include <render-surface.h>
32 #include <drag-and-drop-detector.h>
52 typedef IntrusivePtr<Window> WindowPtr;
53 typedef IntrusivePtr<Orientation> OrientationPtr;
56 * Window provides a surface to render onto with orientation & indicator properties.
58 class Window : public Dali::BaseObject, public Indicator::Observer, public LifeCycleObserver
61 typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
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
70 static Window* New(const PositionSize& posSize, const std::string& name, bool isTransparent = false);
73 * Pass the adaptor back to the overlay. This allows the window to access Core's overlay.
74 * @param[in] adaptor An initialized adaptor
76 void SetAdaptor(Dali::Adaptor& adaptor);
79 * Get the window surface
80 * @return The render surface
82 RenderSurface* GetSurface();
85 * @copydoc Dali::Window::SetIndicatorStyle()
87 void SetIndicatorStyle( Dali::Window::IndicatorStyle style );
90 * @copydoc Dali::Window::ShowIndicator()
92 void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
95 * @copydoc Dali::Window::SetIndicatorBgOpacity()
97 void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
100 * @copydoc Dali::Window::RotateIndicator()
102 void RotateIndicator( Dali::Window::WindowOrientation orientation );
105 * @copydoc Dali::Window::SetClass()
107 void SetClass( std::string name, std::string klass );
110 * @copydoc Dali::Window::Raise()
115 * @copydoc Dali::Window::Lower()
120 * @copydoc Dali::Window::Activate()
125 * @copydoc Dali::Window::GetOrientation()
127 OrientationPtr GetOrientation();
130 * @copydoc Dali::Window::AddAvailableOrientation()
132 void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
135 * @copydoc Dali::Window::RemoveAvailableOrientation()
137 void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
140 * @copydoc Dali::Window::SetAvailableOrientations()
142 void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
145 * @copydoc Dali::Window::GetAvailableOrientations()
147 const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
150 * @copydoc Dali::Window::SetPreferredOrientation()
152 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
155 * @copydoc Dali::Window::GetPreferredOrientation()
157 Dali::Window::WindowOrientation GetPreferredOrientation();
160 * @copydoc Dali::Window::GetDragAndDropDetector() const
162 Dali::DragAndDropDetector GetDragAndDropDetector() const;
165 * @copydoc Dali::Window::GetNativeHandle() const
167 Dali::Any GetNativeHandle() const;
170 * Called from Orientation after the Change signal has been sent
172 void RotationDone( int orientation, int width, int height );
177 * Private constructor.
188 * Second stage initialization
190 void Initialize(const PositionSize& posSize, const std::string& name);
193 * Shows / hides the indicator bar.
194 * Handles close/open if rotation changes whilst hidden
196 void DoShowIndicator( Dali::Window::WindowOrientation lastOrientation );
199 * Close current indicator and open a connection onto the new indicator service.
200 * Effect may not be synchronous if waiting for an indicator update on existing connection.
202 void DoRotateIndicator( Dali::Window::WindowOrientation orientation );
205 * Change the indicator actor's rotation to match the current orientation
207 void SetIndicatorActorRotation();
210 * Set the indicator properties on the window
212 void SetIndicatorProperties( bool isShown, Dali::Window::WindowOrientation lastOrientation );
214 private: // Indicator::Observer interface
217 * @copydoc Dali::Internal::Adaptor::Indicator::Observer::IndicatorTypeChanged()
219 virtual void IndicatorTypeChanged( Indicator::Type type );
222 * @copydoc Dali::Internal::Adaptor::Indicator::Observer::IndicatorClosed()
224 virtual void IndicatorClosed(Indicator* indicator);
227 * @copydoc Dali::Internal::Adaptor::Indicator::Observer::IndicatorVisibilityChanged()
229 virtual void IndicatorVisibilityChanged( bool isVisible );
231 private: // Adaptor::Observer interface
234 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
236 virtual void OnStart();
239 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
241 virtual void OnPause();
244 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
246 virtual void OnResume();
249 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
251 virtual void OnStop();
254 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
256 virtual void OnDestroy();
260 * The user should connect to this signal to get a timing when indicator was shown / hidden.
262 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
266 typedef std::vector<Indicator*> DiscardedIndicators;
268 RenderSurface* mSurface;
269 Dali::Window::IndicatorStyle mIndicatorStyle; ///< indicator style
270 Dali::Window::IndicatorVisibleMode mIndicatorVisible; ///< public state
271 bool mIndicatorIsShown:1; ///< private state
272 bool mShowRotatedIndicatorOnClose:1;
274 bool mIsTransparent:1;
275 bool mWMRotationAppSet:1;
276 Indicator* mIndicator;
277 Dali::Window::WindowOrientation mIndicatorOrientation;
278 Dali::Window::WindowOrientation mNextIndicatorOrientation;
279 Dali::Window::IndicatorBgOpacity mIndicatorOpacityMode;
280 Integration::SystemOverlay* mOverlay;
282 Dali::DragAndDropDetector mDragAndDropDetector;
285 EventHandler* mEventHandler;
287 OrientationPtr mOrientation;
288 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
289 Dali::Window::WindowOrientation mPreferredOrientation;
292 IndicatorSignalType mIndicatorVisibilityChangedSignal;
295 } // namespace Adaptor
296 } // namepsace Internal
298 // Helpers for public-api forwarding methods
300 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
302 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
303 BaseObject& object = window.GetBaseObject();
304 return static_cast<Internal::Adaptor::Window&>(object);
307 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
309 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
310 const BaseObject& object = window.GetBaseObject();
311 return static_cast<const Internal::Adaptor::Window&>(object);
317 #endif // __DALI_INTERNAL_WINDOW_H__