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

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

Issue 2862025: Canvas refactoring part 2.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 6 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 | « gfx/gfx.gyp ('k') | views/controls/menu/menu_win.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/os_exchange_data.h" 8 #include "app/os_exchange_data.h"
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.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 "gfx/canvas.h" 12 #include "gfx/canvas_skia.h"
13 #include "views/controls/button/menu_button.h" 13 #include "views/controls/button/menu_button.h"
14 #include "views/controls/menu/menu_scroll_view_container.h" 14 #include "views/controls/menu/menu_scroll_view_container.h"
15 #include "views/controls/menu/submenu_view.h" 15 #include "views/controls/menu/submenu_view.h"
16 #include "views/drag_utils.h" 16 #include "views/drag_utils.h"
17 #include "views/screen.h" 17 #include "views/screen.h"
18 #include "views/view_constants.h" 18 #include "views/view_constants.h"
19 #include "views/views_delegate.h" 19 #include "views/views_delegate.h"
20 #include "views/widget/root_view.h" 20 #include "views/widget/root_view.h"
21 #include "views/widget/widget.h" 21 #include "views/widget/widget.h"
22 22
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 if (View::ExceededDragThreshold(event.x() - press_pt_.x(), 462 if (View::ExceededDragThreshold(event.x() - press_pt_.x(),
463 event.y() - press_pt_.y())) { 463 event.y() - press_pt_.y())) {
464 MenuItemView* item = state_.item; 464 MenuItemView* item = state_.item;
465 DCHECK(item); 465 DCHECK(item);
466 // Points are in the coordinates of the submenu, need to map to that of 466 // Points are in the coordinates of the submenu, need to map to that of
467 // the selected item. Additionally source may not be the parent of 467 // the selected item. Additionally source may not be the parent of
468 // the selected item, so need to map to screen first then to item. 468 // the selected item, so need to map to screen first then to item.
469 gfx::Point press_loc(press_pt_); 469 gfx::Point press_loc(press_pt_);
470 View::ConvertPointToScreen(source->GetScrollViewContainer(), &press_loc); 470 View::ConvertPointToScreen(source->GetScrollViewContainer(), &press_loc);
471 View::ConvertPointToView(NULL, item, &press_loc); 471 View::ConvertPointToView(NULL, item, &press_loc);
472 gfx::Canvas canvas(item->width(), item->height(), false); 472 gfx::CanvasSkia canvas(item->width(), item->height(), false);
473 item->Paint(&canvas, true); 473 item->Paint(canvas.AsCanvas(), true);
474 474
475 OSExchangeData data; 475 OSExchangeData data;
476 item->GetDelegate()->WriteDragData(item, &data); 476 item->GetDelegate()->WriteDragData(item, &data);
477 drag_utils::SetDragImageOnDataObject(canvas, item->size(), press_loc, 477 drag_utils::SetDragImageOnDataObject(*canvas.AsCanvas(), item->size(), pre ss_loc,
478 &data); 478 &data);
479 StopScrolling(); 479 StopScrolling();
480 int drag_ops = item->GetDelegate()->GetDragOperations(item); 480 int drag_ops = item->GetDelegate()->GetDragOperations(item);
481 drag_in_progress_ = true; 481 drag_in_progress_ = true;
482 item->GetRootView()->StartDragForViewFromMouseEvent( 482 item->GetRootView()->StartDragForViewFromMouseEvent(
483 NULL, data, drag_ops); 483 NULL, data, drag_ops);
484 drag_in_progress_ = false; 484 drag_in_progress_ = false;
485 485
486 if (GetActiveInstance() == this) { 486 if (GetActiveInstance() == this) {
487 if (showing_) { 487 if (showing_) {
(...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1733 1733
1734 MouseEvent release_event(Event::ET_MOUSE_RELEASED, -1, -1, 0); 1734 MouseEvent release_event(Event::ET_MOUSE_RELEASED, -1, -1, 0);
1735 // Reset the active_mouse_view_ before sending mouse released. That way if if 1735 // Reset the active_mouse_view_ before sending mouse released. That way if if
1736 // calls back to use we aren't in a weird state. 1736 // calls back to use we aren't in a weird state.
1737 View* active_view = active_mouse_view_; 1737 View* active_view = active_mouse_view_;
1738 active_mouse_view_ = NULL; 1738 active_mouse_view_ = NULL;
1739 active_view->OnMouseReleased(release_event, true); 1739 active_view->OnMouseReleased(release_event, true);
1740 } 1740 }
1741 1741
1742 } // namespace views 1742 } // namespace views
OLDNEW
« no previous file with comments | « gfx/gfx.gyp ('k') | views/controls/menu/menu_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698