| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_provider.h" | 5 #include "chrome/browser/ui/views/harmony/harmony_layout_provider.h" |
| 6 | 6 |
| 7 gfx::Insets HarmonyLayoutProvider::GetInsetsMetric(int metric) const { | 7 gfx::Insets HarmonyLayoutProvider::GetInsetsMetric(int metric) const { |
| 8 DCHECK_LT(metric, views::VIEWS_INSETS_MAX); | 8 DCHECK_LT(metric, views::VIEWS_INSETS_MAX); |
| 9 switch (metric) { | 9 switch (metric) { |
| 10 case views::INSETS_BUBBLE_CONTENTS: | 10 case views::INSETS_BUBBLE_CONTENTS: |
| 11 case views::INSETS_DIALOG_CONTENTS: | 11 case views::INSETS_DIALOG_CONTENTS: |
| 12 return gfx::Insets(kHarmonyLayoutUnit, kHarmonyLayoutUnit); | 12 return gfx::Insets(kHarmonyLayoutUnit, kHarmonyLayoutUnit); |
| 13 case views::INSETS_CHECKBOX_RADIO_BUTTON: { | 13 case views::INSETS_CHECKBOX_RADIO_BUTTON: { |
| 14 gfx::Insets insets = ChromeLayoutProvider::GetInsetsMetric(metric); | 14 gfx::Insets insets = ChromeLayoutProvider::GetInsetsMetric(metric); |
| 15 // Material Design requires that checkboxes and radio buttons are aligned | 15 // Material Design requires that checkboxes and radio buttons are aligned |
| 16 // flush to the left edge. | 16 // flush to the left edge. |
| 17 return gfx::Insets(insets.top(), 0, insets.bottom(), insets.right()); | 17 return gfx::Insets(insets.top(), 0, insets.bottom(), insets.right()); |
| 18 } | 18 } |
| 19 case views::INSETS_VECTOR_IMAGE_BUTTON: | 19 case views::INSETS_VECTOR_IMAGE_BUTTON: |
| 20 return gfx::Insets(kHarmonyLayoutUnit / 4); | 20 return gfx::Insets(kHarmonyLayoutUnit / 4); |
| 21 case INSETS_TOAST: |
| 22 return gfx::Insets(0, kHarmonyLayoutUnit); |
| 21 default: | 23 default: |
| 22 return ChromeLayoutProvider::GetInsetsMetric(metric); | 24 return ChromeLayoutProvider::GetInsetsMetric(metric); |
| 23 } | 25 } |
| 24 } | 26 } |
| 25 | 27 |
| 26 int HarmonyLayoutProvider::GetDistanceMetric(int metric) const { | 28 int HarmonyLayoutProvider::GetDistanceMetric(int metric) const { |
| 27 DCHECK_GE(metric, views::VIEWS_INSETS_MAX); | 29 DCHECK_GE(metric, views::VIEWS_INSETS_MAX); |
| 28 switch (metric) { | 30 switch (metric) { |
| 29 case views::DISTANCE_BUBBLE_BUTTON_TOP_MARGIN: | 31 case views::DISTANCE_BUBBLE_BUTTON_TOP_MARGIN: |
| 30 return kHarmonyLayoutUnit; | 32 return kHarmonyLayoutUnit; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 case DISTANCE_SUBSECTION_HORIZONTAL_INDENT: | 68 case DISTANCE_SUBSECTION_HORIZONTAL_INDENT: |
| 67 return 0; | 69 return 0; |
| 68 case DISTANCE_UNRELATED_CONTROL_HORIZONTAL: | 70 case DISTANCE_UNRELATED_CONTROL_HORIZONTAL: |
| 69 return kHarmonyLayoutUnit; | 71 return kHarmonyLayoutUnit; |
| 70 case DISTANCE_UNRELATED_CONTROL_HORIZONTAL_LARGE: | 72 case DISTANCE_UNRELATED_CONTROL_HORIZONTAL_LARGE: |
| 71 return kHarmonyLayoutUnit; | 73 return kHarmonyLayoutUnit; |
| 72 case views::DISTANCE_UNRELATED_CONTROL_VERTICAL: | 74 case views::DISTANCE_UNRELATED_CONTROL_VERTICAL: |
| 73 return kHarmonyLayoutUnit; | 75 return kHarmonyLayoutUnit; |
| 74 case DISTANCE_UNRELATED_CONTROL_VERTICAL_LARGE: | 76 case DISTANCE_UNRELATED_CONTROL_VERTICAL_LARGE: |
| 75 return kHarmonyLayoutUnit; | 77 return kHarmonyLayoutUnit; |
| 78 default: |
| 79 return ChromeLayoutProvider::GetDistanceMetric(metric); |
| 76 } | 80 } |
| 77 NOTREACHED(); | |
| 78 return 0; | |
| 79 } | 81 } |
| 80 | 82 |
| 81 views::GridLayout::Alignment | 83 views::GridLayout::Alignment |
| 82 HarmonyLayoutProvider::GetControlLabelGridAlignment() const { | 84 HarmonyLayoutProvider::GetControlLabelGridAlignment() const { |
| 83 return views::GridLayout::LEADING; | 85 return views::GridLayout::LEADING; |
| 84 } | 86 } |
| 85 | 87 |
| 86 bool HarmonyLayoutProvider::UseExtraDialogPadding() const { | 88 bool HarmonyLayoutProvider::UseExtraDialogPadding() const { |
| 87 return false; | 89 return false; |
| 88 } | 90 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 102 } | 104 } |
| 103 | 105 |
| 104 return ((min_width + kHarmonyLayoutUnit - 1) / kHarmonyLayoutUnit) * | 106 return ((min_width + kHarmonyLayoutUnit - 1) / kHarmonyLayoutUnit) * |
| 105 kHarmonyLayoutUnit; | 107 kHarmonyLayoutUnit; |
| 106 } | 108 } |
| 107 | 109 |
| 108 const views::TypographyProvider& HarmonyLayoutProvider::GetTypographyProvider() | 110 const views::TypographyProvider& HarmonyLayoutProvider::GetTypographyProvider() |
| 109 const { | 111 const { |
| 110 return typography_provider_; | 112 return typography_provider_; |
| 111 } | 113 } |
| OLD | NEW |