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>
51 typedef IntrusivePtr<Window> WindowPtr;
52 typedef IntrusivePtr<Orientation> OrientationPtr;
55 * Window provides a surface to render onto with orientation & indicator properties.
57 class Window : public Dali::BaseObject, public IndicatorInterface::Observer, public LifeCycleObserver
60 typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
61 typedef Signal< void () > SignalType;
64 * Create a new Window. This should only be called once by the Application class
65 * @param[in] positionSize The position and size of the window
66 * @param[in] name The window title
67 * @param[in] className The window class name
68 * @param[in] isTransparent Whether window is transparent
69 * @return A newly allocated Window
71 static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false);
74 * Pass the adaptor back to the overlay. This allows the window to access Core's overlay.
75 * @param[in] adaptor An initialized adaptor
77 void SetAdaptor(Dali::Adaptor& adaptor);
80 * Get the window surface
81 * @return The render surface
83 RenderSurface* GetSurface();
86 * @copydoc Dali::Window::ShowIndicator()
88 void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
91 * @copydoc Dali::Window::SetIndicatorBgOpacity()
93 void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
96 * @copydoc Dali::Window::RotateIndicator()
98 void RotateIndicator( Dali::Window::WindowOrientation orientation );
101 * @copydoc Dali::Window::SetClass()
103 void SetClass( std::string name, std::string klass );
106 * @copydoc Dali::Window::Raise()
111 * @copydoc Dali::Window::Lower()
116 * @copydoc Dali::Window::Activate()
121 * @copydoc Dali::Window::AddAvailableOrientation()
123 void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
126 * @copydoc Dali::Window::RemoveAvailableOrientation()
128 void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
131 * @copydoc Dali::Window::SetAvailableOrientations()
133 void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
136 * @copydoc Dali::Window::GetAvailableOrientations()
138 const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
141 * @copydoc Dali::Window::SetPreferredOrientation()
143 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
146 * @copydoc Dali::Window::GetPreferredOrientation()
148 Dali::Window::WindowOrientation GetPreferredOrientation();
151 * @copydoc Dali::Window::GetDragAndDropDetector() const
153 Dali::DragAndDropDetector GetDragAndDropDetector() const;
156 * @copydoc Dali::Window::GetNativeHandle() const
158 Dali::Any GetNativeHandle() const;
160 unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
163 * Called from Orientation after the Change signal has been sent
165 void RotationDone( int orientation, int width, int height );
169 * Private constructor.
180 * Second stage initialization
182 void Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className);
185 * Shows / hides the indicator bar.
186 * Handles close/open if rotation changes whilst hidden
188 void DoShowIndicator( Dali::Window::WindowOrientation lastOrientation );
191 * Close current indicator and open a connection onto the new indicator service.
192 * Effect may not be synchronous if waiting for an indicator update on existing connection.
194 void DoRotateIndicator( Dali::Window::WindowOrientation orientation );
197 * Change the indicator actor's rotation to match the current orientation
199 void SetIndicatorActorRotation();
202 * Set the indicator properties on the window
204 void SetIndicatorProperties( bool isShown, Dali::Window::WindowOrientation lastOrientation );
206 private: // IndicatorInterface::Observer interface
209 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorTypeChanged()
211 virtual void IndicatorTypeChanged( IndicatorInterface::Type type );
214 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorClosed()
216 virtual void IndicatorClosed( IndicatorInterface* indicator);
219 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorVisibilityChanged()
221 virtual void IndicatorVisibilityChanged( bool isVisible );
223 private: // Adaptor::Observer interface
226 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
228 virtual void OnStart();
231 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
233 virtual void OnPause();
236 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
238 virtual void OnResume();
241 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
243 virtual void OnStop();
246 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
248 virtual void OnDestroy();
253 * The user should connect to this signal to get a timing when indicator was shown / hidden.
255 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
258 * This signal is emitted when the window is requesting to be deleted
260 SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
264 typedef std::vector< std::pair< std::string, std::string > > AuxiliaryHints;
266 RenderSurface* mSurface;
267 Dali::Window::IndicatorVisibleMode mIndicatorVisible; ///< public state
268 bool mIndicatorIsShown:1; ///< private state
269 bool mShowRotatedIndicatorOnClose:1;
271 bool mIsTransparent:1;
272 bool mWMRotationAppSet:1;
273 bool mEcoreEventHander:1;
274 bool mResizeEnabled:1;
275 IndicatorInterface* mIndicator;
276 Dali::Window::WindowOrientation mIndicatorOrientation;
277 Dali::Window::WindowOrientation mNextIndicatorOrientation;
278 Dali::Window::IndicatorBgOpacity mIndicatorOpacityMode;
279 Integration::SystemOverlay* mOverlay;
281 Dali::DragAndDropDetector mDragAndDropDetector;
284 EventHandler* mEventHandler;
286 OrientationPtr mOrientation;
287 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
288 Dali::Window::WindowOrientation mPreferredOrientation;
290 std::vector< std::string > mSupportedAuxiliaryHints;
291 AuxiliaryHints mAuxiliaryHints;
294 IndicatorSignalType mIndicatorVisibilityChangedSignal;
295 SignalType mDeleteRequestSignal;
298 } // namespace Adaptor
299 } // namepsace Internal
301 // Helpers for public-api forwarding methods
303 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
305 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
306 BaseObject& object = window.GetBaseObject();
307 return static_cast<Internal::Adaptor::Window&>(object);
310 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
312 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
313 const BaseObject& object = window.GetBaseObject();
314 return static_cast<const Internal::Adaptor::Window&>(object);
320 #endif // __DALI_INTERNAL_WINDOW_H__