| 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 | 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 1780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1791 void ShelfView::ShowContextMenuForView(views::View* source, | 1791 void ShelfView::ShowContextMenuForView(views::View* source, |
| 1792 const gfx::Point& point, | 1792 const gfx::Point& point, |
| 1793 ui::MenuSourceType source_type) { | 1793 ui::MenuSourceType source_type) { |
| 1794 int view_index = view_model_->GetIndexOfView(source); | 1794 int view_index = view_model_->GetIndexOfView(source); |
| 1795 if (view_index == -1) { | 1795 if (view_index == -1) { |
| 1796 Shell::GetInstance()->ShowContextMenu(point, source_type); | 1796 Shell::GetInstance()->ShowContextMenu(point, source_type); |
| 1797 return; | 1797 return; |
| 1798 } | 1798 } |
| 1799 | 1799 |
| 1800 context_menu_model_.reset(Shell::GetInstance()->delegate()->CreateContextMenu( | 1800 context_menu_model_.reset(Shell::GetInstance()->delegate()->CreateContextMenu( |
| 1801 source->GetWidget()->GetNativeView()->GetRootWindow(), | 1801 shelf_, &model_->items()[view_index])); |
| 1802 &model_->items()[view_index])); | |
| 1803 if (!context_menu_model_) | 1802 if (!context_menu_model_) |
| 1804 return; | 1803 return; |
| 1805 | 1804 |
| 1806 base::AutoReset<ShelfID> reseter( | 1805 base::AutoReset<ShelfID> reseter( |
| 1807 &context_menu_id_, | 1806 &context_menu_id_, |
| 1808 view_index == -1 ? 0 : model_->items()[view_index].id); | 1807 view_index == -1 ? 0 : model_->items()[view_index].id); |
| 1809 | 1808 |
| 1810 ShowMenu(context_menu_model_.get(), | 1809 ShowMenu(context_menu_model_.get(), |
| 1811 source, | 1810 source, |
| 1812 point, | 1811 point, |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1959 | 1958 |
| 1960 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { | 1959 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { |
| 1961 const gfx::Rect bounds = GetBoundsInScreen(); | 1960 const gfx::Rect bounds = GetBoundsInScreen(); |
| 1962 int distance = shelf_->SelectValueForShelfAlignment( | 1961 int distance = shelf_->SelectValueForShelfAlignment( |
| 1963 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), | 1962 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), |
| 1964 bounds.x() - coordinate.x(), coordinate.y() - bounds.bottom()); | 1963 bounds.x() - coordinate.x(), coordinate.y() - bounds.bottom()); |
| 1965 return distance > 0 ? distance : 0; | 1964 return distance > 0 ? distance : 0; |
| 1966 } | 1965 } |
| 1967 | 1966 |
| 1968 } // namespace ash | 1967 } // namespace ash |
| OLD | NEW |