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

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

Issue 2518423003: Combine shelf platform and windowed app types. (Closed)
Patch Set: Update platform-app test support; address comment; format. Created 4 years 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/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 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 // Slow down activation animations if shift key is pressed. 578 // Slow down activation animations if shift key is pressed.
579 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> slowing_animations; 579 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> slowing_animations;
580 if (event.IsShiftDown()) { 580 if (event.IsShiftDown()) {
581 slowing_animations.reset(new ui::ScopedAnimationDurationScaleMode( 581 slowing_animations.reset(new ui::ScopedAnimationDurationScaleMode(
582 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION)); 582 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION));
583 } 583 }
584 584
585 // Collect usage statistics before we decide what to do with the click. 585 // Collect usage statistics before we decide what to do with the click.
586 switch (model_->items()[last_pressed_index_].type) { 586 switch (model_->items()[last_pressed_index_].type) {
587 case TYPE_APP_SHORTCUT: 587 case TYPE_APP_SHORTCUT:
588 case TYPE_WINDOWED_APP:
589 case TYPE_PLATFORM_APP:
590 case TYPE_BROWSER_SHORTCUT: 588 case TYPE_BROWSER_SHORTCUT:
589 case TYPE_APP:
James Cook 2016/11/28 22:57:47 Thanks for reordering. These details help.
msw 2016/11/28 23:47:41 Acknowledged.
591 WmShell::Get()->RecordUserMetricsAction(UMA_LAUNCHER_CLICK_ON_APP); 590 WmShell::Get()->RecordUserMetricsAction(UMA_LAUNCHER_CLICK_ON_APP);
592 break; 591 break;
593 592
594 case TYPE_APP_LIST: 593 case TYPE_APP_LIST:
595 WmShell::Get()->RecordUserMetricsAction( 594 WmShell::Get()->RecordUserMetricsAction(
596 UMA_LAUNCHER_CLICK_ON_APPLIST_BUTTON); 595 UMA_LAUNCHER_CLICK_ON_APPLIST_BUTTON);
597 break; 596 break;
598 597
599 case TYPE_APP_PANEL: 598 case TYPE_APP_PANEL:
600 case TYPE_DIALOG: 599 case TYPE_DIALOG:
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 // padding of the first gets properly transferred to the new first item. 1064 // padding of the first gets properly transferred to the new first item.
1066 if (i && view->border()) 1065 if (i && view->border())
1067 view->SetBorder(views::NullBorder()); 1066 view->SetBorder(views::NullBorder());
1068 } 1067 }
1069 overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds); 1068 overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds);
1070 } 1069 }
1071 1070
1072 views::View* ShelfView::CreateViewForItem(const ShelfItem& item) { 1071 views::View* ShelfView::CreateViewForItem(const ShelfItem& item) {
1073 views::View* view = nullptr; 1072 views::View* view = nullptr;
1074 switch (item.type) { 1073 switch (item.type) {
1074 case TYPE_APP_PANEL:
1075 case TYPE_APP_SHORTCUT:
1075 case TYPE_BROWSER_SHORTCUT: 1076 case TYPE_BROWSER_SHORTCUT:
1076 case TYPE_APP_SHORTCUT: 1077 case TYPE_APP:
1077 case TYPE_WINDOWED_APP:
1078 case TYPE_PLATFORM_APP:
1079 case TYPE_DIALOG: 1078 case TYPE_DIALOG:
1080 case TYPE_APP_PANEL:
1081 case TYPE_IME_MENU: { 1079 case TYPE_IME_MENU: {
1082 ShelfButton* button = new ShelfButton(this, this); 1080 ShelfButton* button = new ShelfButton(this, this);
1083 button->SetImage(item.image); 1081 button->SetImage(item.image);
1084 ReflectItemStatus(item, button); 1082 ReflectItemStatus(item, button);
1085 view = button; 1083 view = button;
1086 break; 1084 break;
1087 } 1085 }
1088 1086
1089 case TYPE_APP_LIST: { 1087 case TYPE_APP_LIST: {
1090 view = new AppListButton(this, this, wm_shelf_); 1088 view = new AppListButton(this, this, wm_shelf_);
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1394 return (type == TYPE_APP_SHORTCUT && delegate_->IsAppPinned(app_id)) 1392 return (type == TYPE_APP_SHORTCUT && delegate_->IsAppPinned(app_id))
1395 ? REMOVABLE 1393 ? REMOVABLE
1396 : DRAGGABLE; 1394 : DRAGGABLE;
1397 } 1395 }
1398 1396
1399 bool ShelfView::SameDragType(ShelfItemType typea, ShelfItemType typeb) const { 1397 bool ShelfView::SameDragType(ShelfItemType typea, ShelfItemType typeb) const {
1400 switch (typea) { 1398 switch (typea) {
1401 case TYPE_APP_SHORTCUT: 1399 case TYPE_APP_SHORTCUT:
1402 case TYPE_BROWSER_SHORTCUT: 1400 case TYPE_BROWSER_SHORTCUT:
1403 return (typeb == TYPE_APP_SHORTCUT || typeb == TYPE_BROWSER_SHORTCUT); 1401 return (typeb == TYPE_APP_SHORTCUT || typeb == TYPE_BROWSER_SHORTCUT);
1402 case TYPE_APP_PANEL:
1404 case TYPE_APP_LIST: 1403 case TYPE_APP_LIST:
1405 case TYPE_PLATFORM_APP: 1404 case TYPE_APP:
1406 case TYPE_WINDOWED_APP:
1407 case TYPE_APP_PANEL:
1408 case TYPE_DIALOG: 1405 case TYPE_DIALOG:
1409 case TYPE_IME_MENU: 1406 case TYPE_IME_MENU:
1410 return typeb == typea; 1407 return typeb == typea;
1411 case TYPE_UNDEFINED: 1408 case TYPE_UNDEFINED:
1412 NOTREACHED() << "ShelfItemType must be set."; 1409 NOTREACHED() << "ShelfItemType must be set.";
1413 return false; 1410 return false;
1414 } 1411 }
1415 NOTREACHED(); 1412 NOTREACHED();
1416 return false; 1413 return false;
1417 } 1414 }
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1718 new_view->SetBoundsRect(old_view->bounds()); 1715 new_view->SetBoundsRect(old_view->bounds());
1719 if (overflow_button_ && overflow_button_->visible()) 1716 if (overflow_button_ && overflow_button_->visible())
1720 AnimateToIdealBounds(); 1717 AnimateToIdealBounds();
1721 else 1718 else
1722 bounds_animator_->AnimateViewTo(new_view, old_ideal_bounds); 1719 bounds_animator_->AnimateViewTo(new_view, old_ideal_bounds);
1723 return; 1720 return;
1724 } 1721 }
1725 1722
1726 views::View* view = view_model_->view_at(model_index); 1723 views::View* view = view_model_->view_at(model_index);
1727 switch (item.type) { 1724 switch (item.type) {
1725 case TYPE_APP_PANEL:
1726 case TYPE_APP_SHORTCUT:
1728 case TYPE_BROWSER_SHORTCUT: 1727 case TYPE_BROWSER_SHORTCUT:
1729 // Fallthrough for the new Shelf since it needs to show the activation 1728 case TYPE_APP:
1730 // change as well.
1731 case TYPE_APP_SHORTCUT:
1732 case TYPE_WINDOWED_APP:
1733 case TYPE_PLATFORM_APP:
1734 case TYPE_DIALOG: 1729 case TYPE_DIALOG:
1735 case TYPE_APP_PANEL:
1736 case TYPE_IME_MENU: { 1730 case TYPE_IME_MENU: {
1737 CHECK_EQ(ShelfButton::kViewClassName, view->GetClassName()); 1731 CHECK_EQ(ShelfButton::kViewClassName, view->GetClassName());
1738 ShelfButton* button = static_cast<ShelfButton*>(view); 1732 ShelfButton* button = static_cast<ShelfButton*>(view);
1739 ReflectItemStatus(item, button); 1733 ReflectItemStatus(item, button);
1740 button->SetImage(item.image); 1734 button->SetImage(item.image);
1741 button->SchedulePaint(); 1735 button->SchedulePaint();
1742 break; 1736 break;
1743 } 1737 }
1744 1738
1745 default: 1739 default:
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 1917
1924 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { 1918 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const {
1925 const gfx::Rect bounds = GetBoundsInScreen(); 1919 const gfx::Rect bounds = GetBoundsInScreen();
1926 int distance = wm_shelf_->SelectValueForShelfAlignment( 1920 int distance = wm_shelf_->SelectValueForShelfAlignment(
1927 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), 1921 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(),
1928 bounds.x() - coordinate.x()); 1922 bounds.x() - coordinate.x());
1929 return distance > 0 ? distance : 0; 1923 return distance > 0 ? distance : 0;
1930 } 1924 }
1931 1925
1932 } // namespace ash 1926 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698