| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 parts.push_back(ui::MultiAnimation::Part(200, ui::Tween::LINEAR)); | 372 parts.push_back(ui::MultiAnimation::Part(200, ui::Tween::LINEAR)); |
| 382 ui::MultiAnimation* multi_animation = new ui::MultiAnimation(parts); | 373 ui::MultiAnimation* multi_animation = new ui::MultiAnimation(parts); |
| 383 multi_animation->set_continuous(false); | 374 multi_animation->set_continuous(false); |
| 384 return multi_animation; | 375 return multi_animation; |
| 385 } | 376 } |
| 386 | 377 |
| 387 internal::RootWindow* Window::GetRoot() { | 378 internal::RootWindow* Window::GetRoot() { |
| 388 return parent_ ? parent_->GetRoot() : NULL; | 379 return parent_ ? parent_->GetRoot() : NULL; |
| 389 } | 380 } |
| 390 | 381 |
| 382 void Window::SetBoundsInternal(const gfx::Rect& new_bounds) { |
| 383 const gfx::Rect old_bounds = bounds(); |
| 384 bool was_move = old_bounds.size() == new_bounds.size(); |
| 385 layer_->SetBounds(new_bounds); |
| 386 |
| 387 if (layout_manager_.get()) |
| 388 layout_manager_->OnWindowResized(); |
| 389 if (delegate_) |
| 390 delegate_->OnBoundsChanged(old_bounds, new_bounds); |
| 391 if (IsVisible()) { |
| 392 if (was_move) |
| 393 layer()->ScheduleDraw(); |
| 394 else |
| 395 layer()->SchedulePaint(gfx::Rect()); |
| 396 } |
| 397 } |
| 398 |
| 391 void Window::SetVisible(bool visible) { | 399 void Window::SetVisible(bool visible) { |
| 392 bool was_visible = IsVisible(); | 400 bool was_visible = IsVisible(); |
| 393 layer_->SetVisible(visible); | 401 layer_->SetVisible(visible); |
| 394 bool is_visible = IsVisible(); | 402 bool is_visible = IsVisible(); |
| 395 if (was_visible != is_visible) { | 403 if (was_visible != is_visible) { |
| 396 SchedulePaint(); | 404 SchedulePaint(); |
| 397 if (delegate_) | 405 if (delegate_) |
| 398 delegate_->OnWindowVisibilityChanged(is_visible); | 406 delegate_->OnWindowVisibilityChanged(is_visible); |
| 399 } | 407 } |
| 400 } | 408 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 } | 457 } |
| 450 | 458 |
| 451 return delegate_ ? this : NULL; | 459 return delegate_ ? this : NULL; |
| 452 } | 460 } |
| 453 | 461 |
| 454 void Window::OnPaintLayer(gfx::Canvas* canvas) { | 462 void Window::OnPaintLayer(gfx::Canvas* canvas) { |
| 455 delegate_->OnPaint(canvas); | 463 delegate_->OnPaint(canvas); |
| 456 } | 464 } |
| 457 | 465 |
| 458 } // namespace aura | 466 } // namespace aura |
| OLD | NEW |