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

Side by Side Diff: ui/views/controls/menu/menu_controller.cc

Issue 1454583002: Change Views menus to consistently use GetNativeTheme for theming. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: get menu config from item Created 5 years, 1 month 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
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 "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 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 ui::MENU_SOURCE_KEYBOARD); 1210 ui::MENU_SOURCE_KEYBOARD);
1211 } 1211 }
1212 break; 1212 break;
1213 } 1213 }
1214 1214
1215 default: 1215 default:
1216 break; 1216 break;
1217 } 1217 }
1218 } 1218 }
1219 1219
1220 MenuController::MenuController(ui::NativeTheme* theme, 1220 MenuController::MenuController(bool blocking,
1221 bool blocking,
1222 internal::MenuControllerDelegate* delegate) 1221 internal::MenuControllerDelegate* delegate)
1223 : blocking_run_(blocking), 1222 : blocking_run_(blocking),
1224 showing_(false), 1223 showing_(false),
1225 exit_type_(EXIT_NONE), 1224 exit_type_(EXIT_NONE),
1226 did_capture_(false), 1225 did_capture_(false),
1227 result_(NULL), 1226 result_(NULL),
1228 accept_event_flags_(0), 1227 accept_event_flags_(0),
1229 drop_target_(NULL), 1228 drop_target_(NULL),
1230 drop_position_(MenuDelegate::DROP_UNKNOWN), 1229 drop_position_(MenuDelegate::DROP_UNKNOWN),
1231 owner_(NULL), 1230 owner_(NULL),
1232 possible_drag_(false), 1231 possible_drag_(false),
1233 drag_in_progress_(false), 1232 drag_in_progress_(false),
1234 did_initiate_drag_(false), 1233 did_initiate_drag_(false),
1235 valid_drop_coordinates_(false), 1234 valid_drop_coordinates_(false),
1236 last_drop_operation_(MenuDelegate::DROP_UNKNOWN), 1235 last_drop_operation_(MenuDelegate::DROP_UNKNOWN),
1237 showing_submenu_(false), 1236 showing_submenu_(false),
1238 active_mouse_view_id_(ViewStorage::GetInstance()->CreateStorageID()), 1237 active_mouse_view_id_(ViewStorage::GetInstance()->CreateStorageID()),
1239 delegate_(delegate), 1238 delegate_(delegate),
1240 message_loop_depth_(0), 1239 message_loop_depth_(0),
1241 menu_config_(theme),
1242 closing_event_time_(base::TimeDelta()), 1240 closing_event_time_(base::TimeDelta()),
1243 menu_start_time_(base::TimeTicks()), 1241 menu_start_time_(base::TimeTicks()),
1244 is_combobox_(false), 1242 is_combobox_(false),
1245 item_selected_by_touch_(false), 1243 item_selected_by_touch_(false),
1246 current_mouse_event_target_(nullptr), 1244 current_mouse_event_target_(nullptr),
1247 current_mouse_pressed_state_(0), 1245 current_mouse_pressed_state_(0),
1248 message_loop_(MenuMessageLoop::Create()) { 1246 message_loop_(MenuMessageLoop::Create()) {
1249 active_instance_ = this; 1247 active_instance_ = this;
1250 } 1248 }
1251 1249
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
1726 1724
1727 void MenuController::BuildMenuItemPath(MenuItemView* item, 1725 void MenuController::BuildMenuItemPath(MenuItemView* item,
1728 std::vector<MenuItemView*>* path) { 1726 std::vector<MenuItemView*>* path) {
1729 if (!item) 1727 if (!item)
1730 return; 1728 return;
1731 BuildMenuItemPath(item->GetParentMenuItem(), path); 1729 BuildMenuItemPath(item->GetParentMenuItem(), path);
1732 path->push_back(item); 1730 path->push_back(item);
1733 } 1731 }
1734 1732
1735 void MenuController::StartShowTimer() { 1733 void MenuController::StartShowTimer() {
1736 show_timer_.Start(FROM_HERE, 1734 MenuItemView* item = pending_state_.item ? pending_state_.item : state_.item;
1737 TimeDelta::FromMilliseconds(menu_config_.show_delay), 1735 show_timer_.Start(
1738 this, &MenuController::CommitPendingSelection); 1736 FROM_HERE, TimeDelta::FromMilliseconds(item->GetMenuConfig().show_delay),
1737 this, &MenuController::CommitPendingSelection);
1739 } 1738 }
1740 1739
1741 void MenuController::StopShowTimer() { 1740 void MenuController::StopShowTimer() {
1742 show_timer_.Stop(); 1741 show_timer_.Stop();
1743 } 1742 }
1744 1743
1745 void MenuController::StartCancelAllTimer() { 1744 void MenuController::StartCancelAllTimer() {
1746 cancel_all_timer_.Start(FROM_HERE, 1745 cancel_all_timer_.Start(FROM_HERE,
1747 TimeDelta::FromMilliseconds(kCloseOnExitTime), 1746 TimeDelta::FromMilliseconds(kCloseOnExitTime),
1748 this, &MenuController::CancelAll); 1747 this, &MenuController::CancelAll);
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
2486 } 2485 }
2487 } 2486 }
2488 2487
2489 gfx::Screen* MenuController::GetScreen() { 2488 gfx::Screen* MenuController::GetScreen() {
2490 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; 2489 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL;
2491 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) 2490 return root ? gfx::Screen::GetScreenFor(root->GetNativeView())
2492 : gfx::Screen::GetNativeScreen(); 2491 : gfx::Screen::GetNativeScreen();
2493 } 2492 }
2494 2493
2495 } // namespace views 2494 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_controller.h ('k') | ui/views/controls/menu/menu_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698