| 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 "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 Loading... |
| 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. |
| 66 // TODO(noms): Calculate this constant algorithmically. |
| 67 const int kDisplayFontHeight = 15; |
| 68 SetFontList(GetFontList().DeriveWithHeightUpperBound(kDisplayFontHeight)); |
| 69 |
| 64 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 70 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| 65 if (button_style == THEMED_BUTTON) { | 71 if (button_style == THEMED_BUTTON) { |
| 66 const int kNormalImageSet[] = IMAGE_GRID(IDR_AVATAR_THEMED_BUTTON_NORMAL); | 72 const int kNormalImageSet[] = IMAGE_GRID(IDR_AVATAR_THEMED_BUTTON_NORMAL); |
| 67 const int kHotImageSet[] = IMAGE_GRID(IDR_AVATAR_THEMED_BUTTON_HOVER); | 73 const int kHotImageSet[] = IMAGE_GRID(IDR_AVATAR_THEMED_BUTTON_HOVER); |
| 68 const int kPushedImageSet[] = IMAGE_GRID(IDR_AVATAR_THEMED_BUTTON_PRESSED); | 74 const int kPushedImageSet[] = IMAGE_GRID(IDR_AVATAR_THEMED_BUTTON_PRESSED); |
| 69 | 75 |
| 70 SetBorder(CreateBorder(kNormalImageSet, kHotImageSet, kPushedImageSet)); | 76 SetBorder(CreateBorder(kNormalImageSet, kHotImageSet, kPushedImageSet)); |
| 71 set_menu_marker( | 77 set_menu_marker( |
| 72 rb->GetImageNamed(IDR_AVATAR_THEMED_BUTTON_DROPARROW).ToImageSkia()); | 78 rb->GetImageNamed(IDR_AVATAR_THEMED_BUTTON_DROPARROW).ToImageSkia()); |
| 73 #if defined(OS_WIN) | 79 #if defined(OS_WIN) |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 // We want the button to resize if the new text is shorter. | 177 // We want the button to resize if the new text is shorter. |
| 172 SetText(profiles::GetAvatarButtonTextForProfile(browser_->profile())); | 178 SetText(profiles::GetAvatarButtonTextForProfile(browser_->profile())); |
| 173 SetMinSize(gfx::Size()); | 179 SetMinSize(gfx::Size()); |
| 174 InvalidateLayout(); | 180 InvalidateLayout(); |
| 175 | 181 |
| 176 // Because the width of the button might have changed, the parent browser | 182 // Because the width of the button might have changed, the parent browser |
| 177 // frame needs to recalculate the button bounds and redraw it. | 183 // frame needs to recalculate the button bounds and redraw it. |
| 178 if (parent()) | 184 if (parent()) |
| 179 parent()->Layout(); | 185 parent()->Layout(); |
| 180 } | 186 } |
| OLD | NEW |