| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 images_->bottom_right->height())); | 81 images_->bottom_right->height())); |
| 82 arrow_offset_ = std::max(offset_x, offset_y); | 82 arrow_offset_ = std::max(offset_x, offset_y); |
| 83 } | 83 } |
| 84 | 84 |
| 85 gfx::Rect BubbleBorder::GetBounds(const gfx::Rect& position_relative_to, | 85 gfx::Rect BubbleBorder::GetBounds(const gfx::Rect& position_relative_to, |
| 86 const gfx::Size& contents_size) const { | 86 const gfx::Size& contents_size) const { |
| 87 // Desired size is size of contents enlarged by the size of the border images. | 87 // Desired size is size of contents enlarged by the size of the border images. |
| 88 gfx::Size border_size(contents_size); | 88 gfx::Size border_size(contents_size); |
| 89 gfx::Insets insets; | 89 gfx::Insets insets; |
| 90 GetInsets(&insets); | 90 GetInsets(&insets); |
| 91 border_size.Enlarge(insets.left() + insets.right(), | 91 border_size.Enlarge(insets.width(), insets.height()); |
| 92 insets.top() + insets.bottom()); | |
| 93 | 92 |
| 94 // Screen position depends on the arrow location. | 93 // Screen position depends on the arrow location. |
| 95 // The arrow should overlap the target by some amount since there is space | 94 // The arrow should overlap the target by some amount since there is space |
| 96 // for shadow between arrow tip and bitmap bounds. | 95 // for shadow between arrow tip and bitmap bounds. |
| 97 const int kArrowOverlap = 3; | 96 const int kArrowOverlap = 3; |
| 98 int x = position_relative_to.x(); | 97 int x = position_relative_to.x(); |
| 99 int y = position_relative_to.y(); | 98 int y = position_relative_to.y(); |
| 100 int w = position_relative_to.width(); | 99 int w = position_relative_to.width(); |
| 101 int h = position_relative_to.height(); | 100 int h = position_relative_to.height(); |
| 102 int arrow_offset = override_arrow_offset_ ? override_arrow_offset_ : | 101 int arrow_offset = override_arrow_offset_ ? override_arrow_offset_ : |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 SkRect rect; | 510 SkRect rect; |
| 512 rect.set(SkIntToScalar(bounds.x()), SkIntToScalar(bounds.y()), | 511 rect.set(SkIntToScalar(bounds.x()), SkIntToScalar(bounds.y()), |
| 513 SkIntToScalar(bounds.right()), SkIntToScalar(bounds.bottom())); | 512 SkIntToScalar(bounds.right()), SkIntToScalar(bounds.bottom())); |
| 514 rect.inset(-border_->border_thickness(), -border_->border_thickness()); | 513 rect.inset(-border_->border_thickness(), -border_->border_thickness()); |
| 515 SkScalar radius = SkIntToScalar(BubbleBorder::GetCornerRadius()); | 514 SkScalar radius = SkIntToScalar(BubbleBorder::GetCornerRadius()); |
| 516 path.addRoundRect(rect, radius, radius); | 515 path.addRoundRect(rect, radius, radius); |
| 517 canvas->GetSkCanvas()->drawPath(path, paint); | 516 canvas->GetSkCanvas()->drawPath(path, paint); |
| 518 } | 517 } |
| 519 | 518 |
| 520 } // namespace views | 519 } // namespace views |
| OLD | NEW |