| 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" |
| 11 #include "ash/drag_drop/drag_image_view.h" | 11 #include "ash/drag_drop/drag_image_view.h" |
| 12 #include "ash/metrics/user_metrics_recorder.h" | 12 #include "ash/metrics/user_metrics_recorder.h" |
| 13 #include "ash/root_window_controller.h" | |
| 14 #include "ash/scoped_target_root_window.h" | 13 #include "ash/scoped_target_root_window.h" |
| 15 #include "ash/shelf/app_list_button.h" | 14 #include "ash/shelf/app_list_button.h" |
| 16 #include "ash/shelf/overflow_bubble.h" | 15 #include "ash/shelf/overflow_bubble.h" |
| 17 #include "ash/shelf/overflow_bubble_view.h" | 16 #include "ash/shelf/overflow_bubble_view.h" |
| 18 #include "ash/shelf/overflow_button.h" | 17 #include "ash/shelf/overflow_button.h" |
| 19 #include "ash/shelf/shelf_button.h" | 18 #include "ash/shelf/shelf_button.h" |
| 20 #include "ash/shelf/shelf_constants.h" | 19 #include "ash/shelf/shelf_constants.h" |
| 21 #include "ash/shelf/shelf_delegate.h" | 20 #include "ash/shelf/shelf_delegate.h" |
| 22 #include "ash/shelf/shelf_icon_observer.h" | 21 #include "ash/shelf/shelf_icon_observer.h" |
| 23 #include "ash/shelf/shelf_item_delegate_manager.h" | 22 #include "ash/shelf/shelf_item_delegate_manager.h" |
| (...skipping 1807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1831 launcher_menu_runner_.reset(new views::MenuRunner( | 1830 launcher_menu_runner_.reset(new views::MenuRunner( |
| 1832 menu_model, context_menu ? views::MenuRunner::CONTEXT_MENU : 0)); | 1831 menu_model, context_menu ? views::MenuRunner::CONTEXT_MENU : 0)); |
| 1833 | 1832 |
| 1834 ScopedTargetRootWindow scoped_target( | 1833 ScopedTargetRootWindow scoped_target( |
| 1835 source->GetWidget()->GetNativeView()->GetRootWindow()); | 1834 source->GetWidget()->GetNativeView()->GetRootWindow()); |
| 1836 | 1835 |
| 1837 // Determine the menu alignment dependent on the shelf. | 1836 // Determine the menu alignment dependent on the shelf. |
| 1838 views::MenuAnchorPosition menu_alignment = views::MENU_ANCHOR_TOPLEFT; | 1837 views::MenuAnchorPosition menu_alignment = views::MENU_ANCHOR_TOPLEFT; |
| 1839 gfx::Rect anchor_point = gfx::Rect(click_point, gfx::Size()); | 1838 gfx::Rect anchor_point = gfx::Rect(click_point, gfx::Size()); |
| 1840 | 1839 |
| 1841 ShelfWidget* shelf = RootWindowController::ForShelf( | 1840 ShelfWidget* shelf = layout_manager_->shelf_widget(); |
| 1842 GetWidget()->GetNativeView())->shelf(); | |
| 1843 if (!context_menu) { | 1841 if (!context_menu) { |
| 1844 // Application lists use a bubble. | 1842 // Application lists use a bubble. |
| 1845 ShelfAlignment align = shelf->GetAlignment(); | 1843 ShelfAlignment align = shelf->GetAlignment(); |
| 1846 anchor_point = source->GetBoundsInScreen(); | 1844 anchor_point = source->GetBoundsInScreen(); |
| 1847 | 1845 |
| 1848 // It is possible to invoke the menu while it is sliding into view. To cover | 1846 // It is possible to invoke the menu while it is sliding into view. To cover |
| 1849 // that case, the screen coordinates are offsetted by the animation delta. | 1847 // that case, the screen coordinates are offsetted by the animation delta. |
| 1850 gfx::Vector2d offset = | 1848 gfx::Vector2d offset = |
| 1851 source->GetWidget()->GetNativeWindow()->bounds().origin() - | 1849 source->GetWidget()->GetNativeWindow()->bounds().origin() - |
| 1852 source->GetWidget()->GetNativeWindow()->GetTargetBounds().origin(); | 1850 source->GetWidget()->GetNativeWindow()->GetTargetBounds().origin(); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1960 return false; | 1958 return false; |
| 1961 const ShelfItem* item = ShelfItemForView(view); | 1959 const ShelfItem* item = ShelfItemForView(view); |
| 1962 if (!item) | 1960 if (!item) |
| 1963 return true; | 1961 return true; |
| 1964 ShelfItemDelegate* item_delegate = | 1962 ShelfItemDelegate* item_delegate = |
| 1965 item_manager_->GetShelfItemDelegate(item->id); | 1963 item_manager_->GetShelfItemDelegate(item->id); |
| 1966 return item_delegate->ShouldShowTooltip(); | 1964 return item_delegate->ShouldShowTooltip(); |
| 1967 } | 1965 } |
| 1968 | 1966 |
| 1969 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { | 1967 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { |
| 1970 ShelfWidget* shelf = RootWindowController::ForShelf( | 1968 ShelfAlignment align = layout_manager_->GetAlignment(); |
| 1971 GetWidget()->GetNativeView())->shelf(); | |
| 1972 ShelfAlignment align = shelf->GetAlignment(); | |
| 1973 const gfx::Rect bounds = GetBoundsInScreen(); | 1969 const gfx::Rect bounds = GetBoundsInScreen(); |
| 1974 int distance = 0; | 1970 int distance = 0; |
| 1975 switch (align) { | 1971 switch (align) { |
| 1976 case SHELF_ALIGNMENT_BOTTOM: | 1972 case SHELF_ALIGNMENT_BOTTOM: |
| 1977 distance = bounds.y() - coordinate.y(); | 1973 distance = bounds.y() - coordinate.y(); |
| 1978 break; | 1974 break; |
| 1979 case SHELF_ALIGNMENT_LEFT: | 1975 case SHELF_ALIGNMENT_LEFT: |
| 1980 distance = coordinate.x() - bounds.right(); | 1976 distance = coordinate.x() - bounds.right(); |
| 1981 break; | 1977 break; |
| 1982 case SHELF_ALIGNMENT_RIGHT: | 1978 case SHELF_ALIGNMENT_RIGHT: |
| 1983 distance = bounds.x() - coordinate.x(); | 1979 distance = bounds.x() - coordinate.x(); |
| 1984 break; | 1980 break; |
| 1985 case SHELF_ALIGNMENT_TOP: | 1981 case SHELF_ALIGNMENT_TOP: |
| 1986 distance = coordinate.y() - bounds.bottom(); | 1982 distance = coordinate.y() - bounds.bottom(); |
| 1987 break; | 1983 break; |
| 1988 } | 1984 } |
| 1989 return distance > 0 ? distance : 0; | 1985 return distance > 0 ? distance : 0; |
| 1990 } | 1986 } |
| 1991 | 1987 |
| 1992 } // namespace ash | 1988 } // namespace ash |
| OLD | NEW |