| 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/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/shell_window_ids.h" | 11 #include "ash/common/shell_window_ids.h" |
| 12 #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_factory.h" |
| 15 #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_controller.h" |
| 12 #include "ash/common/wm/window_state.h" | 18 #include "ash/common/wm/window_state.h" |
| 13 #include "ash/common/wm_lookup.h" | 19 #include "ash/common/wm_lookup.h" |
| 14 #include "ash/common/wm_root_window_controller.h" | 20 #include "ash/common/wm_root_window_controller.h" |
| 15 #include "ash/common/wm_window.h" | 21 #include "ash/common/wm_window.h" |
| 16 #include "ash/common/wm_window_property.h" | 22 #include "ash/common/wm_window_property.h" |
| 17 #include "ash/wm/overview/overview_animation_type.h" | |
| 18 #include "ash/wm/overview/scoped_overview_animation_settings.h" | |
| 19 #include "ash/wm/overview/scoped_overview_animation_settings_factory.h" | |
| 20 #include "ash/wm/overview/scoped_transform_overview_window.h" | |
| 21 #include "ash/wm/overview/window_selector.h" | |
| 22 #include "ash/wm/overview/window_selector_controller.h" | |
| 23 #include "base/auto_reset.h" | 23 #include "base/auto_reset.h" |
| 24 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
| 25 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
| 26 #include "base/time/time.h" | 26 #include "base/time/time.h" |
| 27 #include "grit/ash_resources.h" | 27 #include "grit/ash_resources.h" |
| 28 #include "grit/ash_strings.h" | 28 #include "grit/ash_strings.h" |
| 29 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
| 30 #include "ui/base/resource/resource_bundle.h" | 30 #include "ui/base/resource/resource_bundle.h" |
| 31 #include "ui/gfx/canvas.h" | 31 #include "ui/gfx/canvas.h" |
| 32 #include "ui/gfx/geometry/safe_integer_conversions.h" | 32 #include "ui/gfx/geometry/safe_integer_conversions.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 159 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 160 SetImage(views::CustomButton::STATE_NORMAL, | 160 SetImage(views::CustomButton::STATE_NORMAL, |
| 161 rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE)); | 161 rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE)); |
| 162 SetImage(views::CustomButton::STATE_HOVERED, | 162 SetImage(views::CustomButton::STATE_HOVERED, |
| 163 rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE_H)); | 163 rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE_H)); |
| 164 SetImage(views::CustomButton::STATE_PRESSED, | 164 SetImage(views::CustomButton::STATE_PRESSED, |
| 165 rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE_P)); | 165 rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE_P)); |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 | 168 |
| 169 OverviewCloseButton::~OverviewCloseButton() { | 169 OverviewCloseButton::~OverviewCloseButton() {} |
| 170 } | |
| 171 | 170 |
| 172 // A View having rounded corners and a specified background color which is | 171 // A View having rounded corners and a specified background color which is |
| 173 // only painted within the bounds defined by the rounded corners. | 172 // only painted within the bounds defined by the rounded corners. |
| 174 // TODO(varkha): This duplicates code from RoundedImageView. Refactor these | 173 // TODO(varkha): This duplicates code from RoundedImageView. Refactor these |
| 175 // classes and move into ui/views. | 174 // classes and move into ui/views. |
| 176 class RoundedContainerView : public views::View { | 175 class RoundedContainerView : public views::View { |
| 177 public: | 176 public: |
| 178 RoundedContainerView(int corner_radius, SkColor background) | 177 RoundedContainerView(int corner_radius, SkColor background) |
| 179 : corner_radius_(corner_radius), background_(background) {} | 178 : corner_radius_(corner_radius), background_(background) {} |
| 180 | 179 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 204 DISALLOW_COPY_AND_ASSIGN(RoundedContainerView); | 203 DISALLOW_COPY_AND_ASSIGN(RoundedContainerView); |
| 205 }; | 204 }; |
| 206 | 205 |
| 207 } // namespace | 206 } // namespace |
| 208 | 207 |
| 209 WindowSelectorItem::OverviewLabelButton::OverviewLabelButton( | 208 WindowSelectorItem::OverviewLabelButton::OverviewLabelButton( |
| 210 views::ButtonListener* listener, | 209 views::ButtonListener* listener, |
| 211 const base::string16& text) | 210 const base::string16& text) |
| 212 : LabelButton(listener, text) {} | 211 : LabelButton(listener, text) {} |
| 213 | 212 |
| 214 WindowSelectorItem::OverviewLabelButton::~OverviewLabelButton() { | 213 WindowSelectorItem::OverviewLabelButton::~OverviewLabelButton() {} |
| 215 } | |
| 216 | 214 |
| 217 void WindowSelectorItem::OverviewLabelButton::SetBackgroundColor( | 215 void WindowSelectorItem::OverviewLabelButton::SetBackgroundColor( |
| 218 SkColor color) { | 216 SkColor color) { |
| 219 label()->SetBackgroundColor(color); | 217 label()->SetBackgroundColor(color); |
| 220 } | 218 } |
| 221 | 219 |
| 222 gfx::Rect WindowSelectorItem::OverviewLabelButton::GetChildAreaBounds() { | 220 gfx::Rect WindowSelectorItem::OverviewLabelButton::GetChildAreaBounds() { |
| 223 gfx::Rect bounds = GetLocalBounds(); | 221 gfx::Rect bounds = GetLocalBounds(); |
| 224 bounds.Inset(padding_); | 222 bounds.Inset(padding_); |
| 225 if (ash::MaterialDesignController::IsOverviewMaterial()) | 223 if (ash::MaterialDesignController::IsOverviewMaterial()) |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 gfx::Rect inset_bounds(target_bounds_); | 372 gfx::Rect inset_bounds(target_bounds_); |
| 375 if (ash::MaterialDesignController::IsOverviewMaterial()) | 373 if (ash::MaterialDesignController::IsOverviewMaterial()) |
| 376 inset_bounds.Inset(kWindowMarginMD, kWindowMarginMD); | 374 inset_bounds.Inset(kWindowMarginMD, kWindowMarginMD); |
| 377 else | 375 else |
| 378 inset_bounds.Inset(kWindowMargin, kWindowMargin); | 376 inset_bounds.Inset(kWindowMargin, kWindowMargin); |
| 379 SetItemBounds(inset_bounds, OverviewAnimationType::OVERVIEW_ANIMATION_NONE); | 377 SetItemBounds(inset_bounds, OverviewAnimationType::OVERVIEW_ANIMATION_NONE); |
| 380 UpdateHeaderLayout(OverviewAnimationType::OVERVIEW_ANIMATION_NONE); | 378 UpdateHeaderLayout(OverviewAnimationType::OVERVIEW_ANIMATION_NONE); |
| 381 } | 379 } |
| 382 | 380 |
| 383 void WindowSelectorItem::SendAccessibleSelectionEvent() { | 381 void WindowSelectorItem::SendAccessibleSelectionEvent() { |
| 384 window_label_button_view_->NotifyAccessibilityEvent( | 382 window_label_button_view_->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, |
| 385 ui::AX_EVENT_SELECTION, true); | 383 true); |
| 386 } | 384 } |
| 387 | 385 |
| 388 void WindowSelectorItem::SetDimmed(bool dimmed) { | 386 void WindowSelectorItem::SetDimmed(bool dimmed) { |
| 389 dimmed_ = dimmed; | 387 dimmed_ = dimmed; |
| 390 SetOpacity(dimmed ? kDimmedItemOpacity : 1.0f); | 388 SetOpacity(dimmed ? kDimmedItemOpacity : 1.0f); |
| 391 } | 389 } |
| 392 | 390 |
| 393 void WindowSelectorItem::ButtonPressed(views::Button* sender, | 391 void WindowSelectorItem::ButtonPressed(views::Button* sender, |
| 394 const ui::Event& event) { | 392 const ui::Event& event) { |
| 395 if (sender == close_button_) { | 393 if (sender == close_button_) { |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 } | 586 } |
| 589 } | 587 } |
| 590 | 588 |
| 591 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() { | 589 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() { |
| 592 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16( | 590 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16( |
| 593 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME, | 591 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME, |
| 594 GetWindow()->GetTitle())); | 592 GetWindow()->GetTitle())); |
| 595 } | 593 } |
| 596 | 594 |
| 597 } // namespace ash | 595 } // namespace ash |
| OLD | NEW |