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

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: Rebase 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
« no previous file with comments | « tools/metrics/histograms/histograms.xml ('k') | ui/views/controls/styled_label.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/styled_label.h
diff --git a/ui/views/controls/styled_label.h b/ui/views/controls/styled_label.h
index 40cdafb7124c7c711c363e576a71e556c5219aef..57638c50f82b08602e72efbdf047eec68b97d24b 100644
--- a/ui/views/controls/styled_label.h
+++ b/ui/views/controls/styled_label.h
@@ -93,9 +93,18 @@ class VIEWS_EXPORT StyledLabel : public View, public LinkListener {
auto_color_readability_enabled_ = auto_color_readability;
}
- // views::View:
+ // 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:
const char* GetClassName() const override;
gfx::Insets GetInsets() const override;
+ gfx::Size GetPreferredSize() const override;
int GetHeightForWidth(int w) const override;
void Layout() override;
void PreferredSizeChanged() override;
@@ -119,10 +128,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.
@@ -151,6 +161,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.
« no previous file with comments | « tools/metrics/histograms/histograms.xml ('k') | ui/views/controls/styled_label.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698