| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/common/wm/window_cycle_list.h" | 5 #include "ash/common/wm/window_cycle_list.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "ash/common/wm/mru_window_tracker.h" | 10 #include "ash/common/wm/mru_window_tracker.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "ui/views/widget/widget.h" | 28 #include "ui/views/widget/widget.h" |
| 29 #include "ui/views/widget/widget_delegate.h" | 29 #include "ui/views/widget/widget_delegate.h" |
| 30 #include "ui/wm/core/visibility_controller.h" | 30 #include "ui/wm/core/visibility_controller.h" |
| 31 | 31 |
| 32 namespace ash { | 32 namespace ash { |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 bool g_disable_initial_delay = false; | 36 bool g_disable_initial_delay = false; |
| 37 | 37 |
| 38 // Used for the highlight view and the shield (black background). |
| 39 constexpr float kBackgroundCornerRadius = 4.f; |
| 40 |
| 38 // Returns the window immediately below |window| in the current container. | 41 // Returns the window immediately below |window| in the current container. |
| 39 WmWindow* GetWindowBelow(WmWindow* window) { | 42 WmWindow* GetWindowBelow(WmWindow* window) { |
| 40 WmWindow* parent = window->GetParent(); | 43 WmWindow* parent = window->GetParent(); |
| 41 if (!parent) | 44 if (!parent) |
| 42 return nullptr; | 45 return nullptr; |
| 43 const WmWindow::Windows children = parent->GetChildren(); | 46 const WmWindow::Windows children = parent->GetChildren(); |
| 44 auto iter = std::find(children.begin(), children.end(), window); | 47 auto iter = std::find(children.begin(), children.end(), window); |
| 45 CHECK(*iter == window); | 48 CHECK(*iter == window); |
| 46 return (iter != children.begin()) ? *(iter - 1) : nullptr; | 49 return (iter != children.begin()) ? *(iter - 1) : nullptr; |
| 47 } | 50 } |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 mirror_container_->SetPaintToLayer(true); | 276 mirror_container_->SetPaintToLayer(true); |
| 274 mirror_container_->layer()->SetFillsBoundsOpaquely(false); | 277 mirror_container_->layer()->SetFillsBoundsOpaquely(false); |
| 275 | 278 |
| 276 for (WmWindow* window : windows) { | 279 for (WmWindow* window : windows) { |
| 277 // |mirror_container_| owns |view|. | 280 // |mirror_container_| owns |view|. |
| 278 views::View* view = new WindowPreviewView(window); | 281 views::View* view = new WindowPreviewView(window); |
| 279 window_view_map_[window] = view; | 282 window_view_map_[window] = view; |
| 280 mirror_container_->AddChildView(view); | 283 mirror_container_->AddChildView(view); |
| 281 } | 284 } |
| 282 | 285 |
| 283 const float kHighlightCornerRadius = 4; | |
| 284 // The background needs to be painted to fill the layer, not the View, | 286 // The background needs to be painted to fill the layer, not the View, |
| 285 // because the layer animates bounds changes but the View's bounds change | 287 // because the layer animates bounds changes but the View's bounds change |
| 286 // immediately. | 288 // immediately. |
| 287 highlight_view_->set_background(new LayerFillBackgroundPainter( | 289 highlight_view_->set_background(new LayerFillBackgroundPainter( |
| 288 base::WrapUnique(views::Painter::CreateRoundRectWith1PxBorderPainter( | 290 base::WrapUnique(views::Painter::CreateRoundRectWith1PxBorderPainter( |
| 289 SkColorSetA(SK_ColorWHITE, 0x4D), SkColorSetA(SK_ColorWHITE, 0x33), | 291 SkColorSetA(SK_ColorWHITE, 0x4D), SkColorSetA(SK_ColorWHITE, 0x33), |
| 290 kHighlightCornerRadius)))); | 292 kBackgroundCornerRadius)))); |
| 291 highlight_view_->SetPaintToLayer(true); | 293 highlight_view_->SetPaintToLayer(true); |
| 292 highlight_view_->layer()->SetFillsBoundsOpaquely(false); | 294 highlight_view_->layer()->SetFillsBoundsOpaquely(false); |
| 293 | 295 |
| 294 AddChildView(highlight_view_); | 296 AddChildView(highlight_view_); |
| 295 AddChildView(mirror_container_); | 297 AddChildView(mirror_container_); |
| 296 } | 298 } |
| 297 | 299 |
| 298 ~WindowCycleView() override {} | 300 ~WindowCycleView() override {} |
| 299 | 301 |
| 300 void SetTargetWindow(WmWindow* target) { | 302 void SetTargetWindow(WmWindow* target) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 } | 390 } |
| 389 } | 391 } |
| 390 | 392 |
| 391 void OnMouseCaptureLost() override { | 393 void OnMouseCaptureLost() override { |
| 392 WmShell::Get()->window_cycle_controller()->StopCycling(); | 394 WmShell::Get()->window_cycle_controller()->StopCycling(); |
| 393 } | 395 } |
| 394 | 396 |
| 395 void OnPaintBackground(gfx::Canvas* canvas) override { | 397 void OnPaintBackground(gfx::Canvas* canvas) override { |
| 396 // We can't set a bg on the mirror container itself because the highlight | 398 // We can't set a bg on the mirror container itself because the highlight |
| 397 // view needs to be on top of the bg but behind the target windows. | 399 // view needs to be on top of the bg but behind the target windows. |
| 398 canvas->FillRect(mirror_container_->bounds(), | 400 const gfx::RectF shield_bounds(mirror_container_->bounds()); |
| 399 SkColorSetA(SK_ColorBLACK, 0xE6)); | 401 SkPaint paint; |
| 402 paint.setColor(SkColorSetA(SK_ColorBLACK, 0xE6)); |
| 403 paint.setStyle(SkPaint::kFill_Style); |
| 404 float corner_radius = 0.f; |
| 405 if (shield_bounds.width() < width()) { |
| 406 paint.setAntiAlias(true); |
| 407 corner_radius = kBackgroundCornerRadius; |
| 408 } |
| 409 canvas->DrawRoundRect(shield_bounds, corner_radius, paint); |
| 400 } | 410 } |
| 401 | 411 |
| 402 View* GetInitiallyFocusedView() override { | 412 View* GetInitiallyFocusedView() override { |
| 403 return window_view_map_[target_window_]; | 413 return window_view_map_[target_window_]; |
| 404 } | 414 } |
| 405 | 415 |
| 406 WmWindow* target_window() { return target_window_; } | 416 WmWindow* target_window() { return target_window_; } |
| 407 | 417 |
| 408 private: | 418 private: |
| 409 std::map<WmWindow*, views::View*> window_view_map_; | 419 std::map<WmWindow*, views::View*> window_view_map_; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 widget->Init(params); | 638 widget->Init(params); |
| 629 | 639 |
| 630 screen_observer_.Add(display::Screen::GetScreen()); | 640 screen_observer_.Add(display::Screen::GetScreen()); |
| 631 widget->Show(); | 641 widget->Show(); |
| 632 widget->SetCapture(cycle_view_); | 642 widget->SetCapture(cycle_view_); |
| 633 widget->set_auto_release_capture(false); | 643 widget->set_auto_release_capture(false); |
| 634 cycle_ui_widget_ = widget; | 644 cycle_ui_widget_ = widget; |
| 635 } | 645 } |
| 636 | 646 |
| 637 } // namespace ash | 647 } // namespace ash |
| OLD | NEW |