Index: ui/views/bubble/bubble_border.cc |
diff --git a/ui/views/bubble/bubble_border.cc b/ui/views/bubble/bubble_border.cc |
index 03b422aefb285f83b7d39f88271f1ebbab087b19..37fbf373fd72d31e4f2d83b02d2bcdf66c1ad268 100644 |
--- a/ui/views/bubble/bubble_border.cc |
+++ b/ui/views/bubble/bubble_border.cc |
@@ -72,9 +72,6 @@ BorderImages::BorderImages(const int border_image_ids[], |
namespace { |
-// The border and arrow stroke size used in image assets, in pixels. |
-const int kStroke = 1; |
- |
// Bubble border and arrow image resource ids. They don't use the IMAGE_GRID |
// macro because there is no center image. |
const int kNoShadowImages[] = { |
@@ -150,6 +147,8 @@ BorderImages* GetBorderImages(BubbleBorder::Shadow shadow) { |
} // namespace |
+const int BubbleBorder::kStroke = 1; |
+ |
BubbleBorder::BubbleBorder(Arrow arrow, Shadow shadow, SkColor color) |
: arrow_(arrow), |
arrow_offset_(0), |
@@ -172,30 +171,35 @@ gfx::Rect BubbleBorder::GetBounds(const gfx::Rect& anchor_rect, |
int h = anchor_rect.height(); |
const gfx::Size size(GetSizeForContentsSize(contents_size)); |
const int arrow_offset = GetArrowOffset(size); |
- const int arrow_size = |
- images_->arrow_interior_thickness + kStroke - images_->arrow_thickness; |
+ const int arrow_size = GetArrowSize(); |
const bool mid_anchor = alignment_ == ALIGN_ARROW_TO_MID_ANCHOR; |
// Calculate the bubble coordinates based on the border and arrow settings. |
if (is_arrow_on_horizontal(arrow_)) { |
if (is_arrow_on_left(arrow_)) { |
- x += mid_anchor ? w / 2 - arrow_offset : kStroke - GetBorderThickness(); |
+ x += mid_anchor ? |
+ w / 2 - arrow_offset : |
+ kStroke - GetBorderExteriorThickness(); |
} else if (is_arrow_at_center(arrow_)) { |
x += w / 2 - arrow_offset; |
} else { |
- x += mid_anchor ? w / 2 + arrow_offset - size.width() : |
- w - size.width() + GetBorderThickness() - kStroke; |
+ x += mid_anchor ? |
+ w / 2 + arrow_offset - size.width() : |
+ w - size.width() + GetBorderExteriorThickness() - kStroke; |
} |
y += is_arrow_on_top(arrow_) ? h + arrow_size : -arrow_size - size.height(); |
} else if (has_arrow(arrow_)) { |
x += is_arrow_on_left(arrow_) ? w + arrow_size : -arrow_size - size.width(); |
if (is_arrow_on_top(arrow_)) { |
- y += mid_anchor ? h / 2 - arrow_offset : kStroke - GetBorderThickness(); |
+ y += mid_anchor ? |
+ h / 2 - arrow_offset : |
+ kStroke - GetBorderExteriorThickness(); |
} else if (is_arrow_at_center(arrow_)) { |
y += h / 2 - arrow_offset; |
} else { |
- y += mid_anchor ? h / 2 + arrow_offset - size.height() : |
- h - size.height() + GetBorderThickness() - kStroke; |
+ y += mid_anchor ? |
+ h / 2 + arrow_offset - size.height() : |
+ h - size.height() + GetBorderExteriorThickness() - kStroke; |
} |
} else { |
x += (w - size.width()) / 2; |
@@ -205,7 +209,23 @@ gfx::Rect BubbleBorder::GetBounds(const gfx::Rect& anchor_rect, |
return gfx::Rect(x, y, size.width(), size.height()); |
} |
+int BubbleBorder::GetArrowThickness() const { |
+ return images_->arrow_thickness; |
+} |
+ |
+int BubbleBorder::GetTopArrowWidth() const { |
+ return images_->top_arrow.width(); |
+} |
+ |
int BubbleBorder::GetBorderThickness() const { |
+ return images_->border_thickness; |
+} |
+ |
+int BubbleBorder::GetBorderInteriorThickness() const { |
+ return images_->border_interior_thickness; |
+} |
+ |
+int BubbleBorder::GetBorderExteriorThickness() const { |
return images_->border_thickness - images_->border_interior_thickness; |
} |
@@ -225,9 +245,13 @@ int BubbleBorder::GetArrowOffset(const gfx::Size& border_size) const { |
return std::max(min, std::min(arrow_offset_, edge_length - min)); |
} |
+int BubbleBorder::GetArrowSize() const { |
+ return images_->arrow_interior_thickness + kStroke - images_->arrow_thickness; |
+} |
+ |
void BubbleBorder::Paint(const views::View& view, gfx::Canvas* canvas) { |
gfx::Rect bounds(view.GetContentsBounds()); |
- bounds.Inset(-GetBorderThickness(), -GetBorderThickness()); |
+ bounds.Inset(-GetBorderExteriorThickness(), -GetBorderExteriorThickness()); |
const gfx::Rect arrow_bounds = GetArrowRect(view.GetLocalBounds()); |
if (arrow_bounds.IsEmpty()) { |
Painter::PaintPainterAt(canvas, images_->border_painter.get(), bounds); |
@@ -246,7 +270,7 @@ void BubbleBorder::Paint(const views::View& view, gfx::Canvas* canvas) { |
gfx::Insets BubbleBorder::GetInsets() const { |
// The insets contain the stroke and shadow pixels outside the bubble fill. |
- const int inset = GetBorderThickness(); |
+ const int inset = GetBorderExteriorThickness(); |
if ((arrow_paint_type_ == PAINT_NONE) || !has_arrow(arrow_)) |
return gfx::Insets(inset, inset, inset, inset); |
@@ -278,7 +302,7 @@ gfx::Size BubbleBorder::GetSizeForContentsSize( |
std::max(images_->arrow_thickness + images_->border_interior_thickness, |
images_->border_thickness); |
// Only take arrow image sizes into account when the bubble tip is shown. |
- if (arrow_paint_type_ == PAINT_TRANSPARENT || !has_arrow(arrow_)) |
+ if (arrow_paint_type_ == PAINT_NONE || !has_arrow(arrow_)) |
size.SetToMax(gfx::Size(min, min)); |
else if (is_arrow_on_horizontal(arrow_)) |
size.SetToMax(gfx::Size(min_with_arrow_width, min_with_arrow_thickness)); |