| Index: chrome/browser/ui/views/profiles/new_avatar_button.cc
|
| diff --git a/chrome/browser/ui/views/profiles/new_avatar_button.cc b/chrome/browser/ui/views/profiles/new_avatar_button.cc
|
| index 117f703edd5f3505f2c7f86bcfde089611349b8d..173eb145ec1117af9d8b736d215b660cb38d9372 100644
|
| --- a/chrome/browser/ui/views/profiles/new_avatar_button.cc
|
| +++ b/chrome/browser/ui/views/profiles/new_avatar_button.cc
|
| @@ -4,7 +4,6 @@
|
|
|
| #include "chrome/browser/ui/views/profiles/new_avatar_button.h"
|
|
|
| -#include "base/strings/utf_string_conversions.h"
|
| #include "base/win/windows_version.h"
|
| #include "chrome/browser/browser_process.h"
|
| #include "chrome/browser/profiles/profile_manager.h"
|
| @@ -19,33 +18,28 @@
|
| #include "ui/gfx/canvas.h"
|
| #include "ui/gfx/color_utils.h"
|
| #include "ui/gfx/font_list.h"
|
| -#include "ui/gfx/text_constants.h"
|
| #include "ui/gfx/text_elider.h"
|
| #include "ui/views/border.h"
|
| -#include "ui/views/controls/button/label_button_border.h"
|
| #include "ui/views/painter.h"
|
|
|
| namespace {
|
|
|
| // Text padding within the button border.
|
| -const int kLeftRightInset = 7;
|
| -const int kTopBottomInset = 2;
|
| +const int kInset = 10;
|
|
|
| scoped_ptr<views::Border> CreateBorder(const int normal_image_set[],
|
| const int hot_image_set[],
|
| const int pushed_image_set[]) {
|
| - scoped_ptr<views::LabelButtonBorder> border(
|
| - new views::LabelButtonBorder(views::Button::STYLE_TEXTBUTTON));
|
| + scoped_ptr<views::TextButtonDefaultBorder> border(
|
| + new views::TextButtonDefaultBorder());
|
|
|
| - border->SetPainter(false, views::Button::STATE_NORMAL,
|
| + border->SetInsets(gfx::Insets(kInset, kInset, kInset, kInset));
|
| + border->set_normal_painter(
|
| views::Painter::CreateImageGridPainter(normal_image_set));
|
| - border->SetPainter(false, views::Button::STATE_HOVERED,
|
| + border->set_hot_painter(
|
| views::Painter::CreateImageGridPainter(hot_image_set));
|
| - border->SetPainter(false, views::Button::STATE_PRESSED,
|
| + border->set_pushed_painter(
|
| views::Painter::CreateImageGridPainter(pushed_image_set));
|
| -
|
| - border->set_insets(gfx::Insets(kTopBottomInset, kLeftRightInset,
|
| - kTopBottomInset, kLeftRightInset));
|
|
|
| return border.PassAs<views::Border>();
|
| }
|
| @@ -77,11 +71,7 @@
|
| : MenuButton(listener, GetButtonText(browser->profile()), NULL, true),
|
| browser_(browser) {
|
| set_animate_on_state_change(false);
|
| - SetTextColor(views::Button::STATE_NORMAL, SK_ColorWHITE);
|
| - SetTextColor(views::Button::STATE_HOVERED, SK_ColorWHITE);
|
| - SetTextColor(views::Button::STATE_PRESSED, SK_ColorWHITE);
|
| - SetHaloColor(SK_ColorDKGRAY);
|
| - SetHorizontalAlignment(gfx::ALIGN_RIGHT);
|
| + set_icon_placement(ICON_ON_RIGHT);
|
|
|
| ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
|
|
|
| @@ -140,6 +130,22 @@
|
| error->RemoveObserver(this);
|
| }
|
|
|
| +void NewAvatarButton::OnPaintText(gfx::Canvas* canvas, PaintButtonMode mode) {
|
| + // Get text bounds, and then adjust for the top and RTL languages.
|
| + gfx::Rect rect = GetTextBounds();
|
| + rect.Offset(0, -rect.y());
|
| + if (rect.width() > 0)
|
| + rect.set_x(GetMirroredXForRect(rect));
|
| +
|
| + canvas->DrawStringRectWithHalo(
|
| + text(),
|
| + gfx::FontList(),
|
| + SK_ColorWHITE,
|
| + SK_ColorDKGRAY,
|
| + rect,
|
| + gfx::Canvas::NO_SUBPIXEL_RENDERING);
|
| +}
|
| +
|
| void NewAvatarButton::OnProfileAdded(const base::FilePath& profile_path) {
|
| UpdateAvatarButtonAndRelayoutParent();
|
| }
|
| @@ -167,15 +173,14 @@
|
| icon = *rb->GetImageNamed(IDR_WARNING).ToImageSkia();
|
| }
|
|
|
| - SetImage(views::Button::STATE_NORMAL, icon);
|
| + SetIcon(icon);
|
| UpdateAvatarButtonAndRelayoutParent();
|
| }
|
|
|
| void NewAvatarButton::UpdateAvatarButtonAndRelayoutParent() {
|
| // We want the button to resize if the new text is shorter.
|
| SetText(GetButtonText(browser_->profile()));
|
| - set_min_size(gfx::Size());
|
| - InvalidateLayout();
|
| + ClearMaxTextSize();
|
|
|
| // Because the width of the button might have changed, the parent browser
|
| // frame needs to recalculate the button bounds and redraw it.
|
|
|