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

Side by Side Diff: ash/shelf/shelf_view.cc

Issue 2070143003: Add MD ink drop ripple to app list button (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@b612539_shelf_button_ripple
Patch Set: Rebased Created 4 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/shelf/shelf_view.h" 5 #include "ash/shelf/shelf_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 9
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 overflow_button_->OnShelfAlignmentChanged(); 435 overflow_button_->OnShelfAlignmentChanged();
436 LayoutToIdealBounds(); 436 LayoutToIdealBounds();
437 for (int i = 0; i < view_model_->view_size(); ++i) { 437 for (int i = 0; i < view_model_->view_size(); ++i) {
438 if (i >= first_visible_index_ && i <= last_visible_index_) 438 if (i >= first_visible_index_ && i <= last_visible_index_)
439 view_model_->view_at(i)->Layout(); 439 view_model_->view_at(i)->Layout();
440 } 440 }
441 tooltip_.Close(); 441 tooltip_.Close();
442 if (overflow_bubble_) 442 if (overflow_bubble_)
443 overflow_bubble_->Hide(); 443 overflow_bubble_->Hide();
444 // For crbug.com/587931, because AppListButton layout logic is in OnPaint. 444 // For crbug.com/587931, because AppListButton layout logic is in OnPaint.
445 views::View* app_list_button = GetAppListButtonView(); 445 AppListButton* app_list_button = GetAppListButton();
446 if (app_list_button) 446 if (app_list_button)
447 app_list_button->SchedulePaint(); 447 app_list_button->SchedulePaint();
448 } 448 }
449 449
450 void ShelfView::SchedulePaintForAllButtons() { 450 void ShelfView::SchedulePaintForAllButtons() {
451 for (int i = 0; i < view_model_->view_size(); ++i) { 451 for (int i = 0; i < view_model_->view_size(); ++i) {
452 if (i >= first_visible_index_ && i <= last_visible_index_) 452 if (i >= first_visible_index_ && i <= last_visible_index_)
453 view_model_->view_at(i)->SchedulePaint(); 453 view_model_->view_at(i)->SchedulePaint();
454 } 454 }
455 if (overflow_button_ && overflow_button_->visible()) 455 if (overflow_button_ && overflow_button_->visible())
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 } 511 }
512 512
513 bool ShelfView::IsShowingMenu() const { 513 bool ShelfView::IsShowingMenu() const {
514 return launcher_menu_runner_.get() && launcher_menu_runner_->IsRunning(); 514 return launcher_menu_runner_.get() && launcher_menu_runner_->IsRunning();
515 } 515 }
516 516
517 bool ShelfView::IsShowingOverflowBubble() const { 517 bool ShelfView::IsShowingOverflowBubble() const {
518 return overflow_bubble_.get() && overflow_bubble_->IsShowing(); 518 return overflow_bubble_.get() && overflow_bubble_->IsShowing();
519 } 519 }
520 520
521 views::View* ShelfView::GetAppListButtonView() const { 521 AppListButton* ShelfView::GetAppListButton() const {
522 for (int i = 0; i < model_->item_count(); ++i) { 522 for (int i = 0; i < model_->item_count(); ++i) {
523 if (model_->items()[i].type == TYPE_APP_LIST) 523 if (model_->items()[i].type == TYPE_APP_LIST) {
524 return view_model_->view_at(i); 524 views::View* view = view_model_->view_at(i);
525 CHECK_EQ(AppListButton::kViewClassName, view->GetClassName());
526 return static_cast<AppListButton*>(view);
527 }
525 } 528 }
526 529
527 NOTREACHED() << "Applist button not found"; 530 NOTREACHED() << "Applist button not found";
528 return nullptr; 531 return nullptr;
529 } 532 }
530 533
531 bool ShelfView::ShouldHideTooltip(const gfx::Point& cursor_location) const { 534 bool ShelfView::ShouldHideTooltip(const gfx::Point& cursor_location) const {
532 gfx::Rect tooltip_bounds; 535 gfx::Rect tooltip_bounds;
533 for (int i = 0; i < child_count(); ++i) { 536 for (int i = 0; i < child_count(); ++i) {
534 const views::View* child = child_at(i); 537 const views::View* child = child_at(i);
535 if (child != overflow_button_ && ShouldShowTooltipForView(child)) 538 if (child != overflow_button_ && ShouldShowTooltipForView(child))
536 tooltip_bounds.Union(child->GetMirroredBounds()); 539 tooltip_bounds.Union(child->GetMirroredBounds());
537 } 540 }
538 return !tooltip_bounds.Contains(cursor_location); 541 return !tooltip_bounds.Contains(cursor_location);
539 } 542 }
540 543
541 bool ShelfView::ShouldShowTooltipForView(const views::View* view) const { 544 bool ShelfView::ShouldShowTooltipForView(const views::View* view) const {
542 if (view == GetAppListButtonView() && 545 if (view == GetAppListButton() &&
543 Shell::GetInstance()->GetAppListTargetVisibility()) { 546 Shell::GetInstance()->GetAppListTargetVisibility()) {
544 return false; 547 return false;
545 } 548 }
546 const ShelfItem* item = ShelfItemForView(view); 549 const ShelfItem* item = ShelfItemForView(view);
547 if (!item) 550 if (!item)
548 return false; 551 return false;
549 return item_manager_->GetShelfItemDelegate(item->id)->ShouldShowTooltip(); 552 return item_manager_->GetShelfItemDelegate(item->id)->ShouldShowTooltip();
550 } 553 }
551 554
552 base::string16 ShelfView::GetTitleForView(const views::View* view) const { 555 base::string16 ShelfView::GetTitleForView(const views::View* view) const {
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 1758
1756 ShelfItemDelegate::PerformedAction performed_action = 1759 ShelfItemDelegate::PerformedAction performed_action =
1757 item_manager_ 1760 item_manager_
1758 ->GetShelfItemDelegate(model_->items()[last_pressed_index_].id) 1761 ->GetShelfItemDelegate(model_->items()[last_pressed_index_].id)
1759 ->ItemSelected(event); 1762 ->ItemSelected(event);
1760 1763
1761 shelf_button_pressed_metric_tracker_.ButtonPressed(event, sender, 1764 shelf_button_pressed_metric_tracker_.ButtonPressed(event, sender,
1762 performed_action); 1765 performed_action);
1763 1766
1764 if (performed_action == ShelfItemDelegate::kNewWindowCreated || 1767 if (performed_action == ShelfItemDelegate::kNewWindowCreated ||
1765 !ShowListMenuForView(model_->items()[last_pressed_index_], sender, 1768 (performed_action != ShelfItemDelegate::kAppListMenuShown &&
bruthig 2016/06/17 17:58:45 A doc saying the AppListButton handles the ink dro
mohsen 2016/06/18 06:25:15 Added a comment.
1766 event, ink_drop)) { 1769 !ShowListMenuForView(model_->items()[last_pressed_index_], sender,
1770 event, ink_drop))) {
1767 ink_drop->AnimateToState(views::InkDropState::ACTION_TRIGGERED); 1771 ink_drop->AnimateToState(views::InkDropState::ACTION_TRIGGERED);
1768 } 1772 }
1769 } 1773 }
1770 } 1774 }
1771 1775
1772 bool ShelfView::ShowListMenuForView(const ShelfItem& item, 1776 bool ShelfView::ShowListMenuForView(const ShelfItem& item,
1773 views::View* source, 1777 views::View* source,
1774 const ui::Event& event, 1778 const ui::Event& event,
1775 views::InkDrop* ink_drop) { 1779 views::InkDrop* ink_drop) {
1776 ShelfItemDelegate* item_delegate = 1780 ShelfItemDelegate* item_delegate =
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1919 1923
1920 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { 1924 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const {
1921 const gfx::Rect bounds = GetBoundsInScreen(); 1925 const gfx::Rect bounds = GetBoundsInScreen();
1922 int distance = shelf_->SelectValueForShelfAlignment( 1926 int distance = shelf_->SelectValueForShelfAlignment(
1923 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), 1927 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(),
1924 bounds.x() - coordinate.x()); 1928 bounds.x() - coordinate.x());
1925 return distance > 0 ? distance : 0; 1929 return distance > 0 ? distance : 0;
1926 } 1930 }
1927 1931
1928 } // namespace ash 1932 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698