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

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

Issue 10933049: Fixed position of plus image on action box button; added ICON_CENTERED placement to TextButton (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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/button/text_button.h ('k') | ui/views/examples/button_example.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/button/text_button.cc
diff --git a/ui/views/controls/button/text_button.cc b/ui/views/controls/button/text_button.cc
index 1a4c4e700cadce959305fb9e01ea9af2caf37e65..93644c3a16757aef6b58ce12119f32fded54de95 100644
--- a/ui/views/controls/button/text_button.cc
+++ b/ui/views/controls/button/text_button.cc
@@ -730,13 +730,16 @@ void TextButton::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
gfx::Rect text_bounds = GetTextBounds();
int icon_x;
int spacing = text_.empty() ? 0 : icon_text_spacing_;
+ gfx::Insets insets = GetInsets();
if (icon_placement_ == ICON_ON_LEFT) {
icon_x = text_bounds.x() - icon.width() - spacing;
- } else {
+ } else if (icon_placement_ == ICON_ON_RIGHT) {
icon_x = text_bounds.right() + spacing;
+ } else { // ICON_CENTERED
+ DCHECK(text_.empty());
+ icon_x = (width() - insets.width() - icon.width()) / 2 + insets.left();
}
- gfx::Insets insets = GetInsets();
int available_height = height() - insets.height();
int icon_y = (available_height - icon.height()) / 2 + insets.top();
@@ -785,7 +788,7 @@ gfx::Rect TextButton::GetTextBounds() const {
// Make sure the icon is always fully visible.
if (icon_placement_ == ICON_ON_LEFT) {
bounds.Inset(extra_width, 0, 0, 0);
- } else {
+ } else if (icon_placement_ == ICON_ON_RIGHT) {
bounds.Inset(0, 0, extra_width, 0);
}
}
« no previous file with comments | « ui/views/controls/button/text_button.h ('k') | ui/views/examples/button_example.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698