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

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: [ash-md] Makes Ctrl+W accelerator close a selected window in overview mode (UMA) 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
« no previous file with comments | « ash/common/wm/overview/window_selector_item.h ('k') | ash/metrics/user_metrics_recorder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "ash/common/metrics/user_metrics_action.h"
11 #include "ash/common/shell_window_ids.h" 12 #include "ash/common/shell_window_ids.h"
12 #include "ash/common/wm/overview/overview_animation_type.h" 13 #include "ash/common/wm/overview/overview_animation_type.h"
13 #include "ash/common/wm/overview/scoped_overview_animation_settings.h" 14 #include "ash/common/wm/overview/scoped_overview_animation_settings.h"
14 #include "ash/common/wm/overview/scoped_overview_animation_settings_factory.h" 15 #include "ash/common/wm/overview/scoped_overview_animation_settings_factory.h"
15 #include "ash/common/wm/overview/scoped_transform_overview_window.h" 16 #include "ash/common/wm/overview/scoped_transform_overview_window.h"
16 #include "ash/common/wm/overview/window_selector.h" 17 #include "ash/common/wm/overview/window_selector.h"
17 #include "ash/common/wm/overview/window_selector_controller.h" 18 #include "ash/common/wm/overview/window_selector_controller.h"
18 #include "ash/common/wm/window_state.h" 19 #include "ash/common/wm/window_state.h"
19 #include "ash/common/wm_lookup.h" 20 #include "ash/common/wm_lookup.h"
20 #include "ash/common/wm_root_window_controller.h" 21 #include "ash/common/wm_root_window_controller.h"
22 #include "ash/common/wm_shell.h"
21 #include "ash/common/wm_window.h" 23 #include "ash/common/wm_window.h"
22 #include "ash/common/wm_window_property.h" 24 #include "ash/common/wm_window_property.h"
23 #include "base/auto_reset.h" 25 #include "base/auto_reset.h"
24 #include "base/strings/string_util.h" 26 #include "base/strings/string_util.h"
25 #include "base/strings/utf_string_conversions.h" 27 #include "base/strings/utf_string_conversions.h"
26 #include "base/time/time.h" 28 #include "base/time/time.h"
27 #include "grit/ash_resources.h" 29 #include "grit/ash_resources.h"
28 #include "grit/ash_strings.h" 30 #include "grit/ash_strings.h"
29 #include "ui/base/l10n/l10n_util.h" 31 #include "ui/base/l10n/l10n_util.h"
30 #include "ui/base/resource/resource_bundle.h" 32 #include "ui/base/resource/resource_bundle.h"
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 inset_bounds.Inset(kWindowMargin, kWindowMargin); 385 inset_bounds.Inset(kWindowMargin, kWindowMargin);
384 SetItemBounds(inset_bounds, OverviewAnimationType::OVERVIEW_ANIMATION_NONE); 386 SetItemBounds(inset_bounds, OverviewAnimationType::OVERVIEW_ANIMATION_NONE);
385 UpdateHeaderLayout(OverviewAnimationType::OVERVIEW_ANIMATION_NONE); 387 UpdateHeaderLayout(OverviewAnimationType::OVERVIEW_ANIMATION_NONE);
386 } 388 }
387 389
388 void WindowSelectorItem::SendAccessibleSelectionEvent() { 390 void WindowSelectorItem::SendAccessibleSelectionEvent() {
389 window_label_button_view_->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, 391 window_label_button_view_->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION,
390 true); 392 true);
391 } 393 }
392 394
395 void WindowSelectorItem::CloseWindow() {
396 if (ash::MaterialDesignController::IsOverviewMaterial()) {
397 gfx::Rect inset_bounds(target_bounds_);
398 inset_bounds.Inset(target_bounds_.width() * kPreCloseScale,
399 target_bounds_.height() * kPreCloseScale);
400 OverviewAnimationType animation_type =
401 OverviewAnimationType::OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM;
402 // Scale down both the window and label.
403 SetBounds(inset_bounds, animation_type);
404 // First animate opacity to an intermediate value concurrently with the
405 // scaling animation.
406 AnimateOpacity(kClosingItemOpacity, animation_type);
407
408 // Fade out the window and the label, effectively hiding them.
409 AnimateOpacity(
410 0.0, OverviewAnimationType::OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM);
411 }
412 transform_window_.Close();
413 }
414
393 void WindowSelectorItem::SetDimmed(bool dimmed) { 415 void WindowSelectorItem::SetDimmed(bool dimmed) {
394 dimmed_ = dimmed; 416 dimmed_ = dimmed;
395 SetOpacity(dimmed ? kDimmedItemOpacity : 1.0f); 417 SetOpacity(dimmed ? kDimmedItemOpacity : 1.0f);
396 } 418 }
397 419
398 void WindowSelectorItem::ButtonPressed(views::Button* sender, 420 void WindowSelectorItem::ButtonPressed(views::Button* sender,
399 const ui::Event& event) { 421 const ui::Event& event) {
400 if (sender == close_button_) { 422 if (sender == close_button_) {
401 if (ash::MaterialDesignController::IsOverviewMaterial()) { 423 WmShell::Get()->RecordUserMetricsAction(UMA_WINDOW_OVERVIEW_CLOSE_BUTTON);
402 gfx::Rect inset_bounds(target_bounds_); 424 CloseWindow();
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 window_selector_->WindowClosing(this);
418 transform_window_.Close();
419 return; 425 return;
420 } 426 }
421 CHECK(sender == window_label_button_view_); 427 CHECK(sender == window_label_button_view_);
422 window_selector_->SelectWindow(transform_window_.window()); 428 window_selector_->SelectWindow(transform_window_.window());
423 } 429 }
424 430
425 void WindowSelectorItem::OnWindowDestroying(WmWindow* window) { 431 void WindowSelectorItem::OnWindowDestroying(WmWindow* window) {
426 window->RemoveObserver(this); 432 window->RemoveObserver(this);
427 transform_window_.OnWindowDestroyed(); 433 transform_window_.OnWindowDestroyed();
428 } 434 }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 window_label_selector_window->SetOpacity(opacity); 646 window_label_selector_window->SetOpacity(opacity);
641 } 647 }
642 648
643 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() { 649 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() {
644 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16( 650 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16(
645 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME, 651 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME,
646 GetWindow()->GetTitle())); 652 GetWindow()->GetTitle()));
647 } 653 }
648 654
649 } // namespace ash 655 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/overview/window_selector_item.h ('k') | ash/metrics/user_metrics_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698