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

Side by Side Diff: ui/views/bubble/bubble_border.cc

Issue 10689145: Fix BubbleBorder wrong arrow for BOTTOM_LEFT and RIGHT_TOP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | « no previous file | 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/bubble/bubble_border.h" 5 #include "ui/views/bubble/bubble_border.h"
6 6
7 #include <algorithm> // for std::max 7 #include <algorithm> // for std::max
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "grit/ui_resources.h" 10 #include "grit/ui_resources.h"
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 start_y += (is_horizontal ? 0 : before_arrow + arrow->height()); 448 start_y += (is_horizontal ? 0 : before_arrow + arrow->height());
449 canvas->TileImageInt(*edge, start_x, start_y, 449 canvas->TileImageInt(*edge, start_x, start_y,
450 is_horizontal ? after_arrow : edge->width(), 450 is_horizontal ? after_arrow : edge->width(),
451 is_horizontal ? edge->height() : after_arrow); 451 is_horizontal ? edge->height() : after_arrow);
452 } 452 }
453 } 453 }
454 454
455 void BubbleBorder::DrawArrowInterior(gfx::Canvas* canvas, 455 void BubbleBorder::DrawArrowInterior(gfx::Canvas* canvas,
456 float tip_x, 456 float tip_x,
457 float tip_y) const { 457 float tip_y) const {
458 const bool is_horizontal = is_arrow_on_horizontal(arrow_location_);
458 const int offset_to_next_vertex = 459 const int offset_to_next_vertex =
Peter Kasting 2012/07/10 22:45:27 Nit: Slightly simpler: const bool positive_offs
xiyuan 2012/07/11 00:53:55 Changed. I like yours better.
459 (is_arrow_on_left(arrow_location_) || is_arrow_on_top(arrow_location_)) ? 460 ((!is_horizontal && is_arrow_on_left(arrow_location_)) ||
461 (is_horizontal && is_arrow_on_top(arrow_location_))) ?
460 kArrowInteriorHeight : -kArrowInteriorHeight; 462 kArrowInteriorHeight : -kArrowInteriorHeight;
461 463
462 SkPath path; 464 SkPath path;
463 path.incReserve(4); 465 path.incReserve(4);
464 path.moveTo(SkDoubleToScalar(tip_x), SkDoubleToScalar(tip_y)); 466 path.moveTo(SkDoubleToScalar(tip_x), SkDoubleToScalar(tip_y));
465 path.lineTo(SkDoubleToScalar(tip_x + offset_to_next_vertex), 467 path.lineTo(SkDoubleToScalar(tip_x + offset_to_next_vertex),
466 SkDoubleToScalar(tip_y + offset_to_next_vertex)); 468 SkDoubleToScalar(tip_y + offset_to_next_vertex));
467 if (is_arrow_on_horizontal(arrow_location_)) { 469 if (is_horizontal) {
468 path.lineTo(SkDoubleToScalar(tip_x - offset_to_next_vertex), 470 path.lineTo(SkDoubleToScalar(tip_x - offset_to_next_vertex),
469 SkDoubleToScalar(tip_y + offset_to_next_vertex)); 471 SkDoubleToScalar(tip_y + offset_to_next_vertex));
470 } else { 472 } else {
471 path.lineTo(SkDoubleToScalar(tip_x + offset_to_next_vertex), 473 path.lineTo(SkDoubleToScalar(tip_x + offset_to_next_vertex),
472 SkDoubleToScalar(tip_y - offset_to_next_vertex)); 474 SkDoubleToScalar(tip_y - offset_to_next_vertex));
473 } 475 }
474 path.close(); 476 path.close();
475 477
476 SkPaint paint; 478 SkPaint paint;
477 paint.setStyle(SkPaint::kFill_Style); 479 paint.setStyle(SkPaint::kFill_Style);
(...skipping 21 matching lines...) Expand all
499 paint.setColor(border_->background_color()); 501 paint.setColor(border_->background_color());
500 SkPath path; 502 SkPath path;
501 gfx::Rect bounds(view->GetContentsBounds()); 503 gfx::Rect bounds(view->GetContentsBounds());
502 bounds.Inset(-border_->border_thickness(), -border_->border_thickness()); 504 bounds.Inset(-border_->border_thickness(), -border_->border_thickness());
503 SkScalar radius = SkIntToScalar(BubbleBorder::GetCornerRadius()); 505 SkScalar radius = SkIntToScalar(BubbleBorder::GetCornerRadius());
504 path.addRoundRect(gfx::RectToSkRect(bounds), radius, radius); 506 path.addRoundRect(gfx::RectToSkRect(bounds), radius, radius);
505 canvas->DrawPath(path, paint); 507 canvas->DrawPath(path, paint);
506 } 508 }
507 509
508 } // namespace views 510 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698