| 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 "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/layout_manager.h" |
| 12 #include "ui/aura/window_delegate.h" | 13 #include "ui/aura/window_delegate.h" |
| 13 #include "ui/aura/window_manager.h" | 14 #include "ui/aura/window_manager.h" |
| 14 #include "ui/gfx/canvas_skia.h" | 15 #include "ui/gfx/canvas_skia.h" |
| 15 #include "ui/gfx/compositor/compositor.h" | 16 #include "ui/gfx/compositor/compositor.h" |
| 16 #include "ui/gfx/compositor/layer.h" | 17 #include "ui/gfx/compositor/layer.h" |
| 17 | 18 |
| 18 namespace aura { | 19 namespace aura { |
| 19 | 20 |
| 20 Window::Window(WindowDelegate* delegate) | 21 Window::Window(WindowDelegate* delegate) |
| 21 : delegate_(delegate), | 22 : delegate_(delegate), |
| (...skipping 30 matching lines...) Expand all Loading... |
| 52 void Window::SetVisibility(Visibility visibility) { | 53 void Window::SetVisibility(Visibility visibility) { |
| 53 if (visibility_ == visibility) | 54 if (visibility_ == visibility) |
| 54 return; | 55 return; |
| 55 | 56 |
| 56 visibility_ = visibility; | 57 visibility_ = visibility; |
| 57 layer_->set_visible(visibility_ != VISIBILITY_HIDDEN); | 58 layer_->set_visible(visibility_ != VISIBILITY_HIDDEN); |
| 58 if (layer_->visible()) | 59 if (layer_->visible()) |
| 59 SchedulePaint(); | 60 SchedulePaint(); |
| 60 } | 61 } |
| 61 | 62 |
| 63 void Window::SetLayoutManager(LayoutManager* layout_manager) { |
| 64 layout_manager_.reset(layout_manager); |
| 65 } |
| 66 |
| 62 void Window::SetBounds(const gfx::Rect& bounds, int anim_ms) { | 67 void Window::SetBounds(const gfx::Rect& bounds, int anim_ms) { |
| 63 // TODO: support anim_ms | 68 // TODO: support anim_ms |
| 64 // TODO: funnel this through the Desktop. | 69 // TODO: funnel this through the Desktop. |
| 65 bool was_move = bounds_.size() == bounds.size(); | 70 bool was_move = bounds_.size() == bounds.size(); |
| 71 gfx::Rect old_bounds = bounds_; |
| 66 bounds_ = bounds; | 72 bounds_ = bounds; |
| 67 layer_->SetBounds(bounds); | 73 layer_->SetBounds(bounds); |
| 74 if (layout_manager_.get()) |
| 75 layout_manager_->OnWindowResized(); |
| 76 if (delegate_) |
| 77 delegate_->OnBoundsChanged(old_bounds, bounds_); |
| 68 if (was_move) | 78 if (was_move) |
| 69 SchedulePaintInRect(gfx::Rect()); | 79 SchedulePaintInRect(gfx::Rect()); |
| 70 else | 80 else |
| 71 SchedulePaint(); | 81 SchedulePaint(); |
| 72 } | 82 } |
| 73 | 83 |
| 74 void Window::SchedulePaintInRect(const gfx::Rect& rect) { | 84 void Window::SchedulePaintInRect(const gfx::Rect& rect) { |
| 75 layer_->SchedulePaint(rect); | 85 layer_->SchedulePaint(rect); |
| 76 } | 86 } |
| 77 | 87 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 void Window::SchedulePaint() { | 176 void Window::SchedulePaint() { |
| 167 SchedulePaintInRect(gfx::Rect(0, 0, bounds_.width(), bounds_.height())); | 177 SchedulePaintInRect(gfx::Rect(0, 0, bounds_.width(), bounds_.height())); |
| 168 } | 178 } |
| 169 | 179 |
| 170 void Window::OnPaintLayer(gfx::Canvas* canvas) { | 180 void Window::OnPaintLayer(gfx::Canvas* canvas) { |
| 171 if (delegate_) | 181 if (delegate_) |
| 172 delegate_->OnPaint(canvas); | 182 delegate_->OnPaint(canvas); |
| 173 } | 183 } |
| 174 | 184 |
| 175 } // namespace aura | 185 } // namespace aura |
| OLD | NEW |