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

Side by Side Diff: chrome/browser/ui/views/toolbar/app_menu.cc

Issue 1898633004: Views: Add new SetFocusBehavior method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 4 years, 7 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
OLDNEW
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
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 SetFocusable(true); 287 SetFocusBehavior(FocusBehavior::ALWAYS);
288 set_request_focus_on_press(false); 288 set_request_focus_on_press(false);
289 SetHorizontalAlignment(gfx::ALIGN_CENTER); 289 SetHorizontalAlignment(gfx::ALIGN_CENTER);
290 290
291 in_menu_background_ = new InMenuButtonBackground(type); 291 in_menu_background_ = new InMenuButtonBackground(type);
292 set_background(in_menu_background_); 292 set_background(in_menu_background_);
293 SetBorder(views::Border::CreateEmptyBorder(0, kHorizontalPadding, 0, 293 SetBorder(views::Border::CreateEmptyBorder(0, kHorizontalPadding, 0,
294 kHorizontalPadding)); 294 kHorizontalPadding));
295 SetFontList(MenuConfig::instance().font_list); 295 SetFontList(MenuConfig::instance().font_list);
296 } 296 }
297 297
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 546
547 fullscreen_button_ = new FullscreenButton(this); 547 fullscreen_button_ = new FullscreenButton(this);
548 // all buttons on menu should must be a custom button in order for 548 // all buttons on menu should must be a custom button in order for
549 // the keyboard nativigation work. 549 // the keyboard nativigation work.
550 DCHECK(CustomButton::AsCustomButton(fullscreen_button_)); 550 DCHECK(CustomButton::AsCustomButton(fullscreen_button_));
551 gfx::ImageSkia* full_screen_image = 551 gfx::ImageSkia* full_screen_image =
552 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 552 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
553 IDR_FULLSCREEN_MENU_BUTTON); 553 IDR_FULLSCREEN_MENU_BUTTON);
554 fullscreen_button_->SetImage(ImageButton::STATE_NORMAL, full_screen_image); 554 fullscreen_button_->SetImage(ImageButton::STATE_NORMAL, full_screen_image);
555 555
556 fullscreen_button_->SetFocusable(true); 556 fullscreen_button_->SetFocusBehavior(FocusBehavior::ALWAYS);
557 fullscreen_button_->set_request_focus_on_press(false); 557 fullscreen_button_->set_request_focus_on_press(false);
558 fullscreen_button_->set_tag(fullscreen_index); 558 fullscreen_button_->set_tag(fullscreen_index);
559 fullscreen_button_->SetImageAlignment( 559 fullscreen_button_->SetImageAlignment(
560 ImageButton::ALIGN_CENTER, ImageButton::ALIGN_MIDDLE); 560 ImageButton::ALIGN_CENTER, ImageButton::ALIGN_MIDDLE);
561 fullscreen_button_->set_background( 561 fullscreen_button_->set_background(
562 new InMenuButtonBackground(InMenuButtonBackground::SINGLE_BUTTON)); 562 new InMenuButtonBackground(InMenuButtonBackground::SINGLE_BUTTON));
563 fullscreen_button_->SetAccessibleName(GetAccessibleNameForAppMenuItem( 563 fullscreen_button_->SetAccessibleName(GetAccessibleNameForAppMenuItem(
564 menu_model, fullscreen_index, IDS_ACCNAME_FULLSCREEN)); 564 menu_model, fullscreen_index, IDS_ACCNAME_FULLSCREEN));
565 AddChildView(fullscreen_button_); 565 AddChildView(fullscreen_button_);
566 566
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 0, 1289 0,
1290 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, 1290 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS,
1291 BOOKMARK_LAUNCH_LOCATION_APP_MENU); 1291 BOOKMARK_LAUNCH_LOCATION_APP_MENU);
1292 } 1292 }
1293 1293
1294 int AppMenu::ModelIndexFromCommandId(int command_id) const { 1294 int AppMenu::ModelIndexFromCommandId(int command_id) const {
1295 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); 1295 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id);
1296 DCHECK(ix != command_id_to_entry_.end()); 1296 DCHECK(ix != command_id_to_entry_.end());
1297 return ix->second.second; 1297 return ix->second.second;
1298 } 1298 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698