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 #ifndef CHROME_BROWSER_UI_VIEWS_PROFILE_MENU_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PROFILE_MENU_BUTTON_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_PROFILE_MENU_BUTTON_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PROFILE_MENU_BUTTON_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "ui/base/models/simple_menu_model.h" | 12 #include "ui/base/models/simple_menu_model.h" |
13 #include "views/controls/button/menu_button.h" | 13 #include "views/controls/button/menu_button.h" |
| 14 #include "views/controls/menu/view_menu_delegate.h" |
14 | 15 |
15 class Profile; | 16 class Profile; |
16 class ProfileMenuModel; | 17 class ProfileMenuModel; |
17 | 18 |
18 namespace gfx { | 19 namespace gfx { |
19 class Canvas; | 20 class Canvas; |
20 } | 21 } |
21 | 22 |
22 namespace ui { | 23 namespace ui { |
23 class Accelerator; | 24 class Accelerator; |
24 } | 25 } |
25 | 26 |
26 namespace views { | 27 namespace views { |
27 class Menu2; | 28 class Menu2; |
28 } | 29 } |
29 | 30 |
30 // ProfileMenuButton | 31 // ProfileMenuButton |
31 // | 32 // |
32 // Shows the button for the multiprofile menu with an image layered | 33 // Shows the button for the multiprofile menu with an image layered |
33 // underneath that displays the profile tag. | 34 // underneath that displays the profile tag. |
34 | 35 |
35 class ProfileMenuButton : public views::MenuButton, | 36 class ProfileMenuButton : public views::MenuButton, |
| 37 public views::ViewMenuDelegate, |
36 public ui::SimpleMenuModel::Delegate { | 38 public ui::SimpleMenuModel::Delegate { |
37 public: | 39 public: |
38 // DefaultActiveTextShadow is a darkened blue color that works with Windows | 40 // DefaultActiveTextShadow is a darkened blue color that works with Windows |
39 // default theme background coloring. | 41 // default theme background coloring. |
40 static const SkColor kDefaultActiveTextShadow = 0xFF708DB3; | 42 static const SkColor kDefaultActiveTextShadow = 0xFF708DB3; |
41 // InactiveTextShadow is a light gray for inactive default themed buttons. | 43 // InactiveTextShadow is a light gray for inactive default themed buttons. |
42 static const SkColor kDefaultInactiveTextShadow = SK_ColorLTGRAY; | 44 static const SkColor kDefaultInactiveTextShadow = SK_ColorLTGRAY; |
43 // DarkTextShadow is used to shadow names on themed browser frames. | 45 // DarkTextShadow is used to shadow names on themed browser frames. |
44 static const SkColor kDarkTextShadow = SK_ColorGRAY; | 46 static const SkColor kDarkTextShadow = SK_ColorGRAY; |
45 // Space between window controls and end of profile tag. | 47 // Space between window controls and end of profile tag. |
46 static const int kProfileTagHorizontalSpacing = 5; | 48 static const int kProfileTagHorizontalSpacing = 5; |
47 | 49 |
48 ProfileMenuButton(views::ButtonListener* listener, | 50 ProfileMenuButton(const std::wstring& text, Profile* profile); |
49 const std::wstring& text, | |
50 views::ViewMenuDelegate* menu_delegate, | |
51 Profile* profile); | |
52 | 51 |
53 virtual ~ProfileMenuButton(); | 52 virtual ~ProfileMenuButton(); |
54 | 53 |
55 // Override MenuButton to clamp text at kMaxTextWidth. | 54 // Override MenuButton to clamp text at kMaxTextWidth. |
56 virtual void SetText(const std::wstring& text) OVERRIDE; | 55 virtual void SetText(const std::wstring& text) OVERRIDE; |
57 | 56 |
58 // ui::SimpleMenuModel::Delegate implementation | 57 // ui::SimpleMenuModel::Delegate implementation |
59 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | 58 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
60 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | 59 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
61 virtual bool GetAcceleratorForCommandId( | 60 virtual bool GetAcceleratorForCommandId( |
62 int command_id, ui::Accelerator* accelerator) OVERRIDE; | 61 int command_id, ui::Accelerator* accelerator) OVERRIDE; |
63 virtual void ExecuteCommand(int command_id) OVERRIDE; | 62 virtual void ExecuteCommand(int command_id) OVERRIDE; |
64 | 63 |
65 void RunMenuAt(const gfx::Point& point); | 64 private: |
| 65 // Overridden from views::ViewMenuDelegate: |
| 66 virtual void RunMenu(views::View* source, const gfx::Point& pt) OVERRIDE; |
66 | 67 |
67 private: | |
68 scoped_ptr<views::Menu2> menu_; | 68 scoped_ptr<views::Menu2> menu_; |
69 scoped_ptr<ProfileMenuModel> profile_menu_model_; | 69 scoped_ptr<ProfileMenuModel> profile_menu_model_; |
70 | 70 |
71 DISALLOW_COPY_AND_ASSIGN(ProfileMenuButton); | 71 DISALLOW_COPY_AND_ASSIGN(ProfileMenuButton); |
72 }; | 72 }; |
73 | 73 |
74 #endif // CHROME_BROWSER_UI_VIEWS_PROFILE_MENU_BUTTON_H_ | 74 #endif // CHROME_BROWSER_UI_VIEWS_PROFILE_MENU_BUTTON_H_ |
75 | 75 |
OLD | NEW |