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

Unified Diff: views/controls/button/text_button.cc

Issue 5071002: Add 1px black border for ChromeOS status button. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: change how common code is shared Created 10 years, 1 month 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 | « views/controls/button/text_button.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/button/text_button.cc
diff --git a/views/controls/button/text_button.cc b/views/controls/button/text_button.cc
index e64d3dca5b602996d710cdfb4166a1fda6d8fa84..f758910b9dce71efb04f5aa16d48c9d312c547be 100644
--- a/views/controls/button/text_button.cc
+++ b/views/controls/button/text_button.cc
@@ -190,6 +190,8 @@ TextButton::TextButton(ButtonListener* listener, const std::wstring& text)
color_disabled_(kDisabledColor),
color_highlight_(kHighlightColor),
color_hover_(kHoverColor),
+ text_halo_color_(0),
+ has_text_halo_(false),
has_hover_icon_(false),
has_pushed_icon_(false),
max_width_(0),
@@ -248,6 +250,11 @@ void TextButton::SetHoverColor(SkColor color) {
color_hover_ = color;
}
+void TextButton::SetTextHaloColor(SkColor color) {
+ text_halo_color_ = color;
+ has_text_halo_ = true;
+}
+
void TextButton::ClearMaxTextSize() {
max_text_size_ = text_size_;
}
@@ -360,6 +367,11 @@ void TextButton::Paint(gfx::Canvas* canvas, bool for_drag) {
text_bounds.height(),
draw_string_flags);
#endif
+ } else if (has_text_halo_) {
+ canvas->AsCanvasSkia()->DrawStringWithHalo(
+ text_, font_, text_color, text_halo_color_, text_bounds.x(),
+ text_bounds.y(), text_bounds.width(), text_bounds.height(),
+ draw_string_flags);
} else {
canvas->DrawStringInt(text_,
font_,
@@ -391,6 +403,13 @@ void TextButton::UpdateTextSize() {
gfx::CanvasSkia::SizeStringInt(
text_, font_, &width, &height,
gfx::Canvas::NO_ELLIPSIS | PrefixTypeToCanvasType(prefix_type_));
+
+ // Add 2 extra pixels to width and height when text halo is used.
+ if (has_text_halo_) {
+ width += 2;
+ height += 2;
+ }
+
text_size_.SetSize(width, font_.GetHeight());
max_text_size_.SetSize(std::max(max_text_size_.width(), text_size_.width()),
std::max(max_text_size_.height(),
« no previous file with comments | « views/controls/button/text_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698