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

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

Issue 250943008: Move enum MenuAnchorPosition to reduce deps on menu_item_view.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix indent Created 6 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « ash/root_window_controller.cc ('k') | ash/shell/window_type_launcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1760 bool context_menu, 1760 bool context_menu,
1761 ui::MenuSourceType source_type) { 1761 ui::MenuSourceType source_type) {
1762 closing_event_time_ = base::TimeDelta(); 1762 closing_event_time_ = base::TimeDelta();
1763 launcher_menu_runner_.reset( 1763 launcher_menu_runner_.reset(
1764 new views::MenuRunner(menu_model_adapter->CreateMenu())); 1764 new views::MenuRunner(menu_model_adapter->CreateMenu()));
1765 1765
1766 ScopedTargetRootWindow scoped_target( 1766 ScopedTargetRootWindow scoped_target(
1767 source->GetWidget()->GetNativeView()->GetRootWindow()); 1767 source->GetWidget()->GetNativeView()->GetRootWindow());
1768 1768
1769 // Determine the menu alignment dependent on the shelf. 1769 // Determine the menu alignment dependent on the shelf.
1770 views::MenuItemView::AnchorPosition menu_alignment = 1770 views::MenuAnchorPosition menu_alignment = views::MENU_ANCHOR_TOPLEFT;
1771 views::MenuItemView::TOPLEFT;
1772 gfx::Rect anchor_point = gfx::Rect(click_point, gfx::Size()); 1771 gfx::Rect anchor_point = gfx::Rect(click_point, gfx::Size());
1773 1772
1774 ShelfWidget* shelf = RootWindowController::ForShelf( 1773 ShelfWidget* shelf = RootWindowController::ForShelf(
1775 GetWidget()->GetNativeView())->shelf(); 1774 GetWidget()->GetNativeView())->shelf();
1776 if (!context_menu) { 1775 if (!context_menu) {
1777 // Application lists use a bubble. 1776 // Application lists use a bubble.
1778 ShelfAlignment align = shelf->GetAlignment(); 1777 ShelfAlignment align = shelf->GetAlignment();
1779 anchor_point = source->GetBoundsInScreen(); 1778 anchor_point = source->GetBoundsInScreen();
1780 1779
1781 // It is possible to invoke the menu while it is sliding into view. To cover 1780 // It is possible to invoke the menu while it is sliding into view. To cover
1782 // that case, the screen coordinates are offsetted by the animation delta. 1781 // that case, the screen coordinates are offsetted by the animation delta.
1783 gfx::Vector2d offset = 1782 gfx::Vector2d offset =
1784 source->GetWidget()->GetNativeWindow()->bounds().origin() - 1783 source->GetWidget()->GetNativeWindow()->bounds().origin() -
1785 source->GetWidget()->GetNativeWindow()->GetTargetBounds().origin(); 1784 source->GetWidget()->GetNativeWindow()->GetTargetBounds().origin();
1786 anchor_point.set_x(anchor_point.x() - offset.x()); 1785 anchor_point.set_x(anchor_point.x() - offset.x());
1787 anchor_point.set_y(anchor_point.y() - offset.y()); 1786 anchor_point.set_y(anchor_point.y() - offset.y());
1788 1787
1789 // Shelf items can have an asymmetrical border for spacing reasons. 1788 // Shelf items can have an asymmetrical border for spacing reasons.
1790 // Adjust anchor location for this. 1789 // Adjust anchor location for this.
1791 if (source->border()) 1790 if (source->border())
1792 anchor_point.Inset(source->border()->GetInsets()); 1791 anchor_point.Inset(source->border()->GetInsets());
1793 1792
1794 switch (align) { 1793 switch (align) {
1795 case SHELF_ALIGNMENT_BOTTOM: 1794 case SHELF_ALIGNMENT_BOTTOM:
1796 menu_alignment = views::MenuItemView::BUBBLE_ABOVE; 1795 menu_alignment = views::MENU_ANCHOR_BUBBLE_ABOVE;
1797 break; 1796 break;
1798 case SHELF_ALIGNMENT_LEFT: 1797 case SHELF_ALIGNMENT_LEFT:
1799 menu_alignment = views::MenuItemView::BUBBLE_RIGHT; 1798 menu_alignment = views::MENU_ANCHOR_BUBBLE_RIGHT;
1800 break; 1799 break;
1801 case SHELF_ALIGNMENT_RIGHT: 1800 case SHELF_ALIGNMENT_RIGHT:
1802 menu_alignment = views::MenuItemView::BUBBLE_LEFT; 1801 menu_alignment = views::MENU_ANCHOR_BUBBLE_LEFT;
1803 break; 1802 break;
1804 case SHELF_ALIGNMENT_TOP: 1803 case SHELF_ALIGNMENT_TOP:
1805 menu_alignment = views::MenuItemView::BUBBLE_BELOW; 1804 menu_alignment = views::MENU_ANCHOR_BUBBLE_BELOW;
1806 break; 1805 break;
1807 } 1806 }
1808 } 1807 }
1809 // If this gets deleted while we are in the menu, the shelf will be gone 1808 // If this gets deleted while we are in the menu, the shelf will be gone
1810 // as well. 1809 // as well.
1811 bool got_deleted = false; 1810 bool got_deleted = false;
1812 got_deleted_ = &got_deleted; 1811 got_deleted_ = &got_deleted;
1813 1812
1814 shelf->ForceUndimming(true); 1813 shelf->ForceUndimming(true);
1815 // NOTE: if you convert to HAS_MNEMONICS be sure and update menu building 1814 // NOTE: if you convert to HAS_MNEMONICS be sure and update menu building
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 distance = bounds.x() - coordinate.x(); 1916 distance = bounds.x() - coordinate.x();
1918 break; 1917 break;
1919 case SHELF_ALIGNMENT_TOP: 1918 case SHELF_ALIGNMENT_TOP:
1920 distance = coordinate.y() - bounds.bottom(); 1919 distance = coordinate.y() - bounds.bottom();
1921 break; 1920 break;
1922 } 1921 }
1923 return distance > 0 ? distance : 0; 1922 return distance > 0 ? distance : 0;
1924 } 1923 }
1925 1924
1926 } // namespace ash 1925 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller.cc ('k') | ash/shell/window_type_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698