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>
27 #ifdef DALI_ADAPTOR_COMPILATION
28 #include <dali/integration-api/scene-holder-impl.h>
30 #include <dali/integration-api/adaptors/scene-holder-impl.h>
34 #include <dali/internal/adaptor/common/adaptor-impl.h>
35 #include <dali/public-api/adaptor-framework/window.h>
36 #include <dali/public-api/adaptor-framework/key-grab.h>
37 #include <dali/devel-api/adaptor-framework/window-devel.h>
38 #include <dali/internal/window-system/common/event-handler.h>
44 class RenderSurfaceInterface;
51 class WindowRenderSurface;
55 using WindowPtr = IntrusivePtr< Window >;
56 using OrientationPtr = IntrusivePtr< Orientation >;
57 using EventHandlerPtr = IntrusivePtr< EventHandler >;
60 * Window provides a surface to render onto with orientation & indicator properties.
62 class Window : public Dali::Internal::Adaptor::SceneHolder, public EventHandler::Observer, public ConnectionTracker
65 typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
66 typedef Dali::Window::FocusSignalType FocusSignalType;
67 typedef Dali::Window::ResizedSignalType ResizedSignalType;
68 typedef Dali::Window::FocusChangeSignalType FocusChangeSignalType;
69 typedef Dali::Window::ResizeSignalType ResizeSignalType;
70 typedef Signal< void () > SignalType;
73 * Create a new Window. This should only be called once by the Application class
74 * @param[in] positionSize The position and size of the window
75 * @param[in] name The window title
76 * @param[in] className The window class name
77 * @param[in] isTransparent Whether window is transparent
78 * @return A newly allocated Window
80 static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false);
83 * @copydoc Dali::Window::ShowIndicator()
85 void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
88 * @copydoc Dali::Window::SetIndicatorBgOpacity()
90 void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
93 * @copydoc Dali::Window::RotateIndicator()
95 void RotateIndicator( Dali::Window::WindowOrientation orientation );
98 * @copydoc Dali::Window::SetClass()
100 void SetClass( std::string name, std::string className );
103 * @brief Gets the window class name.
104 * @return The class of the window
106 std::string GetClassName() const;
109 * @copydoc Dali::Window::Raise()
114 * @copydoc Dali::Window::Lower()
119 * @copydoc Dali::Window::Activate()
124 * @copydoc Dali::Window::GetLayerCount()
126 uint32_t GetLayerCount() const;
129 * @copydoc Dali::Window::GetLayer()
131 Dali::Layer GetLayer( uint32_t depth ) const;
134 * @copydoc Dali::DevelWindow::GetRenderTaskList()
136 Dali::RenderTaskList GetRenderTaskList() const;
139 * @copydoc Dali::Window::AddAvailableOrientation()
141 void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
144 * @copydoc Dali::Window::RemoveAvailableOrientation()
146 void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
149 * @copydoc Dali::Window::SetAvailableOrientations()
151 void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
154 * @copydoc Dali::Window::GetAvailableOrientations()
156 const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
159 * @copydoc Dali::Window::SetPreferredOrientation()
161 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
164 * @copydoc Dali::Window::GetPreferredOrientation()
166 Dali::Window::WindowOrientation GetPreferredOrientation();
169 * @copydoc Dali::Window::SetAcceptFocus()
171 void SetAcceptFocus( bool accept );
174 * @copydoc Dali::Window::IsFocusAcceptable()
176 bool IsFocusAcceptable() const;
179 * @copydoc Dali::Window::Show()
184 * @copydoc Dali::Window::Hide()
189 * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount()
191 unsigned int GetSupportedAuxiliaryHintCount() const;
194 * @copydoc Dali::Window::GetSupportedAuxiliaryHint()
196 std::string GetSupportedAuxiliaryHint( unsigned int index ) const;
199 * @copydoc Dali::Window::AddAuxiliaryHint()
201 unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
204 * @copydoc Dali::Window::RemoveAuxiliaryHint()
206 bool RemoveAuxiliaryHint( unsigned int id );
209 * @copydoc Dali::Window::SetAuxiliaryHintValue()
211 bool SetAuxiliaryHintValue( unsigned int id, const std::string& value );
214 * @copydoc Dali::Window::GetAuxiliaryHintValue()
216 std::string GetAuxiliaryHintValue( unsigned int id ) const;
219 * @copydoc Dali::Window::GetAuxiliaryHintId()
221 unsigned int GetAuxiliaryHintId( const std::string& hint ) const;
224 * @copydoc Dali::Window::SetInputRegion()
226 void SetInputRegion( const Rect< int >& inputRegion );
229 * @copydoc Dali::Window::SetType()
231 void SetType( Dali::Window::Type type );
234 * @copydoc Dali::Window::GetType() const
236 Dali::Window::Type GetType() const;
239 * @copydoc Dali::Window::SetNotificationLevel()
241 bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level );
244 * @copydoc Dali::Window::GetNotificationLevel()
246 Dali::Window::NotificationLevel::Type GetNotificationLevel() const;
249 * @copydoc Dali::Window::SetOpaqueState()
251 void SetOpaqueState( bool opaque );
254 * @copydoc Dali::Window::IsOpaqueState()
256 bool IsOpaqueState() const;
259 * @copydoc Dali::Window::SetScreenOffMode()
261 bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode);
264 * @copydoc Dali::Window::GetScreenOffMode()
266 Dali::Window::ScreenOffMode::Type GetScreenOffMode() const;
269 * @copydoc Dali::Window::SetBrightness()
271 bool SetBrightness( int brightness );
274 * @copydoc Dali::Window::GetBrightness()
276 int GetBrightness() const;
279 * @copydoc Dali::Window::SetSize()
281 void SetSize( Dali::Window::WindowSize size );
284 * @copydoc Dali::Window::GetSize()
286 Dali::Window::WindowSize GetSize() const;
289 * @copydoc Dali::Window::SetPosition()
291 void SetPosition( Dali::Window::WindowPosition position );
294 * @copydoc Dali::Window::GetPosition()
296 Dali::Window::WindowPosition GetPosition() const;
299 * @copydoc Dali::DevelWindow::SetPositionSize()
301 void SetPositionSize( PositionSize positionSize );
304 * @copydoc Dali::Window::GetRootLayer()
306 Dali::Layer GetRootLayer() const;
309 * @copydoc Dali::Window::SetTransparency()
311 void SetTransparency( bool transparent );
314 * @copydoc Dali::KeyGrab::GrabKey()
316 bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode );
319 * @copydoc Dali::KeyGrab::UngrabKey()
321 bool UngrabKey( Dali::KEY key );
324 * @copydoc Dali::KeyGrab::GrabKeyList()
326 bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result );
329 * @copydoc Dali::KeyGrab::UngrabKeyList()
331 bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result );
334 * @copydoc Dali::DevelWindow::Get()
336 static Dali::Window Get( Dali::Actor actor );
339 * @copydoc Dali::DevelWindow::SetParent()
341 void SetParent( Dali::Window& parent );
344 * @copydoc Dali::DevelWindow::Unparent()
349 * @copydoc Dali::DevelWindow::GetParent()
351 Dali::Window GetParent();
353 public: // Dali::Internal::Adaptor::SceneHolder
356 * @copydoc Dali::Internal::Adaptor::SceneHolder::GetNativeHandle
358 Dali::Any GetNativeHandle() const override;
361 * @copydoc Dali::Internal::Adaptor::SceneHolder::IsVisible
363 bool IsVisible() const override;
368 * Private constructor.
379 * Second stage initialization
381 void Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className);
384 * Called when the window becomes iconified or deiconified.
386 void OnIconifyChanged( bool iconified );
389 * Called when the window focus is changed.
391 void OnFocusChanged( bool focusIn );
394 * Called when the output is transformed.
396 void OnOutputTransformed();
399 * Called when the window receives a delete request.
401 void OnDeleteRequest();
403 private: // Dali::Internal::Adaptor::SceneHolder
406 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnAdaptorSet
408 void OnAdaptorSet( Dali::Adaptor& adaptor ) override;
411 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnSurfaceSet
413 void OnSurfaceSet( Dali::RenderSurfaceInterface* surface ) override;
416 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnPause
418 void OnPause() override;
421 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnResume
423 void OnResume() override;
426 * @copydoc Dali::Internal::Adaptor::SceneHolder::RecalculateTouchPosition
428 void RecalculateTouchPosition( Integration::Point& point ) override;
430 private: // Dali::Internal::Adaptor::EventHandler::Observer
433 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnTouchPoint
435 void OnTouchPoint( Dali::Integration::Point& point, int timeStamp ) override;
438 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnWheelEvent
440 void OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent ) override;
443 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnKeyEvent
445 void OnKeyEvent( Dali::Integration::KeyEvent& keyEvent ) override;
448 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnRotation
450 void OnRotation( const RotationEvent& rotation ) override;
455 * The user should connect to this signal to get a timing when indicator was shown / hidden.
457 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
460 * @copydoc Dali::Window::FocusChangedSignal()
462 FocusSignalType& FocusChangedSignal() { return mFocusChangedSignal; }
465 * @copydoc Dali::Window::WindowFocusChangedSignal()
467 FocusChangeSignalType& FocusChangeSignal() { return mFocusChangeSignal; }
469 * @copydoc Dali::Window::ResizedSignal()
471 ResizedSignalType& ResizedSignal() { return mResizedSignal; }
473 * @copydoc Dali::Window::ResizedSignal()
475 ResizeSignalType& ResizeSignal() { return mResizeSignal; }
478 * This signal is emitted when the window is requesting to be deleted
480 SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
483 * @copydoc Dali::Window::SignalEventProcessingFinished()
485 Dali::DevelWindow::EventProcessingFinishedSignalType& EventProcessingFinishedSignal() { return mScene.EventProcessingFinishedSignal(); }
489 WindowRenderSurface* mWindowSurface; ///< The window rendering surface
490 WindowBase* mWindowBase;
492 std::string mClassName;
493 bool mIsTransparent:1;
494 bool mIsFocusAcceptable:1;
497 bool mResizeEnabled:1;
498 Dali::Window::Type mType;
499 Dali::Window mParentWindow;
501 OrientationPtr mOrientation;
502 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
503 Dali::Window::WindowOrientation mPreferredOrientation;
505 int mRotationAngle; ///< The angle of the rotation
506 int mWindowWidth; ///< The width of the window
507 int mWindowHeight; ///< The height of the window
509 EventHandlerPtr mEventHandler; ///< The window events handler
512 IndicatorSignalType mIndicatorVisibilityChangedSignal;
513 FocusSignalType mFocusChangedSignal;
514 ResizedSignalType mResizedSignal;
515 SignalType mDeleteRequestSignal;
516 FocusChangeSignalType mFocusChangeSignal;
517 ResizeSignalType mResizeSignal;
520 } // namespace Adaptor
521 } // namepsace Internal
523 // Helpers for public-api forwarding methods
525 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
527 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
528 BaseObject& object = window.GetBaseObject();
529 return static_cast<Internal::Adaptor::Window&>(object);
532 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
534 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
535 const BaseObject& object = window.GetBaseObject();
536 return static_cast<const Internal::Adaptor::Window&>(object);
541 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H