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

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

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More compile fix for ToT Created 6 years, 7 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/menu/submenu_view.h ('k') | ui/views/controls/native/native_view_host.h » ('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/submenu_view.h" 5 #include "ui/views/controls/menu/submenu_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "ui/accessibility/ax_view_state.h" 10 #include "ui/accessibility/ax_view_state.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 for (int i = 0; i < child_count(); ++i) { 114 for (int i = 0; i < child_count(); ++i) {
115 View* child = child_at(i); 115 View* child = child_at(i);
116 if (child->visible()) { 116 if (child->visible()) {
117 gfx::Size child_pref_size = child->GetPreferredSize(); 117 gfx::Size child_pref_size = child->GetPreferredSize();
118 child->SetBounds(x, y, menu_item_width, child_pref_size.height()); 118 child->SetBounds(x, y, menu_item_width, child_pref_size.height());
119 y += child_pref_size.height(); 119 y += child_pref_size.height();
120 } 120 }
121 } 121 }
122 } 122 }
123 123
124 gfx::Size SubmenuView::GetPreferredSize() { 124 gfx::Size SubmenuView::GetPreferredSize() const {
125 if (!has_children()) 125 if (!has_children())
126 return gfx::Size(); 126 return gfx::Size();
127 127
128 max_minor_text_width_ = 0; 128 max_minor_text_width_ = 0;
129 // The maximum width of items which contain maybe a label and multiple views. 129 // The maximum width of items which contain maybe a label and multiple views.
130 int max_complex_width = 0; 130 int max_complex_width = 0;
131 // The max. width of items which contain a label and maybe an accelerator. 131 // The max. width of items which contain a label and maybe an accelerator.
132 int max_simple_width = 0; 132 int max_simple_width = 0;
133 int height = 0; 133 int height = 0;
134 for (int i = 0; i < child_count(); ++i) { 134 for (int i = 0; i < child_count(); ++i) {
135 View* child = child_at(i); 135 const View* child = child_at(i);
136 if (!child->visible()) 136 if (!child->visible())
137 continue; 137 continue;
138 if (child->id() == MenuItemView::kMenuItemViewID) { 138 if (child->id() == MenuItemView::kMenuItemViewID) {
139 MenuItemView* menu = static_cast<MenuItemView*>(child); 139 const MenuItemView* menu = static_cast<const MenuItemView*>(child);
140 const MenuItemView::MenuItemDimensions& dimensions = 140 const MenuItemView::MenuItemDimensions& dimensions =
141 menu->GetDimensions(); 141 menu->GetDimensions();
142 max_simple_width = std::max( 142 max_simple_width = std::max(
143 max_simple_width, dimensions.standard_width); 143 max_simple_width, dimensions.standard_width);
144 max_minor_text_width_ = 144 max_minor_text_width_ =
145 std::max(max_minor_text_width_, dimensions.minor_text_width); 145 std::max(max_minor_text_width_, dimensions.minor_text_width);
146 max_complex_width = std::max(max_complex_width, 146 max_complex_width = std::max(max_complex_width,
147 dimensions.standard_width + dimensions.children_width); 147 dimensions.standard_width + dimensions.children_width);
148 height += dimensions.height; 148 height += dimensions.height;
149 } else { 149 } else {
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 y = std::max(y, 0); 492 y = std::max(y, 0);
493 gfx::Rect new_vis_bounds(x, y, vis_bounds.width(), vis_bounds.height()); 493 gfx::Rect new_vis_bounds(x, y, vis_bounds.width(), vis_bounds.height());
494 if (new_vis_bounds != vis_bounds) { 494 if (new_vis_bounds != vis_bounds) {
495 ScrollRectToVisible(new_vis_bounds); 495 ScrollRectToVisible(new_vis_bounds);
496 return true; 496 return true;
497 } 497 }
498 return false; 498 return false;
499 } 499 }
500 500
501 } // namespace views 501 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/submenu_view.h ('k') | ui/views/controls/native/native_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698