Index: chrome/browser/ui/views/avatar_menu_bubble_view.cc |
diff --git a/chrome/browser/ui/views/avatar_menu_bubble_view.cc b/chrome/browser/ui/views/avatar_menu_bubble_view.cc |
index a4e34ea49c71ebde974a572bf5017d22ad658d3c..11c10a616c6dc509f803d0606bcfdd0dde6fe8d7 100644 |
--- a/chrome/browser/ui/views/avatar_menu_bubble_view.cc |
+++ b/chrome/browser/ui/views/avatar_menu_bubble_view.cc |
@@ -10,6 +10,7 @@ |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/profiles/avatar_menu_model.h" |
#include "chrome/browser/profiles/profile_info_cache.h" |
+#include "chrome/browser/profiles/profile_info_util.h" |
#include "chrome/browser/profiles/profile_manager.h" |
#include "chrome/browser/ui/browser.h" |
#include "grit/generated_resources.h" |
@@ -34,7 +35,6 @@ const SkColor kColor = SK_ColorWHITE; |
const int kItemHeight = 44; |
const int kItemMarginY = 4; |
-const int kIconWidth = 38; |
const int kIconMarginX = 6; |
const int kSeparatorPaddingY = 5; |
@@ -226,17 +226,26 @@ gfx::Size ProfileItemView::GetPreferredSize() { |
int width = std::max(name_label_->GetPreferredSize().width(), |
sync_state_label_->GetPreferredSize().width()); |
width = std::max(edit_link_->GetPreferredSize().width(), width); |
- return gfx::Size(kIconWidth + kIconMarginX + width, kItemHeight); |
+ return gfx::Size(profiles::kAvatarIconWidth + kIconMarginX + width, |
+ kItemHeight); |
} |
void ProfileItemView::Layout() { |
// Profile icon. |
- const SkBitmap& icon = image_view_->GetImage(); |
- gfx::Rect icon_rect = GetCenteredAndScaledRect( |
- icon.width(), icon.height(), 0, 0, kIconWidth, height()); |
sail
2011/11/26 06:59:04
This old code had a bug in it. It assumed that the
|
+ gfx::Rect icon_rect; |
+ if (item_.active) { |
+ // If this is the active item then the icon is already scaled and so |
+ // just use the preferred size. |
+ icon_rect.set_size(image_view_->GetPreferredSize()); |
+ icon_rect.set_y((height() - icon_rect.height()) / 2); |
+ } else { |
+ const SkBitmap& icon = image_view_->GetImage(); |
+ icon_rect = GetCenteredAndScaledRect(icon.width(), icon.height(), 0, 0, |
+ profiles::kAvatarIconWidth, height()); |
+ } |
image_view_->SetBoundsRect(icon_rect); |
- int label_x = icon_rect.right() + kIconMarginX; |
+ int label_x = profiles::kAvatarIconWidth + kIconMarginX; |
int max_label_width = std::max(width() - label_x, 0); |
gfx::Size name_size = name_label_->GetPreferredSize(); |
name_size.set_width(std::min(name_size.width(), max_label_width)); |
@@ -297,8 +306,8 @@ void ProfileItemView::OnFocusStateChanged(bool has_focus) { |
// static |
SkBitmap ProfileItemView::GetBadgedIcon(const SkBitmap& icon) { |
- gfx::Rect icon_rect = GetCenteredAndScaledRect( |
- icon.width(), icon.height(), 0, 0, kIconWidth, kItemHeight); |
+ gfx::Rect icon_rect = GetCenteredAndScaledRect(icon.width(), icon.height(), |
+ 0, 0, profiles::kAvatarIconWidth, kItemHeight); |
ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
SkBitmap badge = rb.GetImageNamed(IDR_PROFILE_SELECTED); |
@@ -361,7 +370,7 @@ gfx::Size AvatarMenuBubbleView::GetPreferredSize() { |
gfx::Size add_profile_size = add_profile_link_->GetPreferredSize(); |
max_width = std::max(max_width, |
- add_profile_size.width() + kIconWidth + kIconMarginX); |
+ add_profile_size.width() + profiles::kAvatarIconWidth + kIconMarginX); |
total_height += add_profile_link_->GetPreferredSize().height(); |
const int kBubbleViewMaxWidth = 800; |
@@ -386,8 +395,8 @@ void AvatarMenuBubbleView::Layout() { |
separator_->SetBounds(0, y, width(), separator_height); |
y += kSeparatorPaddingY + separator_height; |
- add_profile_link_->SetBounds(kIconWidth + kIconMarginX, y, width(), |
- add_profile_link_->GetPreferredSize().height()); |
+ add_profile_link_->SetBounds(profiles::kAvatarIconWidth + kIconMarginX, y, |
+ width(), add_profile_link_->GetPreferredSize().height()); |
} |
bool AvatarMenuBubbleView::AcceleratorPressed( |