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 "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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 max_simple_width, dimensions.standard_width); | 153 max_simple_width, dimensions.standard_width); |
154 max_minor_text_width_ = | 154 max_minor_text_width_ = |
155 std::max(max_minor_text_width_, dimensions.minor_text_width); | 155 std::max(max_minor_text_width_, dimensions.minor_text_width); |
156 max_complex_width = std::max(max_complex_width, | 156 max_complex_width = std::max(max_complex_width, |
157 dimensions.standard_width + dimensions.children_width); | 157 dimensions.standard_width + dimensions.children_width); |
158 } else { | 158 } else { |
159 max_complex_width = std::max(max_complex_width, | 159 max_complex_width = std::max(max_complex_width, |
160 child->GetPreferredSize().width()); | 160 child->GetPreferredSize().width()); |
161 } | 161 } |
162 } | 162 } |
163 if (max_minor_text_width_ > 0) | 163 if (max_minor_text_width_ > 0) { |
164 max_minor_text_width_ += MenuConfig::instance().label_to_minor_text_padding; | 164 max_minor_text_width_ += |
165 | 165 GetMenuItem()->GetMenuConfig().label_to_minor_text_padding; |
| 166 } |
166 // Finish calculating our optimum width. | 167 // Finish calculating our optimum width. |
167 gfx::Insets insets = GetInsets(); | 168 gfx::Insets insets = GetInsets(); |
168 int width = std::max(max_complex_width, | 169 int width = std::max(max_complex_width, |
169 std::max(max_simple_width + max_minor_text_width_ + | 170 std::max(max_simple_width + max_minor_text_width_ + |
170 insets.width(), | 171 insets.width(), |
171 minimum_preferred_width_ - 2 * insets.width())); | 172 minimum_preferred_width_ - 2 * insets.width())); |
172 | 173 |
173 // Then, the height for that width. | 174 // Then, the height for that width. |
174 int height = 0; | 175 int height = 0; |
175 int menu_item_width = width - insets.width(); | 176 int menu_item_width = width - insets.width(); |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 y = std::max(y, 0); | 510 y = std::max(y, 0); |
510 gfx::Rect new_vis_bounds(x, y, vis_bounds.width(), vis_bounds.height()); | 511 gfx::Rect new_vis_bounds(x, y, vis_bounds.width(), vis_bounds.height()); |
511 if (new_vis_bounds != vis_bounds) { | 512 if (new_vis_bounds != vis_bounds) { |
512 ScrollRectToVisible(new_vis_bounds); | 513 ScrollRectToVisible(new_vis_bounds); |
513 return true; | 514 return true; |
514 } | 515 } |
515 return false; | 516 return false; |
516 } | 517 } |
517 | 518 |
518 } // namespace views | 519 } // namespace views |
OLD | NEW |