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

Side by Side Diff: ui/views/controls/menu/menu_item_view.cc

Issue 10824359: Remove ImageSkia::empty and ImageSkia::extractSubset (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/image_view.cc ('k') | ui/views/controls/menu/menu_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ui/views/controls/menu/menu_item_view.h" 5 #include "ui/views/controls/menu/menu_item_view.h"
6 6
7 #include "base/i18n/case_conversion.h" 7 #include "base/i18n/case_conversion.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "grit/ui_strings.h" 10 #include "grit/ui_strings.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 DCHECK_GE(submenu_->child_count(), index); 217 DCHECK_GE(submenu_->child_count(), index);
218 if (type == SEPARATOR) { 218 if (type == SEPARATOR) {
219 submenu_->AddChildViewAt(new MenuSeparator(), index); 219 submenu_->AddChildViewAt(new MenuSeparator(), index);
220 return NULL; 220 return NULL;
221 } 221 }
222 MenuItemView* item = new MenuItemView(this, item_id, type); 222 MenuItemView* item = new MenuItemView(this, item_id, type);
223 if (label.empty() && GetDelegate()) 223 if (label.empty() && GetDelegate())
224 item->SetTitle(GetDelegate()->GetLabel(item_id)); 224 item->SetTitle(GetDelegate()->GetLabel(item_id));
225 else 225 else
226 item->SetTitle(label); 226 item->SetTitle(label);
227 if (!icon.empty()) 227 if (!icon.isNull())
228 item->SetIcon(icon); 228 item->SetIcon(icon);
229 if (type == SUBMENU) 229 if (type == SUBMENU)
230 item->CreateSubmenu(); 230 item->CreateSubmenu();
231 submenu_->AddChildViewAt(item, index); 231 submenu_->AddChildViewAt(item, index);
232 return item; 232 return item;
233 } 233 }
234 234
235 void MenuItemView::RemoveMenuItemAt(int index) { 235 void MenuItemView::RemoveMenuItemAt(int index) {
236 DCHECK(submenu_); 236 DCHECK(submenu_);
237 DCHECK_LE(0, index); 237 DCHECK_LE(0, index);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 item->tooltip_ = tooltip; 359 item->tooltip_ = tooltip;
360 } 360 }
361 361
362 void MenuItemView::SetIcon(const gfx::ImageSkia& icon, int item_id) { 362 void MenuItemView::SetIcon(const gfx::ImageSkia& icon, int item_id) {
363 MenuItemView* item = GetMenuItemByID(item_id); 363 MenuItemView* item = GetMenuItemByID(item_id);
364 DCHECK(item); 364 DCHECK(item);
365 item->SetIcon(icon); 365 item->SetIcon(icon);
366 } 366 }
367 367
368 void MenuItemView::SetIcon(const gfx::ImageSkia& icon) { 368 void MenuItemView::SetIcon(const gfx::ImageSkia& icon) {
369 if (icon.empty()) { 369 if (icon.isNull()) {
370 SetIconView(NULL); 370 SetIconView(NULL);
371 return; 371 return;
372 } 372 }
373 373
374 ImageView* icon_view = new ImageView(); 374 ImageView* icon_view = new ImageView();
375 icon_view->SetImage(&icon); 375 icon_view->SetImage(&icon);
376 SetIconView(icon_view); 376 SetIconView(icon_view);
377 } 377 }
378 378
379 void MenuItemView::SetIconView(View* icon_view) { 379 void MenuItemView::SetIconView(View* icon_view) {
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 temp_width = menu_item->GetMaxIconViewWidth(); 846 temp_width = menu_item->GetMaxIconViewWidth();
847 } else if (menu_item->icon_view()) { 847 } else if (menu_item->icon_view()) {
848 temp_width = menu_item->icon_view()->GetPreferredSize().width(); 848 temp_width = menu_item->icon_view()->GetPreferredSize().width();
849 } 849 }
850 width = std::max(width, temp_width); 850 width = std::max(width, temp_width);
851 } 851 }
852 return width; 852 return width;
853 } 853 }
854 854
855 } // namespace views 855 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/image_view.cc ('k') | ui/views/controls/menu/menu_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698