OLD | NEW |
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/toolbar/app_menu.h" | 5 #include "chrome/browser/ui/views/toolbar/app_menu.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 #include "ui/views/controls/button/image_button.h" | 57 #include "ui/views/controls/button/image_button.h" |
58 #include "ui/views/controls/button/label_button.h" | 58 #include "ui/views/controls/button/label_button.h" |
59 #include "ui/views/controls/button/menu_button.h" | 59 #include "ui/views/controls/button/menu_button.h" |
60 #include "ui/views/controls/label.h" | 60 #include "ui/views/controls/label.h" |
61 #include "ui/views/controls/menu/menu_config.h" | 61 #include "ui/views/controls/menu/menu_config.h" |
62 #include "ui/views/controls/menu/menu_item_view.h" | 62 #include "ui/views/controls/menu/menu_item_view.h" |
63 #include "ui/views/controls/menu/menu_model_adapter.h" | 63 #include "ui/views/controls/menu/menu_model_adapter.h" |
64 #include "ui/views/controls/menu/menu_runner.h" | 64 #include "ui/views/controls/menu/menu_runner.h" |
65 #include "ui/views/controls/menu/menu_scroll_view_container.h" | 65 #include "ui/views/controls/menu/menu_scroll_view_container.h" |
66 #include "ui/views/controls/menu/submenu_view.h" | 66 #include "ui/views/controls/menu/submenu_view.h" |
| 67 #include "ui/views/style/platform_style.h" |
67 #include "ui/views/widget/widget.h" | 68 #include "ui/views/widget/widget.h" |
68 | 69 |
69 using base::UserMetricsAction; | 70 using base::UserMetricsAction; |
70 using bookmarks::BookmarkModel; | 71 using bookmarks::BookmarkModel; |
71 using content::WebContents; | 72 using content::WebContents; |
72 using ui::ButtonMenuItemModel; | 73 using ui::ButtonMenuItemModel; |
73 using ui::MenuModel; | 74 using ui::MenuModel; |
74 using views::CustomButton; | 75 using views::CustomButton; |
75 using views::ImageButton; | 76 using views::ImageButton; |
76 using views::Label; | 77 using views::Label; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 } | 262 } |
262 | 263 |
263 // A button that lives inside a menu item. | 264 // A button that lives inside a menu item. |
264 class InMenuButton : public LabelButton { | 265 class InMenuButton : public LabelButton { |
265 public: | 266 public: |
266 InMenuButton(views::ButtonListener* listener, const base::string16& text) | 267 InMenuButton(views::ButtonListener* listener, const base::string16& text) |
267 : LabelButton(listener, text), in_menu_background_(NULL) {} | 268 : LabelButton(listener, text), in_menu_background_(NULL) {} |
268 ~InMenuButton() override {} | 269 ~InMenuButton() override {} |
269 | 270 |
270 void Init(InMenuButtonBackground::ButtonType type) { | 271 void Init(InMenuButtonBackground::ButtonType type) { |
271 SetFocusable(true); | 272 views::PlatformStyle::SetControlStyleFocus(this); |
272 set_request_focus_on_press(false); | 273 set_request_focus_on_press(false); |
273 SetHorizontalAlignment(gfx::ALIGN_CENTER); | 274 SetHorizontalAlignment(gfx::ALIGN_CENTER); |
274 | 275 |
275 in_menu_background_ = new InMenuButtonBackground(type); | 276 in_menu_background_ = new InMenuButtonBackground(type); |
276 set_background(in_menu_background_); | 277 set_background(in_menu_background_); |
277 SetBorder(views::Border::CreateEmptyBorder(0, kHorizontalPadding, 0, | 278 SetBorder(views::Border::CreateEmptyBorder(0, kHorizontalPadding, 0, |
278 kHorizontalPadding)); | 279 kHorizontalPadding)); |
279 SetFontList(MenuConfig::instance().font_list); | 280 SetFontList(MenuConfig::instance().font_list); |
280 } | 281 } |
281 | 282 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 | 531 |
531 fullscreen_button_ = new FullscreenButton(this); | 532 fullscreen_button_ = new FullscreenButton(this); |
532 // all buttons on menu should must be a custom button in order for | 533 // all buttons on menu should must be a custom button in order for |
533 // the keyboard nativigation work. | 534 // the keyboard nativigation work. |
534 DCHECK(CustomButton::AsCustomButton(fullscreen_button_)); | 535 DCHECK(CustomButton::AsCustomButton(fullscreen_button_)); |
535 gfx::ImageSkia* full_screen_image = | 536 gfx::ImageSkia* full_screen_image = |
536 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 537 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
537 IDR_FULLSCREEN_MENU_BUTTON); | 538 IDR_FULLSCREEN_MENU_BUTTON); |
538 fullscreen_button_->SetImage(ImageButton::STATE_NORMAL, full_screen_image); | 539 fullscreen_button_->SetImage(ImageButton::STATE_NORMAL, full_screen_image); |
539 | 540 |
540 fullscreen_button_->SetFocusable(true); | 541 views::PlatformStyle::SetControlStyleFocus(fullscreen_button_); |
541 fullscreen_button_->set_request_focus_on_press(false); | 542 fullscreen_button_->set_request_focus_on_press(false); |
542 fullscreen_button_->set_tag(fullscreen_index); | 543 fullscreen_button_->set_tag(fullscreen_index); |
543 fullscreen_button_->SetImageAlignment( | 544 fullscreen_button_->SetImageAlignment( |
544 ImageButton::ALIGN_CENTER, ImageButton::ALIGN_MIDDLE); | 545 ImageButton::ALIGN_CENTER, ImageButton::ALIGN_MIDDLE); |
545 fullscreen_button_->set_background( | 546 fullscreen_button_->set_background( |
546 new InMenuButtonBackground(InMenuButtonBackground::SINGLE_BUTTON)); | 547 new InMenuButtonBackground(InMenuButtonBackground::SINGLE_BUTTON)); |
547 fullscreen_button_->SetAccessibleName(GetAccessibleNameForAppMenuItem( | 548 fullscreen_button_->SetAccessibleName(GetAccessibleNameForAppMenuItem( |
548 menu_model, fullscreen_index, IDS_ACCNAME_FULLSCREEN)); | 549 menu_model, fullscreen_index, IDS_ACCNAME_FULLSCREEN)); |
549 AddChildView(fullscreen_button_); | 550 AddChildView(fullscreen_button_); |
550 | 551 |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1266 0, | 1267 0, |
1267 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1268 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
1268 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); | 1269 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); |
1269 } | 1270 } |
1270 | 1271 |
1271 int AppMenu::ModelIndexFromCommandId(int command_id) const { | 1272 int AppMenu::ModelIndexFromCommandId(int command_id) const { |
1272 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); | 1273 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); |
1273 DCHECK(ix != command_id_to_entry_.end()); | 1274 DCHECK(ix != command_id_to_entry_.end()); |
1274 return ix->second.second; | 1275 return ix->second.second; |
1275 } | 1276 } |
OLD | NEW |