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

Side by Side Diff: ui/aura/window.cc

Issue 8082017: Change Window visibility to a simple boolean for now. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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
« no previous file with comments | « ui/aura/window.h ('k') | ui/aura/window_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ui/aura/window.h" 5 #include "ui/aura/window.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/aura/desktop.h" 10 #include "ui/aura/desktop.h"
11 #include "ui/aura/event.h" 11 #include "ui/aura/event.h"
12 #include "ui/aura/event_filter.h" 12 #include "ui/aura/event_filter.h"
13 #include "ui/aura/focus_manager.h" 13 #include "ui/aura/focus_manager.h"
14 #include "ui/aura/layout_manager.h" 14 #include "ui/aura/layout_manager.h"
15 #include "ui/aura/window_delegate.h" 15 #include "ui/aura/window_delegate.h"
16 #include "ui/base/animation/multi_animation.h" 16 #include "ui/base/animation/multi_animation.h"
17 #include "ui/gfx/canvas_skia.h" 17 #include "ui/gfx/canvas_skia.h"
18 #include "ui/gfx/compositor/compositor.h" 18 #include "ui/gfx/compositor/compositor.h"
19 #include "ui/gfx/compositor/layer.h" 19 #include "ui/gfx/compositor/layer.h"
20 20
21 namespace aura { 21 namespace aura {
22 22
23 using internal::RootWindow; 23 using internal::RootWindow;
24 24
25 Window::Window(WindowDelegate* delegate) 25 Window::Window(WindowDelegate* delegate)
26 : delegate_(delegate), 26 : delegate_(delegate),
27 visibility_(VISIBILITY_HIDDEN), 27 visible_(false),
28 parent_(NULL), 28 parent_(NULL),
29 id_(-1), 29 id_(-1),
30 user_data_(NULL) { 30 user_data_(NULL) {
31 } 31 }
32 32
33 Window::~Window() { 33 Window::~Window() {
34 // Let the delegate know we're in the processing of destroying. 34 // Let the delegate know we're in the processing of destroying.
35 if (delegate_) 35 if (delegate_)
36 delegate_->OnWindowDestroying(); 36 delegate_->OnWindowDestroying();
37 37
(...skipping 18 matching lines...) Expand all
56 } 56 }
57 57
58 void Window::Init() { 58 void Window::Init() {
59 ui::Layer::LayerType type = ui::Layer::LAYER_HAS_NO_TEXTURE; 59 ui::Layer::LayerType type = ui::Layer::LAYER_HAS_NO_TEXTURE;
60 if (delegate_) 60 if (delegate_)
61 type = ui::Layer::LAYER_HAS_TEXTURE; 61 type = ui::Layer::LAYER_HAS_TEXTURE;
62 layer_.reset(new ui::Layer(Desktop::GetInstance()->compositor(), type)); 62 layer_.reset(new ui::Layer(Desktop::GetInstance()->compositor(), type));
63 layer_->set_delegate(this); 63 layer_->set_delegate(this);
64 } 64 }
65 65
66 void Window::SetVisibility(Visibility visibility) { 66 void Window::Show() {
67 if (visibility_ == visibility) 67 SetVisible(true);
68 return; 68 }
69 69
70 visibility_ = visibility; 70 void Window::Hide() {
71 layer_->SetVisible(visibility_ != VISIBILITY_HIDDEN); 71 SetVisible(false);
72 SchedulePaint(); 72 ReleaseCapture();
73 if (visibility_ != VISIBILITY_SHOWN) 73 if (Desktop::GetInstance()->active_window() == this ||
74 ReleaseCapture(); 74 !Desktop::GetInstance()->active_window()) {
75 if ((visibility_ == VISIBILITY_HIDDEN &&
76 Desktop::GetInstance()->active_window() == this) ||
77 (visibility_ == VISIBILITY_HIDDEN &&
78 !Desktop::GetInstance()->active_window())) {
79 Desktop::GetInstance()->ActivateTopmostWindow(); 75 Desktop::GetInstance()->ActivateTopmostWindow();
80 } 76 }
81 } 77 }
82 78
83 void Window::SetLayoutManager(LayoutManager* layout_manager) { 79 void Window::SetLayoutManager(LayoutManager* layout_manager) {
84 layout_manager_.reset(layout_manager); 80 layout_manager_.reset(layout_manager);
85 } 81 }
86 82
87 void Window::SetBounds(const gfx::Rect& new_bounds) { 83 void Window::SetBounds(const gfx::Rect& new_bounds) {
88 // TODO: funnel this through the Desktop. 84 // TODO: funnel this through the Desktop.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 bool Window::HitTest(const gfx::Point& point) { 194 bool Window::HitTest(const gfx::Point& point) {
199 gfx::Rect local_bounds(gfx::Point(), bounds().size()); 195 gfx::Rect local_bounds(gfx::Point(), bounds().size());
200 // TODO(beng): hittest masks. 196 // TODO(beng): hittest masks.
201 return local_bounds.Contains(point); 197 return local_bounds.Contains(point);
202 } 198 }
203 199
204 Window* Window::GetEventHandlerForPoint(const gfx::Point& point) { 200 Window* Window::GetEventHandlerForPoint(const gfx::Point& point) {
205 Windows::const_reverse_iterator i = children_.rbegin(); 201 Windows::const_reverse_iterator i = children_.rbegin();
206 for (; i != children_.rend(); ++i) { 202 for (; i != children_.rend(); ++i) {
207 Window* child = *i; 203 Window* child = *i;
208 if (child->visibility() == Window::VISIBILITY_HIDDEN) 204 if (!child->visible())
209 continue; 205 continue;
210 gfx::Point point_in_child_coords(point); 206 gfx::Point point_in_child_coords(point);
211 Window::ConvertPointToWindow(this, child, &point_in_child_coords); 207 Window::ConvertPointToWindow(this, child, &point_in_child_coords);
212 if (child->HitTest(point_in_child_coords)) { 208 if (child->HitTest(point_in_child_coords)) {
213 Window* handler = child->GetEventHandlerForPoint(point_in_child_coords); 209 Window* handler = child->GetEventHandlerForPoint(point_in_child_coords);
214 if (handler && handler->delegate()) 210 if (handler && handler->delegate())
215 return handler; 211 return handler;
216 } 212 }
217 } 213 }
218 return delegate_ ? this : NULL; 214 return delegate_ ? this : NULL;
219 } 215 }
220 216
221 internal::FocusManager* Window::GetFocusManager() { 217 internal::FocusManager* Window::GetFocusManager() {
222 return parent_ ? parent_->GetFocusManager() : NULL; 218 return parent_ ? parent_->GetFocusManager() : NULL;
223 } 219 }
224 220
225 void Window::SetCapture() { 221 void Window::SetCapture() {
226 if (visibility_ != VISIBILITY_SHOWN) 222 if (!visible_)
227 return; 223 return;
228 224
229 RootWindow* root = GetRoot(); 225 RootWindow* root = GetRoot();
230 if (!root) 226 if (!root)
231 return; 227 return;
232 228
233 root->SetCapture(this); 229 root->SetCapture(this);
234 } 230 }
235 231
236 void Window::ReleaseCapture() { 232 void Window::ReleaseCapture() {
(...skipping 15 matching lines...) Expand all
252 parts.push_back(ui::MultiAnimation::Part(200, ui::Tween::LINEAR)); 248 parts.push_back(ui::MultiAnimation::Part(200, ui::Tween::LINEAR));
253 ui::MultiAnimation* multi_animation = new ui::MultiAnimation(parts); 249 ui::MultiAnimation* multi_animation = new ui::MultiAnimation(parts);
254 multi_animation->set_continuous(false); 250 multi_animation->set_continuous(false);
255 return multi_animation; 251 return multi_animation;
256 } 252 }
257 253
258 internal::RootWindow* Window::GetRoot() { 254 internal::RootWindow* Window::GetRoot() {
259 return parent_ ? parent_->GetRoot() : NULL; 255 return parent_ ? parent_->GetRoot() : NULL;
260 } 256 }
261 257
258 void Window::SetVisible(bool visible) {
259 if (visible_ == visible)
260 return;
261
262 visible_ = visible;
263 layer_->SetVisible(visible_);
264 SchedulePaint();
265 }
266
262 void Window::SchedulePaint() { 267 void Window::SchedulePaint() {
263 SchedulePaintInRect(gfx::Rect(0, 0, bounds().width(), bounds().height())); 268 SchedulePaintInRect(gfx::Rect(0, 0, bounds().width(), bounds().height()));
264 } 269 }
265 270
266 void Window::OnPaintLayer(gfx::Canvas* canvas) { 271 void Window::OnPaintLayer(gfx::Canvas* canvas) {
267 delegate_->OnPaint(canvas); 272 delegate_->OnPaint(canvas);
268 } 273 }
269 274
270 } // namespace aura 275 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window.h ('k') | ui/aura/window_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698