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

Side by Side Diff: views/controls/menu/submenu_view.cc

Issue 3289001: Adds support for invisible menu items to bookmark menus and wires it (Closed)
Patch Set: Created 10 years, 3 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
« no previous file with comments | « chrome/browser/views/wrench_menu.cc ('k') | no next file » | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "views/controls/menu/submenu_view.h" 5 #include "views/controls/menu/submenu_view.h"
6 6
7 #include "gfx/canvas.h" 7 #include "gfx/canvas.h"
8 #include "views/controls/menu/menu_config.h" 8 #include "views/controls/menu/menu_config.h"
9 #include "views/controls/menu/menu_controller.h" 9 #include "views/controls/menu/menu_controller.h"
10 #include "views/controls/menu/menu_host.h" 10 #include "views/controls/menu/menu_host.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 else 79 else
80 new_y = 0; 80 new_y = 0;
81 SetBounds(x(), new_y, parent->width(), pref_height); 81 SetBounds(x(), new_y, parent->width(), pref_height);
82 82
83 gfx::Insets insets = GetInsets(); 83 gfx::Insets insets = GetInsets();
84 int x = insets.left(); 84 int x = insets.left();
85 int y = insets.top(); 85 int y = insets.top();
86 int menu_item_width = width() - insets.width(); 86 int menu_item_width = width() - insets.width();
87 for (int i = 0; i < GetChildViewCount(); ++i) { 87 for (int i = 0; i < GetChildViewCount(); ++i) {
88 View* child = GetChildViewAt(i); 88 View* child = GetChildViewAt(i);
89 gfx::Size child_pref_size = child->GetPreferredSize(); 89 if (child->IsVisible()) {
90 child->SetBounds(x, y, menu_item_width, child_pref_size.height()); 90 gfx::Size child_pref_size = child->GetPreferredSize();
91 y += child_pref_size.height(); 91 child->SetBounds(x, y, menu_item_width, child_pref_size.height());
92 y += child_pref_size.height();
93 }
92 } 94 }
93 } 95 }
94 96
95 gfx::Size SubmenuView::GetPreferredSize() { 97 gfx::Size SubmenuView::GetPreferredSize() {
96 if (GetChildViewCount() == 0) 98 if (GetChildViewCount() == 0)
97 return gfx::Size(); 99 return gfx::Size();
98 100
99 max_accelerator_width_ = 0; 101 max_accelerator_width_ = 0;
100 int max_width = 0; 102 int max_width = 0;
101 int height = 0; 103 int height = 0;
102 for (int i = 0; i < GetChildViewCount(); ++i) { 104 for (int i = 0; i < GetChildViewCount(); ++i) {
103 View* child = GetChildViewAt(i); 105 View* child = GetChildViewAt(i);
104 gfx::Size child_pref_size = child->GetPreferredSize(); 106 gfx::Size child_pref_size = child->IsVisible() ?
107 child->GetPreferredSize() : gfx::Size();
105 max_width = std::max(max_width, child_pref_size.width()); 108 max_width = std::max(max_width, child_pref_size.width());
106 height += child_pref_size.height(); 109 height += child_pref_size.height();
107 if (child->GetID() == MenuItemView::kMenuItemViewID) { 110 if (child->GetID() == MenuItemView::kMenuItemViewID) {
108 MenuItemView* menu = static_cast<MenuItemView*>(child); 111 MenuItemView* menu = static_cast<MenuItemView*>(child);
109 max_accelerator_width_ = 112 max_accelerator_width_ =
110 std::max(max_accelerator_width_, menu->GetAcceleratorTextWidth()); 113 std::max(max_accelerator_width_, menu->GetAcceleratorTextWidth());
111 } 114 }
112 } 115 }
113 if (max_accelerator_width_ > 0) { 116 if (max_accelerator_width_ > 0) {
114 max_accelerator_width_ += 117 max_accelerator_width_ +=
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 item_bounds.set_height(kDropIndicatorHeight); 374 item_bounds.set_height(kDropIndicatorHeight);
372 return item_bounds; 375 return item_bounds;
373 376
374 default: 377 default:
375 // Don't render anything for on. 378 // Don't render anything for on.
376 return gfx::Rect(); 379 return gfx::Rect();
377 } 380 }
378 } 381 }
379 382
380 } // namespace views 383 } // namespace views
OLDNEW
« no previous file with comments | « chrome/browser/views/wrench_menu.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698