1 #ifndef __DALI_INTERNAL_WINDOW_H__
2 #define __DALI_INTERNAL_WINDOW_H__
5 * Copyright (c) 2014 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] windowPosition 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& posSize, 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;
161 * Called from Orientation after the Change signal has been sent
163 void RotationDone( int orientation, int width, int height );
167 * Private constructor.
178 * Second stage initialization
180 void Initialize(const PositionSize& posSize, const std::string& name, const std::string& className);
183 * Shows / hides the indicator bar.
184 * Handles close/open if rotation changes whilst hidden
186 void DoShowIndicator( Dali::Window::WindowOrientation lastOrientation );
189 * Close current indicator and open a connection onto the new indicator service.
190 * Effect may not be synchronous if waiting for an indicator update on existing connection.
192 void DoRotateIndicator( Dali::Window::WindowOrientation orientation );
195 * Change the indicator actor's rotation to match the current orientation
197 void SetIndicatorActorRotation();
200 * Set the indicator properties on the window
202 void SetIndicatorProperties( bool isShown, Dali::Window::WindowOrientation lastOrientation );
204 private: // IndicatorInterface::Observer interface
207 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorTypeChanged()
209 virtual void IndicatorTypeChanged( IndicatorInterface::Type type );
212 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorClosed()
214 virtual void IndicatorClosed( IndicatorInterface* indicator);
217 * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorVisibilityChanged()
219 virtual void IndicatorVisibilityChanged( bool isVisible );
221 private: // Adaptor::Observer interface
224 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
226 virtual void OnStart();
229 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
231 virtual void OnPause();
234 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
236 virtual void OnResume();
239 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
241 virtual void OnStop();
244 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
246 virtual void OnDestroy();
251 * The user should connect to this signal to get a timing when indicator was shown / hidden.
253 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
256 * This signal is emitted when the window is requesting to be deleted
258 SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
262 typedef std::vector< IndicatorInterface * > DiscardedIndicators;
264 RenderSurface* mSurface;
265 Dali::Window::IndicatorVisibleMode mIndicatorVisible; ///< public state
266 bool mIndicatorIsShown:1; ///< private state
267 bool mShowRotatedIndicatorOnClose:1;
269 bool mIsTransparent:1;
270 bool mWMRotationAppSet:1;
271 bool mEcoreEventHander:1;
272 IndicatorInterface* mIndicator;
273 Dali::Window::WindowOrientation mIndicatorOrientation;
274 Dali::Window::WindowOrientation mNextIndicatorOrientation;
275 Dali::Window::IndicatorBgOpacity mIndicatorOpacityMode;
276 Integration::SystemOverlay* mOverlay;
278 Dali::DragAndDropDetector mDragAndDropDetector;
281 EventHandler* mEventHandler;
283 OrientationPtr mOrientation;
284 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
285 Dali::Window::WindowOrientation mPreferredOrientation;
288 IndicatorSignalType mIndicatorVisibilityChangedSignal;
289 SignalType mDeleteRequestSignal;
292 } // namespace Adaptor
293 } // namepsace Internal
295 // Helpers for public-api forwarding methods
297 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
299 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
300 BaseObject& object = window.GetBaseObject();
301 return static_cast<Internal::Adaptor::Window&>(object);
304 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
306 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
307 const BaseObject& object = window.GetBaseObject();
308 return static_cast<const Internal::Adaptor::Window&>(object);
314 #endif // __DALI_INTERNAL_WINDOW_H__