OLD | NEW |
---|---|
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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "chrome/app/vector_icons/vector_icons.h" | 10 #include "chrome/app/vector_icons/vector_icons.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON); | 67 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON); |
68 set_animate_on_state_change(false); | 68 set_animate_on_state_change(false); |
69 SetEnabledTextColors(SK_ColorWHITE); | 69 SetEnabledTextColors(SK_ColorWHITE); |
70 SetTextSubpixelRenderingEnabled(false); | 70 SetTextSubpixelRenderingEnabled(false); |
71 SetHorizontalAlignment(gfx::ALIGN_CENTER); | 71 SetHorizontalAlignment(gfx::ALIGN_CENTER); |
72 | 72 |
73 // The largest text height that fits in the button. If the font list height | 73 // The largest text height that fits in the button. If the font list height |
74 // is larger than this, it will be shrunk to match it. | 74 // is larger than this, it will be shrunk to match it. |
75 // TODO(noms): Calculate this constant algorithmically from the button's size. | 75 // TODO(noms): Calculate this constant algorithmically from the button's size. |
76 const int kDisplayFontHeight = 16; | 76 const int kDisplayFontHeight = 16; |
77 SetFontList( | 77 label()->SetFontList( |
78 label()->font_list().DeriveWithHeightUpperBound(kDisplayFontHeight)); | 78 label()->font_list().DeriveWithHeightUpperBound(kDisplayFontHeight)); |
tapted
2017/04/07 07:49:52
This `DeriveWithHeightUpperBound` method is horrib
Peter Kasting
2017/04/08 01:38:54
Long-term, anywhere that uses this should really p
tapted
2017/04/10 12:27:33
Acknowledged.
| |
79 | 79 |
80 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 80 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
81 if (button_style == AvatarButtonStyle::THEMED) { | 81 if (button_style == AvatarButtonStyle::THEMED) { |
82 const int kNormalImageSet[] = IMAGE_GRID(IDR_AVATAR_THEMED_BUTTON_NORMAL); | 82 const int kNormalImageSet[] = IMAGE_GRID(IDR_AVATAR_THEMED_BUTTON_NORMAL); |
83 const int kHotImageSet[] = IMAGE_GRID(IDR_AVATAR_THEMED_BUTTON_HOVER); | 83 const int kHotImageSet[] = IMAGE_GRID(IDR_AVATAR_THEMED_BUTTON_HOVER); |
84 const int kPushedImageSet[] = IMAGE_GRID(IDR_AVATAR_THEMED_BUTTON_PRESSED); | 84 const int kPushedImageSet[] = IMAGE_GRID(IDR_AVATAR_THEMED_BUTTON_PRESSED); |
85 | 85 |
86 SetBorder(CreateBorder(kNormalImageSet, kHotImageSet, kPushedImageSet)); | 86 SetBorder(CreateBorder(kNormalImageSet, kHotImageSet, kPushedImageSet)); |
87 generic_avatar_ = | 87 generic_avatar_ = |
88 *rb->GetImageNamed(IDR_AVATAR_THEMED_BUTTON_AVATAR).ToImageSkia(); | 88 *rb->GetImageNamed(IDR_AVATAR_THEMED_BUTTON_AVATAR).ToImageSkia(); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 } | 208 } |
209 | 209 |
210 // If we are not using the generic button, then reset the spacing between | 210 // If we are not using the generic button, then reset the spacing between |
211 // the text and the possible authentication error icon. | 211 // the text and the possible authentication error icon. |
212 const int kDefaultImageTextSpacing = 5; | 212 const int kDefaultImageTextSpacing = 5; |
213 SetImageLabelSpacing(use_generic_button ? 0 : kDefaultImageTextSpacing); | 213 SetImageLabelSpacing(use_generic_button ? 0 : kDefaultImageTextSpacing); |
214 | 214 |
215 PreferredSizeChanged(); | 215 PreferredSizeChanged(); |
216 delegate_->ButtonPreferredSizeChanged(); | 216 delegate_->ButtonPreferredSizeChanged(); |
217 } | 217 } |
OLD | NEW |