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

Side by Side Diff: chrome/browser/ui/views/profiles/new_avatar_button.cc

Issue 470053004: [Win, Linux] Always display the avatar button text at the same size. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: maybe made test better? Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" 5 #include "chrome/browser/ui/views/profiles/new_avatar_button.h"
6 6
7 #include "base/win/windows_version.h" 7 #include "base/win/windows_version.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/profiles/profile_manager.h" 9 #include "chrome/browser/profiles/profile_manager.h"
10 #include "chrome/browser/profiles/profiles_state.h" 10 #include "chrome/browser/profiles/profiles_state.h"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "grit/theme_resources.h" 12 #include "grit/theme_resources.h"
13 #include "ui/base/resource/resource_bundle.h" 13 #include "ui/base/resource/resource_bundle.h"
14 #include "ui/gfx/canvas.h" 14 #include "ui/gfx/canvas.h"
15 #include "ui/views/border.h" 15 #include "ui/views/border.h"
16 #include "ui/views/controls/button/label_button_border.h" 16 #include "ui/views/controls/button/label_button_border.h"
17 #include "ui/views/painter.h" 17 #include "ui/views/painter.h"
18 18
19 namespace { 19 namespace {
20 20
21 const int kDisplayFontHeight = 15;
22
21 scoped_ptr<views::Border> CreateBorder(const int normal_image_set[], 23 scoped_ptr<views::Border> CreateBorder(const int normal_image_set[],
22 const int hot_image_set[], 24 const int hot_image_set[],
23 const int pushed_image_set[]) { 25 const int pushed_image_set[]) {
24 scoped_ptr<views::LabelButtonBorder> border( 26 scoped_ptr<views::LabelButtonBorder> border(
25 new views::LabelButtonBorder(views::Button::STYLE_TEXTBUTTON)); 27 new views::LabelButtonBorder(views::Button::STYLE_TEXTBUTTON));
26 border->SetPainter(false, views::Button::STATE_NORMAL, 28 border->SetPainter(false, views::Button::STATE_NORMAL,
27 views::Painter::CreateImageGridPainter(normal_image_set)); 29 views::Painter::CreateImageGridPainter(normal_image_set));
28 border->SetPainter(false, views::Button::STATE_HOVERED, 30 border->SetPainter(false, views::Button::STATE_HOVERED,
29 views::Painter::CreateImageGridPainter(hot_image_set)); 31 views::Painter::CreateImageGridPainter(hot_image_set));
30 border->SetPainter(false, views::Button::STATE_PRESSED, 32 border->SetPainter(false, views::Button::STATE_PRESSED,
(...skipping 21 matching lines...) Expand all
52 true), 54 true),
53 browser_(browser) { 55 browser_(browser) {
54 set_animate_on_state_change(false); 56 set_animate_on_state_change(false);
55 SetTextColor(views::Button::STATE_NORMAL, SK_ColorWHITE); 57 SetTextColor(views::Button::STATE_NORMAL, SK_ColorWHITE);
56 SetTextColor(views::Button::STATE_HOVERED, SK_ColorWHITE); 58 SetTextColor(views::Button::STATE_HOVERED, SK_ColorWHITE);
57 SetTextColor(views::Button::STATE_PRESSED, SK_ColorWHITE); 59 SetTextColor(views::Button::STATE_PRESSED, SK_ColorWHITE);
58 SetTextShadows(gfx::ShadowValues(10, 60 SetTextShadows(gfx::ShadowValues(10,
59 gfx::ShadowValue(gfx::Point(), 1.0f, SK_ColorDKGRAY))); 61 gfx::ShadowValue(gfx::Point(), 1.0f, SK_ColorDKGRAY)));
60 SetTextSubpixelRenderingEnabled(false); 62 SetTextSubpixelRenderingEnabled(false);
61 63
64 // Shrink large fonts to make them fit.
65 SetFontList(GetFontList().DeriveWithHeightUpperBound(kDisplayFontHeight));
66
62 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 67 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
63 if (button_style == THEMED_BUTTON) { 68 if (button_style == THEMED_BUTTON) {
64 const int kNormalImageSet[] = IMAGE_GRID(IDR_AVATAR_THEMED_BUTTON_NORMAL); 69 const int kNormalImageSet[] = IMAGE_GRID(IDR_AVATAR_THEMED_BUTTON_NORMAL);
65 const int kHotImageSet[] = IMAGE_GRID(IDR_AVATAR_THEMED_BUTTON_HOVER); 70 const int kHotImageSet[] = IMAGE_GRID(IDR_AVATAR_THEMED_BUTTON_HOVER);
66 const int kPushedImageSet[] = IMAGE_GRID(IDR_AVATAR_THEMED_BUTTON_PRESSED); 71 const int kPushedImageSet[] = IMAGE_GRID(IDR_AVATAR_THEMED_BUTTON_PRESSED);
67 72
68 SetBorder(CreateBorder(kNormalImageSet, kHotImageSet, kPushedImageSet)); 73 SetBorder(CreateBorder(kNormalImageSet, kHotImageSet, kPushedImageSet));
69 set_menu_marker( 74 set_menu_marker(
70 rb->GetImageNamed(IDR_AVATAR_THEMED_BUTTON_DROPARROW).ToImageSkia()); 75 rb->GetImageNamed(IDR_AVATAR_THEMED_BUTTON_DROPARROW).ToImageSkia());
71 #if defined(OS_WIN) 76 #if defined(OS_WIN)
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // We want the button to resize if the new text is shorter. 156 // We want the button to resize if the new text is shorter.
152 SetText(profiles::GetAvatarButtonTextForProfile(browser_->profile())); 157 SetText(profiles::GetAvatarButtonTextForProfile(browser_->profile()));
153 SetMinSize(gfx::Size()); 158 SetMinSize(gfx::Size());
154 InvalidateLayout(); 159 InvalidateLayout();
155 160
156 // Because the width of the button might have changed, the parent browser 161 // Because the width of the button might have changed, the parent browser
157 // frame needs to recalculate the button bounds and redraw it. 162 // frame needs to recalculate the button bounds and redraw it.
158 if (parent()) 163 if (parent())
159 parent()->Layout(); 164 parent()->Layout();
160 } 165 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698