| 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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 } | 277 } |
| 278 | 278 |
| 279 // A button that lives inside a menu item. | 279 // A button that lives inside a menu item. |
| 280 class InMenuButton : public LabelButton { | 280 class InMenuButton : public LabelButton { |
| 281 public: | 281 public: |
| 282 InMenuButton(views::ButtonListener* listener, const base::string16& text) | 282 InMenuButton(views::ButtonListener* listener, const base::string16& text) |
| 283 : LabelButton(listener, text), in_menu_background_(NULL) {} | 283 : LabelButton(listener, text), in_menu_background_(NULL) {} |
| 284 ~InMenuButton() override {} | 284 ~InMenuButton() override {} |
| 285 | 285 |
| 286 void Init(InMenuButtonBackground::ButtonType type) { | 286 void Init(InMenuButtonBackground::ButtonType type) { |
| 287 // An InMenuButton should always be focusable regardless of the platform. |
| 288 // Hence we don't use Button::ConfigureDefaultFocus(). |
| 287 SetFocusBehavior(FocusBehavior::ALWAYS); | 289 SetFocusBehavior(FocusBehavior::ALWAYS); |
| 288 set_request_focus_on_press(false); | 290 set_request_focus_on_press(false); |
| 289 SetHorizontalAlignment(gfx::ALIGN_CENTER); | 291 SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| 290 | 292 |
| 291 in_menu_background_ = new InMenuButtonBackground(type); | 293 in_menu_background_ = new InMenuButtonBackground(type); |
| 292 set_background(in_menu_background_); | 294 set_background(in_menu_background_); |
| 293 SetBorder(views::Border::CreateEmptyBorder(0, kHorizontalPadding, 0, | 295 SetBorder(views::Border::CreateEmptyBorder(0, kHorizontalPadding, 0, |
| 294 kHorizontalPadding)); | 296 kHorizontalPadding)); |
| 295 SetFontList(MenuConfig::instance().font_list); | 297 SetFontList(MenuConfig::instance().font_list); |
| 296 } | 298 } |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 | 548 |
| 547 fullscreen_button_ = new FullscreenButton(this); | 549 fullscreen_button_ = new FullscreenButton(this); |
| 548 // all buttons on menu should must be a custom button in order for | 550 // all buttons on menu should must be a custom button in order for |
| 549 // the keyboard nativigation work. | 551 // the keyboard nativigation work. |
| 550 DCHECK(CustomButton::AsCustomButton(fullscreen_button_)); | 552 DCHECK(CustomButton::AsCustomButton(fullscreen_button_)); |
| 551 gfx::ImageSkia* full_screen_image = | 553 gfx::ImageSkia* full_screen_image = |
| 552 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 554 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 553 IDR_FULLSCREEN_MENU_BUTTON); | 555 IDR_FULLSCREEN_MENU_BUTTON); |
| 554 fullscreen_button_->SetImage(ImageButton::STATE_NORMAL, full_screen_image); | 556 fullscreen_button_->SetImage(ImageButton::STATE_NORMAL, full_screen_image); |
| 555 | 557 |
| 558 // Since |fullscreen_button_| will reside in a menu, make it ALWAYS |
| 559 // focusable regardless of the platform. |
| 556 fullscreen_button_->SetFocusBehavior(FocusBehavior::ALWAYS); | 560 fullscreen_button_->SetFocusBehavior(FocusBehavior::ALWAYS); |
| 557 fullscreen_button_->set_request_focus_on_press(false); | 561 fullscreen_button_->set_request_focus_on_press(false); |
| 558 fullscreen_button_->set_tag(fullscreen_index); | 562 fullscreen_button_->set_tag(fullscreen_index); |
| 559 fullscreen_button_->SetImageAlignment( | 563 fullscreen_button_->SetImageAlignment( |
| 560 ImageButton::ALIGN_CENTER, ImageButton::ALIGN_MIDDLE); | 564 ImageButton::ALIGN_CENTER, ImageButton::ALIGN_MIDDLE); |
| 561 fullscreen_button_->set_background( | 565 fullscreen_button_->set_background( |
| 562 new InMenuButtonBackground(InMenuButtonBackground::SINGLE_BUTTON)); | 566 new InMenuButtonBackground(InMenuButtonBackground::SINGLE_BUTTON)); |
| 563 fullscreen_button_->SetAccessibleName(GetAccessibleNameForAppMenuItem( | 567 fullscreen_button_->SetAccessibleName(GetAccessibleNameForAppMenuItem( |
| 564 menu_model, fullscreen_index, IDS_ACCNAME_FULLSCREEN)); | 568 menu_model, fullscreen_index, IDS_ACCNAME_FULLSCREEN)); |
| 565 AddChildView(fullscreen_button_); | 569 AddChildView(fullscreen_button_); |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1289 0, | 1293 0, |
| 1290 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1294 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
| 1291 BOOKMARK_LAUNCH_LOCATION_APP_MENU); | 1295 BOOKMARK_LAUNCH_LOCATION_APP_MENU); |
| 1292 } | 1296 } |
| 1293 | 1297 |
| 1294 int AppMenu::ModelIndexFromCommandId(int command_id) const { | 1298 int AppMenu::ModelIndexFromCommandId(int command_id) const { |
| 1295 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); | 1299 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); |
| 1296 DCHECK(ix != command_id_to_entry_.end()); | 1300 DCHECK(ix != command_id_to_entry_.end()); |
| 1297 return ix->second.second; | 1301 return ix->second.second; |
| 1298 } | 1302 } |
| OLD | NEW |