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> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 const gfx::Insets insets = GetInsets(); | 151 const gfx::Insets insets = GetInsets(); |
152 size.Enlarge(insets.width(), insets.height()); | 152 size.Enlarge(insets.width(), insets.height()); |
153 | 153 |
154 // Ensure the bubble is large enough to not overlap border and arrow images. | 154 // Ensure the bubble is large enough to not overlap border and arrow images. |
155 const int min = 2 * images_->border_thickness; | 155 const int min = 2 * images_->border_thickness; |
156 const int min_with_arrow_width = min + images_->top_arrow.width(); | 156 const int min_with_arrow_width = min + images_->top_arrow.width(); |
157 const int min_with_arrow_thickness = images_->border_thickness + | 157 const int min_with_arrow_thickness = images_->border_thickness + |
158 std::max(images_->arrow_thickness + images_->border_interior_thickness, | 158 std::max(images_->arrow_thickness + images_->border_interior_thickness, |
159 images_->border_thickness); | 159 images_->border_thickness); |
160 if (is_arrow_on_horizontal(arrow_)) | 160 if (is_arrow_on_horizontal(arrow_)) |
161 size.ClampToMin(gfx::Size(min_with_arrow_width, min_with_arrow_thickness)); | 161 size.SetToMax(gfx::Size(min_with_arrow_width, min_with_arrow_thickness)); |
162 else if (has_arrow(arrow_)) | 162 else if (has_arrow(arrow_)) |
163 size.ClampToMin(gfx::Size(min_with_arrow_thickness, min_with_arrow_width)); | 163 size.SetToMax(gfx::Size(min_with_arrow_thickness, min_with_arrow_width)); |
164 else | 164 else |
165 size.ClampToMin(gfx::Size(min, min)); | 165 size.SetToMax(gfx::Size(min, min)); |
166 | 166 |
167 int x = anchor_rect.x(); | 167 int x = anchor_rect.x(); |
168 int y = anchor_rect.y(); | 168 int y = anchor_rect.y(); |
169 int w = anchor_rect.width(); | 169 int w = anchor_rect.width(); |
170 int h = anchor_rect.height(); | 170 int h = anchor_rect.height(); |
171 const int arrow_offset = GetArrowOffset(size); | 171 const int arrow_offset = GetArrowOffset(size); |
172 const int arrow_size = | 172 const int arrow_size = |
173 images_->arrow_interior_thickness + kStroke - images_->arrow_thickness; | 173 images_->arrow_interior_thickness + kStroke - images_->arrow_thickness; |
174 const bool mid_anchor = alignment_ == ALIGN_ARROW_TO_MID_ANCHOR; | 174 const bool mid_anchor = alignment_ == ALIGN_ARROW_TO_MID_ANCHOR; |
175 | 175 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 // Note: This matches the legacy appearance of SHADOW's extra large inset. | 354 // Note: This matches the legacy appearance of SHADOW's extra large inset. |
355 if (border_->shadow() == BubbleBorder::SHADOW) | 355 if (border_->shadow() == BubbleBorder::SHADOW) |
356 bounds.Inset(-10, -10); | 356 bounds.Inset(-10, -10); |
357 | 357 |
358 SkScalar radius = SkIntToScalar(border_->GetBorderCornerRadius()); | 358 SkScalar radius = SkIntToScalar(border_->GetBorderCornerRadius()); |
359 path.addRoundRect(gfx::RectToSkRect(bounds), radius, radius); | 359 path.addRoundRect(gfx::RectToSkRect(bounds), radius, radius); |
360 canvas->DrawPath(path, paint); | 360 canvas->DrawPath(path, paint); |
361 } | 361 } |
362 | 362 |
363 } // namespace views | 363 } // namespace views |
OLD | NEW |