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

Unified Diff: ui/views/controls/styled_label.h

Issue 843023002: [Smart Lock] Add a private API to show an error bubble anchored to the Smart Lock app window. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update error message strings Created 5 years, 11 months 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
Index: ui/views/controls/styled_label.h
diff --git a/ui/views/controls/styled_label.h b/ui/views/controls/styled_label.h
index adbd7a99ba27cdab3d83074ecdb1dc57b8765faf..f3463514bf59adb3ded1079dfedf96aea3365962 100644
--- a/ui/views/controls/styled_label.h
+++ b/ui/views/controls/styled_label.h
@@ -90,6 +90,14 @@ class VIEWS_EXPORT StyledLabel : public View, public LinkListener {
auto_color_readability_enabled_ = auto_color_readability;
}
+ // Resizes the label so its width is set to the width of the longest line and
+ // its height deduced accordingly.
+ // This is only intended for multi-line labels and is useful when the label's
+ // text contains several lines separated with \n.
+ // |max_width| is the maximum width that will be used (longer lines will be
+ // wrapped). If 0, no maximum width is enforced.
+ void SizeToFit(int max_width);
+
// View implementation:
gfx::Insets GetInsets() const override;
int GetHeightForWidth(int w) const override;
@@ -115,10 +123,11 @@ class VIEWS_EXPORT StyledLabel : public View, public LinkListener {
};
typedef std::list<StyleRange> StyleRanges;
- // Calculates how to layout child views, creates them and sets their size
- // and position. |width| is the horizontal space, in pixels, that the view
- // has to work with. If |dry_run| is true, the view hierarchy is not touched.
- // The return value is the necessary size.
+ // Calculates how to layout child views, creates them and sets their size and
+ // position. |width| is the horizontal space, in pixels, that the view has to
+ // work with. If |dry_run| is true, the view hierarchy is not touched. Caches
+ // the results in |calculated_size_|, |width_at_last_layout_|, and
+ // |width_at_last_size_calculation_|. Returns the needed size.
gfx::Size CalculateAndDoLayout(int width, bool dry_run);
// The text to display.
@@ -147,6 +156,7 @@ class VIEWS_EXPORT StyledLabel : public View, public LinkListener {
// This variable saves the result of the last GetHeightForWidth call in order
// to avoid repeated calculation.
mutable gfx::Size calculated_size_;
+ mutable int width_at_last_size_calculation_;
int width_at_last_layout_;
// Background color on which the label is drawn, for auto color readability.

Powered by Google App Engine
This is Rietveld 408576698