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 <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 265 |
266 void Init(InMenuButtonBackground::ButtonType type) { | 266 void Init(InMenuButtonBackground::ButtonType type) { |
267 SetFocusable(true); | 267 SetFocusable(true); |
268 set_request_focus_on_press(false); | 268 set_request_focus_on_press(false); |
269 SetHorizontalAlignment(gfx::ALIGN_CENTER); | 269 SetHorizontalAlignment(gfx::ALIGN_CENTER); |
270 | 270 |
271 in_menu_background_ = new InMenuButtonBackground(type); | 271 in_menu_background_ = new InMenuButtonBackground(type); |
272 set_background(in_menu_background_); | 272 set_background(in_menu_background_); |
273 SetBorder(views::Border::CreateEmptyBorder(0, kHorizontalPadding, 0, | 273 SetBorder(views::Border::CreateEmptyBorder(0, kHorizontalPadding, 0, |
274 kHorizontalPadding)); | 274 kHorizontalPadding)); |
| 275 SetFontList(MenuConfig::instance().font_list); |
275 } | 276 } |
276 | 277 |
277 void SetOtherButtons(const InMenuButton* left, const InMenuButton* right) { | 278 void SetOtherButtons(const InMenuButton* left, const InMenuButton* right) { |
278 in_menu_background_->SetOtherButtons(left, right); | 279 in_menu_background_->SetOtherButtons(left, right); |
279 } | 280 } |
280 | 281 |
281 // views::LabelButton | 282 // views::LabelButton |
282 void OnNativeThemeChanged(const ui::NativeTheme* theme) override { | 283 void OnNativeThemeChanged(const ui::NativeTheme* theme) override { |
283 const MenuConfig& menu_config = MenuConfig::instance(theme); | |
284 SetFontList(menu_config.font_list); | |
285 | |
286 if (theme) { | 284 if (theme) { |
287 SetTextColor( | 285 SetTextColor( |
288 views::Button::STATE_DISABLED, | 286 views::Button::STATE_DISABLED, |
289 theme->GetSystemColor( | 287 theme->GetSystemColor( |
290 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor)); | 288 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor)); |
291 SetTextColor( | 289 SetTextColor( |
292 views::Button::STATE_HOVERED, | 290 views::Button::STATE_HOVERED, |
293 theme->GetSystemColor( | 291 theme->GetSystemColor( |
294 ui::NativeTheme::kColorId_SelectedMenuItemForegroundColor)); | 292 ui::NativeTheme::kColorId_SelectedMenuItemForegroundColor)); |
295 SetTextColor( | 293 SetTextColor( |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 x += bounds.width(); | 587 x += bounds.width(); |
590 bounds.set_x(x); | 588 bounds.set_x(x); |
591 bounds.set_width(fullscreen_button_->GetPreferredSize().width() + | 589 bounds.set_width(fullscreen_button_->GetPreferredSize().width() + |
592 kFullscreenPadding); | 590 kFullscreenPadding); |
593 fullscreen_button_->SetBoundsRect(bounds); | 591 fullscreen_button_->SetBoundsRect(bounds); |
594 } | 592 } |
595 | 593 |
596 void OnNativeThemeChanged(const ui::NativeTheme* theme) override { | 594 void OnNativeThemeChanged(const ui::NativeTheme* theme) override { |
597 AppMenuView::OnNativeThemeChanged(theme); | 595 AppMenuView::OnNativeThemeChanged(theme); |
598 | 596 |
599 const MenuConfig& menu_config = MenuConfig::instance(theme); | |
600 zoom_label_->SetBorder(views::Border::CreateEmptyBorder( | 597 zoom_label_->SetBorder(views::Border::CreateEmptyBorder( |
601 0, kZoomLabelHorizontalPadding, 0, kZoomLabelHorizontalPadding)); | 598 0, kZoomLabelHorizontalPadding, 0, kZoomLabelHorizontalPadding)); |
602 zoom_label_->SetFontList(menu_config.font_list); | 599 zoom_label_->SetFontList(MenuConfig::instance().font_list); |
603 zoom_label_max_width_valid_ = false; | 600 zoom_label_max_width_valid_ = false; |
604 | 601 |
605 if (theme) { | 602 if (theme) { |
606 zoom_label_->SetEnabledColor(theme->GetSystemColor( | 603 zoom_label_->SetEnabledColor(theme->GetSystemColor( |
607 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor)); | 604 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor)); |
608 gfx::ImageSkia* full_screen_image = | 605 gfx::ImageSkia* full_screen_image = |
609 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 606 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
610 IDR_FULLSCREEN_MENU_BUTTON); | 607 IDR_FULLSCREEN_MENU_BUTTON); |
611 SkColor fg_color = theme->GetSystemColor( | 608 SkColor fg_color = theme->GetSystemColor( |
612 ui::NativeTheme::kColorId_SelectedMenuItemForegroundColor); | 609 ui::NativeTheme::kColorId_SelectedMenuItemForegroundColor); |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 void AppMenu::PopulateMenu(MenuItemView* parent, MenuModel* model) { | 1105 void AppMenu::PopulateMenu(MenuItemView* parent, MenuModel* model) { |
1109 for (int i = 0, max = model->GetItemCount(); i < max; ++i) { | 1106 for (int i = 0, max = model->GetItemCount(); i < max; ++i) { |
1110 // Add the menu item at the end. | 1107 // Add the menu item at the end. |
1111 int menu_index = parent->HasSubmenu() ? | 1108 int menu_index = parent->HasSubmenu() ? |
1112 parent->GetSubmenu()->child_count() : 0; | 1109 parent->GetSubmenu()->child_count() : 0; |
1113 MenuItemView* item = | 1110 MenuItemView* item = |
1114 AddMenuItem(parent, menu_index, model, i, model->GetTypeAt(i)); | 1111 AddMenuItem(parent, menu_index, model, i, model->GetTypeAt(i)); |
1115 | 1112 |
1116 if (model->GetCommandIdAt(i) == IDC_EDIT_MENU || | 1113 if (model->GetCommandIdAt(i) == IDC_EDIT_MENU || |
1117 model->GetCommandIdAt(i) == IDC_ZOOM_MENU) { | 1114 model->GetCommandIdAt(i) == IDC_ZOOM_MENU) { |
1118 const MenuConfig& config = item->GetMenuConfig(); | 1115 const MenuConfig& config = views::MenuConfig::instance(); |
1119 int top_margin = config.item_top_margin + config.separator_height / 2; | 1116 int top_margin = config.item_top_margin + config.separator_height / 2; |
1120 int bottom_margin = | 1117 int bottom_margin = |
1121 config.item_bottom_margin + config.separator_height / 2; | 1118 config.item_bottom_margin + config.separator_height / 2; |
1122 | 1119 |
1123 // Chromeos adds extra vertical space for the menu buttons. | 1120 // Chromeos adds extra vertical space for the menu buttons. |
1124 #if defined(OS_CHROMEOS) | 1121 #if defined(OS_CHROMEOS) |
1125 top_margin += 4; | 1122 top_margin += 4; |
1126 bottom_margin += 5; | 1123 bottom_margin += 5; |
1127 #endif | 1124 #endif |
1128 | 1125 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 0, | 1262 0, |
1266 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1263 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
1267 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); | 1264 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); |
1268 } | 1265 } |
1269 | 1266 |
1270 int AppMenu::ModelIndexFromCommandId(int command_id) const { | 1267 int AppMenu::ModelIndexFromCommandId(int command_id) const { |
1271 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); | 1268 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); |
1272 DCHECK(ix != command_id_to_entry_.end()); | 1269 DCHECK(ix != command_id_to_entry_.end()); |
1273 return ix->second.second; | 1270 return ix->second.second; |
1274 } | 1271 } |
OLD | NEW |