| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/wrench_menu.h" | 5 #include "chrome/browser/ui/views/wrench_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 20 matching lines...) Expand all Loading... |
| 31 #include "grit/chromium_strings.h" | 31 #include "grit/chromium_strings.h" |
| 32 #include "grit/generated_resources.h" | 32 #include "grit/generated_resources.h" |
| 33 #include "grit/theme_resources.h" | 33 #include "grit/theme_resources.h" |
| 34 #include "third_party/skia/include/core/SkCanvas.h" | 34 #include "third_party/skia/include/core/SkCanvas.h" |
| 35 #include "third_party/skia/include/core/SkPaint.h" | 35 #include "third_party/skia/include/core/SkPaint.h" |
| 36 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
| 37 #include "ui/base/layout.h" | 37 #include "ui/base/layout.h" |
| 38 #include "ui/base/resource/resource_bundle.h" | 38 #include "ui/base/resource/resource_bundle.h" |
| 39 #include "ui/gfx/canvas.h" | 39 #include "ui/gfx/canvas.h" |
| 40 #include "ui/gfx/image/canvas_image_source.h" | 40 #include "ui/gfx/image/canvas_image_source.h" |
| 41 #include "ui/gfx/image/image.h" |
| 41 #include "ui/gfx/skia_util.h" | 42 #include "ui/gfx/skia_util.h" |
| 42 #include "ui/views/background.h" | 43 #include "ui/views/background.h" |
| 43 #include "ui/views/controls/button/image_button.h" | 44 #include "ui/views/controls/button/image_button.h" |
| 44 #include "ui/views/controls/button/menu_button.h" | 45 #include "ui/views/controls/button/menu_button.h" |
| 45 #include "ui/views/controls/button/text_button.h" | 46 #include "ui/views/controls/button/text_button.h" |
| 46 #include "ui/views/controls/label.h" | 47 #include "ui/views/controls/label.h" |
| 47 #include "ui/views/controls/menu/menu_config.h" | 48 #include "ui/views/controls/menu/menu_config.h" |
| 48 #include "ui/views/controls/menu/menu_item_view.h" | 49 #include "ui/views/controls/menu/menu_item_view.h" |
| 49 #include "ui/views/controls/menu/menu_runner.h" | 50 #include "ui/views/controls/menu/menu_runner.h" |
| 50 #include "ui/views/controls/menu/menu_scroll_view_container.h" | 51 #include "ui/views/controls/menu/menu_scroll_view_container.h" |
| (...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 menu_item = parent->AppendMenuItemFromModel(model, index, id); | 1075 menu_item = parent->AppendMenuItemFromModel(model, index, id); |
| 1075 } | 1076 } |
| 1076 | 1077 |
| 1077 if (menu_item) { | 1078 if (menu_item) { |
| 1078 // Flush all buttons to the right side of the menu for touch menus. | 1079 // Flush all buttons to the right side of the menu for touch menus. |
| 1079 menu_item->set_use_right_margin( | 1080 menu_item->set_use_right_margin( |
| 1080 ui::GetDisplayLayout() != ui::LAYOUT_TOUCH); | 1081 ui::GetDisplayLayout() != ui::LAYOUT_TOUCH); |
| 1081 menu_item->SetVisible(model->IsVisibleAt(index)); | 1082 menu_item->SetVisible(model->IsVisibleAt(index)); |
| 1082 | 1083 |
| 1083 if (menu_type == MenuModel::TYPE_COMMAND && model->HasIcons()) { | 1084 if (menu_type == MenuModel::TYPE_COMMAND && model->HasIcons()) { |
| 1084 gfx::ImageSkia icon; | 1085 gfx::Image icon; |
| 1085 if (model->GetIconAt(index, &icon)) | 1086 if (model->GetIconAt(index, &icon)) |
| 1086 menu_item->SetIcon(icon); | 1087 menu_item->SetIcon(*icon.ToImageSkia()); |
| 1087 } | 1088 } |
| 1088 } | 1089 } |
| 1089 | 1090 |
| 1090 return menu_item; | 1091 return menu_item; |
| 1091 } | 1092 } |
| 1092 | 1093 |
| 1093 void WrenchMenu::CancelAndEvaluate(MenuModel* model, int index) { | 1094 void WrenchMenu::CancelAndEvaluate(MenuModel* model, int index) { |
| 1094 selected_menu_model_ = model; | 1095 selected_menu_model_ = model; |
| 1095 selected_index_ = index; | 1096 selected_index_ = index; |
| 1096 root_->Cancel(); | 1097 root_->Cancel(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1113 bookmark_menu_delegate_.reset( | 1114 bookmark_menu_delegate_.reset( |
| 1114 new BookmarkMenuDelegate(browser_, | 1115 new BookmarkMenuDelegate(browser_, |
| 1115 browser_, | 1116 browser_, |
| 1116 parent, | 1117 parent, |
| 1117 first_bookmark_command_id_)); | 1118 first_bookmark_command_id_)); |
| 1118 bookmark_menu_delegate_->Init( | 1119 bookmark_menu_delegate_->Init( |
| 1119 this, bookmark_menu_, model->bookmark_bar_node(), 0, | 1120 this, bookmark_menu_, model->bookmark_bar_node(), 0, |
| 1120 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1121 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
| 1121 bookmark_utils::LAUNCH_WRENCH_MENU); | 1122 bookmark_utils::LAUNCH_WRENCH_MENU); |
| 1122 } | 1123 } |
| OLD | NEW |