1 // Copyright (c) 2013 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef XWALK_RUNTIME_BROWSER_UI_NATIVE_APP_WINDOW_TIZEN_H_
6 #define XWALK_RUNTIME_BROWSER_UI_NATIVE_APP_WINDOW_TIZEN_H_
8 #include "xwalk/runtime/browser/ui/screen_orientation.h"
9 #include "xwalk/runtime/browser/ui/native_app_window_views.h"
10 #include "xwalk/tizen/mobile/sensor/sensor_provider.h"
11 #include "xwalk/tizen/mobile/ui/tizen_system_indicator_widget.h"
12 #include "xwalk/tizen/mobile/ui/widget_container_view.h"
13 #include "ui/aura/window_observer.h"
17 // Tizen uses the Views native window but adds its own features like orientation
18 // handling and integration with system indicator bar.
19 class NativeAppWindowTizen
20 : public aura::WindowObserver,
21 public NativeAppWindowViews,
22 public SensorProvider::Observer,
23 public MultiOrientationScreen {
25 explicit NativeAppWindowTizen(const NativeAppWindow::CreateParams& params);
26 virtual ~NativeAppWindowTizen();
30 gfx::Transform GetRotationTransform() const;
31 void ApplyDisplayRotation();
33 // NativeAppWindowViews overrides:
34 virtual void Initialize() OVERRIDE;
36 // WindowObserver overrides:
37 virtual void OnWindowVisibilityChanging(aura::Window* window,
38 bool visible) OVERRIDE;
39 virtual void OnWindowBoundsChanged(aura::Window* window,
40 const gfx::Rect& old_bounds,
41 const gfx::Rect& new_bounds) OVERRIDE;
42 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
44 // views::View overrides:
45 virtual void ViewHierarchyChanged(
46 const ViewHierarchyChangedDetails& details) OVERRIDE;
48 // SensorProvider::Observer overrides:
49 virtual void OnRotationChanged(gfx::Display::Rotation rotation) OVERRIDE;
51 void UpdateTopViewOverlay();
53 // MultiOrientationScreen overrides:
54 virtual Orientation GetCurrentOrientation() const OVERRIDE;
55 virtual void OnAllowedOrientationsChanged(
56 OrientationMask orientations) OVERRIDE;
58 gfx::Display::Rotation GetClosestAllowedRotation(
59 gfx::Display::Rotation) const;
61 #if defined(OS_TIZEN_MOBILE)
62 // The system indicator is implemented as a widget because it needs to
63 // receive events and may also be an overlay on top of the rest of the
64 // content, regular views do not support this. We add it to the container,
65 // that is a view that doesn't draw anything, just passes the bounds
66 // information to the topview layout.
67 // The |indicator_widget_| is owned by the WidgetContainerView.
68 TizenSystemIndicatorWidget* indicator_widget_;
69 scoped_ptr<WidgetContainerView> indicator_container_;
72 gfx::Display display_;
73 OrientationMask allowed_orientations_;
75 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowTizen);
80 #endif // XWALK_RUNTIME_BROWSER_UI_NATIVE_APP_WINDOW_TIZEN_H_