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/launcher/launcher_view.h" | 5 #include "ash/launcher/launcher_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/ash_constants.h" | 9 #include "ash/ash_constants.h" |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
(...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1510 else | 1510 else |
1511 app_list_button->StopLoadingAnimation(); | 1511 app_list_button->StopLoadingAnimation(); |
1512 } | 1512 } |
1513 | 1513 |
1514 void LauncherView::PointerPressedOnButton(views::View* view, | 1514 void LauncherView::PointerPressedOnButton(views::View* view, |
1515 Pointer pointer, | 1515 Pointer pointer, |
1516 const ui::LocatedEvent& event) { | 1516 const ui::LocatedEvent& event) { |
1517 if (drag_view_) | 1517 if (drag_view_) |
1518 return; | 1518 return; |
1519 | 1519 |
1520 tooltip_->Close(); | |
1521 int index = view_model_->GetIndexOfView(view); | 1520 int index = view_model_->GetIndexOfView(view); |
1522 if (index == -1) | 1521 if (index == -1) |
1523 return; | 1522 return; |
1524 | 1523 |
1525 LauncherItemDelegate* item_delegate = item_manager_->GetLauncherItemDelegate( | 1524 LauncherItemDelegate* item_delegate = item_manager_->GetLauncherItemDelegate( |
1526 model_->items()[index].type); | 1525 model_->items()[index].type); |
1527 if (view_model_->view_size() <= 1 || | 1526 if (view_model_->view_size() <= 1 || |
1528 !item_delegate->IsDraggable(model_->items()[index])) | 1527 !item_delegate->IsDraggable(model_->items()[index])) |
1529 return; // View is being deleted or not draggable, ignore request. | 1528 return; // View is being deleted or not draggable, ignore request. |
1530 | 1529 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 model_->items()[view_index].type); | 1597 model_->items()[view_index].type); |
1599 return item_delegate->GetTitle(model_->items()[view_index]); | 1598 return item_delegate->GetTitle(model_->items()[view_index]); |
1600 } | 1599 } |
1601 | 1600 |
1602 void LauncherView::ButtonPressed(views::Button* sender, | 1601 void LauncherView::ButtonPressed(views::Button* sender, |
1603 const ui::Event& event) { | 1602 const ui::Event& event) { |
1604 // Do not handle mouse release during drag. | 1603 // Do not handle mouse release during drag. |
1605 if (dragging()) | 1604 if (dragging()) |
1606 return; | 1605 return; |
1607 | 1606 |
1608 tooltip_->Close(); | |
1609 | |
1610 if (sender == overflow_button_) { | 1607 if (sender == overflow_button_) { |
1611 ToggleOverflowBubble(); | 1608 ToggleOverflowBubble(); |
1612 return; | 1609 return; |
1613 } | 1610 } |
1614 | 1611 |
1615 int view_index = view_model_->GetIndexOfView(sender); | 1612 int view_index = view_model_->GetIndexOfView(sender); |
1616 // May be -1 while in the process of animating closed. | 1613 // May be -1 while in the process of animating closed. |
1617 if (view_index == -1) | 1614 if (view_index == -1) |
1618 return; | 1615 return; |
1619 | 1616 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1690 const gfx::Point& point, | 1687 const gfx::Point& point, |
1691 ui:: MenuSourceType source_type) { | 1688 ui:: MenuSourceType source_type) { |
1692 int view_index = view_model_->GetIndexOfView(source); | 1689 int view_index = view_model_->GetIndexOfView(source); |
1693 // TODO(simon.hong81): Create LauncherContextMenu for applist in its | 1690 // TODO(simon.hong81): Create LauncherContextMenu for applist in its |
1694 // LauncherItemDelegate. | 1691 // LauncherItemDelegate. |
1695 if (view_index != -1 && | 1692 if (view_index != -1 && |
1696 model_->items()[view_index].type == TYPE_APP_LIST) { | 1693 model_->items()[view_index].type == TYPE_APP_LIST) { |
1697 view_index = -1; | 1694 view_index = -1; |
1698 } | 1695 } |
1699 | 1696 |
1700 tooltip_->Close(); | |
1701 | |
1702 if (view_index == -1) { | 1697 if (view_index == -1) { |
1703 Shell::GetInstance()->ShowContextMenu(point, source_type); | 1698 Shell::GetInstance()->ShowContextMenu(point, source_type); |
1704 return; | 1699 return; |
1705 } | 1700 } |
1706 scoped_ptr<ui::MenuModel> menu_model; | 1701 scoped_ptr<ui::MenuModel> menu_model; |
1707 LauncherItemDelegate* item_delegate = item_manager_->GetLauncherItemDelegate( | 1702 LauncherItemDelegate* item_delegate = item_manager_->GetLauncherItemDelegate( |
1708 model_->items()[view_index].type); | 1703 model_->items()[view_index].type); |
1709 menu_model.reset(item_delegate->CreateContextMenu( | 1704 menu_model.reset(item_delegate->CreateContextMenu( |
1710 model_->items()[view_index], | 1705 model_->items()[view_index], |
1711 source->GetWidget()->GetNativeView()->GetRootWindow())); | 1706 source->GetWidget()->GetNativeView()->GetRootWindow())); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1885 break; | 1880 break; |
1886 case ash::SHELF_ALIGNMENT_TOP: | 1881 case ash::SHELF_ALIGNMENT_TOP: |
1887 distance = coordinate.y() - bounds.bottom(); | 1882 distance = coordinate.y() - bounds.bottom(); |
1888 break; | 1883 break; |
1889 } | 1884 } |
1890 return distance > 0 ? distance : 0; | 1885 return distance > 0 ? distance : 0; |
1891 } | 1886 } |
1892 | 1887 |
1893 } // namespace internal | 1888 } // namespace internal |
1894 } // namespace ash | 1889 } // namespace ash |
OLD | NEW |