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

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

Issue 17756003: Colors in views::StyledLabel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Colors from SkColor.h Created 7 years, 6 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 | « ui/views/controls/link.cc ('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 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);
};
« no previous file with comments | « ui/views/controls/link.cc ('k') | ui/views/controls/styled_label.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698