Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: ash/wm/panels/panel_layout_manager.cc

Issue 1929023002: Refactors WindowResizers to use ash/wm/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include <utility> 9 #include <utility>
10 10
11 #include "ash/shelf/shelf.h"
12 #include "ash/shelf/shelf_layout_manager.h"
13 #include "ash/shelf/shelf_types.h"
14 #include "ash/shelf/shelf_util.h"
15 #include "ash/shelf/shelf_widget.h"
16 #include "ash/shell.h" 11 #include "ash/shell.h"
17 #include "ash/shell_window_ids.h" 12 #include "ash/wm/common/shelf/wm_shelf.h"
18 #include "ash/wm/aura/wm_window_aura.h" 13 #include "ash/wm/common/shelf/wm_shelf_util.h"
19 #include "ash/wm/common/window_animation_types.h" 14 #include "ash/wm/common/window_animation_types.h"
20 #include "ash/wm/common/window_parenting_utils.h" 15 #include "ash/wm/common/window_parenting_utils.h"
21 #include "ash/wm/common/window_state.h" 16 #include "ash/wm/common/window_state.h"
22 #include "ash/wm/common/wm_globals.h" 17 #include "ash/wm/common/wm_globals.h"
23 #include "ash/wm/common/wm_root_window_controller.h" 18 #include "ash/wm/common/wm_root_window_controller.h"
19 #include "ash/wm/common/wm_shell_window_ids.h"
24 #include "ash/wm/common/wm_window.h" 20 #include "ash/wm/common/wm_window.h"
25 #include "ash/wm/common/wm_window_property.h" 21 #include "ash/wm/common/wm_window_property.h"
26 #include "ash/wm/overview/window_selector_controller.h"
27 #include "ash/wm/window_animations.h"
28 #include "base/auto_reset.h" 22 #include "base/auto_reset.h"
29 #include "third_party/skia/include/core/SkColor.h" 23 #include "third_party/skia/include/core/SkColor.h"
30 #include "third_party/skia/include/core/SkPaint.h" 24 #include "third_party/skia/include/core/SkPaint.h"
31 #include "third_party/skia/include/core/SkPath.h" 25 #include "third_party/skia/include/core/SkPath.h"
32 #include "ui/aura/window.h"
33 #include "ui/compositor/scoped_layer_animation_settings.h" 26 #include "ui/compositor/scoped_layer_animation_settings.h"
34 #include "ui/gfx/canvas.h" 27 #include "ui/gfx/canvas.h"
35 #include "ui/gfx/geometry/rect.h" 28 #include "ui/gfx/geometry/rect.h"
36 #include "ui/gfx/geometry/vector2d.h" 29 #include "ui/gfx/geometry/vector2d.h"
37 #include "ui/views/background.h" 30 #include "ui/views/background.h"
38 #include "ui/views/widget/widget.h" 31 #include "ui/views/widget/widget.h"
39 32
40 namespace ash { 33 namespace ash {
41 namespace { 34 namespace {
42 35
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } // namespace 176 } // namespace
184 177
185 class PanelCalloutWidget : public views::Widget { 178 class PanelCalloutWidget : public views::Widget {
186 public: 179 public:
187 explicit PanelCalloutWidget(wm::WmWindow* container) : background_(nullptr) { 180 explicit PanelCalloutWidget(wm::WmWindow* container) : background_(nullptr) {
188 InitWidget(container); 181 InitWidget(container);
189 } 182 }
190 183
191 void SetAlignment(wm::ShelfAlignment alignment) { 184 void SetAlignment(wm::ShelfAlignment alignment) {
192 gfx::Rect callout_bounds = GetWindowBoundsInScreen(); 185 gfx::Rect callout_bounds = GetWindowBoundsInScreen();
193 if (IsHorizontalAlignment(alignment)) { 186 if (wm::IsHorizontalAlignment(alignment)) {
194 callout_bounds.set_width(kArrowWidth); 187 callout_bounds.set_width(kArrowWidth);
195 callout_bounds.set_height(kArrowHeight); 188 callout_bounds.set_height(kArrowHeight);
196 } else { 189 } else {
197 callout_bounds.set_width(kArrowHeight); 190 callout_bounds.set_width(kArrowHeight);
198 callout_bounds.set_height(kArrowWidth); 191 callout_bounds.set_height(kArrowWidth);
199 } 192 }
200 SetBounds(callout_bounds); 193 SetBounds(callout_bounds);
201 if (background_->alignment() != alignment) { 194 if (background_->alignment() != alignment) {
202 background_->set_alignment(alignment); 195 background_->set_alignment(alignment);
203 SchedulePaintInRect(gfx::Rect(callout_bounds.size())); 196 SchedulePaintInRect(gfx::Rect(callout_bounds.size()));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 233
241 //////////////////////////////////////////////////////////////////////////////// 234 ////////////////////////////////////////////////////////////////////////////////
242 // PanelLayoutManager public implementation: 235 // PanelLayoutManager public implementation:
243 PanelLayoutManager::PanelLayoutManager(wm::WmWindow* panel_container) 236 PanelLayoutManager::PanelLayoutManager(wm::WmWindow* panel_container)
244 : panel_container_(panel_container), 237 : panel_container_(panel_container),
245 root_window_controller_(panel_container->GetRootWindowController()), 238 root_window_controller_(panel_container->GetRootWindowController()),
246 in_add_window_(false), 239 in_add_window_(false),
247 in_layout_(false), 240 in_layout_(false),
248 show_callout_widgets_(true), 241 show_callout_widgets_(true),
249 dragged_panel_(NULL), 242 dragged_panel_(NULL),
250 shelf_(NULL), 243 shelf_(nullptr),
251 shelf_layout_manager_(NULL),
252 last_active_panel_(NULL), 244 last_active_panel_(NULL),
253 weak_factory_(this) { 245 weak_factory_(this) {
254 DCHECK(panel_container); 246 DCHECK(panel_container);
255 wm::WmGlobals* globals = panel_container->GetGlobals(); 247 wm::WmGlobals* globals = panel_container->GetGlobals();
256 globals->AddActivationObserver(this); 248 globals->AddActivationObserver(this);
257 globals->AddDisplayObserver(this); 249 globals->AddDisplayObserver(this);
258 globals->AddOverviewModeObserver(this); 250 globals->AddOverviewModeObserver(this);
259 root_window_controller_->AddObserver(this); 251 root_window_controller_->AddObserver(this);
260 } 252 }
261 253
262 PanelLayoutManager::~PanelLayoutManager() { 254 PanelLayoutManager::~PanelLayoutManager() {
263 Shutdown(); 255 Shutdown();
264 } 256 }
265 257
266 // static 258 // static
267 PanelLayoutManager* PanelLayoutManager::Get(wm::WmWindow* window) { 259 PanelLayoutManager* PanelLayoutManager::Get(wm::WmWindow* window) {
268 if (!window) 260 if (!window)
269 return nullptr; 261 return nullptr;
270 262
271 return static_cast<PanelLayoutManager*>( 263 return static_cast<PanelLayoutManager*>(
272 window->GetRootWindow() 264 window->GetRootWindow()
273 ->GetChildByShellWindowId(kShellWindowId_PanelContainer) 265 ->GetChildByShellWindowId(kShellWindowId_PanelContainer)
274 ->GetLayoutManager()); 266 ->GetLayoutManager());
275 } 267 }
276 268
277 void PanelLayoutManager::Shutdown() { 269 void PanelLayoutManager::Shutdown() {
278 if (shelf_layout_manager_) 270 if (shelf_) {
279 shelf_layout_manager_->RemoveObserver(this); 271 shelf_->RemoveObserver(this);
280 shelf_layout_manager_ = NULL; 272 shelf_ = nullptr;
273 }
281 for (PanelList::iterator iter = panel_windows_.begin(); 274 for (PanelList::iterator iter = panel_windows_.begin();
282 iter != panel_windows_.end(); ++iter) { 275 iter != panel_windows_.end(); ++iter) {
283 delete iter->callout_widget; 276 delete iter->callout_widget;
284 } 277 }
285 panel_windows_.clear(); 278 panel_windows_.clear();
286 if (shelf_)
287 shelf_->RemoveIconObserver(this);
288 shelf_ = NULL;
289 wm::WmGlobals* globals = panel_container_->GetGlobals(); 279 wm::WmGlobals* globals = panel_container_->GetGlobals();
290 globals->RemoveActivationObserver(this); 280 globals->RemoveActivationObserver(this);
291 globals->RemoveDisplayObserver(this); 281 globals->RemoveDisplayObserver(this);
292 globals->RemoveOverviewModeObserver(this); 282 globals->RemoveOverviewModeObserver(this);
293 root_window_controller_->RemoveObserver(this); 283 root_window_controller_->RemoveObserver(this);
294 } 284 }
295 285
296 void PanelLayoutManager::StartDragging(wm::WmWindow* panel) { 286 void PanelLayoutManager::StartDragging(wm::WmWindow* panel) {
297 DCHECK(!dragged_panel_); 287 DCHECK(!dragged_panel_);
298 dragged_panel_ = panel; 288 dragged_panel_ = panel;
299 Relayout(); 289 Relayout();
300 } 290 }
301 291
302 void PanelLayoutManager::FinishDragging() { 292 void PanelLayoutManager::FinishDragging() {
303 dragged_panel_ = NULL; 293 dragged_panel_ = NULL;
304 Relayout(); 294 Relayout();
305 } 295 }
306 296
307 void PanelLayoutManager::SetShelf(Shelf* shelf) { 297 void PanelLayoutManager::SetShelf(wm::WmShelf* shelf) {
308 DCHECK(!shelf_); 298 DCHECK(!shelf_);
309 DCHECK(!shelf_layout_manager_);
310 shelf_ = shelf; 299 shelf_ = shelf;
311 shelf_->AddIconObserver(this); 300 shelf_->AddObserver(this);
312 if (shelf_->shelf_layout_manager()) { 301 WillChangeVisibilityState(shelf_->GetVisibilityState());
313 shelf_layout_manager_ = shelf_->shelf_layout_manager();
314 WillChangeVisibilityState(shelf_layout_manager_->visibility_state());
315 shelf_layout_manager_->AddObserver(this);
316 }
317 } 302 }
318 303
319 void PanelLayoutManager::ToggleMinimize(wm::WmWindow* panel) { 304 void PanelLayoutManager::ToggleMinimize(wm::WmWindow* panel) {
320 DCHECK(panel->GetParent() == panel_container_); 305 DCHECK(panel->GetParent() == panel_container_);
321 wm::WindowState* window_state = panel->GetWindowState(); 306 wm::WindowState* window_state = panel->GetWindowState();
322 if (window_state->IsMinimized()) 307 if (window_state->IsMinimized())
323 window_state->Restore(); 308 window_state->Restore();
324 else 309 else
325 window_state->Minimize(); 310 window_state->Minimize();
326 } 311 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 const gfx::Size min_size = child->GetMinimumSize(); 430 const gfx::Size min_size = child->GetMinimumSize();
446 bounds.set_width(std::max(min_size.width(), bounds.width())); 431 bounds.set_width(std::max(min_size.width(), bounds.width()));
447 bounds.set_height(std::max(min_size.height(), bounds.height())); 432 bounds.set_height(std::max(min_size.height(), bounds.height()));
448 } 433 }
449 434
450 child->SetBoundsDirect(bounds); 435 child->SetBoundsDirect(bounds);
451 Relayout(); 436 Relayout();
452 } 437 }
453 438
454 //////////////////////////////////////////////////////////////////////////////// 439 ////////////////////////////////////////////////////////////////////////////////
455 // PanelLayoutManager, ShelfIconObserver implementation:
456
457 void PanelLayoutManager::OnShelfIconPositionsChanged() {
458 // TODO: As this is called for every animation step now. Relayout needs to be
459 // updated to use current icon position instead of use the ideal bounds so
460 // that the panels slide with their icons instead of jumping.
461 Relayout();
462 }
463
464 ////////////////////////////////////////////////////////////////////////////////
465 // PanelLayoutManager, ash::ShellObserver implementation: 440 // PanelLayoutManager, ash::ShellObserver implementation:
466 441
467 void PanelLayoutManager::OnOverviewModeEnded() { 442 void PanelLayoutManager::OnOverviewModeEnded() {
468 Relayout(); 443 Relayout();
469 } 444 }
470 445
471 void PanelLayoutManager::OnShelfAlignmentChanged() { 446 void PanelLayoutManager::OnShelfAlignmentChanged() {
472 Relayout(); 447 Relayout();
473 } 448 }
474 449
(...skipping 27 matching lines...) Expand all
502 return; 477 return;
503 } 478 }
504 479
505 if (window_state->IsMinimized()) 480 if (window_state->IsMinimized())
506 MinimizePanel(window_state->window()); 481 MinimizePanel(window_state->window());
507 else 482 else
508 RestorePanel(window_state->window()); 483 RestorePanel(window_state->window());
509 } 484 }
510 485
511 //////////////////////////////////////////////////////////////////////////////// 486 ////////////////////////////////////////////////////////////////////////////////
512 // PanelLayoutManager, aura::client::ActivationChangeObserver implementation: 487 // PanelLayoutManager, wm::WmActivationObserver implementation:
513 488
514 void PanelLayoutManager::OnWindowActivated(wm::WmWindow* gained_active, 489 void PanelLayoutManager::OnWindowActivated(wm::WmWindow* gained_active,
515 wm::WmWindow* lost_active) { 490 wm::WmWindow* lost_active) {
516 // Ignore if the panel that is not managed by this was activated. 491 // Ignore if the panel that is not managed by this was activated.
517 if (gained_active && gained_active->GetType() == ui::wm::WINDOW_TYPE_PANEL && 492 if (gained_active && gained_active->GetType() == ui::wm::WINDOW_TYPE_PANEL &&
518 gained_active->GetParent() == panel_container_) { 493 gained_active->GetParent() == panel_container_) {
519 UpdateStacking(gained_active); 494 UpdateStacking(gained_active);
520 UpdateCallouts(); 495 UpdateCallouts();
521 } 496 }
522 } 497 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 // Advance the iterator before minimizing it: http://crbug.com/393047. 533 // Advance the iterator before minimizing it: http://crbug.com/393047.
559 ++iter; 534 ++iter;
560 if (window != dragged_panel_ && window->IsVisible()) { 535 if (window != dragged_panel_ && window->IsVisible()) {
561 minimized_windows->Add(window); 536 minimized_windows->Add(window);
562 window->GetWindowState()->Minimize(); 537 window->GetWindowState()->Minimize();
563 } 538 }
564 } 539 }
565 restore_windows_on_shelf_visible_ = std::move(minimized_windows); 540 restore_windows_on_shelf_visible_ = std::move(minimized_windows);
566 } 541 }
567 542
543 void PanelLayoutManager::OnShelfIconPositionsChanged() {
544 // TODO: As this is called for every animation step now. Relayout needs to be
545 // updated to use current icon position instead of use the ideal bounds so
546 // that the panels slide with their icons instead of jumping.
547 Relayout();
548 }
549
568 //////////////////////////////////////////////////////////////////////////////// 550 ////////////////////////////////////////////////////////////////////////////////
569 // PanelLayoutManager private implementation: 551 // PanelLayoutManager private implementation:
570 552
571 void PanelLayoutManager::MinimizePanel(wm::WmWindow* panel) { 553 void PanelLayoutManager::MinimizePanel(wm::WmWindow* panel) {
572 panel->SetVisibilityAnimationType( 554 panel->SetVisibilityAnimationType(
573 wm::WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); 555 wm::WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE);
574 ui::Layer* layer = panel->GetLayer(); 556 ui::Layer* layer = panel->GetLayer();
575 ui::ScopedLayerAnimationSettings panel_slide_settings(layer->GetAnimator()); 557 ui::ScopedLayerAnimationSettings panel_slide_settings(layer->GetAnimator());
576 panel_slide_settings.SetPreemptionStrategy( 558 panel_slide_settings.SetPreemptionStrategy(
577 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 559 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
578 panel_slide_settings.SetTransitionDuration( 560 panel_slide_settings.SetTransitionDuration(
579 base::TimeDelta::FromMilliseconds(kPanelSlideDurationMilliseconds)); 561 base::TimeDelta::FromMilliseconds(kPanelSlideDurationMilliseconds));
580 gfx::Rect bounds(panel->GetBounds()); 562 gfx::Rect bounds(panel->GetBounds());
581 bounds.Offset(GetSlideInAnimationOffset(shelf_->alignment())); 563 bounds.Offset(GetSlideInAnimationOffset(shelf_->GetAlignment()));
582 panel->SetBoundsDirect(bounds); 564 panel->SetBoundsDirect(bounds);
583 panel->Hide(); 565 panel->Hide();
584 layer->SetOpacity(0); 566 layer->SetOpacity(0);
585 if (panel->IsActive()) 567 if (panel->IsActive())
586 panel->Deactivate(); 568 panel->Deactivate();
587 Relayout(); 569 Relayout();
588 } 570 }
589 571
590 void PanelLayoutManager::RestorePanel(wm::WmWindow* panel) { 572 void PanelLayoutManager::RestorePanel(wm::WmWindow* panel) {
591 PanelList::iterator found = 573 PanelList::iterator found =
592 std::find(panel_windows_.begin(), panel_windows_.end(), panel); 574 std::find(panel_windows_.begin(), panel_windows_.end(), panel);
593 DCHECK(found != panel_windows_.end()); 575 DCHECK(found != panel_windows_.end());
594 found->slide_in = true; 576 found->slide_in = true;
595 Relayout(); 577 Relayout();
596 } 578 }
597 579
598 void PanelLayoutManager::Relayout() { 580 void PanelLayoutManager::Relayout() {
599 if (!shelf_ || !shelf_->shelf_widget()) 581 if (!shelf_)
600 return; 582 return;
601 583
602 // Suppress layouts during overview mode because changing window bounds 584 // Suppress layouts during overview mode because changing window bounds
603 // interfered with overview mode animations. However, layouts need to be done 585 // interfered with overview mode animations. However, layouts need to be done
604 // when the WindowSelectorController is restoring minimized windows so that 586 // when the WindowSelectorController is restoring minimized windows so that
605 // they actually become visible. 587 // they actually become visible.
606 WindowSelectorController* window_selector_controller = 588 wm::WmGlobals* globals = panel_container_->GetGlobals();
607 Shell::GetInstance()->window_selector_controller(); 589 if (in_layout_ || (globals->IsOverviewModeSelecting() &&
608 if (in_layout_ || !window_selector_controller || 590 !globals->IsOverviewModeRestoringMinimizedWindows())) {
609 (window_selector_controller->IsSelecting() &&
610 !window_selector_controller->IsRestoringMinimizedWindows()))
611 return; 591 return;
592 }
612 593
613 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); 594 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true);
614 595
615 const wm::ShelfAlignment alignment = shelf_->alignment(); 596 const wm::ShelfAlignment alignment = shelf_->GetAlignment();
616 const bool horizontal = shelf_->IsHorizontalAlignment(); 597 const bool horizontal = wm::IsHorizontalAlignment(shelf_->GetAlignment());
617 gfx::Rect shelf_bounds = panel_container_->ConvertRectFromScreen( 598 gfx::Rect shelf_bounds = panel_container_->ConvertRectFromScreen(
618 shelf_->shelf_widget()->GetWindowBoundsInScreen()); 599 shelf_->GetWindow()->GetBoundsInScreen());
619 int panel_start_bounds = kPanelIdealSpacing; 600 int panel_start_bounds = kPanelIdealSpacing;
620 int panel_end_bounds = 601 int panel_end_bounds =
621 horizontal ? panel_container_->GetBounds().width() - kPanelIdealSpacing 602 horizontal ? panel_container_->GetBounds().width() - kPanelIdealSpacing
622 : panel_container_->GetBounds().height() - kPanelIdealSpacing; 603 : panel_container_->GetBounds().height() - kPanelIdealSpacing;
623 wm::WmWindow* active_panel = nullptr; 604 wm::WmWindow* active_panel = nullptr;
624 std::vector<VisiblePanelPositionInfo> visible_panels; 605 std::vector<VisiblePanelPositionInfo> visible_panels;
625 for (PanelList::iterator iter = panel_windows_.begin(); 606 for (PanelList::iterator iter = panel_windows_.begin();
626 iter != panel_windows_.end(); ++iter) { 607 iter != panel_windows_.end(); ++iter) {
627 wm::WmWindow* panel = iter->window; 608 wm::WmWindow* panel = iter->window;
628 iter->callout_widget->SetAlignment(alignment); 609 iter->callout_widget->SetAlignment(alignment);
629 610
630 // Consider the dragged panel as part of the layout as long as it is 611 // Consider the dragged panel as part of the layout as long as it is
631 // touching the shelf. 612 // touching the shelf.
632 if ((!panel->IsVisible() && !iter->slide_in) || 613 if ((!panel->IsVisible() && !iter->slide_in) ||
633 (panel == dragged_panel_ && 614 (panel == dragged_panel_ &&
634 !BoundsAdjacent(panel->GetBounds(), shelf_bounds))) { 615 !BoundsAdjacent(panel->GetBounds(), shelf_bounds))) {
635 continue; 616 continue;
636 } 617 }
637 618
638 // If the shelf is currently hidden (full-screen mode), minimize panel until 619 // If the shelf is currently hidden (full-screen mode), minimize panel until
639 // full-screen mode is exited. When a panel is dragged from another display 620 // full-screen mode is exited. When a panel is dragged from another display
640 // the shelf state does not update before the panel is added so we exclude 621 // the shelf state does not update before the panel is added so we exclude
641 // the dragged panel. 622 // the dragged panel.
642 if (panel != dragged_panel_ && restore_windows_on_shelf_visible_) { 623 if (panel != dragged_panel_ && restore_windows_on_shelf_visible_) {
643 panel->GetWindowState()->Minimize(); 624 panel->GetWindowState()->Minimize();
644 restore_windows_on_shelf_visible_->Add(panel); 625 restore_windows_on_shelf_visible_->Add(panel);
645 continue; 626 continue;
646 } 627 }
647 628
648 gfx::Rect icon_bounds = shelf_->GetScreenBoundsOfItemIconForWindow( 629 gfx::Rect icon_bounds = shelf_->GetScreenBoundsOfItemIconForWindow(panel);
649 wm::WmWindowAura::GetAuraWindow(panel));
650 630
651 // If both the icon width and height are 0 then there is no icon in the 631 // If both the icon width and height are 0 then there is no icon in the
652 // shelf. If the shelf is hidden, one of the height or width will be 632 // shelf. If the shelf is hidden, one of the height or width will be
653 // 0 but the position in the shelf and major dimension is still reported 633 // 0 but the position in the shelf and major dimension is still reported
654 // correctly and the panel can be aligned above where the hidden icon is. 634 // correctly and the panel can be aligned above where the hidden icon is.
655 if (icon_bounds.width() == 0 && icon_bounds.height() == 0) 635 if (icon_bounds.width() == 0 && icon_bounds.height() == 0)
656 continue; 636 continue;
657 637
658 if (panel->IsFocused() || 638 if (panel->IsFocused() ||
659 panel->Contains(panel->GetGlobals()->GetFocusedWindow())) { 639 panel->Contains(panel->GetGlobals()->GetFocusedWindow())) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 // We want to to stack the panels like a deck of cards: 745 // We want to to stack the panels like a deck of cards:
766 // ,--,--,--,-------.--.--. 746 // ,--,--,--,-------.--.--.
767 // | | | | | | | 747 // | | | | | | |
768 // | | | | | | | 748 // | | | | | | |
769 // 749 //
770 // We use the middle of each panel to figure out how to stack the panels. This 750 // We use the middle of each panel to figure out how to stack the panels. This
771 // allows us to update the stacking when a panel is being dragged around by 751 // allows us to update the stacking when a panel is being dragged around by
772 // the titlebar--even though it doesn't update the shelf icon positions, we 752 // the titlebar--even though it doesn't update the shelf icon positions, we
773 // still want the visual effect. 753 // still want the visual effect.
774 std::map<int, wm::WmWindow*> window_ordering; 754 std::map<int, wm::WmWindow*> window_ordering;
775 const bool horizontal = shelf_->IsHorizontalAlignment(); 755 const bool horizontal = wm::IsHorizontalAlignment(shelf_->GetAlignment());
776 for (PanelList::const_iterator it = panel_windows_.begin(); 756 for (PanelList::const_iterator it = panel_windows_.begin();
777 it != panel_windows_.end(); ++it) { 757 it != panel_windows_.end(); ++it) {
778 gfx::Rect bounds = it->window->GetBounds(); 758 gfx::Rect bounds = it->window->GetBounds();
779 window_ordering.insert(std::make_pair(horizontal ? 759 window_ordering.insert(std::make_pair(horizontal ?
780 bounds.x() + bounds.width() / 2 : 760 bounds.x() + bounds.width() / 2 :
781 bounds.y() + bounds.height() / 2, 761 bounds.y() + bounds.height() / 2,
782 it->window)); 762 it->window));
783 } 763 }
784 764
785 wm::WmWindow* previous_panel = nullptr; 765 wm::WmWindow* previous_panel = nullptr;
(...skipping 14 matching lines...) Expand all
800 previous_panel = it->second; 780 previous_panel = it->second;
801 } 781 }
802 782
803 panel_container_->StackChildAtTop(active_panel); 783 panel_container_->StackChildAtTop(active_panel);
804 if (dragged_panel_ && dragged_panel_->GetParent() == panel_container_) 784 if (dragged_panel_ && dragged_panel_->GetParent() == panel_container_)
805 panel_container_->StackChildAtTop(dragged_panel_); 785 panel_container_->StackChildAtTop(dragged_panel_);
806 last_active_panel_ = active_panel; 786 last_active_panel_ = active_panel;
807 } 787 }
808 788
809 void PanelLayoutManager::UpdateCallouts() { 789 void PanelLayoutManager::UpdateCallouts() {
810 const bool horizontal = shelf_->IsHorizontalAlignment(); 790 const bool horizontal = wm::IsHorizontalAlignment(shelf_->GetAlignment());
811 for (PanelList::iterator iter = panel_windows_.begin(); 791 for (PanelList::iterator iter = panel_windows_.begin();
812 iter != panel_windows_.end(); ++iter) { 792 iter != panel_windows_.end(); ++iter) {
813 wm::WmWindow* panel = iter->window; 793 wm::WmWindow* panel = iter->window;
814 views::Widget* callout_widget = iter->callout_widget; 794 views::Widget* callout_widget = iter->callout_widget;
815 wm::WmWindow* callout_widget_window = wm::WmWindow::Get(callout_widget); 795 wm::WmWindow* callout_widget_window = wm::WmWindow::Get(callout_widget);
816 796
817 gfx::Rect current_bounds = panel->GetBoundsInScreen(); 797 gfx::Rect current_bounds = panel->GetBoundsInScreen();
818 gfx::Rect bounds = 798 gfx::Rect bounds =
819 panel->GetParent()->ConvertRectToScreen(panel->GetTargetBounds()); 799 panel->GetParent()->ConvertRectToScreen(panel->GetTargetBounds());
820 gfx::Rect icon_bounds = shelf_->GetScreenBoundsOfItemIconForWindow( 800 gfx::Rect icon_bounds = shelf_->GetScreenBoundsOfItemIconForWindow(panel);
821 wm::WmWindowAura::GetAuraWindow(panel));
822 if (icon_bounds.IsEmpty() || !panel->GetLayer()->GetTargetVisibility() || 801 if (icon_bounds.IsEmpty() || !panel->GetLayer()->GetTargetVisibility() ||
823 panel == dragged_panel_ || !show_callout_widgets_) { 802 panel == dragged_panel_ || !show_callout_widgets_) {
824 callout_widget->Hide(); 803 callout_widget->Hide();
825 callout_widget_window->GetLayer()->SetOpacity(0); 804 callout_widget_window->GetLayer()->SetOpacity(0);
826 continue; 805 continue;
827 } 806 }
828 807
829 gfx::Rect callout_bounds = callout_widget->GetWindowBoundsInScreen(); 808 gfx::Rect callout_bounds = callout_widget->GetWindowBoundsInScreen();
830 gfx::Vector2d slide_vector = bounds.origin() - current_bounds.origin(); 809 gfx::Vector2d slide_vector = bounds.origin() - current_bounds.origin();
831 int slide_distance = horizontal ? slide_vector.x() : slide_vector.y(); 810 int slide_distance = horizontal ? slide_vector.x() : slide_vector.y();
832 int distance_until_over_panel = 0; 811 int distance_until_over_panel = 0;
833 if (horizontal) { 812 if (horizontal) {
834 callout_bounds.set_x( 813 callout_bounds.set_x(
835 icon_bounds.x() + (icon_bounds.width() - callout_bounds.width()) / 2); 814 icon_bounds.x() + (icon_bounds.width() - callout_bounds.width()) / 2);
836 distance_until_over_panel = std::max( 815 distance_until_over_panel = std::max(
837 current_bounds.x() - callout_bounds.x(), 816 current_bounds.x() - callout_bounds.x(),
838 callout_bounds.right() - current_bounds.right()); 817 callout_bounds.right() - current_bounds.right());
839 } else { 818 } else {
840 callout_bounds.set_y( 819 callout_bounds.set_y(
841 icon_bounds.y() + (icon_bounds.height() - 820 icon_bounds.y() + (icon_bounds.height() -
842 callout_bounds.height()) / 2); 821 callout_bounds.height()) / 2);
843 distance_until_over_panel = std::max( 822 distance_until_over_panel = std::max(
844 current_bounds.y() - callout_bounds.y(), 823 current_bounds.y() - callout_bounds.y(),
845 callout_bounds.bottom() - current_bounds.bottom()); 824 callout_bounds.bottom() - current_bounds.bottom());
846 } 825 }
847 if (shelf_->alignment() == wm::SHELF_ALIGNMENT_LEFT) 826 if (shelf_->GetAlignment() == wm::SHELF_ALIGNMENT_LEFT)
848 callout_bounds.set_x(bounds.x() - callout_bounds.width()); 827 callout_bounds.set_x(bounds.x() - callout_bounds.width());
849 else if (shelf_->alignment() == wm::SHELF_ALIGNMENT_RIGHT) 828 else if (shelf_->GetAlignment() == wm::SHELF_ALIGNMENT_RIGHT)
850 callout_bounds.set_x(bounds.right()); 829 callout_bounds.set_x(bounds.right());
851 else 830 else
852 callout_bounds.set_y(bounds.bottom()); 831 callout_bounds.set_y(bounds.bottom());
853 callout_bounds = callout_widget_window->GetParent()->ConvertRectFromScreen( 832 callout_bounds = callout_widget_window->GetParent()->ConvertRectFromScreen(
854 callout_bounds); 833 callout_bounds);
855 834
856 callout_widget_window->SetBoundsDirect(callout_bounds); 835 callout_widget_window->SetBoundsDirect(callout_bounds);
857 panel_container_->StackChildAbove(callout_widget_window, panel); 836 panel_container_->StackChildAbove(callout_widget_window, panel);
858 837
859 ui::Layer* layer = callout_widget_window->GetLayer(); 838 ui::Layer* layer = callout_widget_window->GetLayer();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 // Keyboard hidden, restore original bounds if they exist. 897 // Keyboard hidden, restore original bounds if they exist.
919 panel->SetBoundsDirect(panel_state->GetRestoreBoundsInScreen()); 898 panel->SetBoundsDirect(panel_state->GetRestoreBoundsInScreen());
920 } 899 }
921 } 900 }
922 // This bounds change will have caused a change to the Shelf which does not 901 // This bounds change will have caused a change to the Shelf which does not
923 // propogate automatically to this class, so manually recalculate bounds. 902 // propogate automatically to this class, so manually recalculate bounds.
924 OnWindowResized(); 903 OnWindowResized();
925 } 904 }
926 905
927 } // namespace ash 906 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698