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

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

Issue 2238903003: ash: Remove WmShelf::IsShowingOverflowBubble (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « ash/common/shelf/shelf_view.h ('k') | ash/common/shelf/wm_shelf.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/common/shelf/shelf_view.h" 5 #include "ash/common/shelf/shelf_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 9
10 #include "ash/common/ash_constants.h" 10 #include "ash/common/ash_constants.h"
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 return model_->GetShelfItemDelegate(item->id)->GetTitle(); 546 return model_->GetShelfItemDelegate(item->id)->GetTitle();
547 } 547 }
548 548
549 gfx::Rect ShelfView::GetVisibleItemsBoundsInScreen() { 549 gfx::Rect ShelfView::GetVisibleItemsBoundsInScreen() {
550 gfx::Size preferred_size = GetPreferredSize(); 550 gfx::Size preferred_size = GetPreferredSize();
551 gfx::Point origin(GetMirroredXWithWidthInView(0, preferred_size.width()), 0); 551 gfx::Point origin(GetMirroredXWithWidthInView(0, preferred_size.width()), 0);
552 ConvertPointToScreen(this, &origin); 552 ConvertPointToScreen(this, &origin);
553 return gfx::Rect(origin, preferred_size); 553 return gfx::Rect(origin, preferred_size);
554 } 554 }
555 555
556 void ShelfView::ButtonPressed(views::Button* sender,
James Cook 2016/08/11 22:02:12 This is moved unchanged.
msw 2016/08/11 22:06:21 Acknowledged.
557 const ui::Event& event,
558 views::InkDrop* ink_drop) {
559 if (sender == overflow_button_) {
560 ToggleOverflowBubble();
561 shelf_button_pressed_metric_tracker_.ButtonPressed(
562 event, sender, ShelfItemDelegate::kNoAction);
563 return;
564 }
565
566 // None of the checks in ShouldEventActivateButton() affects overflow button.
567 // So, it is safe to be checked after handling overflow button.
568 if (!ShouldEventActivateButton(sender, event))
569 return;
570
571 // Record the index for the last pressed shelf item.
572 last_pressed_index_ = view_model_->GetIndexOfView(sender);
573 DCHECK_LT(-1, last_pressed_index_);
574
575 // Place new windows on the same display as the button.
576 WmWindow* window = WmLookup::Get()->GetWindowForWidget(sender->GetWidget());
577 scoped_root_window_for_new_windows_.reset(
578 new ScopedRootWindowForNewWindows(window->GetRootWindow()));
579
580 // Slow down activation animations if shift key is pressed.
581 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> slowing_animations;
582 if (event.IsShiftDown()) {
583 slowing_animations.reset(new ui::ScopedAnimationDurationScaleMode(
584 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION));
585 }
586
587 // Collect usage statistics before we decide what to do with the click.
588 switch (model_->items()[last_pressed_index_].type) {
589 case TYPE_APP_SHORTCUT:
590 case TYPE_WINDOWED_APP:
591 case TYPE_PLATFORM_APP:
592 case TYPE_BROWSER_SHORTCUT:
593 WmShell::Get()->RecordUserMetricsAction(UMA_LAUNCHER_CLICK_ON_APP);
594 break;
595
596 case TYPE_APP_LIST:
597 WmShell::Get()->RecordUserMetricsAction(
598 UMA_LAUNCHER_CLICK_ON_APPLIST_BUTTON);
599 break;
600
601 case TYPE_APP_PANEL:
602 case TYPE_DIALOG:
603 case TYPE_IME_MENU:
604 break;
605
606 case TYPE_UNDEFINED:
607 NOTREACHED() << "ShelfItemType must be set.";
608 break;
609 }
610
611 ShelfItemDelegate::PerformedAction performed_action =
612 model_->GetShelfItemDelegate(model_->items()[last_pressed_index_].id)
613 ->ItemSelected(event);
614
615 shelf_button_pressed_metric_tracker_.ButtonPressed(event, sender,
616 performed_action);
617
618 // For the app list menu no TRIGGERED ink drop effect is needed and it
619 // handles its own ACTIVATED/DEACTIVATED states.
620 if (performed_action == ShelfItemDelegate::kNewWindowCreated ||
621 (performed_action != ShelfItemDelegate::kAppListMenuShown &&
622 !ShowListMenuForView(model_->items()[last_pressed_index_], sender, event,
623 ink_drop))) {
624 ink_drop->AnimateToState(views::InkDropState::ACTION_TRIGGERED);
625 }
626 // Allow the menu to clear |scoped_root_window_for_new_windows_| during
627 // OnMenuClosed.
628 if (!IsShowingMenu())
629 scoped_root_window_for_new_windows_.reset();
630 }
631
556 //////////////////////////////////////////////////////////////////////////////// 632 ////////////////////////////////////////////////////////////////////////////////
557 // ShelfView, FocusTraversable implementation: 633 // ShelfView, FocusTraversable implementation:
558 634
559 views::FocusSearch* ShelfView::GetFocusSearch() { 635 views::FocusSearch* ShelfView::GetFocusSearch() {
560 return focus_search_.get(); 636 return focus_search_.get();
561 } 637 }
562 638
563 views::FocusTraversable* ShelfView::GetFocusTraversableParent() { 639 views::FocusTraversable* ShelfView::GetFocusTraversableParent() {
564 return parent()->GetFocusTraversable(); 640 return parent()->GetFocusTraversable();
565 } 641 }
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1677 // dragged item is moved back to its initial position. AnimateToIdealBounds 1753 // dragged item is moved back to its initial position. AnimateToIdealBounds
1678 // will be called again when the new item is added to the |view_model_| but 1754 // will be called again when the new item is added to the |view_model_| but
1679 // at this time the |view_model_| is inconsistent with the |model_|. 1755 // at this time the |view_model_| is inconsistent with the |model_|.
1680 if (!cancelling_drag_model_changed_) 1756 if (!cancelling_drag_model_changed_)
1681 AnimateToIdealBounds(); 1757 AnimateToIdealBounds();
1682 } 1758 }
1683 1759
1684 void ShelfView::OnSetShelfItemDelegate(ShelfID id, 1760 void ShelfView::OnSetShelfItemDelegate(ShelfID id,
1685 ShelfItemDelegate* item_delegate) {} 1761 ShelfItemDelegate* item_delegate) {}
1686 1762
1687 void ShelfView::ButtonPressed(views::Button* sender,
1688 const ui::Event& event,
1689 views::InkDrop* ink_drop) {
1690 if (sender == overflow_button_) {
1691 ToggleOverflowBubble();
1692 shelf_button_pressed_metric_tracker_.ButtonPressed(
1693 event, sender, ShelfItemDelegate::kNoAction);
1694 return;
1695 }
1696
1697 // None of the checks in ShouldEventActivateButton() affects overflow button.
1698 // So, it is safe to be checked after handling overflow button.
1699 if (!ShouldEventActivateButton(sender, event))
1700 return;
1701
1702 // Record the index for the last pressed shelf item.
1703 last_pressed_index_ = view_model_->GetIndexOfView(sender);
1704 DCHECK_LT(-1, last_pressed_index_);
1705
1706 // Place new windows on the same display as the button.
1707 WmWindow* window = WmLookup::Get()->GetWindowForWidget(sender->GetWidget());
1708 scoped_root_window_for_new_windows_.reset(
1709 new ScopedRootWindowForNewWindows(window->GetRootWindow()));
1710
1711 // Slow down activation animations if shift key is pressed.
1712 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> slowing_animations;
1713 if (event.IsShiftDown()) {
1714 slowing_animations.reset(new ui::ScopedAnimationDurationScaleMode(
1715 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION));
1716 }
1717
1718 // Collect usage statistics before we decide what to do with the click.
1719 switch (model_->items()[last_pressed_index_].type) {
1720 case TYPE_APP_SHORTCUT:
1721 case TYPE_WINDOWED_APP:
1722 case TYPE_PLATFORM_APP:
1723 case TYPE_BROWSER_SHORTCUT:
1724 WmShell::Get()->RecordUserMetricsAction(UMA_LAUNCHER_CLICK_ON_APP);
1725 break;
1726
1727 case TYPE_APP_LIST:
1728 WmShell::Get()->RecordUserMetricsAction(
1729 UMA_LAUNCHER_CLICK_ON_APPLIST_BUTTON);
1730 break;
1731
1732 case TYPE_APP_PANEL:
1733 case TYPE_DIALOG:
1734 case TYPE_IME_MENU:
1735 break;
1736
1737 case TYPE_UNDEFINED:
1738 NOTREACHED() << "ShelfItemType must be set.";
1739 break;
1740 }
1741
1742 ShelfItemDelegate::PerformedAction performed_action =
1743 model_->GetShelfItemDelegate(model_->items()[last_pressed_index_].id)
1744 ->ItemSelected(event);
1745
1746 shelf_button_pressed_metric_tracker_.ButtonPressed(event, sender,
1747 performed_action);
1748
1749 // For the app list menu no TRIGGERED ink drop effect is needed and it
1750 // handles its own ACTIVATED/DEACTIVATED states.
1751 if (performed_action == ShelfItemDelegate::kNewWindowCreated ||
1752 (performed_action != ShelfItemDelegate::kAppListMenuShown &&
1753 !ShowListMenuForView(model_->items()[last_pressed_index_], sender, event,
1754 ink_drop))) {
1755 ink_drop->AnimateToState(views::InkDropState::ACTION_TRIGGERED);
1756 }
1757 // Allow the menu to clear |scoped_root_window_for_new_windows_| during
1758 // OnMenuClosed.
1759 if (!IsShowingMenu())
1760 scoped_root_window_for_new_windows_.reset();
1761 }
1762
1763 bool ShelfView::ShowListMenuForView(const ShelfItem& item, 1763 bool ShelfView::ShowListMenuForView(const ShelfItem& item,
1764 views::View* source, 1764 views::View* source,
1765 const ui::Event& event, 1765 const ui::Event& event,
1766 views::InkDrop* ink_drop) { 1766 views::InkDrop* ink_drop) {
1767 ShelfItemDelegate* item_delegate = model_->GetShelfItemDelegate(item.id); 1767 ShelfItemDelegate* item_delegate = model_->GetShelfItemDelegate(item.id);
1768 std::unique_ptr<ui::MenuModel> list_menu_model( 1768 std::unique_ptr<ui::MenuModel> list_menu_model(
1769 item_delegate->CreateApplicationMenu(event.flags())); 1769 item_delegate->CreateApplicationMenu(event.flags()));
1770 1770
1771 // Make sure we have a menu and it has at least two items in addition to the 1771 // Make sure we have a menu and it has at least two items in addition to the
1772 // application title and the 3 spacing separators. 1772 // application title and the 3 spacing separators.
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1924 1924
1925 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { 1925 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const {
1926 const gfx::Rect bounds = GetBoundsInScreen(); 1926 const gfx::Rect bounds = GetBoundsInScreen();
1927 int distance = wm_shelf_->SelectValueForShelfAlignment( 1927 int distance = wm_shelf_->SelectValueForShelfAlignment(
1928 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), 1928 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(),
1929 bounds.x() - coordinate.x()); 1929 bounds.x() - coordinate.x());
1930 return distance > 0 ? distance : 0; 1930 return distance > 0 ? distance : 0;
1931 } 1931 }
1932 1932
1933 } // namespace ash 1933 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/shelf/shelf_view.h ('k') | ash/common/shelf/wm_shelf.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698