Chromium Code Reviews| 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/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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 | 69 |
| 70 // Label background color once in overview mode. | 70 // Label background color once in overview mode. |
| 71 static const SkColor kLabelBackgroundColor = SkColorSetARGB(25, 255, 255, 255); | 71 static const SkColor kLabelBackgroundColor = SkColorSetARGB(25, 255, 255, 255); |
| 72 | 72 |
| 73 // Label background color when exiting overview mode. | 73 // Label background color when exiting overview mode. |
| 74 static const SkColor kLabelExitColor = SkColorSetARGB(255, 90, 90, 90); | 74 static const SkColor kLabelExitColor = SkColorSetARGB(255, 90, 90, 90); |
| 75 | 75 |
| 76 // Corner radius for the selection tiles. | 76 // Corner radius for the selection tiles. |
| 77 static int kLabelBackgroundRadius = 2; | 77 static int kLabelBackgroundRadius = 2; |
| 78 | 78 |
| 79 // Vertical padding for the label, on top of it. | |
| 80 static const int kVerticalLabelPadding = 20; | |
| 81 | |
| 82 // Horizontal padding for the label, on both sides. | 79 // Horizontal padding for the label, on both sides. |
| 83 static const int kHorizontalLabelPadding = 8; | 80 static const int kHorizontalLabelPadding = 8; |
| 84 | 81 |
| 85 // Height of an item header. | 82 // Height of an item header. |
| 86 static const int kHeaderHeight = 32; | 83 static const int kHeaderHeight = 32; |
| 87 | 84 |
| 88 // Opacity for dimmed items. | 85 // Opacity for dimmed items. |
| 89 static const float kDimmedItemOpacity = 0.5f; | 86 static const float kDimmedItemOpacity = 0.5f; |
| 90 | 87 |
| 91 // Opacity for fading out during closing a window. | 88 // Opacity for fading out during closing a window. |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 118 std::unique_ptr<ScopedOverviewAnimationSettings> | 115 std::unique_ptr<ScopedOverviewAnimationSettings> |
| 119 scoped_overview_animation_settings = | 116 scoped_overview_animation_settings = |
| 120 ScopedOverviewAnimationSettingsFactory::Get() | 117 ScopedOverviewAnimationSettingsFactory::Get() |
| 121 ->CreateOverviewAnimationSettings( | 118 ->CreateOverviewAnimationSettings( |
| 122 OverviewAnimationType:: | 119 OverviewAnimationType:: |
| 123 OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN, | 120 OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN, |
| 124 window); | 121 window); |
| 125 window->SetOpacity(1.0f); | 122 window->SetOpacity(1.0f); |
| 126 } | 123 } |
| 127 | 124 |
| 125 // A Button that has a listener and listens to mouse clicks on the visible part | |
| 126 // of an overview window. | |
| 127 class ShieldButton : public views::CustomButton { | |
| 128 public: | |
| 129 ShieldButton(views::ButtonListener* listener, const base::string16& name) | |
| 130 : views::CustomButton(listener) { | |
| 131 SetAccessibleName(name); | |
| 132 } | |
| 133 ~ShieldButton() override {} | |
| 134 | |
| 135 // Resets the listener so that the listener can go out of scope. | |
| 136 void ResetListener() { listener_ = nullptr; } | |
|
tdanderson
2017/01/16 23:43:29
I know this is re-use of existing code, but I'm no
varkha
2017/01/17 17:39:05
Done (edited comment for clarity).
| |
| 137 | |
| 138 protected: | |
| 139 // views::View: | |
| 140 const char* GetClassName() const override { return "ShieldButton"; } | |
| 141 | |
| 142 private: | |
| 143 DISALLOW_COPY_AND_ASSIGN(ShieldButton); | |
| 144 }; | |
| 145 | |
| 146 // A Label used to display caption text above the windows in overview mode. | |
| 147 class OverviewLabel : public views::Label { | |
|
tdanderson
2017/01/16 23:43:29
I wonder if introducing this class is really neces
varkha
2017/01/17 17:39:05
Done.
| |
| 148 public: | |
| 149 OverviewLabel(const base::string16& text) : views::Label(text) { | |
|
tdanderson
2017/01/16 23:43:29
nit: explicit
varkha
2017/01/17 17:39:05
Acknowledged.
| |
| 150 SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
| 151 SetAutoColorReadabilityEnabled(false); | |
| 152 SetEnabledColor(kLabelColor); | |
| 153 // Tell the label what color it will be drawn onto. It will use whether the | |
| 154 // background color is opaque or transparent to decide whether to use | |
| 155 // subpixel | |
| 156 // rendering. Does not actually set the label's background color. | |
|
tdanderson
2017/01/16 23:43:29
nit: line breaks in this comment block
varkha
2017/01/17 17:39:05
Done.
| |
| 157 SetBackgroundColor(kLabelBackgroundColor); | |
| 158 } | |
| 159 | |
| 160 ~OverviewLabel() override {} | |
| 161 | |
| 162 protected: | |
| 163 // views::Label: | |
| 164 const char* GetClassName() const override { return "OverviewLabel"; } | |
| 165 | |
| 166 private: | |
| 167 DISALLOW_COPY_AND_ASSIGN(OverviewLabel); | |
| 168 }; | |
| 169 | |
| 128 } // namespace | 170 } // namespace |
| 129 | 171 |
| 130 WindowSelectorItem::OverviewCloseButton::OverviewCloseButton( | 172 WindowSelectorItem::OverviewCloseButton::OverviewCloseButton( |
| 131 views::ButtonListener* listener) | 173 views::ButtonListener* listener) |
| 132 : views::ImageButton(listener) { | 174 : views::ImageButton(listener) { |
| 133 SetImage(views::CustomButton::STATE_NORMAL, | 175 SetImage(views::CustomButton::STATE_NORMAL, |
| 134 gfx::CreateVectorIcon(kWindowControlCloseIcon, kCloseButtonColor)); | 176 gfx::CreateVectorIcon(kWindowControlCloseIcon, kCloseButtonColor)); |
| 135 SetImageAlignment(views::ImageButton::ALIGN_CENTER, | 177 SetImageAlignment(views::ImageButton::ALIGN_CENTER, |
| 136 views::ImageButton::ALIGN_MIDDLE); | 178 views::ImageButton::ALIGN_MIDDLE); |
| 137 SetMinimumImageSize(gfx::Size(kHeaderHeight, kHeaderHeight)); | 179 SetMinimumImageSize(gfx::Size(kHeaderHeight, kHeaderHeight)); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 162 WmWindow* item_window, | 204 WmWindow* item_window, |
| 163 int corner_radius, | 205 int corner_radius, |
| 164 SkColor background) | 206 SkColor background) |
| 165 : item_(item), | 207 : item_(item), |
| 166 item_window_(item_window), | 208 item_window_(item_window), |
| 167 corner_radius_(corner_radius), | 209 corner_radius_(corner_radius), |
| 168 initial_color_(background), | 210 initial_color_(background), |
| 169 target_color_(background), | 211 target_color_(background), |
| 170 current_value_(0), | 212 current_value_(0), |
| 171 layer_(nullptr), | 213 layer_(nullptr), |
| 172 animation_(new gfx::SlideAnimation(this)) {} | 214 animation_(new gfx::SlideAnimation(this)) { |
| 215 SetPaintToLayer(true); | |
| 216 layer()->SetFillsBoundsOpaquely(false); | |
| 217 } | |
| 173 | 218 |
| 174 ~RoundedContainerView() override { StopObservingLayerAnimations(); } | 219 ~RoundedContainerView() override { StopObservingLayerAnimations(); } |
| 175 | 220 |
| 176 void OnItemRestored() { | 221 void OnItemRestored() { |
| 177 item_ = nullptr; | 222 item_ = nullptr; |
| 178 item_window_ = nullptr; | 223 item_window_ = nullptr; |
| 179 } | 224 } |
| 180 | 225 |
| 181 // Starts observing layer animations so that actions can be taken when | 226 // Starts observing layer animations so that actions can be taken when |
| 182 // particular animations (opacity) complete. It should only be called once | 227 // particular animations (opacity) complete. It should only be called once |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 canvas->ClipPath(path, true); | 292 canvas->ClipPath(path, true); |
| 248 | 293 |
| 249 SkColor target_color = initial_color_; | 294 SkColor target_color = initial_color_; |
| 250 if (target_color_ != target_color) { | 295 if (target_color_ != target_color) { |
| 251 target_color = color_utils::AlphaBlend(target_color_, initial_color_, | 296 target_color = color_utils::AlphaBlend(target_color_, initial_color_, |
| 252 current_value_); | 297 current_value_); |
| 253 } | 298 } |
| 254 canvas->DrawColor(target_color); | 299 canvas->DrawColor(target_color); |
| 255 } | 300 } |
| 256 | 301 |
| 302 const char* GetClassName() const override { return "RoundedContainerView"; } | |
|
tdanderson
2017/01/16 23:43:29
Thanks for adding this.
varkha
2017/01/17 17:39:05
Acknowledged.
| |
| 303 | |
| 257 private: | 304 private: |
| 258 // gfx::AnimationDelegate: | 305 // gfx::AnimationDelegate: |
| 259 void AnimationEnded(const gfx::Animation* animation) override { | 306 void AnimationEnded(const gfx::Animation* animation) override { |
| 260 initial_color_ = target_color_; | 307 initial_color_ = target_color_; |
| 261 // Tabbed browser windows show the overview mode header behind the window | 308 // Tabbed browser windows show the overview mode header behind the window |
| 262 // during the initial animation. Once the initial fade-in completes and the | 309 // during the initial animation. Once the initial fade-in completes and the |
| 263 // overview header is fully exposed update stacking to keep the label above | 310 // overview header is fully exposed update stacking to keep the label above |
| 264 // the item which prevents input events from reaching the window. | 311 // the item which prevents input events from reaching the window. |
| 265 WmWindow* label_window = WmLookup::Get()->GetWindowForWidget(GetWidget()); | 312 WmWindow* label_window = WmLookup::Get()->GetWindowForWidget(GetWidget()); |
| 266 if (label_window && item_window_) | 313 if (label_window && item_window_) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 int corner_radius_; | 353 int corner_radius_; |
| 307 SkColor initial_color_; | 354 SkColor initial_color_; |
| 308 SkColor target_color_; | 355 SkColor target_color_; |
| 309 int current_value_; | 356 int current_value_; |
| 310 ui::Layer* layer_; | 357 ui::Layer* layer_; |
| 311 std::unique_ptr<gfx::SlideAnimation> animation_; | 358 std::unique_ptr<gfx::SlideAnimation> animation_; |
| 312 | 359 |
| 313 DISALLOW_COPY_AND_ASSIGN(RoundedContainerView); | 360 DISALLOW_COPY_AND_ASSIGN(RoundedContainerView); |
| 314 }; | 361 }; |
| 315 | 362 |
| 316 WindowSelectorItem::OverviewLabelButton::OverviewLabelButton( | |
| 317 views::ButtonListener* listener, | |
| 318 const base::string16& text) | |
| 319 : LabelButton(listener, text) {} | |
| 320 | |
| 321 WindowSelectorItem::OverviewLabelButton::~OverviewLabelButton() {} | |
| 322 | |
| 323 void WindowSelectorItem::OverviewLabelButton::SetBackgroundColorHint( | |
| 324 SkColor color) { | |
| 325 // Tell the label what color it will be drawn onto. It will use whether the | |
| 326 // background color is opaque or transparent to decide whether to use subpixel | |
| 327 // rendering. Does not actually set the label's background color. | |
| 328 label()->SetBackgroundColor(color); | |
| 329 } | |
| 330 | |
| 331 gfx::Rect WindowSelectorItem::OverviewLabelButton::GetChildAreaBounds() { | |
| 332 gfx::Rect bounds = GetLocalBounds(); | |
| 333 bounds.Inset(padding_ + gfx::Insets(0, kHorizontalLabelPadding)); | |
| 334 return bounds; | |
| 335 } | |
| 336 | |
| 337 // Container View that has an item label and a close button as children. | 363 // Container View that has an item label and a close button as children. |
|
tdanderson
2017/01/16 23:43:29
This could use some clarification about what Capti
varkha
2017/01/17 17:39:05
Done.
| |
| 338 class WindowSelectorItem::CaptionContainerView : public views::View { | 364 class WindowSelectorItem::CaptionContainerView : public views::View { |
| 339 public: | 365 public: |
| 340 CaptionContainerView(WindowSelectorItem::OverviewLabelButton* label, | 366 CaptionContainerView(ButtonListener* listener, |
| 367 views::Label* label, | |
| 341 views::ImageButton* close_button, | 368 views::ImageButton* close_button, |
| 342 WindowSelectorItem::RoundedContainerView* background) | 369 WindowSelectorItem::RoundedContainerView* background) |
| 343 : label_(label), close_button_(close_button), background_(background) { | 370 : listener_button_(new ShieldButton(listener, label->text())), |
| 344 AddChildView(background_); | 371 background_(background), |
| 345 AddChildView(label_); | 372 label_(label), |
| 346 AddChildView(close_button_); | 373 close_button_(close_button) { |
| 374 background_->AddChildView(label_); | |
| 375 background_->AddChildView(close_button_); | |
|
tdanderson
2017/01/16 23:43:29
optional: as you explained in person, it may be wo
varkha
2017/01/17 17:39:05
Done.
| |
| 376 listener_button_->AddChildView(background_); | |
| 377 AddChildView(listener_button_); | |
| 347 } | 378 } |
| 348 | 379 |
| 380 ShieldButton* listener_button() { return listener_button_; } | |
| 381 | |
| 349 protected: | 382 protected: |
| 350 // views::View: | 383 // views::View: |
| 351 void Layout() override { | 384 void Layout() override { |
| 352 // Position close button in the top right corner sized to its icon size and | 385 // Position close button in the top right corner sized to its icon size and |
| 353 // the label in the top left corner as tall as the button and extending to | 386 // the label in the top left corner as tall as the button and extending to |
| 354 // the button's left edge. | 387 // the button's left edge. |
| 355 // The rest of this container view serves as a shield to prevent input | 388 // The rest of this container view serves as a shield to prevent input |
| 356 // events from reaching the transformed window in overview. | 389 // events from reaching the transformed window in overview. |
| 357 gfx::Rect bounds(GetLocalBounds()); | 390 gfx::Rect bounds(GetLocalBounds()); |
| 358 bounds.Inset(kWindowSelectorMargin, kWindowSelectorMargin); | 391 bounds.Inset(kWindowSelectorMargin, kWindowSelectorMargin); |
| 359 gfx::Rect background_bounds(bounds); | 392 listener_button_->SetBoundsRect(bounds); |
| 360 background_bounds.set_height(close_button_->GetPreferredSize().height()); | 393 |
| 394 const int visible_height = close_button_->GetPreferredSize().height(); | |
| 395 gfx::Rect background_bounds(gfx::Rect(bounds.size())); | |
| 396 background_bounds.set_height(visible_height); | |
| 361 background_->SetBoundsRect(background_bounds); | 397 background_->SetBoundsRect(background_bounds); |
| 362 | 398 |
| 363 const int visible_height = close_button_->GetPreferredSize().height(); | 399 bounds = background_bounds; |
| 364 gfx::Insets label_padding(0, 0, bounds.height() - visible_height, | 400 bounds.Inset(kHorizontalLabelPadding, 0, |
| 365 visible_height); | 401 kHorizontalLabelPadding + visible_height, 0); |
| 366 label_->set_padding(label_padding); | |
| 367 label_->SetBoundsRect(bounds); | 402 label_->SetBoundsRect(bounds); |
| 368 bounds.set_x(bounds.right() - visible_height); | 403 |
| 404 bounds = background_bounds; | |
| 405 bounds.set_x(bounds.width() - visible_height); | |
| 369 bounds.set_width(visible_height); | 406 bounds.set_width(visible_height); |
| 370 bounds.set_height(visible_height); | |
| 371 close_button_->SetBoundsRect(bounds); | 407 close_button_->SetBoundsRect(bounds); |
| 372 } | 408 } |
| 373 | 409 |
| 410 const char* GetClassName() const override { return "CaptionContainerView"; } | |
| 411 | |
| 374 private: | 412 private: |
| 375 WindowSelectorItem::OverviewLabelButton* label_; | 413 ShieldButton* listener_button_; |
| 414 WindowSelectorItem::RoundedContainerView* background_; | |
| 415 views::Label* label_; | |
| 376 views::ImageButton* close_button_; | 416 views::ImageButton* close_button_; |
| 377 WindowSelectorItem::RoundedContainerView* background_; | |
| 378 | 417 |
| 379 DISALLOW_COPY_AND_ASSIGN(CaptionContainerView); | 418 DISALLOW_COPY_AND_ASSIGN(CaptionContainerView); |
| 380 }; | 419 }; |
| 381 | 420 |
| 382 WindowSelectorItem::WindowSelectorItem(WmWindow* window, | 421 WindowSelectorItem::WindowSelectorItem(WmWindow* window, |
| 383 WindowSelector* window_selector) | 422 WindowSelector* window_selector) |
| 384 : dimmed_(false), | 423 : dimmed_(false), |
| 385 root_window_(window->GetRootWindow()), | 424 root_window_(window->GetRootWindow()), |
| 386 transform_window_(window), | 425 transform_window_(window), |
| 387 in_bounds_update_(false), | 426 in_bounds_update_(false), |
| 388 selected_(false), | 427 selected_(false), |
| 389 caption_container_view_(nullptr), | 428 caption_container_view_(nullptr), |
| 390 window_label_button_view_(nullptr), | 429 window_label_view_(nullptr), |
| 391 close_button_(new OverviewCloseButton(this)), | 430 close_button_(new OverviewCloseButton(this)), |
| 392 window_selector_(window_selector), | 431 window_selector_(window_selector), |
| 393 background_view_(nullptr) { | 432 background_view_(nullptr) { |
| 394 CreateWindowLabel(window->GetTitle()); | 433 CreateWindowLabel(window->GetTitle()); |
| 395 GetWindow()->AddObserver(this); | 434 GetWindow()->AddObserver(this); |
| 396 } | 435 } |
| 397 | 436 |
| 398 WindowSelectorItem::~WindowSelectorItem() { | 437 WindowSelectorItem::~WindowSelectorItem() { |
| 399 GetWindow()->RemoveObserver(this); | 438 GetWindow()->RemoveObserver(this); |
| 400 } | 439 } |
| 401 | 440 |
| 402 WmWindow* WindowSelectorItem::GetWindow() { | 441 WmWindow* WindowSelectorItem::GetWindow() { |
| 403 return transform_window_.window(); | 442 return transform_window_.window(); |
| 404 } | 443 } |
| 405 | 444 |
| 406 void WindowSelectorItem::RestoreWindow() { | 445 void WindowSelectorItem::RestoreWindow() { |
| 407 window_label_button_view_->ResetListener(); | 446 caption_container_view_->listener_button()->ResetListener(); |
| 408 close_button_->ResetListener(); | 447 close_button_->ResetListener(); |
| 409 transform_window_.RestoreWindow(); | 448 transform_window_.RestoreWindow(); |
| 410 if (background_view_) { | 449 if (background_view_) { |
| 411 background_view_->OnItemRestored(); | 450 background_view_->OnItemRestored(); |
| 412 background_view_ = nullptr; | 451 background_view_ = nullptr; |
| 413 } | 452 } |
| 414 UpdateHeaderLayout( | 453 UpdateHeaderLayout( |
| 415 HeaderFadeInMode::EXIT, | 454 HeaderFadeInMode::EXIT, |
| 416 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS); | 455 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS); |
| 417 } | 456 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 animation_settings_shadow.SetTweenType( | 518 animation_settings_shadow.SetTweenType( |
| 480 selected ? gfx::Tween::FAST_OUT_LINEAR_IN | 519 selected ? gfx::Tween::FAST_OUT_LINEAR_IN |
| 481 : gfx::Tween::LINEAR_OUT_SLOW_IN); | 520 : gfx::Tween::LINEAR_OUT_SLOW_IN); |
| 482 animation_settings_shadow.SetPreemptionStrategy( | 521 animation_settings_shadow.SetPreemptionStrategy( |
| 483 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 522 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 484 shadow_->shadow_layer()->SetOpacity(selected ? 0.0f : 1.0f); | 523 shadow_->shadow_layer()->SetOpacity(selected ? 0.0f : 1.0f); |
| 485 } | 524 } |
| 486 } | 525 } |
| 487 | 526 |
| 488 void WindowSelectorItem::SendAccessibleSelectionEvent() { | 527 void WindowSelectorItem::SendAccessibleSelectionEvent() { |
| 489 window_label_button_view_->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, | 528 caption_container_view_->listener_button()->NotifyAccessibilityEvent( |
| 490 true); | 529 ui::AX_EVENT_SELECTION, true); |
| 491 } | 530 } |
| 492 | 531 |
| 493 void WindowSelectorItem::CloseWindow() { | 532 void WindowSelectorItem::CloseWindow() { |
| 494 gfx::Rect inset_bounds(target_bounds_); | 533 gfx::Rect inset_bounds(target_bounds_); |
| 495 inset_bounds.Inset(target_bounds_.width() * kPreCloseScale, | 534 inset_bounds.Inset(target_bounds_.width() * kPreCloseScale, |
| 496 target_bounds_.height() * kPreCloseScale); | 535 target_bounds_.height() * kPreCloseScale); |
| 497 OverviewAnimationType animation_type = | 536 OverviewAnimationType animation_type = |
| 498 OverviewAnimationType::OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM; | 537 OverviewAnimationType::OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM; |
| 499 // Scale down both the window and label. | 538 // Scale down both the window and label. |
| 500 SetBounds(inset_bounds, animation_type); | 539 SetBounds(inset_bounds, animation_type); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 521 SetOpacity(dimmed ? kDimmedItemOpacity : 1.0f); | 560 SetOpacity(dimmed ? kDimmedItemOpacity : 1.0f); |
| 522 } | 561 } |
| 523 | 562 |
| 524 void WindowSelectorItem::ButtonPressed(views::Button* sender, | 563 void WindowSelectorItem::ButtonPressed(views::Button* sender, |
| 525 const ui::Event& event) { | 564 const ui::Event& event) { |
| 526 if (sender == close_button_) { | 565 if (sender == close_button_) { |
| 527 WmShell::Get()->RecordUserMetricsAction(UMA_WINDOW_OVERVIEW_CLOSE_BUTTON); | 566 WmShell::Get()->RecordUserMetricsAction(UMA_WINDOW_OVERVIEW_CLOSE_BUTTON); |
| 528 CloseWindow(); | 567 CloseWindow(); |
| 529 return; | 568 return; |
| 530 } | 569 } |
| 531 CHECK(sender == window_label_button_view_); | 570 CHECK(sender == caption_container_view_->listener_button()); |
| 532 window_selector_->SelectWindow(transform_window_.window()); | 571 window_selector_->SelectWindow(transform_window_.window()); |
| 533 } | 572 } |
| 534 | 573 |
| 535 void WindowSelectorItem::OnWindowDestroying(WmWindow* window) { | 574 void WindowSelectorItem::OnWindowDestroying(WmWindow* window) { |
| 536 window->RemoveObserver(this); | 575 window->RemoveObserver(this); |
| 537 transform_window_.OnWindowDestroyed(); | 576 transform_window_.OnWindowDestroyed(); |
| 538 } | 577 } |
| 539 | 578 |
| 540 void WindowSelectorItem::OnWindowTitleChanged(WmWindow* window) { | 579 void WindowSelectorItem::OnWindowTitleChanged(WmWindow* window) { |
| 541 // TODO(flackr): Maybe add the new title to a vector of titles so that we can | 580 // TODO(flackr): Maybe add the new title to a vector of titles so that we can |
| 542 // filter any of the titles the window had while in the overview session. | 581 // filter any of the titles the window had while in the overview session. |
| 543 window_label_button_view_->SetText(window->GetTitle()); | 582 window_label_view_->SetText(window->GetTitle()); |
| 544 UpdateCloseButtonAccessibilityName(); | 583 UpdateButtonAccessibilityName(); |
| 545 } | 584 } |
| 546 | 585 |
| 547 float WindowSelectorItem::GetItemScale(const gfx::Size& size) { | 586 float WindowSelectorItem::GetItemScale(const gfx::Size& size) { |
| 548 gfx::Size inset_size(size.width(), size.height() - 2 * kWindowMargin); | 587 gfx::Size inset_size(size.width(), size.height() - 2 * kWindowMargin); |
| 549 return ScopedTransformOverviewWindow::GetItemScale( | 588 return ScopedTransformOverviewWindow::GetItemScale( |
| 550 transform_window_.GetTargetBoundsInScreen().size(), inset_size, | 589 transform_window_.GetTargetBoundsInScreen().size(), inset_size, |
| 551 transform_window_.GetTopInset(), | 590 transform_window_.GetTopInset(), |
| 552 close_button_->GetPreferredSize().height()); | 591 close_button_->GetPreferredSize().height()); |
| 553 } | 592 } |
| 554 | 593 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 580 | 619 |
| 581 void WindowSelectorItem::SetOpacity(float opacity) { | 620 void WindowSelectorItem::SetOpacity(float opacity) { |
| 582 window_label_->SetOpacity(opacity); | 621 window_label_->SetOpacity(opacity); |
| 583 if (background_view_) { | 622 if (background_view_) { |
| 584 background_view_->AnimateBackgroundOpacity( | 623 background_view_->AnimateBackgroundOpacity( |
| 585 selected_ ? 0.f : kHeaderOpacity * opacity); | 624 selected_ ? 0.f : kHeaderOpacity * opacity); |
| 586 } | 625 } |
| 587 transform_window_.SetOpacity(opacity); | 626 transform_window_.SetOpacity(opacity); |
| 588 } | 627 } |
| 589 | 628 |
| 590 void WindowSelectorItem::UpdateWindowLabel( | |
| 591 const gfx::Rect& window_bounds, | |
| 592 OverviewAnimationType animation_type) { | |
| 593 if (!window_label_->IsVisible()) { | |
| 594 window_label_->Show(); | |
| 595 SetupFadeInAfterLayout(window_label_.get()); | |
| 596 } | |
| 597 | |
| 598 gfx::Rect label_bounds = root_window_->ConvertRectFromScreen(window_bounds); | |
| 599 window_label_button_view_->set_padding( | |
| 600 gfx::Insets(label_bounds.height() - kVerticalLabelPadding, 0, 0, 0)); | |
| 601 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = | |
| 602 ScopedOverviewAnimationSettingsFactory::Get() | |
| 603 ->CreateOverviewAnimationSettings( | |
| 604 animation_type, | |
| 605 WmLookup::Get()->GetWindowForWidget(window_label_.get())); | |
| 606 | |
| 607 WmWindow* window_label_window = | |
| 608 WmLookup::Get()->GetWindowForWidget(window_label_.get()); | |
| 609 window_label_window->SetBounds(label_bounds); | |
| 610 } | |
| 611 | |
| 612 void WindowSelectorItem::CreateWindowLabel(const base::string16& title) { | 629 void WindowSelectorItem::CreateWindowLabel(const base::string16& title) { |
| 613 background_view_ = new RoundedContainerView(this, transform_window_.window(), | 630 background_view_ = new RoundedContainerView(this, transform_window_.window(), |
| 614 kLabelBackgroundRadius, | 631 kLabelBackgroundRadius, |
| 615 transform_window_.GetTopColor()); | 632 transform_window_.GetTopColor()); |
| 616 // |background_view_| will get added as a child to CaptionContainerView. | 633 // |background_view_| will get added as a child to CaptionContainerView. |
| 617 views::Widget::InitParams params_label; | 634 views::Widget::InitParams params_label; |
| 618 params_label.type = views::Widget::InitParams::TYPE_POPUP; | 635 params_label.type = views::Widget::InitParams::TYPE_POPUP; |
| 619 params_label.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 636 params_label.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 620 params_label.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 637 params_label.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 621 params_label.visible_on_all_workspaces = true; | 638 params_label.visible_on_all_workspaces = true; |
| 639 params_label.layer_type = ui::LAYER_NOT_DRAWN; | |
| 622 params_label.name = "OverviewModeLabel"; | 640 params_label.name = "OverviewModeLabel"; |
| 623 params_label.activatable = | 641 params_label.activatable = |
| 624 views::Widget::InitParams::Activatable::ACTIVATABLE_DEFAULT; | 642 views::Widget::InitParams::Activatable::ACTIVATABLE_DEFAULT; |
| 625 params_label.accept_events = true; | 643 params_label.accept_events = true; |
| 626 window_label_.reset(new views::Widget); | 644 window_label_.reset(new views::Widget); |
| 627 root_window_->GetRootWindowController() | 645 root_window_->GetRootWindowController() |
| 628 ->ConfigureWidgetInitParamsForContainer( | 646 ->ConfigureWidgetInitParamsForContainer( |
| 629 window_label_.get(), | 647 window_label_.get(), |
| 630 transform_window_.window()->GetParent()->GetShellWindowId(), | 648 transform_window_.window()->GetParent()->GetShellWindowId(), |
| 631 ¶ms_label); | 649 ¶ms_label); |
| 632 window_label_->set_focus_on_creation(false); | 650 window_label_->set_focus_on_creation(false); |
| 633 window_label_->Init(params_label); | 651 window_label_->Init(params_label); |
| 634 window_label_button_view_ = new OverviewLabelButton(this, title); | 652 window_label_view_ = new OverviewLabel(title); |
| 635 window_label_button_view_->SetBorder(views::NullBorder()); | |
| 636 window_label_button_view_->SetEnabledTextColors(kLabelColor); | |
| 637 window_label_button_view_->set_animate_on_state_change(false); | |
| 638 WmWindow* label_window = | 653 WmWindow* label_window = |
| 639 WmLookup::Get()->GetWindowForWidget(window_label_.get()); | 654 WmLookup::Get()->GetWindowForWidget(window_label_.get()); |
| 640 if (transform_window_.GetTopInset()) { | 655 if (transform_window_.GetTopInset()) { |
| 641 // For windows with headers the overview header fades in above the | 656 // For windows with headers the overview header fades in above the |
| 642 // original window header. | 657 // original window header. |
| 643 label_window->GetParent()->StackChildAbove(label_window, | 658 label_window->GetParent()->StackChildAbove(label_window, |
| 644 transform_window_.window()); | 659 transform_window_.window()); |
| 645 } else { | 660 } else { |
| 646 // For tabbed windows the overview header slides from behind. The stacking | 661 // For tabbed windows the overview header slides from behind. The stacking |
| 647 // is then corrected when the animation completes. | 662 // is then corrected when the animation completes. |
| 648 label_window->GetParent()->StackChildBelow(label_window, | 663 label_window->GetParent()->StackChildBelow(label_window, |
| 649 transform_window_.window()); | 664 transform_window_.window()); |
| 650 } | 665 } |
| 651 window_label_button_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
| 652 // Hint at the background color that the label will be drawn onto (for | |
| 653 // subpixel antialiasing). Does not actually set the background color. | |
| 654 window_label_button_view_->SetBackgroundColorHint(kLabelBackgroundColor); | |
| 655 caption_container_view_ = new CaptionContainerView( | 666 caption_container_view_ = new CaptionContainerView( |
| 656 window_label_button_view_, close_button_, background_view_); | 667 this, window_label_view_, close_button_, background_view_); |
| 657 window_label_->SetContentsView(caption_container_view_); | 668 window_label_->SetContentsView(caption_container_view_); |
| 658 window_label_button_view_->SetVisible(false); | 669 window_label_view_->SetVisible(false); |
| 659 window_label_->SetOpacity(0); | 670 window_label_->SetOpacity(0); |
| 660 window_label_->Show(); | 671 window_label_->Show(); |
| 661 | 672 |
| 662 // TODO(varkha): Restore shadows when programmatic shadows exist. | 673 // TODO(varkha): Restore shadows when programmatic shadows exist. |
| 663 // Note: current shadow implementation does not allow proper animation when | 674 // Note: current shadow implementation does not allow proper animation when |
| 664 // the parent layer bounds change during the animation since | 675 // the parent layer bounds change during the animation since |
| 665 // Shadow::UpdateLayerBounds() only happens before the animation starts. | 676 // Shadow::UpdateLayerBounds() only happens before the animation starts. |
| 666 if (ash::MaterialDesignController::GetMode() == | 677 if (ash::MaterialDesignController::GetMode() == |
| 667 ash::MaterialDesignController::Mode::MATERIAL_EXPERIMENTAL) { | 678 ash::MaterialDesignController::Mode::MATERIAL_EXPERIMENTAL) { |
| 668 shadow_.reset(new ::wm::Shadow()); | 679 shadow_.reset(new ::wm::Shadow()); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 697 // complete but some tests invoke animations with |NON_ZERO_DURATION| | 708 // complete but some tests invoke animations with |NON_ZERO_DURATION| |
| 698 // without waiting for completion so do it here. | 709 // without waiting for completion so do it here. |
| 699 background_view_->StopObservingLayerAnimations(); | 710 background_view_->StopObservingLayerAnimations(); |
| 700 // Make the header visible above the window. It will be faded out when | 711 // Make the header visible above the window. It will be faded out when |
| 701 // the Shutdown() is called. | 712 // the Shutdown() is called. |
| 702 background_view_->AnimateColor(gfx::Tween::EASE_OUT, | 713 background_view_->AnimateColor(gfx::Tween::EASE_OUT, |
| 703 kExitFadeInMilliseconds); | 714 kExitFadeInMilliseconds); |
| 704 background_view_->set_color(kLabelExitColor); | 715 background_view_->set_color(kLabelExitColor); |
| 705 } | 716 } |
| 706 } | 717 } |
| 707 if (!window_label_button_view_->visible()) { | 718 if (!window_label_view_->visible()) { |
| 708 window_label_button_view_->SetVisible(true); | 719 window_label_view_->SetVisible(true); |
| 709 SetupFadeInAfterLayout(window_label_.get()); | 720 SetupFadeInAfterLayout(window_label_.get()); |
| 710 } | 721 } |
| 711 WmWindow* window_label_window = | 722 WmWindow* window_label_window = |
| 712 WmLookup::Get()->GetWindowForWidget(window_label_.get()); | 723 WmLookup::Get()->GetWindowForWidget(window_label_.get()); |
| 713 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = | 724 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = |
| 714 ScopedOverviewAnimationSettingsFactory::Get() | 725 ScopedOverviewAnimationSettingsFactory::Get() |
| 715 ->CreateOverviewAnimationSettings(animation_type, | 726 ->CreateOverviewAnimationSettings(animation_type, |
| 716 window_label_window); | 727 window_label_window); |
| 717 // |window_label_window| covers both the transformed window and the header | 728 // |window_label_window| covers both the transformed window and the header |
| 718 // as well as the gap between the windows to prevent events from reaching | 729 // as well as the gap between the windows to prevent events from reaching |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 745 const float header_opacity = selected_ ? 0.f : kHeaderOpacity * opacity; | 756 const float header_opacity = selected_ ? 0.f : kHeaderOpacity * opacity; |
| 746 WmWindow* window_label_window = | 757 WmWindow* window_label_window = |
| 747 WmLookup::Get()->GetWindowForWidget(window_label_.get()); | 758 WmLookup::Get()->GetWindowForWidget(window_label_.get()); |
| 748 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_label = | 759 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_label = |
| 749 ScopedOverviewAnimationSettingsFactory::Get() | 760 ScopedOverviewAnimationSettingsFactory::Get() |
| 750 ->CreateOverviewAnimationSettings(animation_type, | 761 ->CreateOverviewAnimationSettings(animation_type, |
| 751 window_label_window); | 762 window_label_window); |
| 752 window_label_window->SetOpacity(header_opacity); | 763 window_label_window->SetOpacity(header_opacity); |
| 753 } | 764 } |
| 754 | 765 |
| 755 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() { | 766 void WindowSelectorItem::UpdateButtonAccessibilityName() { |
|
tdanderson
2017/01/16 23:43:29
I see you are removing IDS_ASH_OVERVIEW_CLOSE_ITEM
varkha
2017/01/17 17:39:05
This was already the case. I feel that the Ctrl+W
| |
| 756 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16( | 767 caption_container_view_->listener_button()->SetAccessibleName( |
| 757 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME, | 768 GetWindow()->GetTitle()); |
| 758 GetWindow()->GetTitle())); | |
| 759 } | 769 } |
| 760 | 770 |
| 761 void WindowSelectorItem::FadeOut(std::unique_ptr<views::Widget> widget) { | 771 void WindowSelectorItem::FadeOut(std::unique_ptr<views::Widget> widget) { |
| 762 widget->SetOpacity(1.f); | 772 widget->SetOpacity(1.f); |
| 763 | 773 |
| 764 // Fade out the widget. This animation continues past the lifetime of |this|. | 774 // Fade out the widget. This animation continues past the lifetime of |this|. |
| 765 WmWindow* widget_window = WmLookup::Get()->GetWindowForWidget(widget.get()); | 775 WmWindow* widget_window = WmLookup::Get()->GetWindowForWidget(widget.get()); |
| 766 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = | 776 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = |
| 767 ScopedOverviewAnimationSettingsFactory::Get() | 777 ScopedOverviewAnimationSettingsFactory::Get() |
| 768 ->CreateOverviewAnimationSettings( | 778 ->CreateOverviewAnimationSettings( |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 785 | 795 |
| 786 gfx::SlideAnimation* WindowSelectorItem::GetBackgroundViewAnimation() { | 796 gfx::SlideAnimation* WindowSelectorItem::GetBackgroundViewAnimation() { |
| 787 return background_view_ ? background_view_->animation() : nullptr; | 797 return background_view_ ? background_view_->animation() : nullptr; |
| 788 } | 798 } |
| 789 | 799 |
| 790 WmWindow* WindowSelectorItem::GetOverviewWindowForMinimizedStateForTest() { | 800 WmWindow* WindowSelectorItem::GetOverviewWindowForMinimizedStateForTest() { |
| 791 return transform_window_.GetOverviewWindowForMinimizedState(); | 801 return transform_window_.GetOverviewWindowForMinimizedState(); |
| 792 } | 802 } |
| 793 | 803 |
| 794 } // namespace ash | 804 } // namespace ash |
| OLD | NEW |