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

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

Issue 199050: Wires up drag and drop for bookmark menus and cleans up a couple of... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 3 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "views/controls/menu/menu_controller.h" 5 #include "views/controls/menu/menu_controller.h"
6 6
7 #include "app/gfx/canvas.h" 7 #include "app/gfx/canvas.h"
8 #include "app/l10n_util.h" 8 #include "app/l10n_util.h"
9 #include "app/os_exchange_data.h" 9 #include "app/os_exchange_data.h"
10 #include "base/keyboard_codes.h" 10 #include "base/keyboard_codes.h"
11 #include "base/time.h" 11 #include "base/time.h"
12 #include "views/controls/menu/menu_scroll_view_container.h" 12 #include "views/controls/menu/menu_scroll_view_container.h"
13 #include "views/controls/menu/submenu_view.h" 13 #include "views/controls/menu/submenu_view.h"
14 #include "views/drag_utils.h" 14 #include "views/drag_utils.h"
15 #include "views/screen.h"
15 #include "views/view_constants.h" 16 #include "views/view_constants.h"
16 #include "views/widget/root_view.h" 17 #include "views/widget/root_view.h"
17 #include "views/widget/widget.h" 18 #include "views/widget/widget.h"
18 19
19 using base::Time; 20 using base::Time;
20 using base::TimeDelta; 21 using base::TimeDelta;
21 22
22 // Period of the scroll timer (in milliseconds). 23 // Period of the scroll timer (in milliseconds).
23 static const int kScrollTimerMS = 30; 24 static const int kScrollTimerMS = 30;
24 25
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 state_ = State(); 170 state_ = State();
170 pending_state_.initial_bounds = bounds; 171 pending_state_.initial_bounds = bounds;
171 if (bounds.height() > 1) { 172 if (bounds.height() > 1) {
172 // Inset the bounds slightly, otherwise drag coordinates don't line up 173 // Inset the bounds slightly, otherwise drag coordinates don't line up
173 // nicely and menus close prematurely. 174 // nicely and menus close prematurely.
174 pending_state_.initial_bounds.Inset(0, 1); 175 pending_state_.initial_bounds.Inset(0, 1);
175 } 176 }
176 pending_state_.anchor = position; 177 pending_state_.anchor = position;
177 owner_ = parent; 178 owner_ = parent;
178 179
179 // TODO: push this into Screen.
180 // Calculate the bounds of the monitor we'll show menus on. Do this once to 180 // Calculate the bounds of the monitor we'll show menus on. Do this once to
181 // avoid repeated system queries for the info. 181 // avoid repeated system queries for the info.
182 #if defined(OS_WIN) 182 pending_state_.monitor_bounds = Screen::GetMonitorAreaNearestPoint(
183 POINT initial_loc = { bounds.x(), bounds.y() }; 183 bounds.origin());
184 HMONITOR monitor = MonitorFromPoint(initial_loc, MONITOR_DEFAULTTONEAREST);
185 if (monitor) {
186 MONITORINFO mi = {0};
187 mi.cbSize = sizeof(mi);
188 GetMonitorInfo(monitor, &mi);
189 // Menus appear over the taskbar.
190 pending_state_.monitor_bounds = gfx::Rect(mi.rcMonitor);
191 }
192 #else
193 NOTIMPLEMENTED();
194 #endif
195 184
196 // Set the selection, which opens the initial menu. 185 // Set the selection, which opens the initial menu.
197 SetSelection(root, true, true); 186 SetSelection(root, true, true);
198 187
199 if (!blocking_run_) { 188 if (!blocking_run_) {
200 // Start the timer to hide the menu. This is needed as we get no 189 // Start the timer to hide the menu. This is needed as we get no
201 // notification when the drag has finished. 190 // notification when the drag has finished.
202 StartCancelAllTimer(); 191 StartCancelAllTimer();
203 return NULL; 192 return NULL;
204 } 193 }
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 SetSelection(pending_state_.item->GetParentMenuItem(), true, false); 478 SetSelection(pending_state_.item->GetParentMenuItem(), true, false);
490 } 479 }
491 } 480 }
492 481
493 void MenuController::OnMouseEntered(SubmenuView* source, 482 void MenuController::OnMouseEntered(SubmenuView* source,
494 const MouseEvent& event) { 483 const MouseEvent& event) {
495 // MouseEntered is always followed by a mouse moved, so don't need to 484 // MouseEntered is always followed by a mouse moved, so don't need to
496 // do anything here. 485 // do anything here.
497 } 486 }
498 487
488 bool MenuController::GetDropFormats(
489 SubmenuView* source,
490 int* formats,
491 std::set<OSExchangeData::CustomFormat>* custom_formats) {
492 return source->GetMenuItem()->GetDelegate()->GetDropFormats(
493 source->GetMenuItem(), formats, custom_formats);
494 }
495
496 bool MenuController::AreDropTypesRequired(SubmenuView* source) {
497 return source->GetMenuItem()->GetDelegate()->AreDropTypesRequired(
498 source->GetMenuItem());
499 }
500
499 bool MenuController::CanDrop(SubmenuView* source, const OSExchangeData& data) { 501 bool MenuController::CanDrop(SubmenuView* source, const OSExchangeData& data) {
500 return source->GetMenuItem()->GetDelegate()->CanDrop(source->GetMenuItem(), 502 return source->GetMenuItem()->GetDelegate()->CanDrop(source->GetMenuItem(),
501 data); 503 data);
502 } 504 }
503 505
504 void MenuController::OnDragEntered(SubmenuView* source, 506 void MenuController::OnDragEntered(SubmenuView* source,
505 const DropTargetEvent& event) { 507 const DropTargetEvent& event) {
506 valid_drop_coordinates_ = false; 508 valid_drop_coordinates_ = false;
507 } 509 }
508 510
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 if (!scroll_task_.get()) 1404 if (!scroll_task_.get())
1403 scroll_task_.reset(new MenuScrollTask()); 1405 scroll_task_.reset(new MenuScrollTask());
1404 scroll_task_->Update(part); 1406 scroll_task_->Update(part);
1405 } 1407 }
1406 1408
1407 void MenuController::StopScrolling() { 1409 void MenuController::StopScrolling() {
1408 scroll_task_.reset(NULL); 1410 scroll_task_.reset(NULL);
1409 } 1411 }
1410 1412
1411 } // namespace views 1413 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698