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

Side by Side Diff: chrome/browser/views/browser_actions_container.cc

Issue 316019: Increase visual spacing between browser action buttons to 5px. (Closed)
Patch Set: cr change Created 11 years, 2 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
« no previous file with comments | « chrome/browser/gtk/browser_actions_toolbar_gtk.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/views/browser_actions_container.h" 5 #include "chrome/browser/views/browser_actions_container.h"
6 6
7 #include "app/gfx/canvas.h" 7 #include "app/gfx/canvas.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/stl_util-inl.h" 9 #include "base/stl_util-inl.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 12 matching lines...) Expand all
23 #include "third_party/skia/include/core/SkTypeface.h" 23 #include "third_party/skia/include/core/SkTypeface.h"
24 #include "third_party/skia/include/effects/SkGradientShader.h" 24 #include "third_party/skia/include/effects/SkGradientShader.h"
25 #include "views/controls/button/text_button.h" 25 #include "views/controls/button/text_button.h"
26 26
27 // The size (both dimensions) of the buttons for page actions. 27 // The size (both dimensions) of the buttons for page actions.
28 static const int kButtonSize = 29; 28 static const int kButtonSize = 29;
29 29
30 // The padding between the browser actions and the omnibox/page menu. 30 // The padding between the browser actions and the omnibox/page menu.
31 static const int kHorizontalPadding = 4; 31 static const int kHorizontalPadding = 4;
32 32
33 // The padding between browser action buttons. Visually, the actual number of
34 // empty (non-drawing) pixels is this value + 2 when adjacent browser icons
35 // use their maximum allowed size.
36 static const int kBrowserActionButtonPadding = 3;
37
33 // This is the same value from toolbar.cc. We position the browser actions 38 // This is the same value from toolbar.cc. We position the browser actions
34 // container flush with the edges of the toolbar as a special case so that we 39 // container flush with the edges of the toolbar as a special case so that we
35 // can draw the badge outside the visual bounds of the container. 40 // can draw the badge outside the visual bounds of the container.
36 static const int kControlVertOffset = 6; 41 static const int kControlVertOffset = 6;
37 42
38 // The maximum of the minimum number of browser actions present when there is 43 // The maximum of the minimum number of browser actions present when there is
39 // not enough space to fit all the browser actions in the toolbar. 44 // not enough space to fit all the browser actions in the toolbar.
40 static const int kMinimumNumberOfVisibleBrowserActions = 2; 45 static const int kMinimumNumberOfVisibleBrowserActions = 2;
41 46
42 47
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 // Otherwise, we send the action to the extension. 338 // Otherwise, we send the action to the extension.
334 ExtensionBrowserEventRouter::GetInstance()->BrowserActionExecuted( 339 ExtensionBrowserEventRouter::GetInstance()->BrowserActionExecuted(
335 profile_, browser_action.extension_id(), toolbar_->browser()); 340 profile_, browser_action.extension_id(), toolbar_->browser());
336 } 341 }
337 342
338 gfx::Size BrowserActionsContainer::GetPreferredSize() { 343 gfx::Size BrowserActionsContainer::GetPreferredSize() {
339 if (browser_action_views_.empty()) 344 if (browser_action_views_.empty())
340 return gfx::Size(0, 0); 345 return gfx::Size(0, 0);
341 int width = kHorizontalPadding * 2 + 346 int width = kHorizontalPadding * 2 +
342 browser_action_views_.size() * kButtonSize; 347 browser_action_views_.size() * kButtonSize;
348 if (browser_action_views_.size() > 1)
349 width += (browser_action_views_.size() - 1) * kBrowserActionButtonPadding;
343 return gfx::Size(width, kButtonSize); 350 return gfx::Size(width, kButtonSize);
344 } 351 }
345 352
346 void BrowserActionsContainer::Layout() { 353 void BrowserActionsContainer::Layout() {
347 for (size_t i = 0; i < browser_action_views_.size(); ++i) { 354 for (size_t i = 0; i < browser_action_views_.size(); ++i) {
348 BrowserActionView* view = browser_action_views_[i]; 355 BrowserActionView* view = browser_action_views_[i];
349 int x = kHorizontalPadding + i * kButtonSize; 356 int x = kHorizontalPadding +
357 i * (kButtonSize + kBrowserActionButtonPadding);
350 if (x + kButtonSize <= width()) { 358 if (x + kButtonSize <= width()) {
351 view->SetBounds(x, 0, kButtonSize, height()); 359 view->SetBounds(x, 0, kButtonSize, height());
352 view->SetVisible(true); 360 view->SetVisible(true);
353 } else { 361 } else {
354 view->SetVisible(false); 362 view->SetVisible(false);
355 } 363 }
356 } 364 }
357 } 365 }
358 366
359 void BrowserActionsContainer::Observe(NotificationType type, 367 void BrowserActionsContainer::Observe(NotificationType type,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 std::min(static_cast<int>(browser_action_views_.size()), 416 std::min(static_cast<int>(browser_action_views_.size()),
409 kMinimumNumberOfVisibleBrowserActions) * kButtonSize; 417 kMinimumNumberOfVisibleBrowserActions) * kButtonSize;
410 418
411 // Even if available_width is <= 0, we still return at least the |min_width|. 419 // Even if available_width is <= 0, we still return at least the |min_width|.
412 if (available_width <= 0) 420 if (available_width <= 0)
413 return min_width; 421 return min_width;
414 422
415 return std::max(min_width, available_width - available_width % kButtonSize + 423 return std::max(min_width, available_width - available_width % kButtonSize +
416 kHorizontalPadding * 2); 424 kHorizontalPadding * 2);
417 } 425 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/browser_actions_toolbar_gtk.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698