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

Unified Diff: ui/views/bubble/bubble_border.cc

Issue 82483003: Add GetMinimumSize() for Borders, and make LabelButton auto-size to at least as (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/bubble/bubble_border.h ('k') | ui/views/controls/button/label_button.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/bubble/bubble_border.cc
===================================================================
--- ui/views/bubble/bubble_border.cc (revision 236640)
+++ ui/views/bubble/bubble_border.cc (working copy)
@@ -163,29 +163,11 @@
gfx::Rect BubbleBorder::GetBounds(const gfx::Rect& anchor_rect,
const gfx::Size& contents_size) const {
- // Enlarge the contents size by the thickness of the border images.
- gfx::Size size(contents_size);
- const gfx::Insets insets = GetInsets();
- size.Enlarge(insets.width(), insets.height());
-
- // Ensure the bubble is large enough to not overlap border and arrow images.
- const int min = 2 * images_->border_thickness;
- const int min_with_arrow_width = min + images_->top_arrow.width();
- const int min_with_arrow_thickness = images_->border_thickness +
- 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_))
- 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));
- else
- size.SetToMax(gfx::Size(min_with_arrow_thickness, min_with_arrow_width));
-
int x = anchor_rect.x();
int y = anchor_rect.y();
int w = anchor_rect.width();
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;
@@ -275,6 +257,33 @@
gfx::Insets(inset, first_inset, inset, second_inset);
}
+gfx::Size BubbleBorder::GetMinimumSize() const {
+ return GetSizeForContentsSize(gfx::Size());
+}
+
+gfx::Size BubbleBorder::GetSizeForContentsSize(
+ const gfx::Size& contents_size) const {
+ // Enlarge the contents size by the thickness of the border images.
+ gfx::Size size(contents_size);
+ const gfx::Insets insets = GetInsets();
+ size.Enlarge(insets.width(), insets.height());
+
+ // Ensure the bubble is large enough to not overlap border and arrow images.
+ const int min = 2 * images_->border_thickness;
+ const int min_with_arrow_width = min + images_->top_arrow.width();
+ const int min_with_arrow_thickness = images_->border_thickness +
+ 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_))
+ 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));
+ else
+ size.SetToMax(gfx::Size(min_with_arrow_thickness, min_with_arrow_width));
+ return size;
+}
+
gfx::ImageSkia* BubbleBorder::GetArrowImage() const {
if (!has_arrow(arrow_))
return NULL;
« no previous file with comments | « ui/views/bubble/bubble_border.h ('k') | ui/views/controls/button/label_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698