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

Side by Side Diff: ash/common/wm/overview/window_selector_item.cc

Issue 2131603004: [ash-md] Makes Ctrl+W accelerator close a selected window in overview mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/overview/window_selector_item.h" 5 #include "ash/common/wm/overview/window_selector_item.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/common/material_design/material_design_controller.h" 10 #include "ash/common/material_design/material_design_controller.h"
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 inset_bounds.Inset(kWindowMargin, kWindowMargin); 383 inset_bounds.Inset(kWindowMargin, kWindowMargin);
384 SetItemBounds(inset_bounds, OverviewAnimationType::OVERVIEW_ANIMATION_NONE); 384 SetItemBounds(inset_bounds, OverviewAnimationType::OVERVIEW_ANIMATION_NONE);
385 UpdateHeaderLayout(OverviewAnimationType::OVERVIEW_ANIMATION_NONE); 385 UpdateHeaderLayout(OverviewAnimationType::OVERVIEW_ANIMATION_NONE);
386 } 386 }
387 387
388 void WindowSelectorItem::SendAccessibleSelectionEvent() { 388 void WindowSelectorItem::SendAccessibleSelectionEvent() {
389 window_label_button_view_->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, 389 window_label_button_view_->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION,
390 true); 390 true);
391 } 391 }
392 392
393 void WindowSelectorItem::CloseWindow() {
394 if (ash::MaterialDesignController::IsOverviewMaterial()) {
395 gfx::Rect inset_bounds(target_bounds_);
396 inset_bounds.Inset(target_bounds_.width() * kPreCloseScale,
397 target_bounds_.height() * kPreCloseScale);
398 OverviewAnimationType animation_type =
399 OverviewAnimationType::OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM;
400 // Scale down both the window and label.
401 SetBounds(inset_bounds, animation_type);
402 // First animate opacity to an intermediate value concurrently with the
403 // scaling animation.
404 AnimateOpacity(kClosingItemOpacity, animation_type);
405
406 // Fade out the window and the label, effectively hiding them.
407 AnimateOpacity(
408 0.0, OverviewAnimationType::OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM);
409 }
410 transform_window_.Close();
411 }
412
393 void WindowSelectorItem::SetDimmed(bool dimmed) { 413 void WindowSelectorItem::SetDimmed(bool dimmed) {
394 dimmed_ = dimmed; 414 dimmed_ = dimmed;
395 SetOpacity(dimmed ? kDimmedItemOpacity : 1.0f); 415 SetOpacity(dimmed ? kDimmedItemOpacity : 1.0f);
396 } 416 }
397 417
398 void WindowSelectorItem::ButtonPressed(views::Button* sender, 418 void WindowSelectorItem::ButtonPressed(views::Button* sender,
399 const ui::Event& event) { 419 const ui::Event& event) {
400 if (sender == close_button_) { 420 if (sender == close_button_) {
401 if (ash::MaterialDesignController::IsOverviewMaterial()) { 421 CloseWindow();
402 gfx::Rect inset_bounds(target_bounds_);
403 inset_bounds.Inset(target_bounds_.width() * kPreCloseScale,
404 target_bounds_.height() * kPreCloseScale);
405 OverviewAnimationType animation_type =
406 OverviewAnimationType::OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM;
407 // Scale down both the window and label.
408 SetBounds(inset_bounds, animation_type);
409 // First animate opacity to an intermediate value concurrently with the
410 // scaling animation.
411 AnimateOpacity(kClosingItemOpacity, animation_type);
412
413 // Fade out the window and the label, effectively hiding them.
414 AnimateOpacity(
415 0.0, OverviewAnimationType::OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM);
416 }
417 transform_window_.Close();
418 return; 422 return;
419 } 423 }
420 CHECK(sender == window_label_button_view_); 424 CHECK(sender == window_label_button_view_);
421 window_selector_->SelectWindow(transform_window_.window()); 425 window_selector_->SelectWindow(transform_window_.window());
422 } 426 }
423 427
424 void WindowSelectorItem::OnWindowDestroying(WmWindow* window) { 428 void WindowSelectorItem::OnWindowDestroying(WmWindow* window) {
425 window->RemoveObserver(this); 429 window->RemoveObserver(this);
426 transform_window_.OnWindowDestroyed(); 430 transform_window_.OnWindowDestroyed();
427 } 431 }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 window_label_selector_window->SetOpacity(opacity); 643 window_label_selector_window->SetOpacity(opacity);
640 } 644 }
641 645
642 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() { 646 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() {
643 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16( 647 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16(
644 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME, 648 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME,
645 GetWindow()->GetTitle())); 649 GetWindow()->GetTitle()));
646 } 650 }
647 651
648 } // namespace ash 652 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698