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>
28 #include <dali/public-api/adaptor-framework/window.h>
29 #include <dali/public-api/adaptor-framework/key-grab.h>
30 #include <dali/devel-api/adaptor-framework/window-devel.h>
31 #include <dali/integration-api/adaptor-framework/scene-holder-impl.h>
32 #include <dali/internal/adaptor/common/adaptor-impl.h>
33 #include <dali/internal/window-system/common/event-handler.h>
39 class RenderSurfaceInterface;
46 class WindowRenderSurface;
50 using WindowPtr = IntrusivePtr< Window >;
51 using OrientationPtr = IntrusivePtr< Orientation >;
52 using EventHandlerPtr = IntrusivePtr< EventHandler >;
55 * Window provides a surface to render onto with orientation & indicator properties.
57 class Window : public Dali::Internal::Adaptor::SceneHolder, public EventHandler::Observer, public ConnectionTracker
60 typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
61 typedef Dali::Window::FocusSignalType FocusSignalType;
62 typedef Dali::Window::ResizedSignalType ResizedSignalType;
63 typedef Dali::Window::FocusChangeSignalType FocusChangeSignalType;
64 typedef Dali::Window::ResizeSignalType ResizeSignalType;
65 typedef Dali::DevelWindow::VisibilityChangedSignalType VisibilityChangedSignalType;
66 typedef Signal< void () > SignalType;
69 * Create a new Window. This should only be called once by the Application class
70 * @param[in] positionSize The position and size of the window
71 * @param[in] name The window title
72 * @param[in] className The window class name
73 * @param[in] isTransparent Whether window is transparent
74 * @return A newly allocated Window
76 static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false);
79 * @copydoc Dali::Window::ShowIndicator()
81 void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
84 * @copydoc Dali::Window::SetIndicatorBgOpacity()
86 void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
89 * @copydoc Dali::Window::RotateIndicator()
91 void RotateIndicator( Dali::Window::WindowOrientation orientation );
94 * @copydoc Dali::Window::SetClass()
96 void SetClass( std::string name, std::string className );
99 * @brief Gets the window class name.
100 * @return The class of the window
102 std::string GetClassName() const;
105 * @copydoc Dali::Window::Raise()
110 * @copydoc Dali::Window::Lower()
115 * @copydoc Dali::Window::Activate()
120 * @copydoc Dali::Window::GetLayerCount()
122 uint32_t GetLayerCount() const;
125 * @copydoc Dali::Window::GetLayer()
127 Dali::Layer GetLayer( uint32_t depth ) const;
130 * @copydoc Dali::DevelWindow::GetRenderTaskList()
132 Dali::RenderTaskList GetRenderTaskList() const;
135 * @copydoc Dali::Window::AddAvailableOrientation()
137 void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
140 * @copydoc Dali::Window::RemoveAvailableOrientation()
142 void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
145 * @copydoc Dali::Window::SetAvailableOrientations()
147 void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
150 * @copydoc Dali::Window::GetAvailableOrientations()
152 const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
155 * @copydoc Dali::Window::SetPreferredOrientation()
157 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
160 * @copydoc Dali::Window::GetPreferredOrientation()
162 Dali::Window::WindowOrientation GetPreferredOrientation();
165 * @copydoc Dali::Window::SetAcceptFocus()
167 void SetAcceptFocus( bool accept );
170 * @copydoc Dali::Window::IsFocusAcceptable()
172 bool IsFocusAcceptable() const;
175 * @copydoc Dali::Window::Show()
180 * @copydoc Dali::Window::Hide()
185 * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount()
187 unsigned int GetSupportedAuxiliaryHintCount() const;
190 * @copydoc Dali::Window::GetSupportedAuxiliaryHint()
192 std::string GetSupportedAuxiliaryHint( unsigned int index ) const;
195 * @copydoc Dali::Window::AddAuxiliaryHint()
197 unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
200 * @copydoc Dali::Window::RemoveAuxiliaryHint()
202 bool RemoveAuxiliaryHint( unsigned int id );
205 * @copydoc Dali::Window::SetAuxiliaryHintValue()
207 bool SetAuxiliaryHintValue( unsigned int id, const std::string& value );
210 * @copydoc Dali::Window::GetAuxiliaryHintValue()
212 std::string GetAuxiliaryHintValue( unsigned int id ) const;
215 * @copydoc Dali::Window::GetAuxiliaryHintId()
217 unsigned int GetAuxiliaryHintId( const std::string& hint ) const;
220 * @copydoc Dali::Window::SetInputRegion()
222 void SetInputRegion( const Rect< int >& inputRegion );
225 * @copydoc Dali::Window::SetType()
227 void SetType( Dali::Window::Type type );
230 * @copydoc Dali::Window::GetType() const
232 Dali::Window::Type GetType() const;
235 * @copydoc Dali::Window::SetNotificationLevel()
237 bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level );
240 * @copydoc Dali::Window::GetNotificationLevel()
242 Dali::Window::NotificationLevel::Type GetNotificationLevel() const;
245 * @copydoc Dali::Window::SetOpaqueState()
247 void SetOpaqueState( bool opaque );
250 * @copydoc Dali::Window::IsOpaqueState()
252 bool IsOpaqueState() const;
255 * @copydoc Dali::Window::SetScreenOffMode()
257 bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode);
260 * @copydoc Dali::Window::GetScreenOffMode()
262 Dali::Window::ScreenOffMode::Type GetScreenOffMode() const;
265 * @copydoc Dali::Window::SetBrightness()
267 bool SetBrightness( int brightness );
270 * @copydoc Dali::Window::GetBrightness()
272 int GetBrightness() const;
275 * @copydoc Dali::Window::SetSize()
277 void SetSize( Dali::Window::WindowSize size );
280 * @copydoc Dali::Window::GetSize()
282 Dali::Window::WindowSize GetSize() const;
285 * @copydoc Dali::Window::SetPosition()
287 void SetPosition( Dali::Window::WindowPosition position );
290 * @copydoc Dali::Window::GetPosition()
292 Dali::Window::WindowPosition GetPosition() const;
295 * @copydoc Dali::DevelWindow::SetPositionSize()
297 void SetPositionSize( PositionSize positionSize );
300 * @copydoc Dali::Window::GetRootLayer()
302 Dali::Layer GetRootLayer() const;
305 * @copydoc Dali::Window::SetTransparency()
307 void SetTransparency( bool transparent );
310 * @copydoc Dali::KeyGrab::GrabKey()
312 bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode );
315 * @copydoc Dali::KeyGrab::UngrabKey()
317 bool UngrabKey( Dali::KEY key );
320 * @copydoc Dali::KeyGrab::GrabKeyList()
322 bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result );
325 * @copydoc Dali::KeyGrab::UngrabKeyList()
327 bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result );
330 * @copydoc Dali::DevelWindow::Get()
332 static Dali::Window Get( Dali::Actor actor );
335 * @copydoc Dali::DevelWindow::SetParent()
337 void SetParent( Dali::Window& parent );
340 * @copydoc Dali::DevelWindow::Unparent()
345 * @copydoc Dali::DevelWindow::GetParent()
347 Dali::Window GetParent();
349 public: // Dali::Internal::Adaptor::SceneHolder
352 * @copydoc Dali::Internal::Adaptor::SceneHolder::GetNativeHandle
354 Dali::Any GetNativeHandle() const override;
357 * @copydoc Dali::Internal::Adaptor::SceneHolder::IsVisible
359 bool IsVisible() const override;
364 * Private constructor.
375 * Second stage initialization
377 void Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className);
380 * Called when the window becomes iconified or deiconified.
382 void OnIconifyChanged( bool iconified );
385 * Called when the window focus is changed.
387 void OnFocusChanged( bool focusIn );
390 * Called when the output is transformed.
392 void OnOutputTransformed();
395 * Called when the window receives a delete request.
397 void OnDeleteRequest();
399 private: // Dali::Internal::Adaptor::SceneHolder
402 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnAdaptorSet
404 void OnAdaptorSet( Dali::Adaptor& adaptor ) override;
407 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnSurfaceSet
409 void OnSurfaceSet( Dali::RenderSurfaceInterface* surface ) override;
412 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnPause
414 void OnPause() override;
417 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnResume
419 void OnResume() override;
422 * @copydoc Dali::Internal::Adaptor::SceneHolder::RecalculateTouchPosition
424 void RecalculateTouchPosition( Integration::Point& point ) override;
426 private: // Dali::Internal::Adaptor::EventHandler::Observer
429 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnTouchPoint
431 void OnTouchPoint( Dali::Integration::Point& point, int timeStamp ) override;
434 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnWheelEvent
436 void OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent ) override;
439 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnKeyEvent
441 void OnKeyEvent( Dali::Integration::KeyEvent& keyEvent ) override;
444 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnRotation
446 void OnRotation( const RotationEvent& rotation ) override;
451 * The user should connect to this signal to get a timing when indicator was shown / hidden.
453 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
456 * @copydoc Dali::Window::FocusChangedSignal()
458 FocusSignalType& FocusChangedSignal() { return mFocusChangedSignal; }
461 * @copydoc Dali::Window::WindowFocusChangedSignal()
463 FocusChangeSignalType& FocusChangeSignal() { return mFocusChangeSignal; }
465 * @copydoc Dali::Window::ResizedSignal()
467 ResizedSignalType& ResizedSignal() { return mResizedSignal; }
470 * @copydoc Dali::Window::ResizedSignal()
472 ResizeSignalType& ResizeSignal() { return mResizeSignal; }
475 * This signal is emitted when the window is requesting to be deleted
477 SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
480 * @copydoc Dali::DevelWindow::VisibilityChangedSignal()
482 VisibilityChangedSignalType& VisibilityChangedSignal() { return mVisibilityChangedSignal; }
485 * @copydoc Dali::Window::SignalEventProcessingFinished()
487 Dali::DevelWindow::EventProcessingFinishedSignalType& EventProcessingFinishedSignal() { return mScene.EventProcessingFinishedSignal(); }
491 WindowRenderSurface* mWindowSurface; ///< The window rendering surface
492 WindowBase* mWindowBase;
494 std::string mClassName;
495 bool mIsTransparent:1;
496 bool mIsFocusAcceptable:1;
499 bool mResizeEnabled:1;
500 Dali::Window::Type mType;
501 Dali::Window mParentWindow;
503 OrientationPtr mOrientation;
504 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
505 Dali::Window::WindowOrientation mPreferredOrientation;
507 int mRotationAngle; ///< The angle of the rotation
508 int mWindowWidth; ///< The width of the window
509 int mWindowHeight; ///< The height of the window
511 EventHandlerPtr mEventHandler; ///< The window events handler
514 IndicatorSignalType mIndicatorVisibilityChangedSignal;
515 FocusSignalType mFocusChangedSignal;
516 ResizedSignalType mResizedSignal;
517 SignalType mDeleteRequestSignal;
518 FocusChangeSignalType mFocusChangeSignal;
519 ResizeSignalType mResizeSignal;
520 VisibilityChangedSignalType mVisibilityChangedSignal;
523 } // namespace Adaptor
524 } // namepsace Internal
526 // Helpers for public-api forwarding methods
528 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
530 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
531 BaseObject& object = window.GetBaseObject();
532 return static_cast<Internal::Adaptor::Window&>(object);
535 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
537 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
538 const BaseObject& object = window.GetBaseObject();
539 return static_cast<const Internal::Adaptor::Window&>(object);
544 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H