Chromium Code Reviews| OLD | NEW |
|---|---|
| 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: | |
| 21 return kHarmonyLayoutUnit; | |
| 20 case Metric::DIALOG_BUTTON_MARGIN: | 22 case Metric::DIALOG_BUTTON_MARGIN: |
| 21 return kHarmonyLayoutUnit; | 23 return kHarmonyLayoutUnit; |
| 24 case Metric::DIALOG_BUTTON_MINIMUM_WIDTH: | |
| 25 // Minimum label size plus padding. | |
|
Peter Kasting
2017/02/16 01:14:47
Maybe we should just expose the minimum label widt
Bret
2017/02/16 01:31:04
I think this is okay.
| |
| 26 return 2 * kHarmonyLayoutUnit + | |
| 27 2 * GetMetric(Metric::BUTTON_HORIZONTAL_PADDING); | |
| 22 case Metric::DIALOG_BUTTON_TOP_SPACING: | 28 case Metric::DIALOG_BUTTON_TOP_SPACING: |
| 23 return kHarmonyLayoutUnit; | 29 return kHarmonyLayoutUnit; |
| 24 case Metric::DIALOG_CLOSE_BUTTON_MARGIN: | 30 case Metric::DIALOG_CLOSE_BUTTON_MARGIN: |
| 25 // TODO(pkasting): The "- 4" here is a hack that matches the extra padding | 31 // TODO(pkasting): The "- 4" here is a hack that matches the extra padding |
| 26 // in vector_icon_button.cc and should be removed when that padding is. | 32 // in vector_icon_button.cc and should be removed when that padding is. |
| 27 return (kHarmonyLayoutUnit / 2) - 4; | 33 return (kHarmonyLayoutUnit / 2) - 4; |
| 28 case Metric::PANEL_CONTENT_MARGIN: | 34 case Metric::PANEL_CONTENT_MARGIN: |
| 29 return kHarmonyLayoutUnit; | 35 return kHarmonyLayoutUnit; |
| 30 case Metric::RELATED_BUTTON_HORIZONTAL_SPACING: | 36 case Metric::RELATED_BUTTON_HORIZONTAL_SPACING: |
| 31 return kHarmonyLayoutUnit / 2; | 37 return kHarmonyLayoutUnit / 2; |
| 32 case Metric::RELATED_CONTROL_HORIZONTAL_SPACING: | 38 case Metric::RELATED_CONTROL_HORIZONTAL_SPACING: |
| 33 return kHarmonyLayoutUnit; | 39 return kHarmonyLayoutUnit; |
| 34 case Metric::RELATED_CONTROL_VERTICAL_SPACING: | 40 case Metric::RELATED_CONTROL_VERTICAL_SPACING: |
| 35 return kHarmonyLayoutUnit / 2; | 41 return kHarmonyLayoutUnit / 2; |
| 36 case Metric::RELATED_LABEL_HORIZONTAL_SPACING: | 42 case Metric::RELATED_LABEL_HORIZONTAL_SPACING: |
| 37 return kHarmonyLayoutUnit; | 43 return kHarmonyLayoutUnit; |
| 38 case Metric::SUBSECTION_HORIZONTAL_INDENT: | 44 case Metric::SUBSECTION_HORIZONTAL_INDENT: |
| 39 return 0; | 45 return 0; |
| 46 case Metric::UNRELATED_CONTROL_HORIZONTAL_SPACING: | |
| 47 return kHarmonyLayoutUnit; | |
| 48 case Metric::UNRELATED_CONTROL_HORIZONTAL_SPACING_LARGE: | |
| 49 return kHarmonyLayoutUnit; | |
| 40 case Metric::UNRELATED_CONTROL_VERTICAL_SPACING: | 50 case Metric::UNRELATED_CONTROL_VERTICAL_SPACING: |
| 41 return kHarmonyLayoutUnit; | 51 return kHarmonyLayoutUnit; |
| 42 case Metric::UNRELATED_CONTROL_VERTICAL_SPACING_LARGE: | 52 case Metric::UNRELATED_CONTROL_VERTICAL_SPACING_LARGE: |
| 43 return kHarmonyLayoutUnit; | 53 return kHarmonyLayoutUnit; |
| 44 } | 54 } |
| 45 NOTREACHED(); | 55 NOTREACHED(); |
| 46 return 0; | 56 return 0; |
| 47 } | 57 } |
| 48 | 58 |
| 49 views::GridLayout::Alignment | 59 views::GridLayout::Alignment |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 64 case DialogWidth::SMALL: | 74 case DialogWidth::SMALL: |
| 65 return 320; | 75 return 320; |
| 66 case DialogWidth::MEDIUM: | 76 case DialogWidth::MEDIUM: |
| 67 return 448; | 77 return 448; |
| 68 case DialogWidth::LARGE: | 78 case DialogWidth::LARGE: |
| 69 return 512; | 79 return 512; |
| 70 } | 80 } |
| 71 NOTREACHED(); | 81 NOTREACHED(); |
| 72 return 0; | 82 return 0; |
| 73 } | 83 } |
| OLD | NEW |