1 #ifndef __DALI_INTERNAL_WINDOW_H__
2 #define __DALI_INTERNAL_WINDOW_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/window-system/common/indicator-interface.h>
28 #include <dali/internal/adaptor/common/adaptor-impl.h>
29 #include <dali/public-api/adaptor-framework/window.h>
30 #include <dali/devel-api/adaptor-framework/drag-and-drop-detector.h>
47 class WindowRenderSurface;
50 typedef IntrusivePtr<Window> WindowPtr;
51 typedef IntrusivePtr<Orientation> OrientationPtr;
54 * Window provides a surface to render onto with orientation & indicator properties.
56 class Window : public Dali::BaseObject, public IndicatorInterface::Observer, public LifeCycleObserver
59 typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
60 typedef Dali::Window::FocusSignalType FocusSignalType;
61 typedef Dali::Window::ResizedSignalType ResizedSignalType;
62 typedef Signal< void () > SignalType;
65 * Create a new Window. This should only be called once by the Application class
66 * @param[in] positionSize The position and size of the window
67 * @param[in] name The window title
68 * @param[in] className The window class name
69 * @param[in] isTransparent Whether window is transparent
70 * @return A newly allocated Window
72 static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false);
75 * Pass the adaptor back to the overlay. This allows the window to access Core's overlay.
76 * @param[in] adaptor An initialized adaptor
78 void SetAdaptor(Dali::Adaptor& adaptor);
81 * Get the window surface
82 * @return The render surface
84 WindowRenderSurface* GetSurface();
87 * @copydoc Dali::Window::ShowIndicator()
89 void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
92 * @copydoc Dali::Window::SetIndicatorBgOpacity()
94 void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
97 * Set the indicator visible mode
99 void SetIndicatorVisibleMode( Dali::Window::IndicatorVisibleMode mode );
102 * @copydoc Dali::Window::RotateIndicator()
104 void RotateIndicator( Dali::Window::WindowOrientation orientation );
107 * @copydoc Dali::Window::SetClass()
109 void SetClass( std::string name, std::string className );
112 * @copydoc Dali::Window::Raise()
117 * @copydoc Dali::Window::Lower()
122 * @copydoc Dali::Window::Activate()
127 * @copydoc Dali::Window::AddAvailableOrientation()
129 void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
132 * @copydoc Dali::Window::RemoveAvailableOrientation()
134 void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
137 * @copydoc Dali::Window::SetAvailableOrientations()
139 void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
142 * @copydoc Dali::Window::GetAvailableOrientations()
144 const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
147 * @copydoc Dali::Window::SetPreferredOrientation()
149 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
152 * @copydoc Dali::Window::GetPreferredOrientation()
154 Dali::Window::WindowOrientation GetPreferredOrientation();
157 * @copydoc Dali::Window::GetDragAndDropDetector() const
159 Dali::DragAndDropDetector GetDragAndDropDetector() const;
162 * @copydoc Dali::Window::GetNativeHandle() const
164 Dali::Any GetNativeHandle() const;
167 * @copydoc Dali::Window::SetAcceptFocus()
169 void SetAcceptFocus( bool accept );
172 * @copydoc Dali::Window::IsFocusAcceptable()
174 bool IsFocusAcceptable() const;
177 * @copydoc Dali::Window::Show()
182 * @copydoc Dali::Window::Hide()
187 * @copydoc Dali::Window::IsVisible() const
189 bool IsVisible() const;
192 * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount()
194 unsigned int GetSupportedAuxiliaryHintCount() const;
197 * @copydoc Dali::Window::GetSupportedAuxiliaryHint()
199 std::string GetSupportedAuxiliaryHint( unsigned int index ) const;
202 * @copydoc Dali::Window::AddAuxiliaryHint()
204 unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
207 * @copydoc Dali::Window::RemoveAuxiliaryHint()
209 bool RemoveAuxiliaryHint( unsigned int id );
212 * @copydoc Dali::Window::SetAuxiliaryHintValue()
214 bool SetAuxiliaryHintValue( unsigned int id, const std::string& value );
217 * @copydoc Dali::Window::GetAuxiliaryHintValue()
219 std::string GetAuxiliaryHintValue( unsigned int id ) const;
222 * @copydoc Dali::Window::GetAuxiliaryHintId()
224 unsigned int GetAuxiliaryHintId( const std::string& hint ) const;
227 * @copydoc Dali::Window::SetInputRegion()
229 void SetInputRegion( const Rect< int >& inputRegion );
232 * @copydoc Dali::Window::SetType()
234 void SetType( Dali::Window::Type type );
237 * @copydoc Dali::Window::GetType() const
239 Dali::Window::Type GetType() const;
242 * @copydoc Dali::Window::SetNotificationLevel()
244 bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level );
247 * @copydoc Dali::Window::GetNotificationLevel()
249 Dali::Window::NotificationLevel::Type GetNotificationLevel() const;
252 * @copydoc Dali::Window::SetOpaqueState()
254 void SetOpaqueState( bool opaque );
257 * @copydoc Dali::Window::IsOpaqueState()
259 bool IsOpaqueState() const;
262 * @copydoc Dali::Window::SetScreenOffMode()
264 bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode);
267 * @copydoc Dali::Window::GetScreenOffMode()
269 Dali::Window::ScreenOffMode::Type GetScreenOffMode() const;
272 * @copydoc Dali::Window::SetBrightness()
274 bool SetBrightness( int brightness );
277 * @copydoc Dali::Window::GetBrightness()
279 int GetBrightness() const;
282 * @copydoc Dali::Window::SetSize()
284 void SetSize( Dali::Window::WindowSize size );
287 * @copydoc Dali::Window::GetSize()
289 Dali::Window::WindowSize GetSize() const;
292 * @copydoc Dali::Window::SetPosition()
294 void SetPosition( Dali::Window::WindowPosition position );
297 * @copydoc Dali::Window::GetPosition()
299 Dali::Window::WindowPosition GetPosition() const;
302 * @copydoc Dali::Window::SetTransparency()
304 void SetTransparency( bool transparent );
307 * Called from Orientation after the Change signal has been sent
309 void RotationDone( int orientation, int width, int height );
312 * Called when the window becomes iconified or deiconified.
314 void OnIconifyChanged( bool iconified );
317 * Called when the window focus is changed.
319 void OnFocusChanged( bool focusIn );
322 * Called when the output is transformed.
324 void OnOutputTransformed();
327 * Called when the window receives a delete request
329 void OnDeleteRequest();
333 * Private constructor.
344 * Second stage initialization
346 void Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className);
349 * Shows / hides the indicator bar.
350 * Handles close/open if rotation changes whilst hidden
352 void DoShowIndicator( Dali::Window::WindowOrientation lastOrientation );
355 * Close current indicator and open a connection onto the new indicator service.
356 * Effect may not be synchronous if waiting for an indicator update on existing connection.
358 void DoRotateIndicator( Dali::Window::WindowOrientation orientation );
361 * Change the indicator actor's rotation to match the current orientation
363 void SetIndicatorActorRotation();
366 * Set the indicator properties on the window
368 void SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation );
370 private: // IndicatorInterface::Observer interface
373 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorTypeChanged()
375 virtual void IndicatorTypeChanged( IndicatorInterface::Type type );
378 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorClosed()
380 virtual void IndicatorClosed( IndicatorInterface* indicator);
383 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorVisibilityChanged()
385 virtual void IndicatorVisibilityChanged( bool isVisible );
387 private: // Adaptor::Observer interface
390 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
392 virtual void OnStart();
395 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
397 virtual void OnPause();
400 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
402 virtual void OnResume();
405 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
407 virtual void OnStop();
410 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
412 virtual void OnDestroy();
417 * The user should connect to this signal to get a timing when indicator was shown / hidden.
419 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
422 * @copydoc Dali::Window::FocusChangedSignal()
424 FocusSignalType& FocusChangedSignal() { return mFocusChangedSignal; }
427 * @copydoc Dali::Window::ResizedSignal()
429 ResizedSignalType& ResizedSignal() { return mResizedSignal; }
432 * This signal is emitted when the window is requesting to be deleted
434 SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
438 WindowRenderSurface* mSurface;
439 std::unique_ptr< WindowBase > mWindowBase;
440 Dali::Window::IndicatorVisibleMode mIndicatorVisible; ///< public state
441 bool mIndicatorIsShown:1; ///< private state
442 bool mShowRotatedIndicatorOnClose:1;
444 bool mIsTransparent:1;
445 bool mIsFocusAcceptable:1;
449 bool mResizeEnabled:1;
450 IndicatorInterface* mIndicator;
451 Dali::Window::WindowOrientation mIndicatorOrientation;
452 Dali::Window::WindowOrientation mNextIndicatorOrientation;
453 Dali::Window::IndicatorBgOpacity mIndicatorOpacityMode;
454 Integration::SystemOverlay* mOverlay;
456 Dali::DragAndDropDetector mDragAndDropDetector;
457 Dali::Window::Type mType;
459 OrientationPtr mOrientation;
460 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
461 Dali::Window::WindowOrientation mPreferredOrientation;
464 IndicatorSignalType mIndicatorVisibilityChangedSignal;
465 FocusSignalType mFocusChangedSignal;
466 ResizedSignalType mResizedSignal;
467 SignalType mDeleteRequestSignal;
470 } // namespace Adaptor
471 } // namepsace Internal
473 // Helpers for public-api forwarding methods
475 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
477 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
478 BaseObject& object = window.GetBaseObject();
479 return static_cast<Internal::Adaptor::Window&>(object);
482 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
484 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
485 const BaseObject& object = window.GetBaseObject();
486 return static_cast<const Internal::Adaptor::Window&>(object);
491 #endif // __DALI_INTERNAL_WINDOW_H__