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

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

Issue 2744463002: Add VectorIconButton functionality to ImageButton. (Closed)
Patch Set: WIP: use observer Created 3 years, 9 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>::DestructorAtExit 10 static base::LazyInstance<HarmonyLayoutDelegate>::DestructorAtExit
11 harmony_layout_delegate_ = LAZY_INSTANCE_INITIALIZER; 11 harmony_layout_delegate_ = 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_MARGIN:
23 return 0;
22 case Metric::DIALOG_BUTTON_MARGIN: 24 case Metric::DIALOG_BUTTON_MARGIN:
23 return kHarmonyLayoutUnit; 25 return kHarmonyLayoutUnit;
24 case Metric::BUTTON_MAX_LINKABLE_WIDTH: 26 case Metric::BUTTON_MAX_LINKABLE_WIDTH:
25 return kHarmonyLayoutUnit * 8; 27 return kHarmonyLayoutUnit * 8;
26 case Metric::BUTTON_MINIMUM_WIDTH: 28 case Metric::BUTTON_MINIMUM_WIDTH:
27 case Metric::DIALOG_BUTTON_MINIMUM_WIDTH: 29 case Metric::DIALOG_BUTTON_MINIMUM_WIDTH:
28 // Minimum label size plus padding. 30 // Minimum label size plus padding.
29 return 2 * kHarmonyLayoutUnit + 31 return 2 * kHarmonyLayoutUnit +
30 2 * GetMetric(Metric::BUTTON_HORIZONTAL_PADDING); 32 2 * GetMetric(Metric::BUTTON_HORIZONTAL_PADDING);
31 case Metric::DIALOG_BUTTON_TOP_SPACING: 33 case Metric::DIALOG_BUTTON_TOP_SPACING:
32 return kHarmonyLayoutUnit; 34 return kHarmonyLayoutUnit;
33 case Metric::DIALOG_CLOSE_BUTTON_MARGIN: 35 case Metric::DIALOG_CLOSE_BUTTON_MARGIN:
34 // TODO(pkasting): The "- 4" here is a hack that matches the extra padding 36 return kHarmonyLayoutUnit / 2;
35 // in vector_icon_button.cc and should be removed when that padding is.
36 return (kHarmonyLayoutUnit / 2) - 4;
37 case Metric::PANEL_CONTENT_MARGIN: 37 case Metric::PANEL_CONTENT_MARGIN:
38 return kHarmonyLayoutUnit; 38 return kHarmonyLayoutUnit;
39 case Metric::RELATED_BUTTON_HORIZONTAL_SPACING: 39 case Metric::RELATED_BUTTON_HORIZONTAL_SPACING:
40 return kHarmonyLayoutUnit / 2; 40 return kHarmonyLayoutUnit / 2;
41 case Metric::RELATED_CONTROL_HORIZONTAL_SPACING: 41 case Metric::RELATED_CONTROL_HORIZONTAL_SPACING:
42 return kHarmonyLayoutUnit; 42 return kHarmonyLayoutUnit;
43 case Metric::RELATED_CONTROL_VERTICAL_SPACING: 43 case Metric::RELATED_CONTROL_VERTICAL_SPACING:
44 return kHarmonyLayoutUnit / 2; 44 return kHarmonyLayoutUnit / 2;
45 case Metric::RELATED_LABEL_HORIZONTAL_SPACING: 45 case Metric::RELATED_LABEL_HORIZONTAL_SPACING:
46 return kHarmonyLayoutUnit; 46 return kHarmonyLayoutUnit;
(...skipping 30 matching lines...) Expand all
77 case DialogWidth::SMALL: 77 case DialogWidth::SMALL:
78 return 320; 78 return 320;
79 case DialogWidth::MEDIUM: 79 case DialogWidth::MEDIUM:
80 return 448; 80 return 448;
81 case DialogWidth::LARGE: 81 case DialogWidth::LARGE:
82 return 512; 82 return 512;
83 } 83 }
84 NOTREACHED(); 84 NOTREACHED();
85 return 0; 85 return 0;
86 } 86 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698