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

Side by Side Diff: chrome/browser/ui/views/profile_chooser_view.cc

Issue 24647003: Redesign of the avatar menu button. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sky nits Created 7 years, 2 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/profile_chooser_view.h" 5 #include "chrome/browser/ui/views/profile_chooser_view.h"
6 6
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/profiles/profile_info_util.h" 8 #include "chrome/browser/profiles/profile_info_util.h"
9 #include "chrome/browser/profiles/profile_manager.h" 9 #include "chrome/browser/profiles/profile_manager.h"
10 #include "chrome/browser/profiles/profile_window.h" 10 #include "chrome/browser/profiles/profile_window.h"
(...skipping 26 matching lines...) Expand all
37 #endif 37 #endif
38 38
39 namespace { 39 namespace {
40 40
41 // Helpers -------------------------------------------------------------------- 41 // Helpers --------------------------------------------------------------------
42 42
43 const int kLargeImageSide = 64; 43 const int kLargeImageSide = 64;
44 const int kSmallImageSide = 32; 44 const int kSmallImageSide = 32;
45 const int kMinMenuWidth = 250; 45 const int kMinMenuWidth = 250;
46 const int kButtonHeight = 29; 46 const int kButtonHeight = 29;
47 const int kArrowHeight = 10;
47 48
48 // Current profile avatar image. 49 // Current profile avatar image.
49 views::View* CreateProfileImageView(const gfx::Image& icon) { 50 views::View* CreateProfileImageView(const gfx::Image& icon) {
50 views::ImageView* view = new views::ImageView(); 51 views::ImageView* view = new views::ImageView();
51 52
52 gfx::Image image = profiles::GetSizedAvatarIconWithBorder( 53 gfx::Image image = profiles::GetSizedAvatarIconWithBorder(
53 icon, true, 54 icon, true,
54 kLargeImageSide + profiles::kAvatarIconBorder, 55 kLargeImageSide + profiles::kAvatarIconBorder,
55 kLargeImageSide + profiles::kAvatarIconBorder); 56 kLargeImageSide + profiles::kAvatarIconBorder);
56 view->SetImage(image.ToImageSkia()); 57 view->SetImage(image.ToImageSkia());
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 if (IsShowing()) 189 if (IsShowing())
189 // TODO(bcwhite): handle case where we should show on different window 190 // TODO(bcwhite): handle case where we should show on different window
190 return; 191 return;
191 192
192 profile_bubble_ = new ProfileChooserView( 193 profile_bubble_ = new ProfileChooserView(
193 anchor_view, arrow, anchor_rect, browser); 194 anchor_view, arrow, anchor_rect, browser);
194 views::BubbleDelegateView::CreateBubble(profile_bubble_); 195 views::BubbleDelegateView::CreateBubble(profile_bubble_);
195 profile_bubble_->set_close_on_deactivate(close_on_deactivate_); 196 profile_bubble_->set_close_on_deactivate(close_on_deactivate_);
196 profile_bubble_->SetAlignment(border_alignment); 197 profile_bubble_->SetAlignment(border_alignment);
197 profile_bubble_->GetWidget()->Show(); 198 profile_bubble_->GetWidget()->Show();
199 profile_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE);
198 } 200 }
199 201
200 // static 202 // static
201 bool ProfileChooserView::IsShowing() { 203 bool ProfileChooserView::IsShowing() {
202 return profile_bubble_ != NULL; 204 return profile_bubble_ != NULL;
203 } 205 }
204 206
205 // static 207 // static
206 void ProfileChooserView::Hide() { 208 void ProfileChooserView::Hide() {
207 if (IsShowing()) 209 if (IsShowing())
208 profile_bubble_->GetWidget()->Close(); 210 profile_bubble_->GetWidget()->Close();
209 } 211 }
210 212
211 ProfileChooserView::ProfileChooserView(views::View* anchor_view, 213 ProfileChooserView::ProfileChooserView(views::View* anchor_view,
212 views::BubbleBorder::Arrow arrow, 214 views::BubbleBorder::Arrow arrow,
213 const gfx::Rect& anchor_rect, 215 const gfx::Rect& anchor_rect,
214 Browser* browser) 216 Browser* browser)
215 : BubbleDelegateView(anchor_view, arrow), 217 : BubbleDelegateView(anchor_view, arrow),
216 browser_(browser) { 218 browser_(browser) {
217 // Reset the default margins inherited from the BubbleDelegateView. 219 // Reset the default margins inherited from the BubbleDelegateView.
218 set_margins(gfx::Insets()); 220 set_margins(gfx::Insets());
221 // Compensate for built-in vertical padding in the anchor view's image.
222 set_anchor_view_insets(gfx::Insets(kArrowHeight, 0, kArrowHeight, 0));
219 223
220 ResetLinksAndButtons(); 224 ResetLinksAndButtons();
221 225
222 avatar_menu_.reset(new AvatarMenu( 226 avatar_menu_.reset(new AvatarMenu(
223 &g_browser_process->profile_manager()->GetProfileInfoCache(), 227 &g_browser_process->profile_manager()->GetProfileInfoCache(),
224 this, 228 this,
225 browser_)); 229 browser_));
226 avatar_menu_->RebuildMenu(); 230 avatar_menu_->RebuildMenu();
227 } 231 }
228 232
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 579 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
576 580
577 views::BlueButton* add_account_button = new views::BlueButton( 581 views::BlueButton* add_account_button = new views::BlueButton(
578 NULL, 582 NULL,
579 l10n_util::GetStringFUTF16(IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, 583 l10n_util::GetStringFUTF16(IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON,
580 avatar_item.name)); 584 avatar_item.name));
581 layout->StartRow(1, 0); 585 layout->StartRow(1, 0);
582 layout->AddView(add_account_button); 586 layout->AddView(add_account_button);
583 return view; 587 return view;
584 } 588 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698