| 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>::DestructorAtExit | 10 static base::LazyInstance<HarmonyLayoutDelegate>::DestructorAtExit |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 return kHarmonyLayoutUnit; | 23 return kHarmonyLayoutUnit; |
| 24 case Metric::BUTTON_MAX_LINKABLE_WIDTH: | 24 case Metric::BUTTON_MAX_LINKABLE_WIDTH: |
| 25 return kHarmonyLayoutUnit * 8; | 25 return kHarmonyLayoutUnit * 8; |
| 26 case Metric::BUTTON_MINIMUM_WIDTH: | 26 case Metric::BUTTON_MINIMUM_WIDTH: |
| 27 case Metric::DIALOG_BUTTON_MINIMUM_WIDTH: | 27 case Metric::DIALOG_BUTTON_MINIMUM_WIDTH: |
| 28 // Minimum label size plus padding. | 28 // Minimum label size plus padding. |
| 29 return 2 * kHarmonyLayoutUnit + | 29 return 2 * kHarmonyLayoutUnit + |
| 30 2 * GetMetric(Metric::BUTTON_HORIZONTAL_PADDING); | 30 2 * GetMetric(Metric::BUTTON_HORIZONTAL_PADDING); |
| 31 case Metric::DIALOG_BUTTON_TOP_SPACING: | 31 case Metric::DIALOG_BUTTON_TOP_SPACING: |
| 32 return kHarmonyLayoutUnit; | 32 return kHarmonyLayoutUnit; |
| 33 case Metric::DIALOG_CLOSE_BUTTON_MARGIN: | 33 case Metric::DIALOG_CLOSE_BUTTON_MARGIN: { |
| 34 // TODO(pkasting): The "- 4" here is a hack that matches the extra padding | 34 constexpr int kVisibleMargin = kHarmonyLayoutUnit / 2; |
| 35 // in vector_icon_button.cc and should be removed when that padding is. | 35 // The visible margin is based on the unpadded size, so to get the actual |
| 36 return (kHarmonyLayoutUnit / 2) - 4; | 36 // margin we need to subtract out the padding. |
| 37 return kVisibleMargin - GetMetric(Metric::VECTOR_IMAGE_BUTTON_PADDING); |
| 38 } |
| 37 case Metric::PANEL_CONTENT_MARGIN: | 39 case Metric::PANEL_CONTENT_MARGIN: |
| 38 return kHarmonyLayoutUnit; | 40 return kHarmonyLayoutUnit; |
| 39 case Metric::RELATED_BUTTON_HORIZONTAL_SPACING: | 41 case Metric::RELATED_BUTTON_HORIZONTAL_SPACING: |
| 40 return kHarmonyLayoutUnit / 2; | 42 return kHarmonyLayoutUnit / 2; |
| 41 case Metric::RELATED_CONTROL_HORIZONTAL_SPACING: | 43 case Metric::RELATED_CONTROL_HORIZONTAL_SPACING: |
| 42 return kHarmonyLayoutUnit; | 44 return kHarmonyLayoutUnit; |
| 43 case Metric::RELATED_CONTROL_HORIZONTAL_SPACING_SMALL: | 45 case Metric::RELATED_CONTROL_HORIZONTAL_SPACING_SMALL: |
| 44 return kHarmonyLayoutUnit; | 46 return kHarmonyLayoutUnit; |
| 45 case Metric::RELATED_CONTROL_VERTICAL_SPACING: | 47 case Metric::RELATED_CONTROL_VERTICAL_SPACING: |
| 46 return kHarmonyLayoutUnit / 2; | 48 return kHarmonyLayoutUnit / 2; |
| 47 case Metric::RELATED_CONTROL_VERTICAL_SPACING_SMALL: | 49 case Metric::RELATED_CONTROL_VERTICAL_SPACING_SMALL: |
| 48 return kHarmonyLayoutUnit / 2; | 50 return kHarmonyLayoutUnit / 2; |
| 49 case Metric::RELATED_LABEL_HORIZONTAL_SPACING: | 51 case Metric::RELATED_LABEL_HORIZONTAL_SPACING: |
| 50 return kHarmonyLayoutUnit; | 52 return kHarmonyLayoutUnit; |
| 51 case Metric::SUBSECTION_HORIZONTAL_INDENT: | 53 case Metric::SUBSECTION_HORIZONTAL_INDENT: |
| 52 return 0; | 54 return 0; |
| 53 case Metric::UNRELATED_CONTROL_HORIZONTAL_SPACING: | 55 case Metric::UNRELATED_CONTROL_HORIZONTAL_SPACING: |
| 54 return kHarmonyLayoutUnit; | 56 return kHarmonyLayoutUnit; |
| 55 case Metric::UNRELATED_CONTROL_HORIZONTAL_SPACING_LARGE: | 57 case Metric::UNRELATED_CONTROL_HORIZONTAL_SPACING_LARGE: |
| 56 return kHarmonyLayoutUnit; | 58 return kHarmonyLayoutUnit; |
| 57 case Metric::UNRELATED_CONTROL_VERTICAL_SPACING: | 59 case Metric::UNRELATED_CONTROL_VERTICAL_SPACING: |
| 58 return kHarmonyLayoutUnit; | 60 return kHarmonyLayoutUnit; |
| 59 case Metric::UNRELATED_CONTROL_VERTICAL_SPACING_LARGE: | 61 case Metric::UNRELATED_CONTROL_VERTICAL_SPACING_LARGE: |
| 60 return kHarmonyLayoutUnit; | 62 return kHarmonyLayoutUnit; |
| 63 case Metric::VECTOR_IMAGE_BUTTON_PADDING: |
| 64 return 4; |
| 61 } | 65 } |
| 62 NOTREACHED(); | 66 NOTREACHED(); |
| 63 return 0; | 67 return 0; |
| 64 } | 68 } |
| 65 | 69 |
| 66 views::GridLayout::Alignment | 70 views::GridLayout::Alignment |
| 67 HarmonyLayoutDelegate::GetControlLabelGridAlignment() const { | 71 HarmonyLayoutDelegate::GetControlLabelGridAlignment() const { |
| 68 return views::GridLayout::LEADING; | 72 return views::GridLayout::LEADING; |
| 69 } | 73 } |
| 70 | 74 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 85 case DialogWidth::SMALL: | 89 case DialogWidth::SMALL: |
| 86 return 320; | 90 return 320; |
| 87 case DialogWidth::MEDIUM: | 91 case DialogWidth::MEDIUM: |
| 88 return 448; | 92 return 448; |
| 89 case DialogWidth::LARGE: | 93 case DialogWidth::LARGE: |
| 90 return 512; | 94 return 512; |
| 91 } | 95 } |
| 92 NOTREACHED(); | 96 NOTREACHED(); |
| 93 return 0; | 97 return 0; |
| 94 } | 98 } |
| OLD | NEW |