| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/toolbar/extension_toolbar_menu_view.h" | 5 #include "chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // views::ScrollView::GetPreferredSize() includes the contents' size, but | 67 // views::ScrollView::GetPreferredSize() includes the contents' size, but |
| 68 // not the scrollbar width. Add it in if necessary. | 68 // not the scrollbar width. Add it in if necessary. |
| 69 if (container_->GetPreferredSize().height() > max_height_) | 69 if (container_->GetPreferredSize().height() > max_height_) |
| 70 s.Enlarge(GetScrollBarWidth(), 0); | 70 s.Enlarge(GetScrollBarWidth(), 0); |
| 71 return s; | 71 return s; |
| 72 } | 72 } |
| 73 | 73 |
| 74 int ExtensionToolbarMenuView::GetHeightForWidth(int width) const { | 74 int ExtensionToolbarMenuView::GetHeightForWidth(int width) const { |
| 75 // The width passed in here includes the full width of the menu, so we need | 75 // The width passed in here includes the full width of the menu, so we need |
| 76 // to omit the necessary padding. | 76 // to omit the necessary padding. |
| 77 const views::MenuConfig& menu_config = | 77 const views::MenuConfig& menu_config = views::MenuConfig::instance(); |
| 78 static_cast<const views::MenuItemView*>(parent())->GetMenuConfig(); | |
| 79 int end_padding = menu_config.arrow_to_edge_padding - | 78 int end_padding = menu_config.arrow_to_edge_padding - |
| 80 container_->toolbar_actions_bar()->platform_settings().item_spacing; | 79 container_->toolbar_actions_bar()->platform_settings().item_spacing; |
| 81 width -= start_padding() + end_padding; | 80 width -= start_padding() + end_padding; |
| 82 | 81 |
| 83 return views::ScrollView::GetHeightForWidth(width); | 82 return views::ScrollView::GetHeightForWidth(width); |
| 84 } | 83 } |
| 85 | 84 |
| 86 void ExtensionToolbarMenuView::Layout() { | 85 void ExtensionToolbarMenuView::Layout() { |
| 87 SetPosition(gfx::Point(start_padding(), 0)); | 86 SetPosition(gfx::Point(start_padding(), 0)); |
| 88 SizeToPreferredSize(); | 87 SizeToPreferredSize(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 133 } |
| 135 | 134 |
| 136 int ExtensionToolbarMenuView::start_padding() const { | 135 int ExtensionToolbarMenuView::start_padding() const { |
| 137 // We pad enough on the left so that the first icon starts at the same point | 136 // We pad enough on the left so that the first icon starts at the same point |
| 138 // as the labels. We subtract kItemSpacing because there needs to be padding | 137 // as the labels. We subtract kItemSpacing because there needs to be padding |
| 139 // so we can see the drop indicator. | 138 // so we can see the drop indicator. |
| 140 return views::MenuItemView::label_start() - | 139 return views::MenuItemView::label_start() - |
| 141 container_->toolbar_actions_bar()->platform_settings().item_spacing; | 140 container_->toolbar_actions_bar()->platform_settings().item_spacing; |
| 142 } | 141 } |
| 143 | 142 |
| OLD | NEW |