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

Unified 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: Crash fix for Linux Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.cc
diff --git a/chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.cc b/chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a82e146f9789ddfdf4cdb12ed8a8448da97f7781
--- /dev/null
+++ b/chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.cc
@@ -0,0 +1,55 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.h"
+
+#include "chrome/browser/ui/views/frame/browser_view.h"
+#include "chrome/browser/ui/views/toolbar/browser_actions_container.h"
+#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
+
+namespace {
+
+// Padding to the left of the menu to make sure the icons are in line with the
+// rest of the menu.
+const int kLeftEdgePadding = 33;
+
+// Vertical padding to make sure the icons are centered vertically within the
+// menu.
+const int kVerticalPadding = 8;
+
+} // namespace
+
+ExtensionToolbarMenuView::ExtensionToolbarMenuView(Browser* browser)
+ : browser_(browser) {
+ BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser);
+ container_ = new BrowserActionsContainer(
+ browser_,
+ NULL, // No owner view, means no extra keybindings are registered.
+ browser_view->GetToolbarView()->browser_actions());
+ container_->Init();
+ AddChildView(container_);
+}
+
+ExtensionToolbarMenuView::~ExtensionToolbarMenuView() {
+}
+
+gfx::Size ExtensionToolbarMenuView::GetPreferredSize() const {
+ gfx::Size sz = container_->GetPreferredSize();
+ if (sz.height() == 0)
+ return sz;
+ // 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
+ // edge of the Paste button further down the menu.
+ if (sz.width() > 200)
+ sz.set_width(std::max(sz.width(), 280));
+
+ sz.Enlarge(0, kVerticalPadding);
+ return sz;
+}
+
+void ExtensionToolbarMenuView::Layout() {
+ // All buttons are given the same width.
+ gfx::Size sz = container_->GetPreferredSize();
+ container_->SetBounds(
+ kLeftEdgePadding, 0, sz.width(), sz.height() + (kVerticalPadding / 2));
+}

Powered by Google App Engine
This is Rietveld 408576698