diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-29 20:25:26 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-29 20:25:26 +0000 |
commit | 9ac3a4cfc733516fa5d996829887b1e86e17a049 (patch) | |
tree | 35807c4789b3e51b0c23cbd2f954af9c08059b92 /views | |
parent | de868cafcc3b2b29a58acebc3e37cd7f4fa923da (diff) | |
download | chromium_src-9ac3a4cfc733516fa5d996829887b1e86e17a049.zip chromium_src-9ac3a4cfc733516fa5d996829887b1e86e17a049.tar.gz chromium_src-9ac3a4cfc733516fa5d996829887b1e86e17a049.tar.bz2 |
Make icon-text spacing configurable.
This is to implement shutdown button on login/locker screen,
which has wider icon-text spacing 10 than 5. See crosbug.com/974 for the mock.
BUG=chromium-os:974, chromium-os:5763
TEST=none
Review URL: http://codereview.chromium.org/4192004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64475 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/controls/button/text_button.cc | 15 | ||||
-rw-r--r-- | views/controls/button/text_button.h | 7 |
2 files changed, 15 insertions, 7 deletions
diff --git a/views/controls/button/text_button.cc b/views/controls/button/text_button.cc index bcff70d..e64d3dc 100644 --- a/views/controls/button/text_button.cc +++ b/views/controls/button/text_button.cc @@ -15,8 +15,8 @@ namespace views { -// Padding between the icon and text. -static const int kIconTextPadding = 5; +// Default space between the icon and text. +static const int kDefaultIconTextSpacing = 5; // Preferred padding between text and edge static const int kPreferredPaddingHorizontal = 6; @@ -195,7 +195,8 @@ TextButton::TextButton(ButtonListener* listener, const std::wstring& text) max_width_(0), normal_has_border_(false), show_multiple_icon_states_(true), - prefix_type_(PREFIX_NONE) { + prefix_type_(PREFIX_NONE), + icon_text_spacing_(kDefaultIconTextSpacing) { SetText(text); set_border(new TextButtonBorder); SetAnimationDuration(kHoverAnimationDurationMs); @@ -297,7 +298,7 @@ void TextButton::Paint(gfx::Canvas* canvas, bool for_drag) { if (icon.width() > 0) { content_width += icon.width(); if (!text_.empty()) - content_width += kIconTextPadding; + content_width += icon_text_spacing_; } // Place the icon along the left edge. int icon_x; @@ -311,7 +312,7 @@ void TextButton::Paint(gfx::Canvas* canvas, bool for_drag) { } int text_x = icon_x; if (icon.width() > 0) - text_x += icon.width() + kIconTextPadding; + text_x += icon.width() + icon_text_spacing_; const int text_width = std::min(text_size_.width(), width() - insets.right() - text_x); int text_y = (available_height - text_size_.height()) / 2 + insets.top(); @@ -319,7 +320,7 @@ void TextButton::Paint(gfx::Canvas* canvas, bool for_drag) { // If the icon should go on the other side, swap the elements. if (icon_placement_ == ICON_ON_RIGHT) { int new_text_x = icon_x; - icon_x = new_text_x + text_width + kIconTextPadding; + icon_x = new_text_x + text_width + icon_text_spacing_; text_x = new_text_x; } @@ -409,7 +410,7 @@ gfx::Size TextButton::GetPreferredSize() { insets.height()); if (icon_.width() > 0 && !text_.empty()) - prefsize.Enlarge(kIconTextPadding, 0); + prefsize.Enlarge(icon_text_spacing_, 0); if (max_width_ > 0) prefsize.set_width(std::min(max_width_, prefsize.width())); diff --git a/views/controls/button/text_button.h b/views/controls/button/text_button.h index d37f1aa..7e204d4 100644 --- a/views/controls/button/text_button.h +++ b/views/controls/button/text_button.h @@ -109,6 +109,10 @@ class TextButton : public CustomButton { void set_prefix_type(PrefixType type) { prefix_type_ = type; } + void set_icon_text_spacing(int icon_text_spacing) { + icon_text_spacing_ = icon_text_spacing; + } + // Sets the icon. void SetIcon(const SkBitmap& icon); void SetHoverIcon(const SkBitmap& icon); @@ -226,6 +230,9 @@ class TextButton : public CustomButton { PrefixType prefix_type_; + // Space between icon and text. + int icon_text_spacing_; + DISALLOW_COPY_AND_ASSIGN(TextButton); }; |