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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1751 } | 1754 } |
1752 | 1755 |
1753 ShelfItemDelegate::PerformedAction performed_action = | 1756 ShelfItemDelegate::PerformedAction performed_action = |
1754 item_manager_ | 1757 item_manager_ |
1755 ->GetShelfItemDelegate(model_->items()[last_pressed_index_].id) | 1758 ->GetShelfItemDelegate(model_->items()[last_pressed_index_].id) |
1756 ->ItemSelected(event); | 1759 ->ItemSelected(event); |
1757 | 1760 |
1758 shelf_button_pressed_metric_tracker_.ButtonPressed(event, sender, | 1761 shelf_button_pressed_metric_tracker_.ButtonPressed(event, sender, |
1759 performed_action); | 1762 performed_action); |
1760 | 1763 |
| 1764 // For the app list menu no TRIGGERED ink drop effect is needed and it |
| 1765 // handles its own ACTIVATED/DEACTIVATED states. |
1761 if (performed_action == ShelfItemDelegate::kNewWindowCreated || | 1766 if (performed_action == ShelfItemDelegate::kNewWindowCreated || |
1762 !ShowListMenuForView(model_->items()[last_pressed_index_], sender, | 1767 (performed_action != ShelfItemDelegate::kAppListMenuShown && |
1763 event, ink_drop)) { | 1768 !ShowListMenuForView(model_->items()[last_pressed_index_], sender, |
| 1769 event, ink_drop))) { |
1764 ink_drop->AnimateToState(views::InkDropState::ACTION_TRIGGERED); | 1770 ink_drop->AnimateToState(views::InkDropState::ACTION_TRIGGERED); |
1765 } | 1771 } |
1766 } | 1772 } |
1767 } | 1773 } |
1768 | 1774 |
1769 bool ShelfView::ShowListMenuForView(const ShelfItem& item, | 1775 bool ShelfView::ShowListMenuForView(const ShelfItem& item, |
1770 views::View* source, | 1776 views::View* source, |
1771 const ui::Event& event, | 1777 const ui::Event& event, |
1772 views::InkDrop* ink_drop) { | 1778 views::InkDrop* ink_drop) { |
1773 ShelfItemDelegate* item_delegate = | 1779 ShelfItemDelegate* item_delegate = |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1916 | 1922 |
1917 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { | 1923 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { |
1918 const gfx::Rect bounds = GetBoundsInScreen(); | 1924 const gfx::Rect bounds = GetBoundsInScreen(); |
1919 int distance = shelf_->SelectValueForShelfAlignment( | 1925 int distance = shelf_->SelectValueForShelfAlignment( |
1920 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), | 1926 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), |
1921 bounds.x() - coordinate.x()); | 1927 bounds.x() - coordinate.x()); |
1922 return distance > 0 ? distance : 0; | 1928 return distance > 0 ? distance : 0; |
1923 } | 1929 } |
1924 | 1930 |
1925 } // namespace ash | 1931 } // namespace ash |
OLD | NEW |