| 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 "ui/aura/desktop.h" | 11 #include "ui/aura/desktop.h" |
| 12 #include "ui/aura/desktop_delegate.h" | 12 #include "ui/aura/desktop_delegate.h" |
| 13 #include "ui/aura/event.h" | 13 #include "ui/aura/event.h" |
| 14 #include "ui/aura/event_filter.h" | 14 #include "ui/aura/event_filter.h" |
| 15 #include "ui/aura/layout_manager.h" | 15 #include "ui/aura/layout_manager.h" |
| 16 #include "ui/aura/window_delegate.h" | 16 #include "ui/aura/window_delegate.h" |
| 17 #include "ui/aura/window_observer.h" | 17 #include "ui/aura/window_observer.h" |
| 18 #include "ui/aura/window_types.h" | 18 #include "ui/aura/window_types.h" |
| 19 #include "ui/base/animation/multi_animation.h" | 19 #include "ui/base/animation/multi_animation.h" |
| 20 #include "ui/base/view_prop.h" | 20 #include "ui/base/view_prop.h" |
| 21 #include "ui/gfx/canvas_skia.h" | 21 #include "ui/gfx/canvas_skia.h" |
| 22 #include "ui/gfx/compositor/compositor.h" | 22 #include "ui/gfx/compositor/compositor.h" |
| 23 #include "ui/gfx/compositor/layer.h" | 23 #include "ui/gfx/compositor/layer.h" |
| 24 #include "ui/gfx/screen.h" | 24 #include "ui/gfx/screen.h" |
| 25 | 25 |
| 26 namespace aura { | 26 namespace aura { |
| 27 | 27 |
| 28 Window::Window(WindowDelegate* delegate) | 28 Window::Window(WindowDelegate* delegate) |
| 29 : type_(kWindowType_None), | 29 : type_(WINDOW_TYPE_UNKNOWN), |
| 30 delegate_(delegate), | 30 delegate_(delegate), |
| 31 show_state_(ui::SHOW_STATE_NORMAL), | 31 show_state_(ui::SHOW_STATE_NORMAL), |
| 32 parent_(NULL), | 32 parent_(NULL), |
| 33 transient_parent_(NULL), | 33 transient_parent_(NULL), |
| 34 id_(-1), | 34 id_(-1), |
| 35 user_data_(NULL), | 35 user_data_(NULL), |
| 36 stops_event_propagation_(false) { | 36 stops_event_propagation_(false) { |
| 37 } | 37 } |
| 38 | 38 |
| 39 Window::~Window() { | 39 Window::~Window() { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 68 if (delegate_) | 68 if (delegate_) |
| 69 delegate_->OnWindowDestroyed(); | 69 delegate_->OnWindowDestroyed(); |
| 70 if (parent_) | 70 if (parent_) |
| 71 parent_->RemoveChild(this); | 71 parent_->RemoveChild(this); |
| 72 | 72 |
| 73 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowDestroyed(this)); | 73 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowDestroyed(this)); |
| 74 | 74 |
| 75 STLDeleteValues(&prop_map_); | 75 STLDeleteValues(&prop_map_); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void Window::Init(ui::Layer::LayerType layer_type) { | 78 void Window::Init(ui::Layer::LayerType layer_type, |
| 79 LayerInitialState layer_state) { |
| 79 layer_.reset(new ui::Layer(Desktop::GetInstance()->compositor(), layer_type)); | 80 layer_.reset(new ui::Layer(Desktop::GetInstance()->compositor(), layer_type)); |
| 80 // Windows (and therefore their layers) should initially be hidden, except for | 81 // Windows (and therefore their layers) should initially be hidden, except for |
| 81 // controls. | 82 // controls. |
| 82 layer_->SetVisible(type_ == kWindowType_Control); | 83 layer_->SetVisible(layer_state == LAYER_INITIALLY_VISIBLE); |
| 83 layer_->set_delegate(this); | 84 layer_->set_delegate(this); |
| 84 } | 85 } |
| 85 | 86 |
| 86 void Window::SetType(int type) { | 87 void Window::SetType(WindowType type) { |
| 87 // Cannot change type after the window is initialized. | 88 // Cannot change type after the window is initialized. |
| 88 DCHECK(!layer()); | 89 DCHECK(!layer()); |
| 89 type_ = type; | 90 type_ = type; |
| 90 } | 91 } |
| 91 | 92 |
| 92 void Window::Show() { | 93 void Window::Show() { |
| 93 SetVisible(true); | 94 SetVisible(true); |
| 94 } | 95 } |
| 95 | 96 |
| 96 void Window::Hide() { | 97 void Window::Hide() { |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 } | 539 } |
| 539 | 540 |
| 540 void Window::OnPaintLayer(gfx::Canvas* canvas) { | 541 void Window::OnPaintLayer(gfx::Canvas* canvas) { |
| 541 delegate_->OnPaint(canvas); | 542 delegate_->OnPaint(canvas); |
| 542 } | 543 } |
| 543 | 544 |
| 544 void Window::OnLayerAnimationEnded(const ui::Animation* animation) { | 545 void Window::OnLayerAnimationEnded(const ui::Animation* animation) { |
| 545 } | 546 } |
| 546 | 547 |
| 547 } // namespace aura | 548 } // namespace aura |
| OLD | NEW |