Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: aura/window.h

Issue 7886042: Move Aura to UI subdir. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef AURA_WINDOW_H_
6 #define AURA_WINDOW_H_
7 #pragma once
8
9 #include <vector>
10
11 #include "aura/aura_export.h"
12 #include "base/basictypes.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "ui/gfx/compositor/layer_delegate.h"
15 #include "ui/gfx/rect.h"
16
17 class SkCanvas;
18
19 namespace ui {
20 class Compositor;
21 class Layer;
22 }
23
24 namespace aura {
25
26 class Desktop;
27 class KeyEvent;
28 class MouseEvent;
29 class WindowDelegate;
30 class WindowManager;
31
32 namespace internal {
33 class FocusManager;
34 }
35
36 // Aura window implementation. Interesting events are sent to the
37 // WindowDelegate.
38 // TODO(beng): resolve ownership.
39 class AURA_EXPORT Window : public ui::LayerDelegate {
40 public:
41 enum Visibility {
42 // Don't display the window onscreen and don't let it receive mouse
43 // events. This is the default.
44 VISIBILITY_HIDDEN = 1,
45
46 // Display the window and let it receive mouse events.
47 VISIBILITY_SHOWN = 2,
48
49 // Display the window but prevent it from receiving mouse events.
50 VISIBILITY_SHOWN_NO_INPUT = 3,
51 };
52
53 explicit Window(WindowDelegate* delegate);
54 ~Window();
55
56 void Init();
57
58 int id() const { return id_; }
59 void set_id(int id) { id_ = id; }
60
61 ui::Layer* layer() { return layer_.get(); }
62 const ui::Layer* layer() const { return layer_.get(); }
63
64 // Changes the visibility of the window.
65 void SetVisibility(Visibility visibility);
66 Visibility visibility() const { return visibility_; }
67
68 // Changes the bounds of the window.
69 void SetBounds(const gfx::Rect& bounds, int anim_ms);
70 const gfx::Rect& bounds() const { return bounds_; }
71
72 // Marks the a portion of window as needing to be painted.
73 void SchedulePaintInRect(const gfx::Rect& rect);
74
75 // Sets the contents of the window.
76 void SetCanvas(const SkCanvas& canvas, const gfx::Point& origin);
77
78 // Sets the parent window of the window. If NULL, the window is parented to
79 // the desktop's window.
80 void SetParent(Window* parent);
81 Window* parent() { return parent_; }
82
83 // Returns true if this Window is the container for toplevel windows.
84 virtual bool IsTopLevelWindowContainer() const;
85
86 // Move the specified child of this Window to the front of the z-order.
87 // TODO(beng): this is (obviously) feeble.
88 void MoveChildToFront(Window* child);
89
90 // Tree operations.
91 // TODO(beng): Child windows are currently not owned by the hierarchy. We
92 // should change this.
93 void AddChild(Window* child);
94 void RemoveChild(Window* child);
95
96 static void ConvertPointToWindow(Window* source,
97 Window* target,
98 gfx::Point* point);
99
100 // Handles a mouse event. Returns true if handled.
101 bool OnMouseEvent(MouseEvent* event);
102
103 // Handles a key event. Returns true if handled.
104 bool OnKeyEvent(KeyEvent* event);
105
106 WindowDelegate* delegate() { return delegate_; }
107
108 // Returns true if the mouse pointer at the specified |point| can trigger an
109 // event for this Window.
110 // TODO(beng):
111 // A Window can supply a hit-test mask to cause some portions of itself to not
112 // trigger events, causing the events to fall through to the Window behind.
113 bool HitTest(const gfx::Point& point);
114
115 // Returns the Window that most closely encloses |point| for the purposes of
116 // event targeting.
117 Window* GetEventHandlerForPoint(const gfx::Point& point);
118
119 // Returns the FocusManager for the Window, which may be attached to a parent
120 // Window. Can return NULL if the Window has no FocusManager.
121 virtual internal::FocusManager* GetFocusManager();
122
123 // The Window does not own this object.
124 void set_user_data(void* user_data) { user_data_ = user_data; }
125 void* user_data() const { return user_data_; }
126
127 private:
128 typedef std::vector<Window*> Windows;
129
130 // If SchedulePaint has been invoked on the Window the delegate is notified.
131 void UpdateLayerCanvas();
132
133 // Schedules a paint for the Window's entire bounds.
134 void SchedulePaint();
135
136 // Overridden from ui::LayerDelegate:
137 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE;
138
139 WindowDelegate* delegate_;
140
141 Visibility visibility_;
142
143 scoped_ptr<ui::Layer> layer_;
144
145 // Bounds of the window in the desktop's coordinate system.
146 gfx::Rect bounds_;
147
148 // The Window's parent.
149 // TODO(beng): Implement NULL-ness for toplevels.
150 Window* parent_;
151
152 // Child windows. Topmost is last.
153 Windows children_;
154
155 int id_;
156
157 scoped_ptr<WindowManager> window_manager_;
158
159 void* user_data_;
160
161 DISALLOW_COPY_AND_ASSIGN(Window);
162 };
163
164 } // namespace aura
165
166 #endif // AURA_WINDOW_H_
OLDNEW
« no previous file with comments | « aura/test_suite.cc ('k') | aura/window.cc » ('j') | ui/aura/aura.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698