| 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" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 Desktop::GetInstance()->ActivateTopmostWindow(); | 89 Desktop::GetInstance()->ActivateTopmostWindow(); |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool Window::IsVisible() const { | 93 bool Window::IsVisible() const { |
| 94 return layer_->IsDrawn(); | 94 return layer_->IsDrawn(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void Window::Maximize() { | 97 void Window::Maximize() { |
| 98 if (UpdateShowStateAndRestoreBounds(ui::SHOW_STATE_MAXIMIZED)) | 98 if (UpdateShowStateAndRestoreBounds(ui::SHOW_STATE_MAXIMIZED)) |
| 99 SetBounds(gfx::Screen::GetMonitorWorkAreaNearestWindow(this)); | 99 SetBoundsInternal(gfx::Screen::GetMonitorWorkAreaNearestWindow(this)); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void Window::Fullscreen() { | 102 void Window::Fullscreen() { |
| 103 if (UpdateShowStateAndRestoreBounds(ui::SHOW_STATE_FULLSCREEN)) | 103 if (UpdateShowStateAndRestoreBounds(ui::SHOW_STATE_FULLSCREEN)) |
| 104 SetBounds(gfx::Screen::GetMonitorAreaNearestWindow(this)); | 104 SetBoundsInternal(gfx::Screen::GetMonitorAreaNearestWindow(this)); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void Window::Restore() { | 107 void Window::Restore() { |
| 108 if (show_state_ != ui::SHOW_STATE_NORMAL) { | 108 if (show_state_ != ui::SHOW_STATE_NORMAL) { |
| 109 show_state_ = ui::SHOW_STATE_NORMAL; | 109 show_state_ = ui::SHOW_STATE_NORMAL; |
| 110 SetBounds(restore_bounds_); | 110 SetBoundsInternal(restore_bounds_); |
| 111 restore_bounds_.SetRect(0, 0, 0, 0); | 111 restore_bounds_.SetRect(0, 0, 0, 0); |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 | 114 |
| 115 void Window::Activate() { | 115 void Window::Activate() { |
| 116 // If we support minimization need to ensure this restores the window first. | 116 // If we support minimization need to ensure this restores the window first. |
| 117 aura::Desktop::GetInstance()->SetActiveWindow(this, this); | 117 aura::Desktop::GetInstance()->SetActiveWindow(this, this); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void Window::Deactivate() { | 120 void Window::Deactivate() { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 131 | 131 |
| 132 const ToplevelWindowContainer* Window::AsToplevelWindowContainer() const { | 132 const ToplevelWindowContainer* Window::AsToplevelWindowContainer() const { |
| 133 return NULL; | 133 return NULL; |
| 134 } | 134 } |
| 135 | 135 |
| 136 void Window::SetLayoutManager(LayoutManager* layout_manager) { | 136 void Window::SetLayoutManager(LayoutManager* layout_manager) { |
| 137 layout_manager_.reset(layout_manager); | 137 layout_manager_.reset(layout_manager); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void Window::SetBounds(const gfx::Rect& new_bounds) { | 140 void Window::SetBounds(const gfx::Rect& new_bounds) { |
| 141 // TODO: funnel this through the Desktop. | 141 if (show_state_ == ui::SHOW_STATE_MAXIMIZED || |
| 142 gfx::Rect old_bounds = bounds(); | 142 show_state_ == ui::SHOW_STATE_FULLSCREEN) { |
| 143 bool was_move = old_bounds.size() == new_bounds.size(); | 143 restore_bounds_ = new_bounds; |
| 144 layer_->SetBounds(new_bounds); | 144 return; |
| 145 | |
| 146 if (layout_manager_.get()) | |
| 147 layout_manager_->OnWindowResized(); | |
| 148 if (delegate_) | |
| 149 delegate_->OnBoundsChanged(old_bounds, new_bounds); | |
| 150 if (IsVisible()) { | |
| 151 if (was_move) | |
| 152 layer()->ScheduleDraw(); | |
| 153 else | |
| 154 layer()->SchedulePaint(gfx::Rect()); | |
| 155 } | 145 } |
| 146 SetBoundsInternal(new_bounds); |
| 156 } | 147 } |
| 157 | 148 |
| 158 const gfx::Rect& Window::bounds() const { | 149 const gfx::Rect& Window::bounds() const { |
| 159 return layer_->bounds(); | 150 return layer_->bounds(); |
| 160 } | 151 } |
| 161 | 152 |
| 162 void Window::SchedulePaintInRect(const gfx::Rect& rect) { | 153 void Window::SchedulePaintInRect(const gfx::Rect& rect) { |
| 163 layer_->SchedulePaint(rect); | 154 layer_->SchedulePaint(rect); |
| 164 } | 155 } |
| 165 | 156 |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 parts.push_back(ui::MultiAnimation::Part(200, ui::Tween::LINEAR)); | 385 parts.push_back(ui::MultiAnimation::Part(200, ui::Tween::LINEAR)); |
| 395 ui::MultiAnimation* multi_animation = new ui::MultiAnimation(parts); | 386 ui::MultiAnimation* multi_animation = new ui::MultiAnimation(parts); |
| 396 multi_animation->set_continuous(false); | 387 multi_animation->set_continuous(false); |
| 397 return multi_animation; | 388 return multi_animation; |
| 398 } | 389 } |
| 399 | 390 |
| 400 internal::RootWindow* Window::GetRoot() { | 391 internal::RootWindow* Window::GetRoot() { |
| 401 return parent_ ? parent_->GetRoot() : NULL; | 392 return parent_ ? parent_->GetRoot() : NULL; |
| 402 } | 393 } |
| 403 | 394 |
| 395 void Window::SetBoundsInternal(const gfx::Rect& new_bounds) { |
| 396 const gfx::Rect old_bounds = bounds(); |
| 397 bool was_move = old_bounds.size() == new_bounds.size(); |
| 398 layer_->SetBounds(new_bounds); |
| 399 |
| 400 if (layout_manager_.get()) |
| 401 layout_manager_->OnWindowResized(); |
| 402 if (delegate_) |
| 403 delegate_->OnBoundsChanged(old_bounds, new_bounds); |
| 404 if (IsVisible()) { |
| 405 if (was_move) |
| 406 layer()->ScheduleDraw(); |
| 407 else |
| 408 layer()->SchedulePaint(gfx::Rect()); |
| 409 } |
| 410 } |
| 411 |
| 404 void Window::SetVisible(bool visible) { | 412 void Window::SetVisible(bool visible) { |
| 405 if (visible == layer_->visible()) | 413 if (visible == layer_->visible()) |
| 406 return; // No change. | 414 return; // No change. |
| 407 | 415 |
| 408 bool was_visible = IsVisible(); | 416 bool was_visible = IsVisible(); |
| 409 layer_->SetVisible(visible); | 417 layer_->SetVisible(visible); |
| 410 bool is_visible = IsVisible(); | 418 bool is_visible = IsVisible(); |
| 411 if (was_visible != is_visible) { | 419 if (was_visible != is_visible) { |
| 412 SchedulePaint(); | 420 SchedulePaint(); |
| 413 if (delegate_) | 421 if (delegate_) |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 } | 475 } |
| 468 | 476 |
| 469 return delegate_ ? this : NULL; | 477 return delegate_ ? this : NULL; |
| 470 } | 478 } |
| 471 | 479 |
| 472 void Window::OnPaintLayer(gfx::Canvas* canvas) { | 480 void Window::OnPaintLayer(gfx::Canvas* canvas) { |
| 473 delegate_->OnPaint(canvas); | 481 delegate_->OnPaint(canvas); |
| 474 } | 482 } |
| 475 | 483 |
| 476 } // namespace aura | 484 } // namespace aura |
| OLD | NEW |