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 <adaptor-impl.h>
28 #include <indicator-impl.h>
30 #include <orientation.h>
31 #include <render-surface.h>
32 #include <drag-and-drop-detector.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 Indicator::Observer, public LifeCycleObserver
61 typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
62 typedef Signal< void () > SignalType;
65 * Create a new Window. This should only be called once by the Application class
66 * @param[in] windowPosition 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& posSize, 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 RenderSurface* 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 * @copydoc Dali::Window::RotateIndicator()
99 void RotateIndicator( Dali::Window::WindowOrientation orientation );
102 * @copydoc Dali::Window::SetClass()
104 void SetClass( std::string name, std::string klass );
107 * @copydoc Dali::Window::Raise()
112 * @copydoc Dali::Window::Lower()
117 * @copydoc Dali::Window::Activate()
122 * @copydoc Dali::Window::AddAvailableOrientation()
124 void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
127 * @copydoc Dali::Window::RemoveAvailableOrientation()
129 void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
132 * @copydoc Dali::Window::SetAvailableOrientations()
134 void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
137 * @copydoc Dali::Window::GetAvailableOrientations()
139 const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
142 * @copydoc Dali::Window::SetPreferredOrientation()
144 void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
147 * @copydoc Dali::Window::GetPreferredOrientation()
149 Dali::Window::WindowOrientation GetPreferredOrientation();
152 * @copydoc Dali::Window::GetDragAndDropDetector() const
154 Dali::DragAndDropDetector GetDragAndDropDetector() const;
157 * @copydoc Dali::Window::GetNativeHandle() const
159 Dali::Any GetNativeHandle() const;
162 * Called from Orientation after the Change signal has been sent
164 void RotationDone( int orientation, int width, int height );
168 * Private constructor.
179 * Second stage initialization
181 void Initialize(const PositionSize& posSize, const std::string& name, const std::string& className);
184 * Shows / hides the indicator bar.
185 * Handles close/open if rotation changes whilst hidden
187 void DoShowIndicator( Dali::Window::WindowOrientation lastOrientation );
190 * Close current indicator and open a connection onto the new indicator service.
191 * Effect may not be synchronous if waiting for an indicator update on existing connection.
193 void DoRotateIndicator( Dali::Window::WindowOrientation orientation );
196 * Change the indicator actor's rotation to match the current orientation
198 void SetIndicatorActorRotation();
201 * Set the indicator properties on the window
203 void SetIndicatorProperties( bool isShown, Dali::Window::WindowOrientation lastOrientation );
205 private: // Indicator::Observer interface
208 * @copydoc Dali::Internal::Adaptor::Indicator::Observer::IndicatorTypeChanged()
210 virtual void IndicatorTypeChanged( Indicator::Type type );
213 * @copydoc Dali::Internal::Adaptor::Indicator::Observer::IndicatorClosed()
215 virtual void IndicatorClosed(Indicator* indicator);
218 * @copydoc Dali::Internal::Adaptor::Indicator::Observer::IndicatorVisibilityChanged()
220 virtual void IndicatorVisibilityChanged( bool isVisible );
222 private: // Adaptor::Observer interface
225 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
227 virtual void OnStart();
230 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
232 virtual void OnPause();
235 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
237 virtual void OnResume();
240 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
242 virtual void OnStop();
245 * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
247 virtual void OnDestroy();
252 * The user should connect to this signal to get a timing when indicator was shown / hidden.
254 IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
257 * This signal is emitted when the window is requesting to be deleted
259 SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
263 typedef std::vector<Indicator*> DiscardedIndicators;
265 RenderSurface* mSurface;
266 Dali::Window::IndicatorVisibleMode mIndicatorVisible; ///< public state
267 bool mIndicatorIsShown:1; ///< private state
268 bool mShowRotatedIndicatorOnClose:1;
270 bool mIsTransparent:1;
271 bool mWMRotationAppSet:1;
272 bool mEcoreEventHander:1;
273 Indicator* mIndicator;
274 Dali::Window::WindowOrientation mIndicatorOrientation;
275 Dali::Window::WindowOrientation mNextIndicatorOrientation;
276 Dali::Window::IndicatorBgOpacity mIndicatorOpacityMode;
277 Integration::SystemOverlay* mOverlay;
279 Dali::DragAndDropDetector mDragAndDropDetector;
282 EventHandler* mEventHandler;
284 OrientationPtr mOrientation;
285 std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
286 Dali::Window::WindowOrientation mPreferredOrientation;
289 IndicatorSignalType mIndicatorVisibilityChangedSignal;
290 SignalType mDeleteRequestSignal;
293 } // namespace Adaptor
294 } // namepsace Internal
296 // Helpers for public-api forwarding methods
298 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
300 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
301 BaseObject& object = window.GetBaseObject();
302 return static_cast<Internal::Adaptor::Window&>(object);
305 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
307 DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
308 const BaseObject& object = window.GetBaseObject();
309 return static_cast<const Internal::Adaptor::Window&>(object);
315 #endif // __DALI_INTERNAL_WINDOW_H__