Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.h" | |
| 6 | |
| 7 #include "chrome/browser/ui/views/frame/browser_view.h" | |
| 8 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" | |
| 9 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | |
| 10 | |
| 11 namespace { | |
| 12 | |
| 13 // Padding to the left of the menu to make sure the icons are in line with the | |
| 14 // rest of the menu. | |
| 15 const int kLeftEdgePadding = 33; | |
| 16 | |
| 17 // Vertical padding to make sure the icons are centered vertically within the | |
| 18 // menu. | |
| 19 const int kVerticalPadding = 8; | |
| 20 | |
| 21 } // namespace | |
| 22 | |
| 23 ExtensionToolbarMenuView::ExtensionToolbarMenuView(Browser* browser) | |
| 24 : browser_(browser) { | |
| 25 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); | |
| 26 container_ = new BrowserActionsContainer( | |
| 27 browser_, | |
| 28 NULL, // No owner view, means no extra keybindings are registered. | |
| 29 browser_view->GetToolbarView()->browser_actions()); | |
| 30 container_->Init(); | |
| 31 AddChildView(container_); | |
| 32 } | |
| 33 | |
| 34 ExtensionToolbarMenuView::~ExtensionToolbarMenuView() { | |
| 35 } | |
| 36 | |
| 37 gfx::Size ExtensionToolbarMenuView::GetPreferredSize() const { | |
| 38 gfx::Size sz = container_->GetPreferredSize(); | |
| 39 if (sz.height() == 0) | |
| 40 return sz; | |
| 41 // If we go above 6 icons, make sure the seventh is in line with the right | |
|
Devlin
2014/06/26 16:29:13
If I'm reading this comment right, it doesn't quit
Finnur
2014/06/27 14:23:38
You are correct on both accounts. I've fixed this
| |
| 42 // edge of the Paste button further down the menu. | |
| 43 if (sz.width() > 200) | |
| 44 sz.set_width(std::max(sz.width(), 280)); | |
| 45 | |
| 46 sz.Enlarge(0, kVerticalPadding); | |
| 47 return sz; | |
| 48 } | |
| 49 | |
| 50 void ExtensionToolbarMenuView::Layout() { | |
| 51 // All buttons are given the same width. | |
| 52 gfx::Size sz = container_->GetPreferredSize(); | |
| 53 container_->SetBounds( | |
| 54 kLeftEdgePadding, 0, sz.width(), sz.height() + (kVerticalPadding / 2)); | |
| 55 } | |
| OLD | NEW |