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 1746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1757 true, | 1757 true, |
1758 source_type); | 1758 source_type); |
1759 } | 1759 } |
1760 | 1760 |
1761 void ShelfView::ShowMenu(ui::MenuModel* menu_model, | 1761 void ShelfView::ShowMenu(ui::MenuModel* menu_model, |
1762 views::View* source, | 1762 views::View* source, |
1763 const gfx::Point& click_point, | 1763 const gfx::Point& click_point, |
1764 bool context_menu, | 1764 bool context_menu, |
1765 ui::MenuSourceType source_type) { | 1765 ui::MenuSourceType source_type) { |
1766 closing_event_time_ = base::TimeDelta(); | 1766 closing_event_time_ = base::TimeDelta(); |
1767 launcher_menu_runner_.reset(new views::MenuRunner(menu_model)); | 1767 launcher_menu_runner_.reset(new views::MenuRunner( |
| 1768 menu_model, context_menu ? views::MenuRunner::CONTEXT_MENU : 0)); |
1768 | 1769 |
1769 ScopedTargetRootWindow scoped_target( | 1770 ScopedTargetRootWindow scoped_target( |
1770 source->GetWidget()->GetNativeView()->GetRootWindow()); | 1771 source->GetWidget()->GetNativeView()->GetRootWindow()); |
1771 | 1772 |
1772 // Determine the menu alignment dependent on the shelf. | 1773 // Determine the menu alignment dependent on the shelf. |
1773 views::MenuAnchorPosition menu_alignment = views::MENU_ANCHOR_TOPLEFT; | 1774 views::MenuAnchorPosition menu_alignment = views::MENU_ANCHOR_TOPLEFT; |
1774 gfx::Rect anchor_point = gfx::Rect(click_point, gfx::Size()); | 1775 gfx::Rect anchor_point = gfx::Rect(click_point, gfx::Size()); |
1775 | 1776 |
1776 ShelfWidget* shelf = RootWindowController::ForShelf( | 1777 ShelfWidget* shelf = RootWindowController::ForShelf( |
1777 GetWidget()->GetNativeView())->shelf(); | 1778 GetWidget()->GetNativeView())->shelf(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1809 } | 1810 } |
1810 } | 1811 } |
1811 // If this gets deleted while we are in the menu, the shelf will be gone | 1812 // If this gets deleted while we are in the menu, the shelf will be gone |
1812 // as well. | 1813 // as well. |
1813 bool got_deleted = false; | 1814 bool got_deleted = false; |
1814 got_deleted_ = &got_deleted; | 1815 got_deleted_ = &got_deleted; |
1815 | 1816 |
1816 shelf->ForceUndimming(true); | 1817 shelf->ForceUndimming(true); |
1817 // NOTE: if you convert to HAS_MNEMONICS be sure and update menu building | 1818 // NOTE: if you convert to HAS_MNEMONICS be sure and update menu building |
1818 // code. | 1819 // code. |
1819 if (launcher_menu_runner_->RunMenuAt( | 1820 if (launcher_menu_runner_->RunMenuAt(source->GetWidget(), |
1820 source->GetWidget(), | 1821 NULL, |
1821 NULL, | 1822 anchor_point, |
1822 anchor_point, | 1823 menu_alignment, |
1823 menu_alignment, | 1824 source_type) == |
1824 source_type, | |
1825 context_menu ? views::MenuRunner::CONTEXT_MENU : 0) == | |
1826 views::MenuRunner::MENU_DELETED) { | 1825 views::MenuRunner::MENU_DELETED) { |
1827 if (!got_deleted) { | 1826 if (!got_deleted) { |
1828 got_deleted_ = NULL; | 1827 got_deleted_ = NULL; |
1829 shelf->ForceUndimming(false); | 1828 shelf->ForceUndimming(false); |
1830 } | 1829 } |
1831 return; | 1830 return; |
1832 } | 1831 } |
1833 got_deleted_ = NULL; | 1832 got_deleted_ = NULL; |
1834 shelf->ForceUndimming(false); | 1833 shelf->ForceUndimming(false); |
1835 | 1834 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1919 distance = bounds.x() - coordinate.x(); | 1918 distance = bounds.x() - coordinate.x(); |
1920 break; | 1919 break; |
1921 case SHELF_ALIGNMENT_TOP: | 1920 case SHELF_ALIGNMENT_TOP: |
1922 distance = coordinate.y() - bounds.bottom(); | 1921 distance = coordinate.y() - bounds.bottom(); |
1923 break; | 1922 break; |
1924 } | 1923 } |
1925 return distance > 0 ? distance : 0; | 1924 return distance > 0 ? distance : 0; |
1926 } | 1925 } |
1927 | 1926 |
1928 } // namespace ash | 1927 } // namespace ash |
OLD | NEW |