| OLD | NEW |
| 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/wm/overview/window_selector_item.h" | 5 #include "ash/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/screen_util.h" | 10 #include "ash/screen_util.h" |
| 11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 12 #include "ash/shell_window_ids.h" | 12 #include "ash/shell_window_ids.h" |
| 13 #include "ash/wm/overview/overview_animation_type.h" | 13 #include "ash/wm/overview/overview_animation_type.h" |
| 14 #include "ash/wm/overview/scoped_overview_animation_settings.h" | 14 #include "ash/wm/overview/scoped_overview_animation_settings.h" |
| 15 #include "ash/wm/overview/scoped_transform_overview_window.h" | 15 #include "ash/wm/overview/scoped_transform_overview_window.h" |
| 16 #include "ash/wm/overview/window_selector.h" |
| 16 #include "ash/wm/overview/window_selector_controller.h" | 17 #include "ash/wm/overview/window_selector_controller.h" |
| 17 #include "ash/wm/window_state.h" | 18 #include "ash/wm/window_state.h" |
| 18 #include "base/auto_reset.h" | 19 #include "base/auto_reset.h" |
| 19 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 21 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 22 #include "grit/ash_resources.h" | 23 #include "grit/ash_resources.h" |
| 23 #include "grit/ash_strings.h" | 24 #include "grit/ash_strings.h" |
| 24 #include "ui/aura/window.h" | 25 #include "ui/aura/window.h" |
| 25 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 120 |
| 120 WindowSelectorItem::OverviewLabelButton::~OverviewLabelButton() { | 121 WindowSelectorItem::OverviewLabelButton::~OverviewLabelButton() { |
| 121 } | 122 } |
| 122 | 123 |
| 123 gfx::Rect WindowSelectorItem::OverviewLabelButton::GetChildAreaBounds() { | 124 gfx::Rect WindowSelectorItem::OverviewLabelButton::GetChildAreaBounds() { |
| 124 gfx::Rect bounds = GetLocalBounds(); | 125 gfx::Rect bounds = GetLocalBounds(); |
| 125 bounds.Inset(0, top_padding_, 0, 0); | 126 bounds.Inset(0, top_padding_, 0, 0); |
| 126 return bounds; | 127 return bounds; |
| 127 } | 128 } |
| 128 | 129 |
| 129 WindowSelectorItem::WindowSelectorItem(aura::Window* window) | 130 WindowSelectorItem::WindowSelectorItem(aura::Window* window, |
| 131 WindowSelector* window_selector) |
| 130 : dimmed_(false), | 132 : dimmed_(false), |
| 131 root_window_(window->GetRootWindow()), | 133 root_window_(window->GetRootWindow()), |
| 132 transform_window_(window), | 134 transform_window_(window), |
| 133 in_bounds_update_(false), | 135 in_bounds_update_(false), |
| 134 window_label_button_view_(nullptr), | 136 window_label_button_view_(nullptr), |
| 135 close_button_(new OverviewCloseButton(this)) { | 137 close_button_(new OverviewCloseButton(this)), |
| 138 window_selector_(window_selector) { |
| 136 CreateWindowLabel(window->title()); | 139 CreateWindowLabel(window->title()); |
| 137 views::Widget::InitParams params; | 140 views::Widget::InitParams params; |
| 138 params.type = views::Widget::InitParams::TYPE_POPUP; | 141 params.type = views::Widget::InitParams::TYPE_POPUP; |
| 139 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 142 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 140 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 143 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 141 params.parent = Shell::GetContainer(root_window_, | 144 params.parent = Shell::GetContainer(root_window_, |
| 142 kShellWindowId_OverlayContainer); | 145 kShellWindowId_OverlayContainer); |
| 143 close_button_widget_.set_focus_on_creation(false); | 146 close_button_widget_.set_focus_on_creation(false); |
| 144 close_button_widget_.Init(params); | 147 close_button_widget_.Init(params); |
| 145 close_button_->SetVisible(false); | 148 close_button_->SetVisible(false); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 SetOpacity(dimmed ? kDimmedItemOpacity : 1.0f); | 221 SetOpacity(dimmed ? kDimmedItemOpacity : 1.0f); |
| 219 } | 222 } |
| 220 | 223 |
| 221 void WindowSelectorItem::ButtonPressed(views::Button* sender, | 224 void WindowSelectorItem::ButtonPressed(views::Button* sender, |
| 222 const ui::Event& event) { | 225 const ui::Event& event) { |
| 223 if (sender == close_button_) { | 226 if (sender == close_button_) { |
| 224 transform_window_.Close(); | 227 transform_window_.Close(); |
| 225 return; | 228 return; |
| 226 } | 229 } |
| 227 CHECK(sender == window_label_button_view_); | 230 CHECK(sender == window_label_button_view_); |
| 228 wm::GetWindowState(transform_window_.window())->Activate(); | 231 window_selector_->SelectWindow(transform_window_.window()); |
| 229 } | 232 } |
| 230 | 233 |
| 231 void WindowSelectorItem::OnWindowDestroying(aura::Window* window) { | 234 void WindowSelectorItem::OnWindowDestroying(aura::Window* window) { |
| 232 window->RemoveObserver(this); | 235 window->RemoveObserver(this); |
| 233 transform_window_.OnWindowDestroyed(); | 236 transform_window_.OnWindowDestroyed(); |
| 234 } | 237 } |
| 235 | 238 |
| 236 void WindowSelectorItem::OnWindowTitleChanged(aura::Window* window) { | 239 void WindowSelectorItem::OnWindowTitleChanged(aura::Window* window) { |
| 237 // TODO(flackr): Maybe add the new title to a vector of titles so that we can | 240 // TODO(flackr): Maybe add the new title to a vector of titles so that we can |
| 238 // filter any of the titles the window had while in the overview session. | 241 // filter any of the titles the window had while in the overview session. |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 close_button_transform); | 341 close_button_transform); |
| 339 } | 342 } |
| 340 | 343 |
| 341 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() { | 344 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() { |
| 342 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16( | 345 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16( |
| 343 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME, | 346 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME, |
| 344 GetWindow()->title())); | 347 GetWindow()->title())); |
| 345 } | 348 } |
| 346 | 349 |
| 347 } // namespace ash | 350 } // namespace ash |
| OLD | NEW |