| OLD | NEW |
| 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 Loading... |
| 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 int offset_to_next_vertex = | 458 const bool is_horizontal = is_arrow_on_horizontal(arrow_location_); |
| 459 (is_arrow_on_left(arrow_location_) || is_arrow_on_top(arrow_location_)) ? | 459 const bool positive_offset = is_horizontal ? |
| 460 is_arrow_on_top(arrow_location_) : is_arrow_on_left(arrow_location_); |
| 461 const int offset_to_next_vertex = positive_offset ? |
| 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 Loading... |
| 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 |
| OLD | NEW |