Chromium Code Reviews| Index: ui/views/controls/styled_label.h |
| diff --git a/ui/views/controls/styled_label.h b/ui/views/controls/styled_label.h |
| index 4b7e092c121c44b65002bb35f05d4e4db400439f..31b6f61693e5014e15e4e23e4a336e50845de749 100644 |
| --- a/ui/views/controls/styled_label.h |
| +++ b/ui/views/controls/styled_label.h |
| @@ -10,6 +10,7 @@ |
| #include "base/basictypes.h" |
| #include "base/strings/string16.h" |
| +#include "third_party/skia/include/core/SkColor.h" |
| #include "ui/base/range/range.h" |
| #include "ui/gfx/size.h" |
| #include "ui/views/controls/link_listener.h" |
| @@ -39,6 +40,9 @@ class VIEWS_EXPORT StyledLabel : public View, public LinkListener { |
| // values defined in gfx::Font::FontStyle (BOLD, ITALIC, UNDERLINE). |
| int font_style; |
| + // The text color for the range. |
| + SkColor color; |
| + |
| // Tooltip for the range. |
| string16 tooltip; |
| @@ -60,6 +64,17 @@ class VIEWS_EXPORT StyledLabel : public View, public LinkListener { |
| // |range| must be contained in |text_|. |
| void AddStyleRange(const ui::Range& range, const RangeStyleInfo& style_info); |
| + // Enables or disables auto-color-readability (enabled by default). If this |
| + // is enabled, color_utils::GetReadableColor() will be used to ensure that |
| + // the foreground colors are readable over the background color. The |
| + // background color must be set with SetBackgroundColor() for this to work. |
| + void SetAutoColorReadabilityEnabled(bool enabled); |
|
Evan Stade
2013/07/08 18:14:04
is this used somewhere?
fdoray
2013/07/09 18:13:47
No. But a method with the same name in views::Labe
Evan Stade
2013/07/09 18:35:18
yes, remove dead code.
fdoray
2013/07/09 20:54:28
Done.
|
| + |
| + // Sets the background color. This won't be explicitly drawn, but the label |
| + // will force the text color to be readable over it. |
| + void SetBackgroundColor(SkColor color); |
|
Ben Goodger (Google)
2013/07/09 17:36:15
This name implies the background will be drawn tho
fdoray
2013/07/09 18:13:47
I chose this name because it's used in views::Labe
|
| + SkColor background_color() const { return background_color_; } |
| + |
| // View implementation: |
| virtual gfx::Insets GetInsets() const OVERRIDE; |
| virtual int GetHeightForWidth(int w) OVERRIDE; |
| @@ -106,6 +121,14 @@ class VIEWS_EXPORT StyledLabel : public View, public LinkListener { |
| // to avoid repeated calculation. |
| gfx::Size calculated_size_; |
| + // Background color, for auto color readability. |
| + SkColor background_color_; |
| + bool background_color_set_; |
| + |
| + // Indicates whether the foreground colors can be modified to be readable |
| + // over the background color. |
| + bool auto_color_readability_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(StyledLabel); |
| }; |