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

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

Issue 1064763002: views: Make SubmenuView::PaintChildren use the canvas via PaintRecorder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: submenu: . Created 5 years, 8 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
« no previous file with comments | « ui/views/controls/menu/submenu_view.h ('k') | no next file » | 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 "ui/views/controls/menu/submenu_view.h" 5 #include "ui/views/controls/menu/submenu_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "ui/accessibility/ax_view_state.h" 10 #include "ui/accessibility/ax_view_state.h"
11 #include "ui/compositor/paint_context.h" 11 #include "ui/compositor/paint_context.h"
12 #include "ui/compositor/paint_recorder.h"
12 #include "ui/events/event.h" 13 #include "ui/events/event.h"
13 #include "ui/gfx/canvas.h" 14 #include "ui/gfx/canvas.h"
14 #include "ui/gfx/geometry/safe_integer_conversions.h" 15 #include "ui/gfx/geometry/safe_integer_conversions.h"
15 #include "ui/views/controls/menu/menu_config.h" 16 #include "ui/views/controls/menu/menu_config.h"
16 #include "ui/views/controls/menu/menu_controller.h" 17 #include "ui/views/controls/menu/menu_controller.h"
17 #include "ui/views/controls/menu/menu_host.h" 18 #include "ui/views/controls/menu/menu_host.h"
18 #include "ui/views/controls/menu/menu_item_view.h" 19 #include "ui/views/controls/menu/menu_item_view.h"
19 #include "ui/views/controls/menu/menu_scroll_view_container.h" 20 #include "ui/views/controls/menu/menu_scroll_view_container.h"
20 #include "ui/views/widget/root_view.h" 21 #include "ui/views/widget/root_view.h"
21 #include "ui/views/widget/widget.h" 22 #include "ui/views/widget/widget.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 state->role = ui::AX_ROLE_MENU_LIST_POPUP; 185 state->role = ui::AX_ROLE_MENU_LIST_POPUP;
185 } 186 }
186 187
187 ui::TextInputClient* SubmenuView::GetTextInputClient() { 188 ui::TextInputClient* SubmenuView::GetTextInputClient() {
188 return &prefix_selector_; 189 return &prefix_selector_;
189 } 190 }
190 191
191 void SubmenuView::PaintChildren(const ui::PaintContext& context) { 192 void SubmenuView::PaintChildren(const ui::PaintContext& context) {
192 View::PaintChildren(context); 193 View::PaintChildren(context);
193 194
194 if (drop_item_ && drop_position_ != MenuDelegate::DROP_ON) 195 bool paint_drop_indicator = false;
195 PaintDropIndicator(context.canvas(), drop_item_, drop_position_); 196 if (drop_item_) {
sadrul 2015/04/07 18:49:01 I assume PaintContext::canvas() will be removed so
danakj 2015/04/07 18:49:25 yep!
197 switch (drop_position_) {
198 case MenuDelegate::DROP_NONE:
199 case MenuDelegate::DROP_ON:
200 break;
201 case MenuDelegate::DROP_UNKNOWN:
202 case MenuDelegate::DROP_BEFORE:
203 case MenuDelegate::DROP_AFTER:
204 paint_drop_indicator = true;
205 break;
206 }
207 }
208
209 if (paint_drop_indicator) {
210 gfx::Rect bounds = CalculateDropIndicatorBounds(drop_item_, drop_position_);
211 ui::PaintRecorder recorder(context);
212 recorder.canvas()->FillRect(bounds, kDropIndicatorColor);
213 }
196 } 214 }
197 215
198 bool SubmenuView::GetDropFormats( 216 bool SubmenuView::GetDropFormats(
199 int* formats, 217 int* formats,
200 std::set<OSExchangeData::CustomFormat>* custom_formats) { 218 std::set<OSExchangeData::CustomFormat>* custom_formats) {
201 DCHECK(GetMenuItem()->GetMenuController()); 219 DCHECK(GetMenuItem()->GetMenuController());
202 return GetMenuItem()->GetMenuController()->GetDropFormats(this, formats, 220 return GetMenuItem()->GetMenuController()->GetDropFormats(this, formats,
203 custom_formats); 221 custom_formats);
204 } 222 }
205 223
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 } 456 }
439 457
440 const char* SubmenuView::GetClassName() const { 458 const char* SubmenuView::GetClassName() const {
441 return kViewClassName; 459 return kViewClassName;
442 } 460 }
443 461
444 void SubmenuView::OnBoundsChanged(const gfx::Rect& previous_bounds) { 462 void SubmenuView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
445 SchedulePaint(); 463 SchedulePaint();
446 } 464 }
447 465
448 void SubmenuView::PaintDropIndicator(gfx::Canvas* canvas,
449 MenuItemView* item,
450 MenuDelegate::DropPosition position) {
451 if (position == MenuDelegate::DROP_NONE)
452 return;
453
454 gfx::Rect bounds = CalculateDropIndicatorBounds(item, position);
455 canvas->FillRect(bounds, kDropIndicatorColor);
456 }
457
458 void SubmenuView::SchedulePaintForDropIndicator( 466 void SubmenuView::SchedulePaintForDropIndicator(
459 MenuItemView* item, 467 MenuItemView* item,
460 MenuDelegate::DropPosition position) { 468 MenuDelegate::DropPosition position) {
461 if (item == NULL) 469 if (item == NULL)
462 return; 470 return;
463 471
464 if (position == MenuDelegate::DROP_ON) { 472 if (position == MenuDelegate::DROP_ON) {
465 item->SchedulePaint(); 473 item->SchedulePaint();
466 } else if (position != MenuDelegate::DROP_NONE) { 474 } else if (position != MenuDelegate::DROP_NONE) {
467 SchedulePaintInRect(CalculateDropIndicatorBounds(item, position)); 475 SchedulePaintInRect(CalculateDropIndicatorBounds(item, position));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 y = std::max(y, 0); 510 y = std::max(y, 0);
503 gfx::Rect new_vis_bounds(x, y, vis_bounds.width(), vis_bounds.height()); 511 gfx::Rect new_vis_bounds(x, y, vis_bounds.width(), vis_bounds.height());
504 if (new_vis_bounds != vis_bounds) { 512 if (new_vis_bounds != vis_bounds) {
505 ScrollRectToVisible(new_vis_bounds); 513 ScrollRectToVisible(new_vis_bounds);
506 return true; 514 return true;
507 } 515 }
508 return false; 516 return false;
509 } 517 }
510 518
511 } // namespace views 519 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/submenu_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698