1 #ifndef __DALI_INTERNAL_WINDOW_H__
2 #define __DALI_INTERNAL_WINDOW_H__
5 * Copyright (c) 2017 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 <base/lifecycle-observer.h>
27 #include <base/interfaces/indicator-interface.h>
28 #include <adaptor-impl.h>
30 #include <orientation.h>
31 #include <render-surface.h>
32 #include <drag-and-drop-detector.h>
33 #include <window-devel.h>
52 typedef IntrusivePtr<Window> WindowPtr;
53 typedef IntrusivePtr<Orientation> OrientationPtr;
56 * Window provides a surface to render onto with orientation & indicator properties.
58 class Window : public Dali::BaseObject, public IndicatorInterface::Observer, public LifeCycleObserver
61 typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
62 typedef Dali::DevelWindow::FocusSignalType FocusSignalType;
63 typedef Signal< void () > SignalType;
66 * Create a new Window. This should only be called once by the Application class
67 * @param[in] windowPosition The position and size of the window
68 * @param[in] name The window title
69 * @param[in] className The window class name
70 * @param[in] isTransparent Whether window is transparent
71 * @return A newly allocated Window
73 static Window* New(const PositionSize& posSize, const std::string& name, const std::string& className, bool isTransparent = false);
76 * Pass the adaptor back to the overlay. This allows the window to access Core's overlay.
77 * @param[in] adaptor An initialized adaptor
79 void SetAdaptor(Dali::Adaptor& adaptor);
82 * Get the window surface
83 * @return The render surface
85 RenderSurface* GetSurface();
88 * @copydoc Dali::Window::ShowIndicator()
90 void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
93 * @copydoc Dali::Window::SetIndicatorBgOpacity()
95 void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
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 klass );
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 * @brief Sets whether window accepts focus or not.
165 * @param[in] accept If focus is accepted or not. Default is true.
167 void SetAcceptFocus( bool accept );
170 * @brief Returns whether window accepts focus or not.
172 * @param[in] window The window to accept focus
173 * @return True if the window accept focus, false otherwise
175 bool IsFocusAcceptable();
178 * Called from Orientation after the Change signal has been sent
180 void RotationDone( int orientation, int width, int height );
184 * Private constructor.
195 * Second stage initialization
197 void Initialize(const PositionSize& posSize, const std::string& name, const std::string& className);
200 * Shows / hides the indicator bar.
201 * Handles close/open if rotation changes whilst hidden
203 void DoShowIndicator( Dali::Window::WindowOrientation lastOrientation );
206 * Close current indicator and open a connection onto the new indicator service.
207 * Effect may not be synchronous if waiting for an indicator update on existing connection.
209 void DoRotateIndicator( Dali::Window::WindowOrientation orientation );
212 * Change the indicator actor's rotation to match the current orientation
214 void SetIndicatorActorRotation();
217 * Set the indicator properties on the window
219 void SetIndicatorProperties( bool isShown, Dali::Window::WindowOrientation lastOrientation );
221 private: // IndicatorInterface::Observer interface
224 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorTypeChanged()
226 virtual void IndicatorTypeChanged( IndicatorInterface::Type type );
229 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorClosed()
231 virtual void IndicatorClosed( IndicatorInterface* indicator);
234 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorVisibilityChanged()
236 virtual void IndicatorVisibilityChanged( bool isVisible );
238 private: // Adaptor::Observer interface
241 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
243 virtual void OnStart();
246 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
248 virtual void OnPause();
251 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
253 virtual void OnResume();
256 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
258 virtual void OnStop();
261 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
263 virtual void OnDestroy();
268 * The user should connect to this signal to get a timing when indicator was shown / hidden.
270 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
273 * The user should connect to this signal to get a timing when window gains focus or loses focus.
275 FocusSignalType& FocusChangedSignal() { return mFocusChangedSignal; }
278 * This signal is emitted when the window is requesting to be deleted
280 SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
284 typedef std::vector< IndicatorInterface * > DiscardedIndicators;
286 RenderSurface* mSurface;
287 Dali::Window::IndicatorVisibleMode mIndicatorVisible; ///< public state
288 bool mIndicatorIsShown:1; ///< private state
289 bool mShowRotatedIndicatorOnClose:1;
291 bool mIsTransparent:1;
292 bool mWMRotationAppSet:1;
293 bool mEcoreEventHander:1;
294 bool mIsFocusAcceptable:1;
295 IndicatorInterface* mIndicator;
296 Dali::Window::WindowOrientation mIndicatorOrientation;
297 Dali::Window::WindowOrientation mNextIndicatorOrientation;
298 Dali::Window::IndicatorBgOpacity mIndicatorOpacityMode;
299 Integration::SystemOverlay* mOverlay;
301 Dali::DragAndDropDetector mDragAndDropDetector;
304 EventHandler* mEventHandler;
306 OrientationPtr mOrientation;
307 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
308 Dali::Window::WindowOrientation mPreferredOrientation;
311 IndicatorSignalType mIndicatorVisibilityChangedSignal;
312 FocusSignalType mFocusChangedSignal;
313 SignalType mDeleteRequestSignal;
316 } // namespace Adaptor
317 } // namepsace Internal
319 // Helpers for public-api forwarding methods
321 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
323 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
324 BaseObject& object = window.GetBaseObject();
325 return static_cast<Internal::Adaptor::Window&>(object);
328 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
330 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
331 const BaseObject& object = window.GetBaseObject();
332 return static_cast<const Internal::Adaptor::Window&>(object);
338 #endif // __DALI_INTERNAL_WINDOW_H__