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

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: nits 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"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 browser_(browser), 54 browser_(browser),
55 suppress_mouse_released_action_(false) { 55 suppress_mouse_released_action_(false) {
56 set_animate_on_state_change(false); 56 set_animate_on_state_change(false);
57 SetTextColor(views::Button::STATE_NORMAL, SK_ColorWHITE); 57 SetTextColor(views::Button::STATE_NORMAL, SK_ColorWHITE);
58 SetTextColor(views::Button::STATE_HOVERED, SK_ColorWHITE); 58 SetTextColor(views::Button::STATE_HOVERED, SK_ColorWHITE);
59 SetTextColor(views::Button::STATE_PRESSED, SK_ColorWHITE); 59 SetTextColor(views::Button::STATE_PRESSED, SK_ColorWHITE);
60 SetTextShadows(gfx::ShadowValues(10, 60 SetTextShadows(gfx::ShadowValues(10,
61 gfx::ShadowValue(gfx::Point(), 1.0f, SK_ColorDKGRAY))); 61 gfx::ShadowValue(gfx::Point(), 1.0f, SK_ColorDKGRAY)));
62 SetTextSubpixelRenderingEnabled(false); 62 SetTextSubpixelRenderingEnabled(false);
63 63
64 // The largest text height that fits in the button. If the font list height
65 // is larger than this, it will be shrunk to match it.
Peter Kasting 2014/08/29 18:12:26 Nit: Maybe a TODO about changing the constant here
noms (inactive) 2014/08/29 18:20:22 Done.
66 const int kDisplayFontHeight = 15;
67 SetFontList(GetFontList().DeriveWithHeightUpperBound(kDisplayFontHeight));
68
64 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 69 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
65 if (button_style == THEMED_BUTTON) { 70 if (button_style == THEMED_BUTTON) {
66 const int kNormalImageSet[] = IMAGE_GRID(IDR_AVATAR_THEMED_BUTTON_NORMAL); 71 const int kNormalImageSet[] = IMAGE_GRID(IDR_AVATAR_THEMED_BUTTON_NORMAL);
67 const int kHotImageSet[] = IMAGE_GRID(IDR_AVATAR_THEMED_BUTTON_HOVER); 72 const int kHotImageSet[] = IMAGE_GRID(IDR_AVATAR_THEMED_BUTTON_HOVER);
68 const int kPushedImageSet[] = IMAGE_GRID(IDR_AVATAR_THEMED_BUTTON_PRESSED); 73 const int kPushedImageSet[] = IMAGE_GRID(IDR_AVATAR_THEMED_BUTTON_PRESSED);
69 74
70 SetBorder(CreateBorder(kNormalImageSet, kHotImageSet, kPushedImageSet)); 75 SetBorder(CreateBorder(kNormalImageSet, kHotImageSet, kPushedImageSet));
71 set_menu_marker( 76 set_menu_marker(
72 rb->GetImageNamed(IDR_AVATAR_THEMED_BUTTON_DROPARROW).ToImageSkia()); 77 rb->GetImageNamed(IDR_AVATAR_THEMED_BUTTON_DROPARROW).ToImageSkia());
73 #if defined(OS_WIN) 78 #if defined(OS_WIN)
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 // We want the button to resize if the new text is shorter. 176 // We want the button to resize if the new text is shorter.
172 SetText(profiles::GetAvatarButtonTextForProfile(browser_->profile())); 177 SetText(profiles::GetAvatarButtonTextForProfile(browser_->profile()));
173 SetMinSize(gfx::Size()); 178 SetMinSize(gfx::Size());
174 InvalidateLayout(); 179 InvalidateLayout();
175 180
176 // Because the width of the button might have changed, the parent browser 181 // Because the width of the button might have changed, the parent browser
177 // frame needs to recalculate the button bounds and redraw it. 182 // frame needs to recalculate the button bounds and redraw it.
178 if (parent()) 183 if (parent())
179 parent()->Layout(); 184 parent()->Layout();
180 } 185 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698