| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/wm/panels/panel_layout_manager.h" | 5 #include "ash/wm/panels/panel_layout_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 PanelInfo panel_info; | 364 PanelInfo panel_info; |
| 365 panel_info.window = child; | 365 panel_info.window = child; |
| 366 panel_info.callout_widget = new PanelCalloutWidget(panel_container_); | 366 panel_info.callout_widget = new PanelCalloutWidget(panel_container_); |
| 367 if (child != dragged_panel_) { | 367 if (child != dragged_panel_) { |
| 368 // Set the panel to 0 opacity until it has been positioned to prevent it | 368 // Set the panel to 0 opacity until it has been positioned to prevent it |
| 369 // from flashing briefly at position (0, 0). | 369 // from flashing briefly at position (0, 0). |
| 370 child->layer()->SetOpacity(0); | 370 child->layer()->SetOpacity(0); |
| 371 panel_info.slide_in = true; | 371 panel_info.slide_in = true; |
| 372 } | 372 } |
| 373 panel_windows_.push_back(panel_info); | 373 panel_windows_.push_back(panel_info); |
| 374 child->AddObserver(this); | |
| 375 wm::GetWindowState(child)->AddObserver(this); | 374 wm::GetWindowState(child)->AddObserver(this); |
| 376 Relayout(); | 375 Relayout(); |
| 377 } | 376 } |
| 378 | 377 |
| 379 void PanelLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) { | 378 void PanelLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) { |
| 380 } | 379 } |
| 381 | 380 |
| 382 void PanelLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { | 381 void PanelLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { |
| 383 if (child->type() == ui::wm::WINDOW_TYPE_POPUP) | 382 if (child->type() == ui::wm::WINDOW_TYPE_POPUP) |
| 384 return; | 383 return; |
| 385 PanelList::iterator found = | 384 PanelList::iterator found = |
| 386 std::find(panel_windows_.begin(), panel_windows_.end(), child); | 385 std::find(panel_windows_.begin(), panel_windows_.end(), child); |
| 387 if (found != panel_windows_.end()) { | 386 if (found != panel_windows_.end()) { |
| 388 delete found->callout_widget; | 387 delete found->callout_widget; |
| 389 panel_windows_.erase(found); | 388 panel_windows_.erase(found); |
| 390 } | 389 } |
| 391 child->RemoveObserver(this); | |
| 392 wm::GetWindowState(child)->RemoveObserver(this); | 390 wm::GetWindowState(child)->RemoveObserver(this); |
| 393 | 391 |
| 394 if (dragged_panel_ == child) | 392 if (dragged_panel_ == child) |
| 395 dragged_panel_ = NULL; | 393 dragged_panel_ = NULL; |
| 396 | 394 |
| 397 if (last_active_panel_ == child) | 395 if (last_active_panel_ == child) |
| 398 last_active_panel_ = NULL; | 396 last_active_panel_ = NULL; |
| 399 | 397 |
| 400 Relayout(); | 398 Relayout(); |
| 401 } | 399 } |
| 402 | 400 |
| 403 void PanelLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child, | 401 void PanelLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child, |
| 404 bool visible) { | 402 bool visible) { |
| 403 if (visible) |
| 404 wm::GetWindowState(child)->Restore(); |
| 405 Relayout(); | 405 Relayout(); |
| 406 } | 406 } |
| 407 | 407 |
| 408 void PanelLayoutManager::SetChildBounds(aura::Window* child, | 408 void PanelLayoutManager::SetChildBounds(aura::Window* child, |
| 409 const gfx::Rect& requested_bounds) { | 409 const gfx::Rect& requested_bounds) { |
| 410 gfx::Rect bounds(requested_bounds); | 410 gfx::Rect bounds(requested_bounds); |
| 411 const gfx::Rect& max_bounds = panel_container_->GetRootWindow()->bounds(); | 411 const gfx::Rect& max_bounds = panel_container_->GetRootWindow()->bounds(); |
| 412 const int max_width = max_bounds.width() * kMaxWidthFactor; | 412 const int max_width = max_bounds.width() * kMaxWidthFactor; |
| 413 const int max_height = max_bounds.height() * kMaxHeightFactor; | 413 const int max_height = max_bounds.height() * kMaxHeightFactor; |
| 414 if (bounds.width() > max_width) | 414 if (bounds.width() > max_width) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 } | 474 } |
| 475 return; | 475 return; |
| 476 } | 476 } |
| 477 | 477 |
| 478 if (window_state->IsMinimized()) | 478 if (window_state->IsMinimized()) |
| 479 MinimizePanel(window_state->window()); | 479 MinimizePanel(window_state->window()); |
| 480 else | 480 else |
| 481 RestorePanel(window_state->window()); | 481 RestorePanel(window_state->window()); |
| 482 } | 482 } |
| 483 | 483 |
| 484 void PanelLayoutManager::OnWindowVisibilityChanged( | |
| 485 aura::Window* window, bool visible) { | |
| 486 if (visible) | |
| 487 wm::GetWindowState(window)->Restore(); | |
| 488 } | |
| 489 | |
| 490 //////////////////////////////////////////////////////////////////////////////// | 484 //////////////////////////////////////////////////////////////////////////////// |
| 491 // PanelLayoutManager, aura::client::ActivationChangeObserver implementation: | 485 // PanelLayoutManager, aura::client::ActivationChangeObserver implementation: |
| 492 | 486 |
| 493 void PanelLayoutManager::OnWindowActivated(aura::Window* gained_active, | 487 void PanelLayoutManager::OnWindowActivated(aura::Window* gained_active, |
| 494 aura::Window* lost_active) { | 488 aura::Window* lost_active) { |
| 495 // Ignore if the panel that is not managed by this was activated. | 489 // Ignore if the panel that is not managed by this was activated. |
| 496 if (gained_active && gained_active->type() == ui::wm::WINDOW_TYPE_PANEL && | 490 if (gained_active && gained_active->type() == ui::wm::WINDOW_TYPE_PANEL && |
| 497 gained_active->parent() == panel_container_) { | 491 gained_active->parent() == panel_container_) { |
| 498 UpdateStacking(gained_active); | 492 UpdateStacking(gained_active); |
| 499 UpdateCallouts(); | 493 UpdateCallouts(); |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 | 880 |
| 887 void PanelLayoutManager::OnKeyboardBoundsChanging( | 881 void PanelLayoutManager::OnKeyboardBoundsChanging( |
| 888 const gfx::Rect& keyboard_bounds) { | 882 const gfx::Rect& keyboard_bounds) { |
| 889 // This bounds change will have caused a change to the Shelf which does not | 883 // This bounds change will have caused a change to the Shelf which does not |
| 890 // propogate automatically to this class, so manually recalculate bounds. | 884 // propogate automatically to this class, so manually recalculate bounds. |
| 891 OnWindowResized(); | 885 OnWindowResized(); |
| 892 } | 886 } |
| 893 | 887 |
| 894 } // namespace internal | 888 } // namespace internal |
| 895 } // namespace ash | 889 } // namespace ash |
| OLD | NEW |