Chromium Code Reviews| 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 SetBoundsInternal(new_bounds); | |
| 147 } | |
| 145 | 148 |
| 146 if (layout_manager_.get()) | 149 void Window::SetMinimumSize(const gfx::Size& minimum_size) { |
| 147 layout_manager_->OnWindowResized(); | 150 minimum_size_ = minimum_size; |
| 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 } | |
| 156 } | 151 } |
| 157 | 152 |
| 158 const gfx::Rect& Window::bounds() const { | 153 const gfx::Rect& Window::bounds() const { |
| 159 return layer_->bounds(); | 154 return layer_->bounds(); |
| 160 } | 155 } |
| 161 | 156 |
| 162 void Window::SchedulePaintInRect(const gfx::Rect& rect) { | 157 void Window::SchedulePaintInRect(const gfx::Rect& rect) { |
| 163 layer_->SchedulePaint(rect); | 158 layer_->SchedulePaint(rect); |
| 164 } | 159 } |
| 165 | 160 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 369 parts.push_back(ui::MultiAnimation::Part(200, ui::Tween::LINEAR)); | 364 parts.push_back(ui::MultiAnimation::Part(200, ui::Tween::LINEAR)); |
| 370 ui::MultiAnimation* multi_animation = new ui::MultiAnimation(parts); | 365 ui::MultiAnimation* multi_animation = new ui::MultiAnimation(parts); |
| 371 multi_animation->set_continuous(false); | 366 multi_animation->set_continuous(false); |
| 372 return multi_animation; | 367 return multi_animation; |
| 373 } | 368 } |
| 374 | 369 |
| 375 internal::RootWindow* Window::GetRoot() { | 370 internal::RootWindow* Window::GetRoot() { |
| 376 return parent_ ? parent_->GetRoot() : NULL; | 371 return parent_ ? parent_->GetRoot() : NULL; |
| 377 } | 372 } |
| 378 | 373 |
| 374 void Window::SetBoundsInternal(const gfx::Rect& new_bounds) { | |
| 375 // TODO: funnel this through the Desktop. | |
|
Ben Goodger (Google)
2011/10/14 15:40:05
You can remove this comment now.
oshima
2011/10/15 02:10:50
Done.
| |
| 376 const gfx::Rect old_bounds = bounds(); | |
| 377 bool was_move = old_bounds.size() == new_bounds.size(); | |
| 378 layer_->SetBounds(new_bounds); | |
| 379 | |
| 380 if (layout_manager_.get()) | |
| 381 layout_manager_->OnWindowResized(); | |
| 382 if (delegate_) | |
| 383 delegate_->OnBoundsChanged(old_bounds, new_bounds); | |
| 384 if (IsVisible()) { | |
| 385 if (was_move) | |
| 386 layer()->ScheduleDraw(); | |
| 387 else | |
| 388 layer()->SchedulePaint(gfx::Rect()); | |
| 389 } | |
| 390 } | |
| 391 | |
| 379 void Window::SetVisible(bool visible) { | 392 void Window::SetVisible(bool visible) { |
| 380 bool was_visible = IsVisible(); | 393 bool was_visible = IsVisible(); |
| 381 layer_->SetVisible(visible); | 394 layer_->SetVisible(visible); |
| 382 bool is_visible = IsVisible(); | 395 bool is_visible = IsVisible(); |
| 383 if (was_visible != is_visible) { | 396 if (was_visible != is_visible) { |
| 384 SchedulePaint(); | 397 SchedulePaint(); |
| 385 if (delegate_) | 398 if (delegate_) |
| 386 delegate_->OnWindowVisibilityChanged(is_visible); | 399 delegate_->OnWindowVisibilityChanged(is_visible); |
| 387 } | 400 } |
| 388 } | 401 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 437 } | 450 } |
| 438 | 451 |
| 439 return delegate_ ? this : NULL; | 452 return delegate_ ? this : NULL; |
| 440 } | 453 } |
| 441 | 454 |
| 442 void Window::OnPaintLayer(gfx::Canvas* canvas) { | 455 void Window::OnPaintLayer(gfx::Canvas* canvas) { |
| 443 delegate_->OnPaint(canvas); | 456 delegate_->OnPaint(canvas); |
| 444 } | 457 } |
| 445 | 458 |
| 446 } // namespace aura | 459 } // namespace aura |
| OLD | NEW |