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

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: Rebase Created 7 years, 5 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..5f31ca65ab3a975ab8af76fb61f1144ecaa26b96 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,14 @@ class VIEWS_EXPORT StyledLabel : public View, public LinkListener {
// |range| must be contained in |text_|.
void AddStyleRange(const ui::Range& range, const RangeStyleInfo& style_info);
+ // Sets the color of the background on which the label is drawn. This won't
+ // be explicitly drawn, but the label will force the text color to be
+ // readable over it.
+ void SetDisplayedOnBackgroundColor(SkColor color);
+ SkColor displayed_on_background_color() const {
+ return displayed_on_background_color_;
+ }
+
// View implementation:
virtual gfx::Insets GetInsets() const OVERRIDE;
virtual int GetHeightForWidth(int w) OVERRIDE;
@@ -106,6 +118,10 @@ class VIEWS_EXPORT StyledLabel : public View, public LinkListener {
// to avoid repeated calculation.
gfx::Size calculated_size_;
+ // Background color on which the label is drawn, for auto color readability.
+ SkColor displayed_on_background_color_;
+ bool displayed_on_background_color_set_;
+
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