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

Unified Diff: chrome/browser/ui/views/avatar_label.cc

Issue 17176015: Improve the look of the avatar label button (views). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments. Created 7 years, 6 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 | « chrome/browser/ui/views/avatar_label.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/avatar_label.cc
diff --git a/chrome/browser/ui/views/avatar_label.cc b/chrome/browser/ui/views/avatar_label.cc
index 8a6465dbed8ca2fd98fdf1ce4cd7fe12117e7082..11a7056be368f783fa056a205d32a6221fcc1b3d 100644
--- a/chrome/browser/ui/views/avatar_label.cc
+++ b/chrome/browser/ui/views/avatar_label.cc
@@ -4,8 +4,8 @@
#include "chrome/browser/ui/views/avatar_label.h"
+#include "base/memory/scoped_ptr.h"
#include "chrome/browser/themes/theme_properties.h"
-#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/views/avatar_menu_bubble_view.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "grit/generated_resources.h"
@@ -13,8 +13,49 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/theme_provider.h"
-#include "ui/gfx/point.h"
-#include "ui/gfx/rect.h"
+#include "ui/gfx/canvas.h"
+#include "ui/gfx/color_utils.h"
+#include "ui/views/painter.h"
+
+namespace {
+
+// A special text button border for the managed user avatar label.
+class AvatarLabelBorder: public views::TextButtonBorder {
+ public:
+ explicit AvatarLabelBorder(ui::ThemeProvider* theme_provider);
+
+ virtual void Paint(const views::View& view, gfx::Canvas* canvas) OVERRIDE;
+
+ private:
+ scoped_ptr<views::Painter> hot_painter_;
+ scoped_ptr<views::Painter> painter_;
+
+ DISALLOW_COPY_AND_ASSIGN(AvatarLabelBorder);
+};
+
+AvatarLabelBorder::AvatarLabelBorder(ui::ThemeProvider* theme_provider) {
+ const int kHorizontalInset = 10;
+ const int kVerticalInset = 2;
+ SetInsets(gfx::Insets(
+ kVerticalInset, kHorizontalInset, kVerticalInset, kHorizontalInset));
+ SkColor color = theme_provider->GetColor(
+ ThemeProperties::COLOR_MANAGED_USER_LABEL_BACKGROUND);
+ SkColor color2 = color_utils::BlendTowardOppositeLuminance(color, 0x20);
+ painter_.reset(views::Painter::CreateVerticalGradient(color, color2));
+ hot_painter_.reset(views::Painter::CreateVerticalGradient(color2, color));
+}
+
+void AvatarLabelBorder::Paint(const views::View& view, gfx::Canvas* canvas) {
+ const views::TextButton* button =
+ static_cast<const views::TextButton*>(&view);
+ if (button->state() == views::TextButton::STATE_HOVERED ||
+ button->state() == views::TextButton::STATE_PRESSED)
+ hot_painter_->Paint(canvas, view.size());
+ else
+ painter_->Paint(canvas, view.size());
+}
+
+} // namespace
AvatarLabel::AvatarLabel(BrowserView* browser_view,
ui::ThemeProvider* theme_provider)
@@ -25,13 +66,7 @@ AvatarLabel::AvatarLabel(BrowserView* browser_view,
SetFont(ui::ResourceBundle::GetSharedInstance().GetFont(
ui::ResourceBundle::SmallFont));
ClearMaxTextSize();
- views::TextButtonNativeThemeBorder* border =
- new views::TextButtonNativeThemeBorder(this);
- const int kHorizontalInset = 10;
- const int kVerticalInset = 2;
- border->SetInsets(gfx::Insets(
- kVerticalInset, kHorizontalInset, kVerticalInset, kHorizontalInset));
- set_border(border);
+ set_border(new AvatarLabelBorder(theme_provider));
UpdateLabelStyle();
}
@@ -45,15 +80,12 @@ bool AvatarLabel::OnMousePressed(const ui::MouseEvent& event) {
return true;
}
-void AvatarLabel::GetExtraParams(ui::NativeTheme::ExtraParams* params) const {
- TextButton::GetExtraParams(params);
- params->button.background_color = theme_provider_->GetColor(
- ThemeProperties::COLOR_MANAGED_USER_LABEL_BACKGROUND);
-}
-
void AvatarLabel::UpdateLabelStyle() {
SkColor color_label =
theme_provider_->GetColor(ThemeProperties::COLOR_MANAGED_USER_LABEL);
SetEnabledColor(color_label);
+ SetHighlightColor(color_label);
+ SetHoverColor(color_label);
+ SetDisabledColor(color_label);
SchedulePaint();
}
« no previous file with comments | « chrome/browser/ui/views/avatar_label.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698