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

Unified Diff: ash/wm/overview/window_selector_item.cc

Issue 810033010: Remove TransparentActivateWindowButton from Overview Mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: ash/wm/overview/window_selector_item.cc
diff --git a/ash/wm/overview/window_selector_item.cc b/ash/wm/overview/window_selector_item.cc
index 7350ebdeed59394c0325f3d91ffa0909bd9110ed..cd54c6a6ba2bfe03373892ff0c419f822db44383 100644
--- a/ash/wm/overview/window_selector_item.cc
+++ b/ash/wm/overview/window_selector_item.cc
@@ -25,10 +25,12 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/geometry/vector2d.h"
+#include "ui/gfx/text_constants.h"
#include "ui/gfx/transform_util.h"
#include "ui/strings/grit/ui_strings.h"
+#include "ui/views/border.h"
#include "ui/views/controls/button/image_button.h"
-#include "ui/views/controls/label.h"
+#include "ui/views/controls/button/label_button.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/widget/widget.h"
#include "ui/wm/core/window_util.h"
@@ -45,9 +47,6 @@ static const int kWindowMargin = 30;
// Foreground label color.
static const SkColor kLabelColor = SK_ColorWHITE;
-// Background label color.
-static const SkColor kLabelBackground = SK_ColorTRANSPARENT;
-
// Label shadow color.
static const SkColor kLabelShadow = 0xB0000000;
@@ -117,10 +116,8 @@ WindowSelectorItem::WindowSelectorItem(aura::Window* root_window)
: dimmed_(false),
root_window_(root_window),
in_bounds_update_(false),
- window_label_view_(nullptr),
- close_button_(new OverviewCloseButton(this)),
- selector_item_activate_window_button_(
- new TransparentActivateWindowButton(root_window, this)) {
+ window_label_button_view_(nullptr),
+ close_button_(new OverviewCloseButton(this)) {
views::Widget::InitParams params;
params.type = views::Widget::InitParams::TYPE_POPUP;
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
@@ -155,13 +152,7 @@ void WindowSelectorItem::AddWindow(aura::Window* window) {
ScopedTransformOverviewWindow* transform_window =
new ScopedTransformOverviewWindow(window);
transform_windows_.push_back(transform_window);
- // The transparent overlays are added at the front of the z-order when
- // created so make sure the selector item's transparent overlay is behind the
- // overlay for the window that was just added.
- transform_window->activate_button()->StackAbove(
- selector_item_activate_window_button_.get());
- UpdateSelectorButtons();
UpdateCloseButtonAccessibilityName();
}
@@ -223,7 +214,6 @@ void WindowSelectorItem::RemoveWindow(const aura::Window* window) {
UpdateWindowLabels(target_bounds_,
OverviewAnimationType::OVERVIEW_ANIMATION_NONE);
UpdateCloseButtonLayout(OverviewAnimationType::OVERVIEW_ANIMATION_NONE);
- UpdateSelectorButtons();
}
bool WindowSelectorItem::empty() const {
@@ -252,7 +242,6 @@ void WindowSelectorItem::SetBounds(aura::Window* root_window,
// SetItemBounds is called before UpdateCloseButtonLayout so the close button
// can properly use the updated windows bounds.
UpdateCloseButtonLayout(animation_type);
- UpdateSelectorButtons();
}
void WindowSelectorItem::RecomputeWindowTransforms() {
@@ -266,11 +255,11 @@ void WindowSelectorItem::RecomputeWindowTransforms() {
OverviewAnimationType::OVERVIEW_ANIMATION_NONE);
UpdateCloseButtonLayout(OverviewAnimationType::OVERVIEW_ANIMATION_NONE);
- UpdateSelectorButtons();
}
void WindowSelectorItem::SendFocusAlert() const {
- selector_item_activate_window_button_->SendFocusAlert();
+ window_label_button_view_->NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS,
+ true);
}
void WindowSelectorItem::SetDimmed(bool dimmed) {
@@ -280,25 +269,22 @@ void WindowSelectorItem::SetDimmed(bool dimmed) {
void WindowSelectorItem::ButtonPressed(views::Button* sender,
const ui::Event& event) {
- CHECK(!transform_windows_.empty());
- SelectionTransformWindow()->Close();
+ if (sender == close_button_) {
+ CHECK(!transform_windows_.empty());
+ SelectionTransformWindow()->Close();
+ return;
+ }
+ wm::GetWindowState(SelectionWindow())->Activate();
bruthig 2015/01/09 17:04:33 I'm assuming this is handling the clicks on the La
Nina 2015/01/21 16:24:16 I don't think we want to add a redundant if clause
}
void WindowSelectorItem::OnWindowTitleChanged(aura::Window* window) {
// TODO(flackr): Maybe add the new title to a vector of titles so that we can
// filter any of the titles the window had while in the overview session.
if (window == SelectionWindow()) {
- window_label_view_->SetText(window->title());
+ window_label_button_view_->SetText(window->title());
UpdateCloseButtonAccessibilityName();
}
UpdateCloseButtonLayout(OverviewAnimationType::OVERVIEW_ANIMATION_NONE);
- UpdateSelectorButtons();
-}
-
-void WindowSelectorItem::Select() {
- aura::Window* selection_window = SelectionWindow();
- if (selection_window)
- wm::GetWindowState(selection_window)->Activate();
}
void WindowSelectorItem::SetItemBounds(aura::Window* root_window,
@@ -377,51 +363,35 @@ void WindowSelectorItem::CreateWindowLabel(const base::string16& title) {
params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
params.parent = Shell::GetContainer(root_window_,
kShellWindowId_OverlayContainer);
- params.accept_events = false;
params.visible_on_all_workspaces = true;
window_label_->set_focus_on_creation(false);
window_label_->Init(params);
- window_label_view_ = new views::Label;
- window_label_view_->SetEnabledColor(kLabelColor);
- window_label_view_->SetBackgroundColor(kLabelBackground);
- window_label_view_->SetShadows(gfx::ShadowValues(
+ window_label_button_view_ = new views::LabelButton(this, title);
+ window_label_button_view_->SetTextColor(views::LabelButton::STATE_NORMAL,
+ kLabelColor);
+ window_label_button_view_->SetTextColor(views::LabelButton::STATE_HOVERED,
+ kLabelColor);
+ window_label_button_view_->SetTextColor(views::LabelButton::STATE_PRESSED,
+ kLabelColor);
+ window_label_button_view_->set_animate_on_state_change(false);
+ window_label_button_view_->SetHorizontalAlignment(gfx::ALIGN_CENTER);
+ window_label_button_view_->SetBorder(views::Border::NullBorder());
+ window_label_button_view_->SetTextShadows(gfx::ShadowValues(
1,
gfx::ShadowValue(
gfx::Point(0, kVerticalShadowOffset), kShadowBlur, kLabelShadow)));
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
- window_label_view_->SetFontList(
+ window_label_button_view_->SetFontList(
bundle.GetFontList(ui::ResourceBundle::BoldFont));
- window_label_view_->SetText(title);
views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kVertical,
0,
kVerticalLabelPadding,
0);
- window_label_view_->SetLayoutManager(layout);
- window_label_->SetContentsView(window_label_view_);
+ window_label_button_view_->SetLayoutManager(layout);
+ window_label_->SetContentsView(window_label_button_view_);
window_label_->Show();
}
-void WindowSelectorItem::UpdateSelectorButtons() {
- CHECK(!transform_windows_.empty());
-
- selector_item_activate_window_button_->SetBounds(target_bounds());
- selector_item_activate_window_button_->SetAccessibleName(
- transform_windows_.front()->window()->title());
-
- for (auto* transform_window : transform_windows_) {
- TransparentActivateWindowButton* activate_button =
- transform_window->activate_button();
-
- // If there is only one window in this, then expand the transparent overlay
- // so that touch exploration in ChromVox only provides spoken feedback once
- // within |this| selector item's bounds.
- gfx::Rect bounds = transform_windows_.size() == 1
- ? target_bounds() : GetTransformedBounds(transform_window->window());
- activate_button->SetBounds(bounds);
- activate_button->SetAccessibleName(transform_window->window()->title());
- }
-}
-
void WindowSelectorItem::UpdateCloseButtonLayout(
OverviewAnimationType animation_type) {
if (!close_button_->visible()) {

Powered by Google App Engine
This is Rietveld 408576698