1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H
5 * Copyright (c) 2018 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>
26 #include <dali/internal/adaptor/common/lifecycle-observer.h>
27 #include <dali/internal/adaptor/common/adaptor-impl.h>
28 #include <dali/internal/window-system/common/indicator-interface.h>
29 #include <dali/public-api/adaptor-framework/window.h>
30 #include <dali/public-api/adaptor-framework/key-grab.h>
31 #include <dali/devel-api/adaptor-framework/drag-and-drop-detector.h>
42 class WindowRenderSurface;
46 typedef IntrusivePtr<Window> WindowPtr;
47 typedef IntrusivePtr<Orientation> OrientationPtr;
50 * Window provides a surface to render onto with orientation & indicator properties.
52 class Window : public Dali::BaseObject, public IndicatorInterface::Observer, public LifeCycleObserver, public ConnectionTracker
55 typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
56 typedef Dali::Window::FocusSignalType FocusSignalType;
57 typedef Dali::Window::ResizedSignalType ResizedSignalType;
58 typedef Signal< void () > SignalType;
61 * Create a new Window. This should only be called once by the Application class
62 * @param[in] positionSize The position and size of the window
63 * @param[in] name The window title
64 * @param[in] className The window class name
65 * @param[in] isTransparent Whether window is transparent
66 * @return A newly allocated Window
68 static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false);
71 * Pass the adaptor back to the overlay. This allows the window to access Core's overlay.
72 * @param[in] adaptor An initialized adaptor
74 void SetAdaptor(Dali::Adaptor& adaptor);
77 * Get the window surface
78 * @return The render surface
80 WindowRenderSurface* GetSurface();
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 * Set the indicator visible mode
95 void SetIndicatorVisibleMode( Dali::Window::IndicatorVisibleMode mode );
98 * @copydoc Dali::Window::RotateIndicator()
100 void RotateIndicator( Dali::Window::WindowOrientation orientation );
103 * @copydoc Dali::Window::SetClass()
105 void SetClass( std::string name, std::string className );
108 * @copydoc Dali::Window::Raise()
113 * @copydoc Dali::Window::Lower()
118 * @copydoc Dali::Window::Activate()
123 * @copydoc Dali::Window::AddAvailableOrientation()
125 void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
128 * @copydoc Dali::Window::RemoveAvailableOrientation()
130 void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
133 * @copydoc Dali::Window::SetAvailableOrientations()
135 void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
138 * @copydoc Dali::Window::GetAvailableOrientations()
140 const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
143 * @copydoc Dali::Window::SetPreferredOrientation()
145 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
148 * @copydoc Dali::Window::GetPreferredOrientation()
150 Dali::Window::WindowOrientation GetPreferredOrientation();
153 * @copydoc Dali::Window::GetDragAndDropDetector() const
155 Dali::DragAndDropDetector GetDragAndDropDetector() const;
158 * @copydoc Dali::Window::GetNativeHandle() const
160 Dali::Any GetNativeHandle() const;
163 * @copydoc Dali::Window::SetAcceptFocus()
165 void SetAcceptFocus( bool accept );
168 * @copydoc Dali::Window::IsFocusAcceptable()
170 bool IsFocusAcceptable() const;
173 * @copydoc Dali::Window::Show()
178 * @copydoc Dali::Window::Hide()
183 * @copydoc Dali::Window::IsVisible() const
185 bool IsVisible() const;
188 * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount()
190 unsigned int GetSupportedAuxiliaryHintCount() const;
193 * @copydoc Dali::Window::GetSupportedAuxiliaryHint()
195 std::string GetSupportedAuxiliaryHint( unsigned int index ) const;
198 * @copydoc Dali::Window::AddAuxiliaryHint()
200 unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
203 * @copydoc Dali::Window::RemoveAuxiliaryHint()
205 bool RemoveAuxiliaryHint( unsigned int id );
208 * @copydoc Dali::Window::SetAuxiliaryHintValue()
210 bool SetAuxiliaryHintValue( unsigned int id, const std::string& value );
213 * @copydoc Dali::Window::GetAuxiliaryHintValue()
215 std::string GetAuxiliaryHintValue( unsigned int id ) const;
218 * @copydoc Dali::Window::GetAuxiliaryHintId()
220 unsigned int GetAuxiliaryHintId( const std::string& hint ) const;
223 * @copydoc Dali::Window::SetInputRegion()
225 void SetInputRegion( const Rect< int >& inputRegion );
228 * @copydoc Dali::Window::SetType()
230 void SetType( Dali::Window::Type type );
233 * @copydoc Dali::Window::GetType() const
235 Dali::Window::Type GetType() const;
238 * @copydoc Dali::Window::SetNotificationLevel()
240 bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level );
243 * @copydoc Dali::Window::GetNotificationLevel()
245 Dali::Window::NotificationLevel::Type GetNotificationLevel() const;
248 * @copydoc Dali::Window::SetOpaqueState()
250 void SetOpaqueState( bool opaque );
253 * @copydoc Dali::Window::IsOpaqueState()
255 bool IsOpaqueState() const;
258 * @copydoc Dali::Window::SetScreenOffMode()
260 bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode);
263 * @copydoc Dali::Window::GetScreenOffMode()
265 Dali::Window::ScreenOffMode::Type GetScreenOffMode() const;
268 * @copydoc Dali::Window::SetBrightness()
270 bool SetBrightness( int brightness );
273 * @copydoc Dali::Window::GetBrightness()
275 int GetBrightness() const;
278 * @copydoc Dali::Window::SetSize()
280 void SetSize( Dali::Window::WindowSize size );
283 * @copydoc Dali::Window::GetSize()
285 Dali::Window::WindowSize GetSize() const;
288 * @copydoc Dali::Window::SetPosition()
290 void SetPosition( Dali::Window::WindowPosition position );
293 * @copydoc Dali::Window::GetPosition()
295 Dali::Window::WindowPosition GetPosition() const;
298 * @copydoc Dali::DevelWindow::SetPositionSize()
300 void SetPositionSize( PositionSize positionSize );
303 * @copydoc Dali::Window::SetTransparency()
305 void SetTransparency( bool transparent );
308 * @copydoc Dali::KeyGrab::GrabKey()
310 bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode );
313 * @copydoc Dali::KeyGrab::UngrabKey()
315 bool UngrabKey( Dali::KEY key );
318 * @copydoc Dali::KeyGrab::GrabKeyList()
320 bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result );
323 * @copydoc Dali::KeyGrab::UngrabKeyList()
325 bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result );
328 * Called from Orientation after the Change signal has been sent
330 void RotationDone( int orientation, int width, int height );
335 * Private constructor.
346 * Second stage initialization
348 void Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className);
351 * Shows / hides the indicator bar.
352 * Handles close/open if rotation changes whilst hidden
354 void DoShowIndicator( Dali::Window::WindowOrientation lastOrientation );
357 * Close current indicator and open a connection onto the new indicator service.
358 * Effect may not be synchronous if waiting for an indicator update on existing connection.
360 void DoRotateIndicator( Dali::Window::WindowOrientation orientation );
363 * Change the indicator actor's rotation to match the current orientation
365 void SetIndicatorActorRotation();
368 * Set the indicator properties on the window
370 void SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation );
373 * Called when the window becomes iconified or deiconified.
375 void OnIconifyChanged( bool iconified );
378 * Called when the window focus is changed.
380 void OnFocusChanged( bool focusIn );
383 * Called when the output is transformed.
385 void OnOutputTransformed();
388 * Called when the window receives a delete request.
390 void OnDeleteRequest();
393 * Called when the Ecore indicator event is received.
395 void OnIndicatorFlicked();
397 private: // IndicatorInterface::Observer interface
400 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorTypeChanged()
402 virtual void IndicatorTypeChanged( IndicatorInterface::Type type );
405 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorClosed()
407 virtual void IndicatorClosed( IndicatorInterface* indicator);
410 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorVisibilityChanged()
412 virtual void IndicatorVisibilityChanged( bool isVisible );
414 private: // Adaptor::Observer interface
417 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
419 virtual void OnStart();
422 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
424 virtual void OnPause();
427 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
429 virtual void OnResume();
432 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
434 virtual void OnStop();
437 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
439 virtual void OnDestroy();
444 * The user should connect to this signal to get a timing when indicator was shown / hidden.
446 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
449 * @copydoc Dali::Window::FocusChangedSignal()
451 FocusSignalType& FocusChangedSignal() { return mFocusChangedSignal; }
454 * @copydoc Dali::Window::ResizedSignal()
456 ResizedSignalType& ResizedSignal() { return mResizedSignal; }
459 * This signal is emitted when the window is requesting to be deleted
461 SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
465 WindowRenderSurface* mSurface;
466 WindowBase* mWindowBase;
467 Dali::Window::IndicatorVisibleMode mIndicatorVisible; ///< public state
468 bool mIndicatorIsShown:1; ///< private state
469 bool mShowRotatedIndicatorOnClose:1;
471 bool mIsTransparent:1;
472 bool mIsFocusAcceptable:1;
476 bool mResizeEnabled:1;
477 std::unique_ptr< IndicatorInterface > mIndicator;
478 Dali::Window::WindowOrientation mIndicatorOrientation;
479 Dali::Window::WindowOrientation mNextIndicatorOrientation;
480 Dali::Window::IndicatorBgOpacity mIndicatorOpacityMode;
482 Dali::DragAndDropDetector mDragAndDropDetector;
483 Dali::Window::Type mType;
485 OrientationPtr mOrientation;
486 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
487 Dali::Window::WindowOrientation mPreferredOrientation;
490 IndicatorSignalType mIndicatorVisibilityChangedSignal;
491 FocusSignalType mFocusChangedSignal;
492 ResizedSignalType mResizedSignal;
493 SignalType mDeleteRequestSignal;
496 } // namespace Adaptor
497 } // namepsace Internal
499 // Helpers for public-api forwarding methods
501 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
503 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
504 BaseObject& object = window.GetBaseObject();
505 return static_cast<Internal::Adaptor::Window&>(object);
508 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
510 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
511 const BaseObject& object = window.GetBaseObject();
512 return static_cast<const Internal::Adaptor::Window&>(object);
517 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H