1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H
5 * Copyright (c) 2019 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>
24 #include <dali/public-api/actors/layer.h>
25 #include <dali/public-api/render-tasks/render-task-list.h>
26 #include <dali/integration-api/scene.h>
29 #include <dali/internal/adaptor/common/lifecycle-observer.h>
30 #include <dali/internal/adaptor/common/adaptor-impl.h>
31 #include <dali/internal/window-system/common/indicator-interface.h>
32 #include <dali/public-api/adaptor-framework/window.h>
33 #include <dali/public-api/adaptor-framework/key-grab.h>
34 #include <dali/devel-api/adaptor-framework/drag-and-drop-detector.h>
46 class WindowRenderSurface;
50 typedef IntrusivePtr<Window> WindowPtr;
51 typedef IntrusivePtr<Orientation> OrientationPtr;
54 * Window provides a surface to render onto with orientation & indicator properties.
56 class Window : public Dali::BaseObject, public IndicatorInterface::Observer, public LifeCycleObserver, public ConnectionTracker
59 typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
60 typedef Dali::Window::FocusSignalType FocusSignalType;
61 typedef Dali::Window::ResizedSignalType ResizedSignalType;
62 typedef Signal< void () > SignalType;
65 * Create a new Window. This should only be called once by the Application class
66 * @param[in] positionSize The position and size of the window
67 * @param[in] name The window title
68 * @param[in] className The window class name
69 * @param[in] isTransparent Whether window is transparent
70 * @return A newly allocated Window
72 static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false);
75 * Pass the adaptor back to the overlay. This allows the window to access Core's overlay.
76 * @param[in] adaptor An initialized adaptor
78 void SetAdaptor(Dali::Adaptor& adaptor);
81 * Get the window surface
82 * @return The render surface
84 WindowRenderSurface* GetSurface();
87 * @copydoc Dali::Window::ShowIndicator()
89 void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
92 * @copydoc Dali::Window::SetIndicatorBgOpacity()
94 void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
97 * Set the indicator visible mode
99 void SetIndicatorVisibleMode( Dali::Window::IndicatorVisibleMode mode );
102 * @copydoc Dali::Window::RotateIndicator()
104 void RotateIndicator( Dali::Window::WindowOrientation orientation );
107 * @copydoc Dali::Window::SetClass()
109 void SetClass( std::string name, std::string className );
112 * @copydoc Dali::Window::Raise()
117 * @copydoc Dali::Window::Lower()
122 * @copydoc Dali::Window::Activate()
127 * @copydoc Dali::Window::Add()
129 void Add( Dali::Actor actor );
132 * @copydoc Dali::Window::Remove()
134 void Remove( Dali::Actor remove );
137 * @copydoc Dali::Window::SetBackgroundColor()
139 void SetBackgroundColor(Vector4 color);
142 * @copydoc Dali::Window::GetBackgroundColor()
144 Vector4 GetBackgroundColor() const;
147 * @copydoc Dali::Window::GetRootLayer()
149 Dali::Layer GetRootLayer() const;
152 * @copydoc Dali::Window::GetLayerCount()
154 uint32_t GetLayerCount() const;
157 * @copydoc Dali::Window::GetLayer()
159 Dali::Layer GetLayer( uint32_t depth ) const;
162 * @copydoc Dali::Window::AddAvailableOrientation()
164 void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
167 * @copydoc Dali::Window::RemoveAvailableOrientation()
169 void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
172 * @copydoc Dali::Window::SetAvailableOrientations()
174 void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
177 * @copydoc Dali::Window::GetAvailableOrientations()
179 const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
182 * @copydoc Dali::Window::SetPreferredOrientation()
184 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
187 * @copydoc Dali::Window::GetPreferredOrientation()
189 Dali::Window::WindowOrientation GetPreferredOrientation();
192 * @copydoc Dali::Window::GetDragAndDropDetector() const
194 Dali::DragAndDropDetector GetDragAndDropDetector() const;
197 * @copydoc Dali::Window::GetNativeHandle() const
199 Dali::Any GetNativeHandle() const;
202 * @copydoc Dali::Window::SetAcceptFocus()
204 void SetAcceptFocus( bool accept );
207 * @copydoc Dali::Window::IsFocusAcceptable()
209 bool IsFocusAcceptable() const;
212 * @copydoc Dali::Window::Show()
217 * @copydoc Dali::Window::Hide()
222 * @copydoc Dali::Window::IsVisible() const
224 bool IsVisible() const;
227 * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount()
229 unsigned int GetSupportedAuxiliaryHintCount() const;
232 * @copydoc Dali::Window::GetSupportedAuxiliaryHint()
234 std::string GetSupportedAuxiliaryHint( unsigned int index ) const;
237 * @copydoc Dali::Window::AddAuxiliaryHint()
239 unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
242 * @copydoc Dali::Window::RemoveAuxiliaryHint()
244 bool RemoveAuxiliaryHint( unsigned int id );
247 * @copydoc Dali::Window::SetAuxiliaryHintValue()
249 bool SetAuxiliaryHintValue( unsigned int id, const std::string& value );
252 * @copydoc Dali::Window::GetAuxiliaryHintValue()
254 std::string GetAuxiliaryHintValue( unsigned int id ) const;
257 * @copydoc Dali::Window::GetAuxiliaryHintId()
259 unsigned int GetAuxiliaryHintId( const std::string& hint ) const;
262 * @copydoc Dali::Window::SetInputRegion()
264 void SetInputRegion( const Rect< int >& inputRegion );
267 * @copydoc Dali::Window::SetType()
269 void SetType( Dali::Window::Type type );
272 * @copydoc Dali::Window::GetType() const
274 Dali::Window::Type GetType() const;
277 * @copydoc Dali::Window::SetNotificationLevel()
279 bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level );
282 * @copydoc Dali::Window::GetNotificationLevel()
284 Dali::Window::NotificationLevel::Type GetNotificationLevel() const;
287 * @copydoc Dali::Window::SetOpaqueState()
289 void SetOpaqueState( bool opaque );
292 * @copydoc Dali::Window::IsOpaqueState()
294 bool IsOpaqueState() const;
297 * @copydoc Dali::Window::SetScreenOffMode()
299 bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode);
302 * @copydoc Dali::Window::GetScreenOffMode()
304 Dali::Window::ScreenOffMode::Type GetScreenOffMode() const;
307 * @copydoc Dali::Window::SetBrightness()
309 bool SetBrightness( int brightness );
312 * @copydoc Dali::Window::GetBrightness()
314 int GetBrightness() const;
317 * @copydoc Dali::Window::SetSize()
319 void SetSize( Dali::Window::WindowSize size );
322 * @copydoc Dali::Window::GetSize()
324 Dali::Window::WindowSize GetSize() const;
327 * @copydoc Dali::Window::SetPosition()
329 void SetPosition( Dali::Window::WindowPosition position );
332 * @copydoc Dali::Window::GetPosition()
334 Dali::Window::WindowPosition GetPosition() const;
337 * @copydoc Dali::DevelWindow::SetPositionSize()
339 void SetPositionSize( PositionSize positionSize );
342 * @copydoc Dali::Window::SetTransparency()
344 void SetTransparency( bool transparent );
347 * @copydoc Dali::KeyGrab::GrabKey()
349 bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode );
352 * @copydoc Dali::KeyGrab::UngrabKey()
354 bool UngrabKey( Dali::KEY key );
357 * @copydoc Dali::KeyGrab::GrabKeyList()
359 bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result );
362 * @copydoc Dali::KeyGrab::UngrabKeyList()
364 bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result );
367 * Called from Orientation after the Change signal has been sent
369 void RotationDone( int orientation, int width, int height );
372 * @brief Retrieves the unique ID of the window.
375 uint32_t GetId() const;
380 * Private constructor.
391 * Second stage initialization
393 void Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className);
396 * Shows / hides the indicator bar.
397 * Handles close/open if rotation changes whilst hidden
399 void DoShowIndicator( Dali::Window::WindowOrientation lastOrientation );
402 * Close current indicator and open a connection onto the new indicator service.
403 * Effect may not be synchronous if waiting for an indicator update on existing connection.
405 void DoRotateIndicator( Dali::Window::WindowOrientation orientation );
408 * Change the indicator actor's rotation to match the current orientation
410 void SetIndicatorActorRotation();
413 * Set the indicator properties on the window
415 void SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation );
418 * Called when the window becomes iconified or deiconified.
420 void OnIconifyChanged( bool iconified );
423 * Called when the window focus is changed.
425 void OnFocusChanged( bool focusIn );
428 * Called when the output is transformed.
430 void OnOutputTransformed();
433 * Called when the window receives a delete request.
435 void OnDeleteRequest();
438 * Called when the Ecore indicator event is received.
440 void OnIndicatorFlicked();
442 private: // IndicatorInterface::Observer interface
445 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorTypeChanged()
447 virtual void IndicatorTypeChanged( IndicatorInterface::Type type );
450 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorClosed()
452 virtual void IndicatorClosed( IndicatorInterface* indicator);
455 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorVisibilityChanged()
457 virtual void IndicatorVisibilityChanged( bool isVisible );
459 private: // Adaptor::Observer interface
462 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
464 virtual void OnStart();
467 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
469 virtual void OnPause();
472 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
474 virtual void OnResume();
477 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
479 virtual void OnStop();
482 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
484 virtual void OnDestroy();
489 * The user should connect to this signal to get a timing when indicator was shown / hidden.
491 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
494 * @copydoc Dali::Window::FocusChangedSignal()
496 FocusSignalType& FocusChangedSignal() { return mFocusChangedSignal; }
499 * @copydoc Dali::Window::ResizedSignal()
501 ResizedSignalType& ResizedSignal() { return mResizedSignal; }
504 * This signal is emitted when the window is requesting to be deleted
506 SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
510 static uint32_t mWindowCounter; ///< A counter to track the window creation
511 uint32_t mId; ///< A unique ID to identify the window starting from 0
512 std::unique_ptr< WindowRenderSurface > mSurface;
513 Dali::Integration::Scene mScene;
514 WindowBase* mWindowBase;
515 Dali::Window::IndicatorVisibleMode mIndicatorVisible; ///< public state
516 bool mIndicatorIsShown:1; ///< private state
517 bool mShowRotatedIndicatorOnClose:1;
519 bool mIsTransparent:1;
520 bool mIsFocusAcceptable:1;
524 bool mResizeEnabled:1;
525 std::unique_ptr< IndicatorInterface > mIndicator;
526 Dali::Window::WindowOrientation mIndicatorOrientation;
527 Dali::Window::WindowOrientation mNextIndicatorOrientation;
528 Dali::Window::IndicatorBgOpacity mIndicatorOpacityMode;
530 Dali::DragAndDropDetector mDragAndDropDetector;
531 Dali::Window::Type mType;
533 OrientationPtr mOrientation;
534 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
535 Dali::Window::WindowOrientation mPreferredOrientation;
537 Vector4 mBackgroundColor;
540 IndicatorSignalType mIndicatorVisibilityChangedSignal;
541 FocusSignalType mFocusChangedSignal;
542 ResizedSignalType mResizedSignal;
543 SignalType mDeleteRequestSignal;
546 } // namespace Adaptor
547 } // namepsace Internal
549 // Helpers for public-api forwarding methods
551 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
553 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
554 BaseObject& object = window.GetBaseObject();
555 return static_cast<Internal::Adaptor::Window&>(object);
558 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
560 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
561 const BaseObject& object = window.GetBaseObject();
562 return static_cast<const Internal::Adaptor::Window&>(object);
567 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H