| 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 ~InMenuButton() override {} | 256 ~InMenuButton() override {} |
| 257 | 257 |
| 258 void Init(InMenuButtonBackground::ButtonType type) { | 258 void Init(InMenuButtonBackground::ButtonType type) { |
| 259 // An InMenuButton should always be focusable regardless of the platform. | 259 // An InMenuButton should always be focusable regardless of the platform. |
| 260 // Hence we don't use SetFocusForPlatform(). | 260 // Hence we don't use SetFocusForPlatform(). |
| 261 SetFocusBehavior(FocusBehavior::ALWAYS); | 261 SetFocusBehavior(FocusBehavior::ALWAYS); |
| 262 SetHorizontalAlignment(gfx::ALIGN_CENTER); | 262 SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| 263 | 263 |
| 264 in_menu_background_ = new InMenuButtonBackground(type); | 264 in_menu_background_ = new InMenuButtonBackground(type); |
| 265 set_background(in_menu_background_); | 265 set_background(in_menu_background_); |
| 266 SetBorder(views::Border::CreateEmptyBorder(0, kHorizontalPadding, 0, | 266 SetBorder( |
| 267 kHorizontalPadding)); | 267 views::CreateEmptyBorder(0, kHorizontalPadding, 0, kHorizontalPadding)); |
| 268 SetFontList(MenuConfig::instance().font_list); | 268 SetFontList(MenuConfig::instance().font_list); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void GetAccessibleNodeData(ui::AXNodeData* node_data) override { | 271 void GetAccessibleNodeData(ui::AXNodeData* node_data) override { |
| 272 LabelButton::GetAccessibleNodeData(node_data); | 272 LabelButton::GetAccessibleNodeData(node_data); |
| 273 node_data->role = ui::AX_ROLE_MENU_ITEM; | 273 node_data->role = ui::AX_ROLE_MENU_ITEM; |
| 274 } | 274 } |
| 275 | 275 |
| 276 // views::LabelButton | 276 // views::LabelButton |
| 277 void OnNativeThemeChanged(const ui::NativeTheme* theme) override { | 277 void OnNativeThemeChanged(const ui::NativeTheme* theme) override { |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 x += bounds.width(); | 577 x += bounds.width(); |
| 578 bounds.set_x(x); | 578 bounds.set_x(x); |
| 579 bounds.set_width(fullscreen_button_->GetPreferredSize().width() + | 579 bounds.set_width(fullscreen_button_->GetPreferredSize().width() + |
| 580 kFullscreenPadding); | 580 kFullscreenPadding); |
| 581 fullscreen_button_->SetBoundsRect(bounds); | 581 fullscreen_button_->SetBoundsRect(bounds); |
| 582 } | 582 } |
| 583 | 583 |
| 584 void OnNativeThemeChanged(const ui::NativeTheme* theme) override { | 584 void OnNativeThemeChanged(const ui::NativeTheme* theme) override { |
| 585 AppMenuView::OnNativeThemeChanged(theme); | 585 AppMenuView::OnNativeThemeChanged(theme); |
| 586 | 586 |
| 587 zoom_label_->SetBorder(views::Border::CreateEmptyBorder( | 587 zoom_label_->SetBorder(views::CreateEmptyBorder( |
| 588 0, kZoomLabelHorizontalPadding, 0, kZoomLabelHorizontalPadding)); | 588 0, kZoomLabelHorizontalPadding, 0, kZoomLabelHorizontalPadding)); |
| 589 zoom_label_->SetFontList(MenuConfig::instance().font_list); | 589 zoom_label_->SetFontList(MenuConfig::instance().font_list); |
| 590 zoom_label_max_width_valid_ = false; | 590 zoom_label_max_width_valid_ = false; |
| 591 | 591 |
| 592 if (theme) { | 592 if (theme) { |
| 593 zoom_label_->SetEnabledColor(theme->GetSystemColor( | 593 zoom_label_->SetEnabledColor(theme->GetSystemColor( |
| 594 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor)); | 594 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor)); |
| 595 gfx::ImageSkia* full_screen_image = | 595 gfx::ImageSkia* full_screen_image = |
| 596 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 596 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 597 IDR_FULLSCREEN_MENU_BUTTON); | 597 IDR_FULLSCREEN_MENU_BUTTON); |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1234 0, | 1234 0, |
| 1235 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1235 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
| 1236 BOOKMARK_LAUNCH_LOCATION_APP_MENU); | 1236 BOOKMARK_LAUNCH_LOCATION_APP_MENU); |
| 1237 } | 1237 } |
| 1238 | 1238 |
| 1239 int AppMenu::ModelIndexFromCommandId(int command_id) const { | 1239 int AppMenu::ModelIndexFromCommandId(int command_id) const { |
| 1240 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); | 1240 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); |
| 1241 DCHECK(ix != command_id_to_entry_.end()); | 1241 DCHECK(ix != command_id_to_entry_.end()); |
| 1242 return ix->second.second; | 1242 return ix->second.second; |
| 1243 } | 1243 } |
| OLD | NEW |