| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 case DISTANCE_SUBSECTION_HORIZONTAL_INDENT: | 66 case DISTANCE_SUBSECTION_HORIZONTAL_INDENT: |
| 65 return 0; | 67 return 0; |
| 66 case DISTANCE_UNRELATED_CONTROL_HORIZONTAL: | 68 case DISTANCE_UNRELATED_CONTROL_HORIZONTAL: |
| 67 return kHarmonyLayoutUnit; | 69 return kHarmonyLayoutUnit; |
| 68 case DISTANCE_UNRELATED_CONTROL_HORIZONTAL_LARGE: | 70 case DISTANCE_UNRELATED_CONTROL_HORIZONTAL_LARGE: |
| 69 return kHarmonyLayoutUnit; | 71 return kHarmonyLayoutUnit; |
| 70 case views::DISTANCE_UNRELATED_CONTROL_VERTICAL: | 72 case views::DISTANCE_UNRELATED_CONTROL_VERTICAL: |
| 71 return kHarmonyLayoutUnit; | 73 return kHarmonyLayoutUnit; |
| 72 case DISTANCE_UNRELATED_CONTROL_VERTICAL_LARGE: | 74 case DISTANCE_UNRELATED_CONTROL_VERTICAL_LARGE: |
| 73 return kHarmonyLayoutUnit; | 75 return kHarmonyLayoutUnit; |
| 76 default: |
| 77 return ChromeLayoutProvider::GetDistanceMetric(metric); |
| 74 } | 78 } |
| 75 NOTREACHED(); | |
| 76 return 0; | |
| 77 } | 79 } |
| 78 | 80 |
| 79 views::GridLayout::Alignment | 81 views::GridLayout::Alignment |
| 80 HarmonyLayoutProvider::GetControlLabelGridAlignment() const { | 82 HarmonyLayoutProvider::GetControlLabelGridAlignment() const { |
| 81 return views::GridLayout::LEADING; | 83 return views::GridLayout::LEADING; |
| 82 } | 84 } |
| 83 | 85 |
| 84 bool HarmonyLayoutProvider::UseExtraDialogPadding() const { | 86 bool HarmonyLayoutProvider::UseExtraDialogPadding() const { |
| 85 return false; | 87 return false; |
| 86 } | 88 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 100 } | 102 } |
| 101 | 103 |
| 102 return ((min_width + kHarmonyLayoutUnit - 1) / kHarmonyLayoutUnit) * | 104 return ((min_width + kHarmonyLayoutUnit - 1) / kHarmonyLayoutUnit) * |
| 103 kHarmonyLayoutUnit; | 105 kHarmonyLayoutUnit; |
| 104 } | 106 } |
| 105 | 107 |
| 106 const views::TypographyProvider& HarmonyLayoutProvider::GetTypographyProvider() | 108 const views::TypographyProvider& HarmonyLayoutProvider::GetTypographyProvider() |
| 107 const { | 109 const { |
| 108 return typography_provider_; | 110 return typography_provider_; |
| 109 } | 111 } |
| OLD | NEW |