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/public-api/adaptor-framework/window.h>
32 #include <dali/public-api/adaptor-framework/key-grab.h>
33 #include <dali/devel-api/adaptor-framework/drag-and-drop-detector.h>
34 #include <dali/devel-api/adaptor-framework/window-devel.h>
47 class RotationObserver;
48 class WindowRenderSurface;
52 using WindowPtr = IntrusivePtr< Window >;
53 using OrientationPtr = IntrusivePtr< Orientation >;
54 using EventHandlerPtr = IntrusivePtr< EventHandler >;
57 * Window provides a surface to render onto with orientation & indicator properties.
59 class Window : public Dali::BaseObject, public LifeCycleObserver, public ConnectionTracker
62 typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
63 typedef Dali::Window::FocusSignalType FocusSignalType;
64 typedef Dali::Window::ResizedSignalType ResizedSignalType;
65 typedef Signal< void () > SignalType;
68 * Create a new Window. This should only be called once by the Application class
69 * @param[in] positionSize The position and size of the window
70 * @param[in] name The window title
71 * @param[in] className The window class name
72 * @param[in] isTransparent Whether window is transparent
73 * @return A newly allocated Window
75 static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false);
78 * Pass the adaptor back to the overlay. This allows the window to access Core's overlay.
79 * @param[in] adaptor An initialized adaptor
81 void SetAdaptor(Dali::Adaptor& adaptor);
84 * Pass the adaptor back to the overlay. This allows the window to access Core's overlay.
85 * @param[in] adaptor implementation An initialized adaptor implementation
87 void SetAdaptor(Adaptor& adaptor);
90 * Get the window surface
91 * @return The render surface
93 WindowRenderSurface* GetSurface() const;
96 * Set the window surface
97 * @param[in] surface The surface
99 void SetSurface(WindowRenderSurface* surface);
102 * @copydoc Dali::Window::ShowIndicator()
104 void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
107 * @copydoc Dali::Window::SetIndicatorBgOpacity()
109 void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
112 * @copydoc Dali::Window::RotateIndicator()
114 void RotateIndicator( Dali::Window::WindowOrientation orientation );
117 * @copydoc Dali::Window::SetClass()
119 void SetClass( std::string name, std::string className );
122 * @brief Gets the window name.
123 * @return The name of the window
125 std::string GetName() const;
128 * @brief Gets the window class name.
129 * @return The class of the window
131 std::string GetClassName() const;
134 * @copydoc Dali::Window::Raise()
139 * @copydoc Dali::Window::Lower()
144 * @copydoc Dali::Window::Activate()
149 * @copydoc Dali::Window::Add()
151 void Add( Dali::Actor actor );
154 * @copydoc Dali::Window::Remove()
156 void Remove( Dali::Actor remove );
159 * @copydoc Dali::Window::SetBackgroundColor()
161 void SetBackgroundColor(Vector4 color);
164 * @copydoc Dali::Window::GetBackgroundColor()
166 Vector4 GetBackgroundColor() const;
169 * @copydoc Dali::Window::GetRootLayer()
171 Dali::Layer GetRootLayer() const;
174 * @copydoc Dali::Window::GetLayerCount()
176 uint32_t GetLayerCount() const;
179 * @copydoc Dali::Window::GetLayer()
181 Dali::Layer GetLayer( uint32_t depth ) const;
184 * @copydoc Dali::Window::AddAvailableOrientation()
186 void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
189 * @copydoc Dali::Window::RemoveAvailableOrientation()
191 void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
194 * @copydoc Dali::Window::SetAvailableOrientations()
196 void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
199 * @copydoc Dali::Window::GetAvailableOrientations()
201 const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
204 * @copydoc Dali::Window::SetPreferredOrientation()
206 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
209 * @copydoc Dali::Window::GetPreferredOrientation()
211 Dali::Window::WindowOrientation GetPreferredOrientation();
214 * @copydoc Dali::Window::GetDragAndDropDetector() const
216 Dali::DragAndDropDetector GetDragAndDropDetector() const;
219 * @copydoc Dali::Window::GetNativeHandle() const
221 Dali::Any GetNativeHandle() const;
224 * @copydoc Dali::Window::SetAcceptFocus()
226 void SetAcceptFocus( bool accept );
229 * @copydoc Dali::Window::IsFocusAcceptable()
231 bool IsFocusAcceptable() const;
234 * @copydoc Dali::Window::Show()
239 * @copydoc Dali::Window::Hide()
244 * @copydoc Dali::Window::IsVisible() const
246 bool IsVisible() const;
249 * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount()
251 unsigned int GetSupportedAuxiliaryHintCount() const;
254 * @copydoc Dali::Window::GetSupportedAuxiliaryHint()
256 std::string GetSupportedAuxiliaryHint( unsigned int index ) const;
259 * @copydoc Dali::Window::AddAuxiliaryHint()
261 unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
264 * @copydoc Dali::Window::RemoveAuxiliaryHint()
266 bool RemoveAuxiliaryHint( unsigned int id );
269 * @copydoc Dali::Window::SetAuxiliaryHintValue()
271 bool SetAuxiliaryHintValue( unsigned int id, const std::string& value );
274 * @copydoc Dali::Window::GetAuxiliaryHintValue()
276 std::string GetAuxiliaryHintValue( unsigned int id ) const;
279 * @copydoc Dali::Window::GetAuxiliaryHintId()
281 unsigned int GetAuxiliaryHintId( const std::string& hint ) const;
284 * @copydoc Dali::Window::SetInputRegion()
286 void SetInputRegion( const Rect< int >& inputRegion );
289 * @copydoc Dali::Window::SetType()
291 void SetType( Dali::Window::Type type );
294 * @copydoc Dali::Window::GetType() const
296 Dali::Window::Type GetType() const;
299 * @copydoc Dali::Window::SetNotificationLevel()
301 bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level );
304 * @copydoc Dali::Window::GetNotificationLevel()
306 Dali::Window::NotificationLevel::Type GetNotificationLevel() const;
309 * @copydoc Dali::Window::SetOpaqueState()
311 void SetOpaqueState( bool opaque );
314 * @copydoc Dali::Window::IsOpaqueState()
316 bool IsOpaqueState() const;
319 * @copydoc Dali::Window::SetScreenOffMode()
321 bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode);
324 * @copydoc Dali::Window::GetScreenOffMode()
326 Dali::Window::ScreenOffMode::Type GetScreenOffMode() const;
329 * @copydoc Dali::Window::SetBrightness()
331 bool SetBrightness( int brightness );
334 * @copydoc Dali::Window::GetBrightness()
336 int GetBrightness() const;
339 * @copydoc Dali::Window::SetSize()
341 void SetSize( Dali::Window::WindowSize size );
344 * @copydoc Dali::Window::GetSize()
346 Dali::Window::WindowSize GetSize() const;
349 * @copydoc Dali::Window::SetPosition()
351 void SetPosition( Dali::Window::WindowPosition position );
354 * @copydoc Dali::Window::GetPosition()
356 Dali::Window::WindowPosition GetPosition() const;
359 * @copydoc Dali::DevelWindow::SetPositionSize()
361 void SetPositionSize( PositionSize positionSize );
364 * @copydoc Dali::DevelWindow::GetRootLayer()
366 Dali::Layer GetRootLayer();
369 * @copydoc Dali::Window::SetTransparency()
371 void SetTransparency( bool transparent );
374 * @copydoc Dali::KeyGrab::GrabKey()
376 bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode );
379 * @copydoc Dali::KeyGrab::UngrabKey()
381 bool UngrabKey( Dali::KEY key );
384 * @copydoc Dali::KeyGrab::GrabKeyList()
386 bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result );
389 * @copydoc Dali::KeyGrab::UngrabKeyList()
391 bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result );
394 * Called from Orientation after the Change signal has been sent
396 void RotationDone( int orientation, int width, int height );
399 * @brief Retrieves the unique ID of the window.
402 uint32_t GetId() const;
405 * Feed (Send) touch event to core and gesture manager
406 * @param[in] touchEvent The touch event holding the touch point information.
408 void FeedTouchPoint( TouchPoint& point, int timeStamp );
411 * Feed (Send) wheel event to core and gesture manager
412 * @param[in] wheelEvent The wheel event
414 void FeedWheelEvent( WheelEvent& wheelEvent );
417 * Feed (Send) key event to core
418 * @param[in] keyEvent The key event holding the key information.
420 void FeedKeyEvent( KeyEvent& keyEvent );
423 * Called when the adaptor is paused.
428 * Called when the adaptor is resumed (from pause).
433 * Set the rotation observer (note, some adaptors may not have a rotation observer)
434 * @param[in] observer The rotation observer
435 * @return If the rotation observer is set
437 bool SetRotationObserver( RotationObserver* observer );
442 * Private constructor.
453 * Second stage initialization
455 void Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className);
458 * Called when the window becomes iconified or deiconified.
460 void OnIconifyChanged( bool iconified );
463 * Called when the window focus is changed.
465 void OnFocusChanged( bool focusIn );
468 * Called when the output is transformed.
470 void OnOutputTransformed();
473 * Called when the window receives a delete request.
475 void OnDeleteRequest();
477 private: // Adaptor::Observer interface
480 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
482 virtual void OnStart();
485 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
487 virtual void OnPause();
490 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
492 virtual void OnResume();
495 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
497 virtual void OnStop();
500 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
502 virtual void OnDestroy();
507 * The user should connect to this signal to get a timing when indicator was shown / hidden.
509 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
512 * @copydoc Dali::Window::FocusChangedSignal()
514 FocusSignalType& FocusChangedSignal() { return mFocusChangedSignal; }
517 * @copydoc Dali::Window::ResizedSignal()
519 ResizedSignalType& ResizedSignal() { return mResizedSignal; }
522 * This signal is emitted when the window is requesting to be deleted
524 SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
527 * @copydoc Dali::Window::SignalEventProcessingFinished()
529 Dali::DevelWindow::EventProcessingFinishedSignalType& EventProcessingFinishedSignal() { return mScene.EventProcessingFinishedSignal(); };
532 * @copydoc Dali::Window::KeyEventSignal()
534 Dali::DevelWindow::KeyEventSignalType& KeyEventSignal() { return mScene.KeyEventSignal(); };
537 * @copydoc Dali::Window::TouchSignal()
539 Dali::DevelWindow::TouchSignalType& TouchSignal() { return mScene.TouchSignal(); };
542 * @copydoc Dali::Window::WheelEventSignal()
544 Dali::DevelWindow::WheelEventSignalType& WheelEventSignal() { return mScene.WheelEventSignal(); };
548 static uint32_t mWindowCounter; ///< A counter to track the window creation
549 uint32_t mId; ///< A unique ID to identify the window starting from 0
550 std::unique_ptr< WindowRenderSurface >mSurface; ///< The window rendering surface
551 Dali::Integration::Scene mScene;
552 WindowBase* mWindowBase;
554 std::string mClassName;
556 bool mIsTransparent:1;
557 bool mIsFocusAcceptable:1;
561 bool mResizeEnabled:1;
563 Dali::DragAndDropDetector mDragAndDropDetector;
564 Dali::Window::Type mType;
566 OrientationPtr mOrientation;
567 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
568 Dali::Window::WindowOrientation mPreferredOrientation;
570 EventHandlerPtr mEventHandler; ///< The window events handler
572 Vector4 mBackgroundColor;
575 IndicatorSignalType mIndicatorVisibilityChangedSignal;
576 FocusSignalType mFocusChangedSignal;
577 ResizedSignalType mResizedSignal;
578 SignalType mDeleteRequestSignal;
583 } // namespace Adaptor
584 } // namepsace Internal
586 // Helpers for public-api forwarding methods
588 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
590 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
591 BaseObject& object = window.GetBaseObject();
592 return static_cast<Internal::Adaptor::Window&>(object);
595 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
597 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
598 const BaseObject& object = window.GetBaseObject();
599 return static_cast<const Internal::Adaptor::Window&>(object);
604 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H