• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The Chromium Authors. 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.
4 
5 #ifndef MOJO_EXAMPLES_AURA_DEMO_WINDOW_TREE_HOST_VIEW_MANAGER_H_
6 #define MOJO_EXAMPLES_AURA_DEMO_WINDOW_TREE_HOST_VIEW_MANAGER_H_
7 
8 #include "mojo/services/public/cpp/view_manager/node_observer.h"
9 #include "ui/aura/window_tree_host.h"
10 #include "ui/events/event_source.h"
11 #include "ui/gfx/geometry/rect.h"
12 
13 class SkBitmap;
14 
15 namespace ui {
16 class Compositor;
17 }
18 
19 namespace mojo {
20 
21 class WindowTreeHostMojoDelegate;
22 
23 class WindowTreeHostMojo : public aura::WindowTreeHost,
24                            public ui::EventSource,
25                            public view_manager::NodeObserver {
26  public:
27   WindowTreeHostMojo(view_manager::Node* node,
28                      WindowTreeHostMojoDelegate* delegate);
29   virtual ~WindowTreeHostMojo();
30 
31   // Returns the WindowTreeHostMojo for the specified compositor.
32   static WindowTreeHostMojo* ForCompositor(ui::Compositor* compositor);
33 
bounds()34   const gfx::Rect& bounds() const { return bounds_; }
35 
36   // Sets the contents to show in this WindowTreeHost. This forwards to the
37   // delegate.
38   void SetContents(const SkBitmap& contents);
39 
SendEventToProcessor(ui::Event * event)40   ui::EventDispatchDetails SendEventToProcessor(ui::Event* event) {
41     return ui::EventSource::SendEventToProcessor(event);
42   }
43 
44  private:
45   // WindowTreeHost:
46   virtual ui::EventSource* GetEventSource() OVERRIDE;
47   virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE;
48   virtual void Show() OVERRIDE;
49   virtual void Hide() OVERRIDE;
50   virtual gfx::Rect GetBounds() const OVERRIDE;
51   virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
52   virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE;
53   virtual void SetCapture() OVERRIDE;
54   virtual void ReleaseCapture() OVERRIDE;
55   virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE;
56   virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
57   virtual void SetCursorNative(gfx::NativeCursor cursor) OVERRIDE;
58   virtual void MoveCursorToNative(const gfx::Point& location) OVERRIDE;
59   virtual void OnCursorVisibilityChangedNative(bool show) OVERRIDE;
60 
61   // ui::EventSource:
62   virtual ui::EventProcessor* GetEventProcessor() OVERRIDE;
63 
64   // view_manager::NodeObserver:
65   virtual void OnNodeBoundsChange(
66       view_manager::Node* node,
67       const gfx::Rect& old_bounds,
68       const gfx::Rect& new_bounds,
69       view_manager::NodeObserver::DispositionChangePhase phase) OVERRIDE;
70 
71   view_manager::Node* node_;
72 
73   gfx::Rect bounds_;
74 
75   WindowTreeHostMojoDelegate* delegate_;
76 
77   DISALLOW_COPY_AND_ASSIGN(WindowTreeHostMojo);
78 };
79 
80 }  // namespace mojo
81 
82 #endif  // MOJO_EXAMPLES_AURA_DEMO_WINDOW_TREE_HOST_VIEW_MANAGER_H_
83