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 #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 "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "base/string_util.h" | |
11 #include "ui/aura/client/stacking_client.h" | 12 #include "ui/aura/client/stacking_client.h" |
12 #include "ui/aura/desktop.h" | 13 #include "ui/aura/desktop.h" |
13 #include "ui/aura/event.h" | 14 #include "ui/aura/event.h" |
14 #include "ui/aura/event_filter.h" | 15 #include "ui/aura/event_filter.h" |
15 #include "ui/aura/layout_manager.h" | 16 #include "ui/aura/layout_manager.h" |
16 #include "ui/aura/window_delegate.h" | 17 #include "ui/aura/window_delegate.h" |
17 #include "ui/aura/window_observer.h" | 18 #include "ui/aura/window_observer.h" |
18 #include "ui/aura/window_types.h" | 19 #include "ui/aura/window_types.h" |
19 #include "ui/base/animation/multi_animation.h" | 20 #include "ui/base/animation/multi_animation.h" |
20 #include "ui/gfx/canvas_skia.h" | 21 #include "ui/gfx/canvas_skia.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 if (parent_) | 68 if (parent_) |
68 parent_->RemoveChild(this); | 69 parent_->RemoveChild(this); |
69 | 70 |
70 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowDestroyed(this)); | 71 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowDestroyed(this)); |
71 } | 72 } |
72 | 73 |
73 void Window::Init(ui::Layer::LayerType layer_type) { | 74 void Window::Init(ui::Layer::LayerType layer_type) { |
74 layer_.reset(new ui::Layer(Desktop::GetInstance()->compositor(), layer_type)); | 75 layer_.reset(new ui::Layer(Desktop::GetInstance()->compositor(), layer_type)); |
75 layer_->SetVisible(false); | 76 layer_->SetVisible(false); |
76 layer_->set_delegate(this); | 77 layer_->set_delegate(this); |
78 #if ndef NDEBUG | |
tfarina
2011/11/11 18:46:28
nit: #ifndef
Ben Goodger (Google)
2011/11/14 22:59:09
mostly we do !defined()
| |
79 std::string layer_name(name()); | |
tfarina
2011/11/11 18:46:28
nit: name() -> name_
| |
80 if (layer_name.empty()) | |
81 layer_name.append("Unnamed Window"); | |
82 | |
83 if (id() != -1) { | |
tfarina
2011/11/11 18:46:28
nit: id() -> id_
| |
84 char id_buf[10]; | |
85 base::snprintf(id_buf, sizeof(id_buf), " %d", id()); | |
tfarina
2011/11/11 18:46:28
nit: id() -> id_
| |
86 layer_name.append(id_buf); | |
Ben Goodger (Google)
2011/11/14 22:59:09
I agree with tfarina's nits here, prevalent style
| |
87 } | |
88 layer_->set_name(layer_name); | |
89 #endif | |
77 } | 90 } |
78 | 91 |
79 void Window::SetType(WindowType type) { | 92 void Window::SetType(WindowType type) { |
80 // Cannot change type after the window is initialized. | 93 // Cannot change type after the window is initialized. |
81 DCHECK(!layer()); | 94 DCHECK(!layer()); |
82 type_ = type; | 95 type_ = type; |
83 } | 96 } |
84 | 97 |
85 void Window::Show() { | 98 void Window::Show() { |
86 SetVisible(true); | 99 SetVisible(true); |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
489 | 502 |
490 return delegate_ ? this : NULL; | 503 return delegate_ ? this : NULL; |
491 } | 504 } |
492 | 505 |
493 void Window::OnPaintLayer(gfx::Canvas* canvas) { | 506 void Window::OnPaintLayer(gfx::Canvas* canvas) { |
494 if (delegate_) | 507 if (delegate_) |
495 delegate_->OnPaint(canvas); | 508 delegate_->OnPaint(canvas); |
496 } | 509 } |
497 | 510 |
498 } // namespace aura | 511 } // namespace aura |
OLD | NEW |