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 "ui/views/controls/menu/menu_controller.h" | 5 #include "ui/views/controls/menu/menu_controller.h" |
6 | 6 |
7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 1674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1685 | 1685 |
1686 void MenuController::BuildMenuItemPath(MenuItemView* item, | 1686 void MenuController::BuildMenuItemPath(MenuItemView* item, |
1687 std::vector<MenuItemView*>* path) { | 1687 std::vector<MenuItemView*>* path) { |
1688 if (!item) | 1688 if (!item) |
1689 return; | 1689 return; |
1690 BuildMenuItemPath(item->GetParentMenuItem(), path); | 1690 BuildMenuItemPath(item->GetParentMenuItem(), path); |
1691 path->push_back(item); | 1691 path->push_back(item); |
1692 } | 1692 } |
1693 | 1693 |
1694 void MenuController::StartShowTimer() { | 1694 void MenuController::StartShowTimer() { |
1695 MenuItemView* item = pending_state_.item ? pending_state_.item : state_.item; | |
1696 show_timer_.Start( | 1695 show_timer_.Start( |
1697 FROM_HERE, TimeDelta::FromMilliseconds(item->GetMenuConfig().show_delay), | 1696 FROM_HERE, TimeDelta::FromMilliseconds(MenuConfig::instance().show_delay), |
1698 this, &MenuController::CommitPendingSelection); | 1697 this, &MenuController::CommitPendingSelection); |
1699 } | 1698 } |
1700 | 1699 |
1701 void MenuController::StopShowTimer() { | 1700 void MenuController::StopShowTimer() { |
1702 show_timer_.Stop(); | 1701 show_timer_.Stop(); |
1703 } | 1702 } |
1704 | 1703 |
1705 void MenuController::StartCancelAllTimer() { | 1704 void MenuController::StartCancelAllTimer() { |
1706 cancel_all_timer_.Start(FROM_HERE, | 1705 cancel_all_timer_.Start(FROM_HERE, |
1707 TimeDelta::FromMilliseconds(kCloseOnExitTime), | 1706 TimeDelta::FromMilliseconds(kCloseOnExitTime), |
(...skipping 22 matching lines...) Expand all Loading... |
1730 pref.set_width(std::min(pref.width(), | 1729 pref.set_width(std::min(pref.width(), |
1731 item->GetDelegate()->GetMaxWidthForMenu(item))); | 1730 item->GetDelegate()->GetMaxWidthForMenu(item))); |
1732 if (!state_.monitor_bounds.IsEmpty()) | 1731 if (!state_.monitor_bounds.IsEmpty()) |
1733 pref.set_width(std::min(pref.width(), state_.monitor_bounds.width())); | 1732 pref.set_width(std::min(pref.width(), state_.monitor_bounds.width())); |
1734 | 1733 |
1735 // Assume we can honor prefer_leading. | 1734 // Assume we can honor prefer_leading. |
1736 *is_leading = prefer_leading; | 1735 *is_leading = prefer_leading; |
1737 | 1736 |
1738 int x, y; | 1737 int x, y; |
1739 | 1738 |
1740 const MenuConfig& menu_config = item->GetMenuConfig(); | 1739 const MenuConfig& menu_config = MenuConfig::instance(); |
1741 | 1740 |
1742 if (!item->GetParentMenuItem()) { | 1741 if (!item->GetParentMenuItem()) { |
1743 // First item, position relative to initial location. | 1742 // First item, position relative to initial location. |
1744 x = state_.initial_bounds.x(); | 1743 x = state_.initial_bounds.x(); |
1745 | 1744 |
1746 // Offsets for context menu prevent menu items being selected by | 1745 // Offsets for context menu prevent menu items being selected by |
1747 // simply opening the menu (bug 142992). | 1746 // simply opening the menu (bug 142992). |
1748 if (menu_config.offset_context_menus && state_.context_menu) | 1747 if (menu_config.offset_context_menus && state_.context_menu) |
1749 x += 1; | 1748 x += 1; |
1750 | 1749 |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2530 } | 2529 } |
2531 } | 2530 } |
2532 | 2531 |
2533 gfx::Screen* MenuController::GetScreen() { | 2532 gfx::Screen* MenuController::GetScreen() { |
2534 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; | 2533 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; |
2535 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) | 2534 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) |
2536 : gfx::Screen::GetNativeScreen(); | 2535 : gfx::Screen::GetNativeScreen(); |
2537 } | 2536 } |
2538 | 2537 |
2539 } // namespace views | 2538 } // namespace views |
OLD | NEW |