| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/avatar_menu_bubble_view.h" | 5 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "ui/gfx/image/image.h" | 23 #include "ui/gfx/image/image.h" |
| 24 #include "ui/views/controls/button/custom_button.h" | 24 #include "ui/views/controls/button/custom_button.h" |
| 25 #include "ui/views/controls/button/image_button.h" | 25 #include "ui/views/controls/button/image_button.h" |
| 26 #include "ui/views/controls/image_view.h" | 26 #include "ui/views/controls/image_view.h" |
| 27 #include "ui/views/controls/label.h" | 27 #include "ui/views/controls/label.h" |
| 28 #include "ui/views/controls/link.h" | 28 #include "ui/views/controls/link.h" |
| 29 #include "ui/views/controls/separator.h" | 29 #include "ui/views/controls/separator.h" |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 // TODO(msw): Get color from theme/window color. | |
| 34 const SkColor kColor = SK_ColorWHITE; | |
| 35 | |
| 36 const int kItemHeight = 44; | 33 const int kItemHeight = 44; |
| 37 const int kItemMarginY = 4; | 34 const int kItemMarginY = 4; |
| 38 const int kIconMarginX = 6; | 35 const int kIconMarginX = 6; |
| 39 const int kSeparatorPaddingY = 5; | 36 const int kSeparatorPaddingY = 5; |
| 40 | 37 |
| 41 inline int Round(double x) { | 38 inline int Round(double x) { |
| 42 return static_cast<int>(x + 0.5); | 39 return static_cast<int>(x + 0.5); |
| 43 } | 40 } |
| 44 | 41 |
| 45 gfx::Rect GetCenteredAndScaledRect(int src_width, int src_height, | 42 gfx::Rect GetCenteredAndScaledRect(int src_width, int src_height, |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 } // namespace | 332 } // namespace |
| 336 | 333 |
| 337 | 334 |
| 338 // AvatarMenuBubbleView ------------------------------------------------------- | 335 // AvatarMenuBubbleView ------------------------------------------------------- |
| 339 | 336 |
| 340 AvatarMenuBubbleView::AvatarMenuBubbleView( | 337 AvatarMenuBubbleView::AvatarMenuBubbleView( |
| 341 views::View* anchor_view, | 338 views::View* anchor_view, |
| 342 views::BubbleBorder::ArrowLocation arrow_location, | 339 views::BubbleBorder::ArrowLocation arrow_location, |
| 343 const gfx::Rect& anchor_rect, | 340 const gfx::Rect& anchor_rect, |
| 344 Browser* browser) | 341 Browser* browser) |
| 345 : BubbleDelegateView(anchor_view, arrow_location, kColor), | 342 : BubbleDelegateView(anchor_view, arrow_location), |
| 346 add_profile_link_(NULL), | 343 add_profile_link_(NULL), |
| 347 anchor_rect_(anchor_rect), | 344 anchor_rect_(anchor_rect), |
| 348 browser_(browser) { | 345 browser_(browser) { |
| 349 avatar_menu_model_.reset(new AvatarMenuModel( | 346 avatar_menu_model_.reset(new AvatarMenuModel( |
| 350 &g_browser_process->profile_manager()->GetProfileInfoCache(), | 347 &g_browser_process->profile_manager()->GetProfileInfoCache(), |
| 351 this, browser_)); | 348 this, browser_)); |
| 352 // Build the menu for the first time. | 349 // Build the menu for the first time. |
| 353 OnAvatarMenuModelChanged(avatar_menu_model_.get()); | 350 OnAvatarMenuModelChanged(avatar_menu_model_.get()); |
| 354 } | 351 } |
| 355 | 352 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 | 486 |
| 490 add_profile_link_ = new views::Link( | 487 add_profile_link_ = new views::Link( |
| 491 l10n_util::GetStringUTF16(IDS_PROFILES_CREATE_NEW_PROFILE_LINK)); | 488 l10n_util::GetStringUTF16(IDS_PROFILES_CREATE_NEW_PROFILE_LINK)); |
| 492 add_profile_link_->set_listener(this); | 489 add_profile_link_->set_listener(this); |
| 493 add_profile_link_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 490 add_profile_link_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 494 add_profile_link_->SetEnabledColor(SkColorSetRGB(0xe3, 0xed, 0xf6)); | 491 add_profile_link_->SetEnabledColor(SkColorSetRGB(0xe3, 0xed, 0xf6)); |
| 495 AddChildView(add_profile_link_); | 492 AddChildView(add_profile_link_); |
| 496 | 493 |
| 497 PreferredSizeChanged(); | 494 PreferredSizeChanged(); |
| 498 } | 495 } |
| OLD | NEW |