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

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

Issue 7003080: Change profile menu button to avatar button (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Change profile menu button to avatar button Created 9 years, 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/views/profile_menu_button.h"
6
7 #include "chrome/browser/ui/profile_menu_model.h"
8 #include "ui/base/text/text_elider.h"
9 #include "ui/gfx/color_utils.h"
10 #include "views/controls/button/button.h"
11 #include "views/controls/menu/menu_item_view.h"
12 #include "views/controls/menu/menu_model_adapter.h"
13 #include "views/window/window.h"
14
15 // Menu should display below the profile button tag image on the frame. This
16 // offset size depends on whether the frame is in glass or opaque mode.
17 const int kMenuDisplayOffset = 7;
18
19 // TextHover is slightly darker than enabled color, for a subtle hover shift.
20 const SkColor kTextHover = 0xFFDDDDDD;
21 const SkColor kTextEnabled = SK_ColorWHITE;
22 const SkColor kTextHighlighted = SK_ColorWHITE;
23
24 // Horizontal padding beside profile menu button, to center it in the
25 // underlying tag image.
26 const int kProfileButtonBorderSpacing = 10;
27
28 // Maximum width for name string in pixels.
29 const int kMaxTextWidth = 200;
30
31 ProfileMenuButton::ProfileMenuButton(const std::wstring& text, Profile* profile)
32 : MenuButton(NULL, text, this, true) {
33 // Turn off hover highlighting and position button in the center of the
34 // underlying profile tag image.
35 set_border(views::Border::CreateEmptyBorder(
36 0, kProfileButtonBorderSpacing, 0, kProfileButtonBorderSpacing));
37 SetHoverColor(kTextHover);
38 SetEnabledColor(kTextEnabled);
39 SetHighlightColor(kTextHighlighted);
40
41 profile_menu_model_.reset(new ProfileMenuModel);
42 }
43
44 ProfileMenuButton::~ProfileMenuButton() {}
45
46 void ProfileMenuButton::SetText(const std::wstring& text) {
47 MenuButton::SetText(UTF16ToWideHack(ui::ElideText(WideToUTF16Hack(text),
48 font(), kMaxTextWidth, false)));
49 }
50
51 // views::ViewMenuDelegate implementation
52 void ProfileMenuButton::RunMenu(views::View* source, const gfx::Point &pt) {
53 views::MenuModelAdapter menu_model_adapter(profile_menu_model_.get());
54 views::MenuItemView menu(&menu_model_adapter);
55 menu_model_adapter.BuildMenu(&menu);
56
57 gfx::Point menu_point(pt.x(), pt.y() + kMenuDisplayOffset);
58 menu.RunMenuAt(source->GetWidget()->GetNativeWindow(), NULL,
59 gfx::Rect(pt, gfx::Size(0, 0)),
60 views::MenuItemView::TOPRIGHT,
61 true);
62 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/profile_menu_button.h ('k') | chrome/browser/ui/views/profile_tag_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698