1 #ifndef __DALI_INTERNAL_WINDOW_H__
2 #define __DALI_INTERNAL_WINDOW_H__
5 * Copyright (c) 2017 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 <base/interfaces/indicator-interface.h>
28 #include <adaptor-impl.h>
30 #include <orientation.h>
31 #include <render-surface.h>
32 #include <drag-and-drop-detector.h>
33 #include <window-devel.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 IndicatorInterface::Observer, public LifeCycleObserver
61 typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
62 typedef Dali::DevelWindow::FocusSignalType FocusSignalType;
63 typedef Dali::DevelWindow::ResizedSignalType ResizedSignalType;
64 typedef Signal< void () > SignalType;
67 * Create a new Window. This should only be called once by the Application class
68 * @param[in] positionSize The position and size of the window
69 * @param[in] name The window title
70 * @param[in] className The window class name
71 * @param[in] isTransparent Whether window is transparent
72 * @return A newly allocated Window
74 static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false);
77 * Pass the adaptor back to the overlay. This allows the window to access Core's overlay.
78 * @param[in] adaptor An initialized adaptor
80 void SetAdaptor(Dali::Adaptor& adaptor);
83 * Get the window surface
84 * @return The render surface
86 RenderSurface* GetSurface();
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::AddAvailableOrientation()
126 void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
129 * @copydoc Dali::Window::RemoveAvailableOrientation()
131 void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
134 * @copydoc Dali::Window::SetAvailableOrientations()
136 void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
139 * @copydoc Dali::Window::GetAvailableOrientations()
141 const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
144 * @copydoc Dali::Window::SetPreferredOrientation()
146 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
149 * @copydoc Dali::Window::GetPreferredOrientation()
151 Dali::Window::WindowOrientation GetPreferredOrientation();
154 * @copydoc Dali::Window::GetDragAndDropDetector() const
156 Dali::DragAndDropDetector GetDragAndDropDetector() const;
159 * @copydoc Dali::Window::GetNativeHandle() const
161 Dali::Any GetNativeHandle() const;
164 * @copydoc Dali::DevelWindow::SetAcceptFocus()
166 void SetAcceptFocus( bool accept );
169 * @copydoc Dali::DevelWindow::IsFocusAcceptable()
171 bool IsFocusAcceptable();
174 * @copydoc Dali::DevelWindow::Show()
179 * @copydoc Dali::DevelWindow::Hide()
184 * @copydoc Dali::DevelWindow::IsVisible() const
186 bool IsVisible() const;
189 * @copydoc Dali::DevelWindow::GetSupportedAuxiliaryHintCount()
191 unsigned int GetSupportedAuxiliaryHintCount();
194 * @copydoc Dali::DevelWindow::GetSupportedAuxiliaryHint()
196 std::string GetSupportedAuxiliaryHint( unsigned int index );
199 * @copydoc Dali::DevelWindow::AddAuxiliaryHint()
201 unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
204 * @copydoc Dali::DevelWindow::RemoveAuxiliaryHint()
206 bool RemoveAuxiliaryHint( unsigned int id );
209 * @copydoc Dali::DevelWindow::SetAuxiliaryHintValue()
211 bool SetAuxiliaryHintValue( unsigned int id, const std::string& value );
214 * @copydoc Dali::DevelWindow::GetAuxiliaryHintValue()
216 std::string GetAuxiliaryHintValue( unsigned int id ) const;
219 * @copydoc Dali::DevelWindow::GetAuxiliaryHintId()
221 unsigned int GetAuxiliaryHintId( const std::string& hint ) const;
224 * @copydoc Dali::DevelWindow::SetInputRegion()
226 void SetInputRegion( const Rect< int >& inputRegion );
229 * @copydoc Dali::DevelWindow::SetType()
231 void SetType( Dali::DevelWindow::Type type );
234 * @copydoc Dali::DevelWindow::GetType() const
236 Dali::DevelWindow::Type GetType() const;
239 * @copydoc Dali::DevelWindow::SetNotificationLevel()
241 bool SetNotificationLevel( Dali::DevelWindow::NotificationLevel::Type level );
244 * @copydoc Dali::DevelWindow::GetNotificationLevel()
246 Dali::DevelWindow::NotificationLevel::Type GetNotificationLevel();
249 * @copydoc Dali::DevelWindow::SetOpaqueState()
251 void SetOpaqueState( bool opaque );
254 * @copydoc Dali::DevelWindow::IsOpaqueState()
256 bool IsOpaqueState();
259 * @copydoc Dali::DevelWindow::SetScreenMode()
261 bool SetScreenMode( Dali::DevelWindow::ScreenMode::Type screenMode );
264 * @copydoc Dali::DevelWindow::GetScreenMode()
266 Dali::DevelWindow::ScreenMode::Type GetScreenMode();
269 * @copydoc Dali::DevelWindow::SetBrightness()
271 bool SetBrightness( int brightness );
274 * @copydoc Dali::DevelWindow::GetBrightness()
279 * @copydoc Dali::DevelWindow::SetSize()
281 void SetSize( Dali::DevelWindow::WindowSize size );
284 * @copydoc Dali::DevelWindow::GetSize()
286 Dali::DevelWindow::WindowSize GetSize();
289 * @copydoc Dali::DevelWindow::SetPosition()
291 void SetPosition( Dali::DevelWindow::WindowPosition position );
294 * @copydoc Dali::DevelWindow::GetPosition()
296 Dali::DevelWindow::WindowPosition GetPosition();
299 * Called from Orientation after the Change signal has been sent
301 void RotationDone( int orientation, int width, int height );
305 * Private constructor.
316 * Second stage initialization
318 void Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className);
321 * Shows / hides the indicator bar.
322 * Handles close/open if rotation changes whilst hidden
324 void DoShowIndicator( Dali::Window::WindowOrientation lastOrientation );
327 * Close current indicator and open a connection onto the new indicator service.
328 * Effect may not be synchronous if waiting for an indicator update on existing connection.
330 void DoRotateIndicator( Dali::Window::WindowOrientation orientation );
333 * Change the indicator actor's rotation to match the current orientation
335 void SetIndicatorActorRotation();
338 * Set the indicator properties on the window
340 void SetIndicatorProperties( bool isShown, Dali::Window::WindowOrientation lastOrientation );
342 private: // IndicatorInterface::Observer interface
345 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorTypeChanged()
347 virtual void IndicatorTypeChanged( IndicatorInterface::Type type );
350 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorClosed()
352 virtual void IndicatorClosed( IndicatorInterface* indicator);
355 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorVisibilityChanged()
357 virtual void IndicatorVisibilityChanged( bool isVisible );
359 private: // Adaptor::Observer interface
362 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
364 virtual void OnStart();
367 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
369 virtual void OnPause();
372 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
374 virtual void OnResume();
377 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
379 virtual void OnStop();
382 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
384 virtual void OnDestroy();
389 * The user should connect to this signal to get a timing when indicator was shown / hidden.
391 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
394 * @copydoc Dali::DevelWindow::FocusChangedSignal()
396 FocusSignalType& FocusChangedSignal() { return mFocusChangedSignal; }
399 * @copydoc Dali::DevelWindow::ResizedSignal()
401 ResizedSignalType& ResizedSignal() { return mResizedSignal; }
404 * This signal is emitted when the window is requesting to be deleted
406 SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
410 typedef std::vector< std::pair< std::string, std::string > > AuxiliaryHints;
412 RenderSurface* mSurface;
413 Dali::Window::IndicatorVisibleMode mIndicatorVisible; ///< public state
414 bool mIndicatorIsShown:1; ///< private state
415 bool mShowRotatedIndicatorOnClose:1;
417 bool mIsTransparent:1;
418 bool mWMRotationAppSet:1;
419 bool mEcoreEventHander:1;
420 bool mIsFocusAcceptable:1;
423 bool mResizeEnabled:1;
424 IndicatorInterface* mIndicator;
425 Dali::Window::WindowOrientation mIndicatorOrientation;
426 Dali::Window::WindowOrientation mNextIndicatorOrientation;
427 Dali::Window::IndicatorBgOpacity mIndicatorOpacityMode;
428 Integration::SystemOverlay* mOverlay;
430 Dali::DragAndDropDetector mDragAndDropDetector;
431 Dali::DevelWindow::Type mType;
434 EventHandler* mEventHandler;
436 OrientationPtr mOrientation;
437 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
438 Dali::Window::WindowOrientation mPreferredOrientation;
440 std::vector< std::string > mSupportedAuxiliaryHints;
441 AuxiliaryHints mAuxiliaryHints;
444 IndicatorSignalType mIndicatorVisibilityChangedSignal;
445 FocusSignalType mFocusChangedSignal;
446 ResizedSignalType mResizedSignal;
447 SignalType mDeleteRequestSignal;
450 } // namespace Adaptor
451 } // namepsace Internal
453 // Helpers for public-api forwarding methods
455 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
457 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
458 BaseObject& object = window.GetBaseObject();
459 return static_cast<Internal::Adaptor::Window&>(object);
462 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
464 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
465 const BaseObject& object = window.GetBaseObject();
466 return static_cast<const Internal::Adaptor::Window&>(object);
472 #endif // __DALI_INTERNAL_WINDOW_H__