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

Side by Side Diff: chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.cc

Issue 324393002: Extension Toolbar redesign, part 1 (overflow) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Linux width issue Created 6 years, 5 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
OLDNEW
(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;
Peter Kasting 2014/06/30 23:36:34 Can we get this constant from elsewhere? Seems li
Finnur 2014/07/02 16:59:57 Yes, I've found the right function to call.
16
17 // Vertical padding to make sure the icons are centered vertically within the
18 // menu.
19 const int kVerticalPadding = 8;
Peter Kasting 2014/06/30 23:36:34 Can we compute this from the icon sizes and menu h
Finnur 2014/07/02 16:59:57 This comment of mine is incorrect. I've revised it
20
21 // The max width we report back to the menu, when there is a full set of icons
22 // in the first row. Linux has a little wider menu than Windows, so we allocate
23 // more space.
24 #if defined(OS_LINUX)
25 const int kFixedMaxWidth = 312;
Devlin 2014/06/27 15:19:28 unfortunate that these aren't defined anywhere els
Peter Kasting 2014/06/30 23:36:34 It seems like we ought to be able to compute these
Finnur 2014/07/02 16:59:57 I took a stab at doing this properly, but ran out
26 #else
27 const int kFixedMaxWidth = 280;
28 #endif
29
30 // The amount of pixels that fits all but the last icon of a row in the menu.
31 #if defined(OS_LINUX)
32 const int kResizeWidth = 258;
33 #else
34 const int kResizeWidth = 200;
35 #endif
36
37 } // namespace
38
39 ExtensionToolbarMenuView::ExtensionToolbarMenuView(Browser* browser)
40 : browser_(browser) {
41 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser);
42 container_ = new BrowserActionsContainer(
43 browser_,
44 NULL, // No owner view, means no extra keybindings are registered.
45 browser_view->GetToolbarView()->browser_actions());
46 container_->Init();
47 AddChildView(container_);
48 }
49
50 ExtensionToolbarMenuView::~ExtensionToolbarMenuView() {
51 }
52
53 gfx::Size ExtensionToolbarMenuView::GetPreferredSize() const {
54 gfx::Size sz = container_->GetPreferredSize();
55 if (sz.height() == 0)
56 return sz;
57 // If we fill up max icons per row, make sure the last icon is in line with
58 // the right edge of the Paste button further down the menu.
59 if (sz.width() > kResizeWidth) {
60 // If we even more room, maybe consider adding another icon?
Peter Kasting 2014/06/30 23:36:34 Nit: This sentence no grammar
Finnur 2014/07/02 16:59:57 YAH U CAN HAZ GRAMMER.
61 DCHECK_LT(sz.width(), kFixedMaxWidth);
62
63 sz.set_width(std::max(sz.width(), kFixedMaxWidth));
64 }
65
66 sz.Enlarge(0, kVerticalPadding);
67 return sz;
68 }
69
70 void ExtensionToolbarMenuView::Layout() {
71 // All buttons are given the same width.
72 gfx::Size sz = container_->GetPreferredSize();
73 container_->SetBounds(
74 kLeftEdgePadding, 0, sz.width(), sz.height() + (kVerticalPadding / 2));
75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698