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 Dali::DevelWindow::TransitionEffectEventSignalType TransitionEffectEventSignalType;
67 typedef Signal< void () > SignalType;
70 * Create a new Window. This should only be called once by the Application class
71 * @param[in] positionSize The position and size of the window
72 * @param[in] name The window title
73 * @param[in] className The window class name
74 * @param[in] isTransparent Whether window is transparent
75 * @return A newly allocated Window
77 static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false);
80 * @copydoc Dali::Window::ShowIndicator()
82 void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
85 * @copydoc Dali::Window::SetIndicatorBgOpacity()
87 void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
90 * @copydoc Dali::Window::RotateIndicator()
92 void RotateIndicator( Dali::Window::WindowOrientation orientation );
95 * @copydoc Dali::Window::SetClass()
97 void SetClass( std::string name, std::string className );
100 * @brief Gets the window class name.
101 * @return The class of the window
103 std::string GetClassName() const;
106 * @copydoc Dali::Window::Raise()
111 * @copydoc Dali::Window::Lower()
116 * @copydoc Dali::Window::Activate()
121 * @copydoc Dali::Window::GetLayerCount()
123 uint32_t GetLayerCount() const;
126 * @copydoc Dali::Window::GetLayer()
128 Dali::Layer GetLayer( uint32_t depth ) const;
131 * @copydoc Dali::DevelWindow::GetRenderTaskList()
133 Dali::RenderTaskList GetRenderTaskList() const;
136 * @copydoc Dali::Window::AddAvailableOrientation()
138 void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
141 * @copydoc Dali::Window::RemoveAvailableOrientation()
143 void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
146 * @copydoc Dali::Window::SetAvailableOrientations()
148 void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
151 * @copydoc Dali::Window::GetAvailableOrientations()
153 const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
156 * @copydoc Dali::Window::SetPreferredOrientation()
158 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
161 * @copydoc Dali::Window::GetPreferredOrientation()
163 Dali::Window::WindowOrientation GetPreferredOrientation();
166 * @copydoc Dali::Window::SetAcceptFocus()
168 void SetAcceptFocus( bool accept );
171 * @copydoc Dali::Window::IsFocusAcceptable()
173 bool IsFocusAcceptable() const;
176 * @copydoc Dali::Window::Show()
181 * @copydoc Dali::Window::Hide()
186 * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount()
188 unsigned int GetSupportedAuxiliaryHintCount() const;
191 * @copydoc Dali::Window::GetSupportedAuxiliaryHint()
193 std::string GetSupportedAuxiliaryHint( unsigned int index ) const;
196 * @copydoc Dali::Window::AddAuxiliaryHint()
198 unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
201 * @copydoc Dali::Window::RemoveAuxiliaryHint()
203 bool RemoveAuxiliaryHint( unsigned int id );
206 * @copydoc Dali::Window::SetAuxiliaryHintValue()
208 bool SetAuxiliaryHintValue( unsigned int id, const std::string& value );
211 * @copydoc Dali::Window::GetAuxiliaryHintValue()
213 std::string GetAuxiliaryHintValue( unsigned int id ) const;
216 * @copydoc Dali::Window::GetAuxiliaryHintId()
218 unsigned int GetAuxiliaryHintId( const std::string& hint ) const;
221 * @copydoc Dali::Window::SetInputRegion()
223 void SetInputRegion( const Rect< int >& inputRegion );
226 * @copydoc Dali::Window::SetType()
228 void SetType( Dali::Window::Type type );
231 * @copydoc Dali::Window::GetType() const
233 Dali::Window::Type GetType() const;
236 * @copydoc Dali::Window::SetNotificationLevel()
238 bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level );
241 * @copydoc Dali::Window::GetNotificationLevel()
243 Dali::Window::NotificationLevel::Type GetNotificationLevel() const;
246 * @copydoc Dali::Window::SetOpaqueState()
248 void SetOpaqueState( bool opaque );
251 * @copydoc Dali::Window::IsOpaqueState()
253 bool IsOpaqueState() const;
256 * @copydoc Dali::Window::SetScreenOffMode()
258 bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode);
261 * @copydoc Dali::Window::GetScreenOffMode()
263 Dali::Window::ScreenOffMode::Type GetScreenOffMode() const;
266 * @copydoc Dali::Window::SetBrightness()
268 bool SetBrightness( int brightness );
271 * @copydoc Dali::Window::GetBrightness()
273 int GetBrightness() const;
276 * @copydoc Dali::Window::SetSize()
278 void SetSize( Dali::Window::WindowSize size );
281 * @copydoc Dali::Window::GetSize()
283 Dali::Window::WindowSize GetSize() const;
286 * @copydoc Dali::Window::SetPosition()
288 void SetPosition( Dali::Window::WindowPosition position );
291 * @copydoc Dali::Window::GetPosition()
293 Dali::Window::WindowPosition GetPosition() const;
296 * @copydoc Dali::DevelWindow::SetPositionSize()
298 void SetPositionSize( PositionSize positionSize );
301 * @copydoc Dali::Window::GetRootLayer()
303 Dali::Layer GetRootLayer() const;
306 * @copydoc Dali::Window::SetTransparency()
308 void SetTransparency( bool transparent );
311 * @copydoc Dali::KeyGrab::GrabKey()
313 bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode );
316 * @copydoc Dali::KeyGrab::UngrabKey()
318 bool UngrabKey( Dali::KEY key );
321 * @copydoc Dali::KeyGrab::GrabKeyList()
323 bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result );
326 * @copydoc Dali::KeyGrab::UngrabKeyList()
328 bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result );
331 * @copydoc Dali::DevelWindow::Get()
333 static Dali::Window Get( Dali::Actor actor );
336 * @copydoc Dali::DevelWindow::SetParent()
338 void SetParent( Dali::Window& parent );
341 * @copydoc Dali::DevelWindow::Unparent()
346 * @copydoc Dali::DevelWindow::GetParent()
348 Dali::Window GetParent();
350 public: // Dali::Internal::Adaptor::SceneHolder
353 * @copydoc Dali::Internal::Adaptor::SceneHolder::GetNativeHandle
355 Dali::Any GetNativeHandle() const override;
358 * @copydoc Dali::Internal::Adaptor::SceneHolder::IsVisible
360 bool IsVisible() const override;
365 * Private constructor.
376 * Second stage initialization
378 void Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className);
381 * Called when the window becomes iconified or deiconified.
383 void OnIconifyChanged( bool iconified );
386 * Called when the window focus is changed.
388 void OnFocusChanged( bool focusIn );
391 * Called when the output is transformed.
393 void OnOutputTransformed();
396 * Called when the window receives a delete request.
398 void OnDeleteRequest();
401 * Called when the window receives a Transition effect-start/end event.
403 void OnTransitionEffectEvent( DevelWindow::EffectState state, DevelWindow::EffectType type );
405 private: // Dali::Internal::Adaptor::SceneHolder
408 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnAdaptorSet
410 void OnAdaptorSet( Dali::Adaptor& adaptor ) override;
413 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnSurfaceSet
415 void OnSurfaceSet( Dali::RenderSurfaceInterface* surface ) override;
418 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnPause
420 void OnPause() override;
423 * @copydoc Dali::Internal::Adaptor::SceneHolder::OnResume
425 void OnResume() override;
428 * @copydoc Dali::Internal::Adaptor::SceneHolder::RecalculateTouchPosition
430 void RecalculateTouchPosition( Integration::Point& point ) override;
432 private: // Dali::Internal::Adaptor::EventHandler::Observer
435 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnTouchPoint
437 void OnTouchPoint( Dali::Integration::Point& point, int timeStamp ) override;
440 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnWheelEvent
442 void OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent ) override;
445 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnKeyEvent
447 void OnKeyEvent( Dali::Integration::KeyEvent& keyEvent ) override;
450 * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnRotation
452 void OnRotation( const RotationEvent& rotation ) override;
457 * The user should connect to this signal to get a timing when indicator was shown / hidden.
459 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
462 * @copydoc Dali::Window::FocusChangedSignal()
464 FocusSignalType& FocusChangedSignal() { return mFocusChangedSignal; }
467 * @copydoc Dali::Window::WindowFocusChangedSignal()
469 FocusChangeSignalType& FocusChangeSignal() { return mFocusChangeSignal; }
471 * @copydoc Dali::Window::ResizedSignal()
473 ResizedSignalType& ResizedSignal() { return mResizedSignal; }
476 * @copydoc Dali::Window::ResizedSignal()
478 ResizeSignalType& ResizeSignal() { return mResizeSignal; }
481 * This signal is emitted when the window is requesting to be deleted
483 SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
486 * @copydoc Dali::DevelWindow::VisibilityChangedSignal()
488 VisibilityChangedSignalType& VisibilityChangedSignal() { return mVisibilityChangedSignal; }
491 * @copydoc Dali::Window::SignalEventProcessingFinished()
493 Dali::DevelWindow::EventProcessingFinishedSignalType& EventProcessingFinishedSignal() { return mScene.EventProcessingFinishedSignal(); }
496 * @copydoc Dali::DevelWindow::TransitionEffectEventSignal()
498 TransitionEffectEventSignalType& TransitionEffectEventSignal() { return mTransitionEffectEventSignal; }
502 WindowRenderSurface* mWindowSurface; ///< The window rendering surface
503 WindowBase* mWindowBase;
505 std::string mClassName;
506 bool mIsTransparent:1;
507 bool mIsFocusAcceptable:1;
510 bool mResizeEnabled:1;
511 Dali::Window::Type mType;
512 Dali::Window mParentWindow;
514 OrientationPtr mOrientation;
515 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
516 Dali::Window::WindowOrientation mPreferredOrientation;
518 int mRotationAngle; ///< The angle of the rotation
519 int mWindowWidth; ///< The width of the window
520 int mWindowHeight; ///< The height of the window
522 EventHandlerPtr mEventHandler; ///< The window events handler
525 IndicatorSignalType mIndicatorVisibilityChangedSignal;
526 FocusSignalType mFocusChangedSignal;
527 ResizedSignalType mResizedSignal;
528 SignalType mDeleteRequestSignal;
529 FocusChangeSignalType mFocusChangeSignal;
530 ResizeSignalType mResizeSignal;
531 VisibilityChangedSignalType mVisibilityChangedSignal;
532 TransitionEffectEventSignalType mTransitionEffectEventSignal;
535 } // namespace Adaptor
536 } // namepsace Internal
538 // Helpers for public-api forwarding methods
540 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
542 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
543 BaseObject& object = window.GetBaseObject();
544 return static_cast<Internal::Adaptor::Window&>(object);
547 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
549 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
550 const BaseObject& object = window.GetBaseObject();
551 return static_cast<const Internal::Adaptor::Window&>(object);
556 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H