OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef AURA_WINDOW_H_ | 5 #ifndef AURA_WINDOW_H_ |
6 #define AURA_WINDOW_H_ | 6 #define AURA_WINDOW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "ui/gfx/native_widget_types.h" | |
14 #include "ui/gfx/rect.h" | 13 #include "ui/gfx/rect.h" |
15 | 14 |
16 class SkCanvas; | 15 class SkCanvas; |
17 | 16 |
18 namespace ui { | 17 namespace ui { |
19 class Compositor; | 18 class Compositor; |
20 class Layer; | 19 class Layer; |
21 } | 20 } |
22 | 21 |
23 namespace aura { | 22 namespace aura { |
(...skipping 11 matching lines...) Expand all Loading... |
35 // events. This is the default. | 34 // events. This is the default. |
36 VISIBILITY_HIDDEN = 1, | 35 VISIBILITY_HIDDEN = 1, |
37 | 36 |
38 // Display the window and let it receive mouse events. | 37 // Display the window and let it receive mouse events. |
39 VISIBILITY_SHOWN = 2, | 38 VISIBILITY_SHOWN = 2, |
40 | 39 |
41 // Display the window but prevent it from receiving mouse events. | 40 // Display the window but prevent it from receiving mouse events. |
42 VISIBILITY_SHOWN_NO_INPUT = 3, | 41 VISIBILITY_SHOWN_NO_INPUT = 3, |
43 }; | 42 }; |
44 | 43 |
45 explicit Window(Desktop* desktop); | 44 explicit Window(WindowDelegate* delegate); |
46 ~Window(); | 45 ~Window(); |
47 | 46 |
48 void set_delegate(WindowDelegate* d) { delegate_ = d; } | 47 void Init(); |
49 | 48 |
50 int id() const { return id_; } | 49 int id() const { return id_; } |
51 void set_id(int id) { id_ = id; } | 50 void set_id(int id) { id_ = id; } |
52 | 51 |
| 52 ui::Layer* layer() { return layer_.get(); } |
| 53 const ui::Layer* layer() const { return layer_.get(); } |
| 54 |
53 // Changes the visibility of the window. | 55 // Changes the visibility of the window. |
54 void SetVisibility(Visibility visibility); | 56 void SetVisibility(Visibility visibility); |
55 Visibility visibility() const { return visibility_; } | 57 Visibility visibility() const { return visibility_; } |
56 | 58 |
57 // Changes the bounds of the window. | 59 // Changes the bounds of the window. |
58 void SetBounds(const gfx::Rect& bounds, int anim_ms); | 60 void SetBounds(const gfx::Rect& bounds, int anim_ms); |
59 const gfx::Rect& bounds() const { return bounds_; } | 61 const gfx::Rect& bounds() const { return bounds_; } |
60 | 62 |
61 // Marks the window as needing to be painted. | 63 // Marks the window as needing to be painted. |
62 void SchedulePaint(const gfx::Rect& bounds); | 64 void SchedulePaint(const gfx::Rect& bounds); |
63 | 65 |
64 // Sets the contents of the window. | 66 // Sets the contents of the window. |
65 void SetCanvas(const SkCanvas& canvas, const gfx::Point& origin); | 67 void SetCanvas(const SkCanvas& canvas, const gfx::Point& origin); |
66 | 68 |
| 69 // Sets the parent window of the window. If NULL, the window is parented to |
| 70 // the desktop's window. |
| 71 void SetParent(Window* parent); |
| 72 Window* parent() { return parent_; } |
| 73 |
67 // Draw the window and its children. | 74 // Draw the window and its children. |
68 void DrawTree(); | 75 void DrawTree(); |
69 | 76 |
70 // Tree operations. | 77 // Tree operations. |
71 // TODO(beng): Child windows are currently not owned by the hierarchy. We | 78 // TODO(beng): Child windows are currently not owned by the hierarchy. We |
72 // should change this. | 79 // should change this. |
73 void AddChild(Window* child); | 80 void AddChild(Window* child); |
74 void RemoveChild(Window* child); | 81 void RemoveChild(Window* child); |
75 Window* parent() { return parent_; } | |
76 | 82 |
77 // Handles a mouse event. Returns true if handled. | 83 // Handles a mouse event. Returns true if handled. |
78 bool OnMouseEvent(const MouseEvent& event); | 84 bool OnMouseEvent(const MouseEvent& event); |
79 | 85 |
80 private: | 86 private: |
81 typedef std::vector<Window*> Windows; | 87 typedef std::vector<Window*> Windows; |
82 | 88 |
83 // If SchedulePaint has been invoked on the Window the delegate is notified. | 89 // If SchedulePaint has been invoked on the Window the delegate is notified. |
84 void UpdateLayerCanvas(); | 90 void UpdateLayerCanvas(); |
85 | 91 |
(...skipping 25 matching lines...) Expand all Loading... |
111 Windows children_; | 117 Windows children_; |
112 | 118 |
113 int id_; | 119 int id_; |
114 | 120 |
115 DISALLOW_COPY_AND_ASSIGN(Window); | 121 DISALLOW_COPY_AND_ASSIGN(Window); |
116 }; | 122 }; |
117 | 123 |
118 } // namespace aura | 124 } // namespace aura |
119 | 125 |
120 #endif // AURA_WINDOW_H_ | 126 #endif // AURA_WINDOW_H_ |
OLD | NEW |