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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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. | 287 // An InMenuButton should always be focusable regardless of the platform. |
288 // Hence we don't use Button::ConfigureDefaultFocus(). | 288 // Hence we don't use Button::ConfigureDefaultFocus(). |
289 SetFocusBehavior(FocusBehavior::ALWAYS); | 289 SetFocusBehavior(FocusBehavior::ALWAYS); |
290 set_request_focus_on_press(false); | |
291 SetHorizontalAlignment(gfx::ALIGN_CENTER); | 290 SetHorizontalAlignment(gfx::ALIGN_CENTER); |
292 | 291 |
293 in_menu_background_ = new InMenuButtonBackground(type); | 292 in_menu_background_ = new InMenuButtonBackground(type); |
294 set_background(in_menu_background_); | 293 set_background(in_menu_background_); |
295 SetBorder(views::Border::CreateEmptyBorder(0, kHorizontalPadding, 0, | 294 SetBorder(views::Border::CreateEmptyBorder(0, kHorizontalPadding, 0, |
296 kHorizontalPadding)); | 295 kHorizontalPadding)); |
297 SetFontList(MenuConfig::instance().font_list); | 296 SetFontList(MenuConfig::instance().font_list); |
298 } | 297 } |
299 | 298 |
300 void SetOtherButtons(const InMenuButton* left, const InMenuButton* right) { | 299 void SetOtherButtons(const InMenuButton* left, const InMenuButton* right) { |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 // the keyboard nativigation work. | 550 // the keyboard nativigation work. |
552 DCHECK(CustomButton::AsCustomButton(fullscreen_button_)); | 551 DCHECK(CustomButton::AsCustomButton(fullscreen_button_)); |
553 gfx::ImageSkia* full_screen_image = | 552 gfx::ImageSkia* full_screen_image = |
554 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 553 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
555 IDR_FULLSCREEN_MENU_BUTTON); | 554 IDR_FULLSCREEN_MENU_BUTTON); |
556 fullscreen_button_->SetImage(ImageButton::STATE_NORMAL, full_screen_image); | 555 fullscreen_button_->SetImage(ImageButton::STATE_NORMAL, full_screen_image); |
557 | 556 |
558 // Since |fullscreen_button_| will reside in a menu, make it ALWAYS | 557 // Since |fullscreen_button_| will reside in a menu, make it ALWAYS |
559 // focusable regardless of the platform. | 558 // focusable regardless of the platform. |
560 fullscreen_button_->SetFocusBehavior(FocusBehavior::ALWAYS); | 559 fullscreen_button_->SetFocusBehavior(FocusBehavior::ALWAYS); |
561 fullscreen_button_->set_request_focus_on_press(false); | |
562 fullscreen_button_->set_tag(fullscreen_index); | 560 fullscreen_button_->set_tag(fullscreen_index); |
563 fullscreen_button_->SetImageAlignment( | 561 fullscreen_button_->SetImageAlignment( |
564 ImageButton::ALIGN_CENTER, ImageButton::ALIGN_MIDDLE); | 562 ImageButton::ALIGN_CENTER, ImageButton::ALIGN_MIDDLE); |
565 fullscreen_button_->set_background( | 563 fullscreen_button_->set_background( |
566 new InMenuButtonBackground(InMenuButtonBackground::SINGLE_BUTTON)); | 564 new InMenuButtonBackground(InMenuButtonBackground::SINGLE_BUTTON)); |
567 fullscreen_button_->SetAccessibleName(GetAccessibleNameForAppMenuItem( | 565 fullscreen_button_->SetAccessibleName(GetAccessibleNameForAppMenuItem( |
568 menu_model, fullscreen_index, IDS_ACCNAME_FULLSCREEN)); | 566 menu_model, fullscreen_index, IDS_ACCNAME_FULLSCREEN)); |
569 AddChildView(fullscreen_button_); | 567 AddChildView(fullscreen_button_); |
570 | 568 |
571 // Need to set a font list for the zoom label width calculations. | 569 // Need to set a font list for the zoom label width calculations. |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 0, | 1291 0, |
1294 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1292 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
1295 BOOKMARK_LAUNCH_LOCATION_APP_MENU); | 1293 BOOKMARK_LAUNCH_LOCATION_APP_MENU); |
1296 } | 1294 } |
1297 | 1295 |
1298 int AppMenu::ModelIndexFromCommandId(int command_id) const { | 1296 int AppMenu::ModelIndexFromCommandId(int command_id) const { |
1299 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); | 1297 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); |
1300 DCHECK(ix != command_id_to_entry_.end()); | 1298 DCHECK(ix != command_id_to_entry_.end()); |
1301 return ix->second.second; | 1299 return ix->second.second; |
1302 } | 1300 } |
OLD | NEW |