OLD | NEW |
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/aura/wm_window_aura.h" | 10 #include "ash/aura/wm_window_aura.h" |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 overflow_button_->OnShelfAlignmentChanged(); | 431 overflow_button_->OnShelfAlignmentChanged(); |
432 LayoutToIdealBounds(); | 432 LayoutToIdealBounds(); |
433 for (int i = 0; i < view_model_->view_size(); ++i) { | 433 for (int i = 0; i < view_model_->view_size(); ++i) { |
434 if (i >= first_visible_index_ && i <= last_visible_index_) | 434 if (i >= first_visible_index_ && i <= last_visible_index_) |
435 view_model_->view_at(i)->Layout(); | 435 view_model_->view_at(i)->Layout(); |
436 } | 436 } |
437 tooltip_.Close(); | 437 tooltip_.Close(); |
438 if (overflow_bubble_) | 438 if (overflow_bubble_) |
439 overflow_bubble_->Hide(); | 439 overflow_bubble_->Hide(); |
440 // For crbug.com/587931, because AppListButton layout logic is in OnPaint. | 440 // For crbug.com/587931, because AppListButton layout logic is in OnPaint. |
441 views::View* app_list_button = GetAppListButtonView(); | 441 AppListButton* app_list_button = GetAppListButton(); |
442 if (app_list_button) | 442 if (app_list_button) |
443 app_list_button->SchedulePaint(); | 443 app_list_button->SchedulePaint(); |
444 } | 444 } |
445 | 445 |
446 void ShelfView::SchedulePaintForAllButtons() { | 446 void ShelfView::SchedulePaintForAllButtons() { |
447 for (int i = 0; i < view_model_->view_size(); ++i) { | 447 for (int i = 0; i < view_model_->view_size(); ++i) { |
448 if (i >= first_visible_index_ && i <= last_visible_index_) | 448 if (i >= first_visible_index_ && i <= last_visible_index_) |
449 view_model_->view_at(i)->SchedulePaint(); | 449 view_model_->view_at(i)->SchedulePaint(); |
450 } | 450 } |
451 if (overflow_button_ && overflow_button_->visible()) | 451 if (overflow_button_ && overflow_button_->visible()) |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 } | 505 } |
506 | 506 |
507 bool ShelfView::IsShowingMenu() const { | 507 bool ShelfView::IsShowingMenu() const { |
508 return launcher_menu_runner_.get() && launcher_menu_runner_->IsRunning(); | 508 return launcher_menu_runner_.get() && launcher_menu_runner_->IsRunning(); |
509 } | 509 } |
510 | 510 |
511 bool ShelfView::IsShowingOverflowBubble() const { | 511 bool ShelfView::IsShowingOverflowBubble() const { |
512 return overflow_bubble_.get() && overflow_bubble_->IsShowing(); | 512 return overflow_bubble_.get() && overflow_bubble_->IsShowing(); |
513 } | 513 } |
514 | 514 |
515 views::View* ShelfView::GetAppListButtonView() const { | 515 AppListButton* ShelfView::GetAppListButton() const { |
516 for (int i = 0; i < model_->item_count(); ++i) { | 516 for (int i = 0; i < model_->item_count(); ++i) { |
517 if (model_->items()[i].type == TYPE_APP_LIST) | 517 if (model_->items()[i].type == TYPE_APP_LIST) { |
518 return view_model_->view_at(i); | 518 views::View* view = view_model_->view_at(i); |
| 519 CHECK_EQ(AppListButton::kViewClassName, view->GetClassName()); |
| 520 return static_cast<AppListButton*>(view); |
| 521 } |
519 } | 522 } |
520 | 523 |
521 NOTREACHED() << "Applist button not found"; | 524 NOTREACHED() << "Applist button not found"; |
522 return nullptr; | 525 return nullptr; |
523 } | 526 } |
524 | 527 |
525 bool ShelfView::ShouldHideTooltip(const gfx::Point& cursor_location) const { | 528 bool ShelfView::ShouldHideTooltip(const gfx::Point& cursor_location) const { |
526 gfx::Rect tooltip_bounds; | 529 gfx::Rect tooltip_bounds; |
527 for (int i = 0; i < child_count(); ++i) { | 530 for (int i = 0; i < child_count(); ++i) { |
528 const views::View* child = child_at(i); | 531 const views::View* child = child_at(i); |
529 if (child != overflow_button_ && ShouldShowTooltipForView(child)) | 532 if (child != overflow_button_ && ShouldShowTooltipForView(child)) |
530 tooltip_bounds.Union(child->GetMirroredBounds()); | 533 tooltip_bounds.Union(child->GetMirroredBounds()); |
531 } | 534 } |
532 return !tooltip_bounds.Contains(cursor_location); | 535 return !tooltip_bounds.Contains(cursor_location); |
533 } | 536 } |
534 | 537 |
535 bool ShelfView::ShouldShowTooltipForView(const views::View* view) const { | 538 bool ShelfView::ShouldShowTooltipForView(const views::View* view) const { |
536 if (view == GetAppListButtonView() && | 539 if (view == GetAppListButton() && |
537 Shell::GetInstance()->GetAppListTargetVisibility()) { | 540 Shell::GetInstance()->GetAppListTargetVisibility()) { |
538 return false; | 541 return false; |
539 } | 542 } |
540 const ShelfItem* item = ShelfItemForView(view); | 543 const ShelfItem* item = ShelfItemForView(view); |
541 if (!item) | 544 if (!item) |
542 return false; | 545 return false; |
543 return item_manager_->GetShelfItemDelegate(item->id)->ShouldShowTooltip(); | 546 return item_manager_->GetShelfItemDelegate(item->id)->ShouldShowTooltip(); |
544 } | 547 } |
545 | 548 |
546 base::string16 ShelfView::GetTitleForView(const views::View* view) const { | 549 base::string16 ShelfView::GetTitleForView(const views::View* view) const { |
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1737 } | 1740 } |
1738 | 1741 |
1739 ShelfItemDelegate::PerformedAction performed_action = | 1742 ShelfItemDelegate::PerformedAction performed_action = |
1740 item_manager_ | 1743 item_manager_ |
1741 ->GetShelfItemDelegate(model_->items()[last_pressed_index_].id) | 1744 ->GetShelfItemDelegate(model_->items()[last_pressed_index_].id) |
1742 ->ItemSelected(event); | 1745 ->ItemSelected(event); |
1743 | 1746 |
1744 shelf_button_pressed_metric_tracker_.ButtonPressed(event, sender, | 1747 shelf_button_pressed_metric_tracker_.ButtonPressed(event, sender, |
1745 performed_action); | 1748 performed_action); |
1746 | 1749 |
| 1750 // For the app list menu no TRIGGERED ink drop effect is needed and it |
| 1751 // handles its own ACTIVATED/DEACTIVATED states. |
1747 if (performed_action == ShelfItemDelegate::kNewWindowCreated || | 1752 if (performed_action == ShelfItemDelegate::kNewWindowCreated || |
1748 !ShowListMenuForView(model_->items()[last_pressed_index_], sender, | 1753 (performed_action != ShelfItemDelegate::kAppListMenuShown && |
1749 event, ink_drop)) { | 1754 !ShowListMenuForView(model_->items()[last_pressed_index_], sender, |
| 1755 event, ink_drop))) { |
1750 ink_drop->AnimateToState(views::InkDropState::ACTION_TRIGGERED); | 1756 ink_drop->AnimateToState(views::InkDropState::ACTION_TRIGGERED); |
1751 } | 1757 } |
1752 } | 1758 } |
1753 } | 1759 } |
1754 | 1760 |
1755 bool ShelfView::ShowListMenuForView(const ShelfItem& item, | 1761 bool ShelfView::ShowListMenuForView(const ShelfItem& item, |
1756 views::View* source, | 1762 views::View* source, |
1757 const ui::Event& event, | 1763 const ui::Event& event, |
1758 views::InkDrop* ink_drop) { | 1764 views::InkDrop* ink_drop) { |
1759 ShelfItemDelegate* item_delegate = | 1765 ShelfItemDelegate* item_delegate = |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1901 | 1907 |
1902 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { | 1908 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { |
1903 const gfx::Rect bounds = GetBoundsInScreen(); | 1909 const gfx::Rect bounds = GetBoundsInScreen(); |
1904 int distance = shelf_->SelectValueForShelfAlignment( | 1910 int distance = shelf_->SelectValueForShelfAlignment( |
1905 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), | 1911 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), |
1906 bounds.x() - coordinate.x()); | 1912 bounds.x() - coordinate.x()); |
1907 return distance > 0 ? distance : 0; | 1913 return distance > 0 ? distance : 0; |
1908 } | 1914 } |
1909 | 1915 |
1910 } // namespace ash | 1916 } // namespace ash |
OLD | NEW |