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

Side by Side Diff: chrome/browser/ui/views/harmony/harmony_layout_delegate.cc

Issue 2702403010: Fix the absence of padding on some UI buttons. (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/harmony/harmony_layout_delegate.h" 5 #include "chrome/browser/ui/views/harmony/harmony_layout_delegate.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 static base::LazyInstance<HarmonyLayoutDelegate> harmony_layout_delegate_ = 10 static base::LazyInstance<HarmonyLayoutDelegate> harmony_layout_delegate_ =
11 LAZY_INSTANCE_INITIALIZER; 11 LAZY_INSTANCE_INITIALIZER;
12 12
13 // static 13 // static
14 HarmonyLayoutDelegate* HarmonyLayoutDelegate::Get() { 14 HarmonyLayoutDelegate* HarmonyLayoutDelegate::Get() {
15 return harmony_layout_delegate_.Pointer(); 15 return harmony_layout_delegate_.Pointer();
16 } 16 }
17 17
18 int HarmonyLayoutDelegate::GetMetric(Metric metric) const { 18 int HarmonyLayoutDelegate::GetMetric(Metric metric) const {
19 switch (metric) { 19 switch (metric) {
20 case Metric::BUTTON_HORIZONTAL_PADDING: 20 case Metric::BUTTON_HORIZONTAL_PADDING:
21 return kHarmonyLayoutUnit; 21 return kHarmonyLayoutUnit;
22 case Metric::BUTTON_MINIMUM_WIDTH:
23 // Minimum label size plus padding.
24 return 2 * kHarmonyLayoutUnit +
25 2 * GetMetric(Metric::BUTTON_HORIZONTAL_PADDING);
22 case Metric::DIALOG_BUTTON_MARGIN: 26 case Metric::DIALOG_BUTTON_MARGIN:
23 return kHarmonyLayoutUnit; 27 return kHarmonyLayoutUnit;
24 case Metric::DIALOG_BUTTON_MINIMUM_WIDTH: 28 case Metric::DIALOG_BUTTON_MINIMUM_WIDTH:
25 // Minimum label size plus padding. 29 return GetMetric(Metric::BUTTON_MINIMUM_WIDTH);
Peter Kasting 2017/02/24 02:00:50 Nit: Honestly I'd find it a bit clearer to do c
Bret 2017/02/24 02:29:45 Done, just for BUTTON_MINIMUM_WIDTH. I'll let Alle
26 return 2 * kHarmonyLayoutUnit +
27 2 * GetMetric(Metric::BUTTON_HORIZONTAL_PADDING);
28 case Metric::DIALOG_BUTTON_TOP_SPACING: 30 case Metric::DIALOG_BUTTON_TOP_SPACING:
29 return kHarmonyLayoutUnit; 31 return kHarmonyLayoutUnit;
30 case Metric::DIALOG_CLOSE_BUTTON_MARGIN: 32 case Metric::DIALOG_CLOSE_BUTTON_MARGIN:
31 // TODO(pkasting): The "- 4" here is a hack that matches the extra padding 33 // TODO(pkasting): The "- 4" here is a hack that matches the extra padding
32 // in vector_icon_button.cc and should be removed when that padding is. 34 // in vector_icon_button.cc and should be removed when that padding is.
33 return (kHarmonyLayoutUnit / 2) - 4; 35 return (kHarmonyLayoutUnit / 2) - 4;
34 case Metric::PANEL_CONTENT_MARGIN: 36 case Metric::PANEL_CONTENT_MARGIN:
35 return kHarmonyLayoutUnit; 37 return kHarmonyLayoutUnit;
36 case Metric::RELATED_BUTTON_HORIZONTAL_SPACING: 38 case Metric::RELATED_BUTTON_HORIZONTAL_SPACING:
37 return kHarmonyLayoutUnit / 2; 39 return kHarmonyLayoutUnit / 2;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 case DialogWidth::SMALL: 76 case DialogWidth::SMALL:
75 return 320; 77 return 320;
76 case DialogWidth::MEDIUM: 78 case DialogWidth::MEDIUM:
77 return 448; 79 return 448;
78 case DialogWidth::LARGE: 80 case DialogWidth::LARGE:
79 return 512; 81 return 512;
80 } 82 }
81 NOTREACHED(); 83 NOTREACHED();
82 return 0; 84 return 0;
83 } 85 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/chrome_views_delegate.cc ('k') | chrome/browser/ui/views/harmony/layout_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698