| 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_DIALOG_BUTTON: | |
| 11 case views::INSETS_PANEL: | |
| 12 case views::INSETS_BUBBLE_CONTENTS: | |
| 13 return gfx::Insets(kHarmonyLayoutUnit); | |
| 14 case views::INSETS_BUBBLE_TITLE: | |
| 15 case views::INSETS_DIALOG_TITLE: { | |
| 16 constexpr int top = kHarmonyLayoutUnit; | |
| 17 constexpr int side = kHarmonyLayoutUnit; | |
| 18 // Titles are inset at the top and sides, but not at the bottom. | |
| 19 return gfx::Insets(top, side, 0, side); | |
| 20 } | |
| 21 case views::INSETS_VECTOR_IMAGE_BUTTON: | 10 case views::INSETS_VECTOR_IMAGE_BUTTON: |
| 22 return gfx::Insets(kHarmonyLayoutUnit / 4); | 11 return gfx::Insets(kHarmonyLayoutUnit / 4); |
| 12 default: |
| 13 return ChromeLayoutProvider::GetInsetsMetric(metric); |
| 23 } | 14 } |
| 24 NOTREACHED(); | |
| 25 return gfx::Insets(); | |
| 26 } | 15 } |
| 27 | 16 |
| 28 int HarmonyLayoutProvider::GetDistanceMetric(int metric) const { | 17 int HarmonyLayoutProvider::GetDistanceMetric(int metric) const { |
| 29 DCHECK_GE(metric, views::VIEWS_INSETS_MAX); | 18 DCHECK_GE(metric, views::VIEWS_INSETS_MAX); |
| 30 switch (metric) { | 19 switch (metric) { |
| 20 case views::DISTANCE_BUBBLE_CONTENTS_HORIZONTAL_MARGIN: |
| 21 case views::DISTANCE_BUBBLE_CONTENTS_VERTICAL_MARGIN: |
| 22 case views::DISTANCE_DIALOG_CONTENTS_HORIZONTAL_MARGIN: |
| 23 case views::DISTANCE_DIALOG_CONTENTS_VERTICAL_MARGIN: |
| 24 return kHarmonyLayoutUnit; |
| 31 case DISTANCE_CONTROL_LIST_VERTICAL: | 25 case DISTANCE_CONTROL_LIST_VERTICAL: |
| 32 return kHarmonyLayoutUnit * 3 / 4; | 26 return kHarmonyLayoutUnit * 3 / 4; |
| 33 case views::DISTANCE_CLOSE_BUTTON_MARGIN: { | 27 case views::DISTANCE_CLOSE_BUTTON_MARGIN: { |
| 34 constexpr int kVisibleMargin = kHarmonyLayoutUnit / 2; | 28 constexpr int kVisibleMargin = kHarmonyLayoutUnit / 2; |
| 35 // The visible margin is based on the unpadded size, so to get the actual | 29 // The visible margin is based on the unpadded size, so to get the actual |
| 36 // margin we need to subtract out the padding. | 30 // margin we need to subtract out the padding. |
| 37 return kVisibleMargin - kHarmonyLayoutUnit / 4; | 31 return kVisibleMargin - kHarmonyLayoutUnit / 4; |
| 38 } | 32 } |
| 39 case views::DISTANCE_RELATED_BUTTON_HORIZONTAL: | 33 case views::DISTANCE_RELATED_BUTTON_HORIZONTAL: |
| 40 return kHarmonyLayoutUnit / 2; | 34 return kHarmonyLayoutUnit / 2; |
| 41 case views::DISTANCE_RELATED_CONTROL_HORIZONTAL: | 35 case views::DISTANCE_RELATED_CONTROL_HORIZONTAL: |
| 42 return kHarmonyLayoutUnit; | 36 return kHarmonyLayoutUnit; |
| 43 case DISTANCE_RELATED_CONTROL_HORIZONTAL_SMALL: | 37 case DISTANCE_RELATED_CONTROL_HORIZONTAL_SMALL: |
| 44 return kHarmonyLayoutUnit; | 38 return kHarmonyLayoutUnit; |
| 45 case views::DISTANCE_RELATED_CONTROL_VERTICAL: | 39 case views::DISTANCE_RELATED_CONTROL_VERTICAL: |
| 46 return kHarmonyLayoutUnit / 2; | 40 return kHarmonyLayoutUnit / 2; |
| 47 case DISTANCE_RELATED_CONTROL_VERTICAL_SMALL: | 41 case DISTANCE_RELATED_CONTROL_VERTICAL_SMALL: |
| 48 return kHarmonyLayoutUnit / 2; | 42 return kHarmonyLayoutUnit / 2; |
| 49 case DISTANCE_DIALOG_BUTTON_MARGIN: | 43 case views::DISTANCE_DIALOG_BUTTON_BOTTOM_MARGIN: |
| 50 return kHarmonyLayoutUnit; | 44 return kHarmonyLayoutUnit; |
| 51 case DISTANCE_DIALOG_BUTTON_TOP: | 45 case DISTANCE_DIALOG_BUTTON_TOP: |
| 52 return kHarmonyLayoutUnit; | 46 return kHarmonyLayoutUnit; |
| 53 case views::DISTANCE_DIALOG_BUTTON_MINIMUM_WIDTH: | 47 case views::DISTANCE_DIALOG_BUTTON_MINIMUM_WIDTH: |
| 54 case DISTANCE_BUTTON_MINIMUM_WIDTH: | 48 case DISTANCE_BUTTON_MINIMUM_WIDTH: |
| 55 // Minimum label size plus padding. | 49 // Minimum label size plus padding. |
| 56 return 2 * kHarmonyLayoutUnit + | 50 return 2 * kHarmonyLayoutUnit + |
| 57 2 * GetDistanceMetric(views::DISTANCE_BUTTON_HORIZONTAL_PADDING); | 51 2 * GetDistanceMetric(views::DISTANCE_BUTTON_HORIZONTAL_PADDING); |
| 58 case views::DISTANCE_BUTTON_HORIZONTAL_PADDING: | 52 case views::DISTANCE_BUTTON_HORIZONTAL_PADDING: |
| 59 return kHarmonyLayoutUnit; | 53 return kHarmonyLayoutUnit; |
| 60 case views::DISTANCE_BUTTON_MAX_LINKABLE_WIDTH: | 54 case views::DISTANCE_BUTTON_MAX_LINKABLE_WIDTH: |
| 61 return kHarmonyLayoutUnit * 7; | 55 return kHarmonyLayoutUnit * 7; |
| 62 case DISTANCE_RELATED_LABEL_HORIZONTAL: | 56 case DISTANCE_RELATED_LABEL_HORIZONTAL: |
| 63 return kHarmonyLayoutUnit; | 57 return kHarmonyLayoutUnit; |
| 64 case DISTANCE_SUBSECTION_HORIZONTAL_INDENT: | 58 case DISTANCE_SUBSECTION_HORIZONTAL_INDENT: |
| 65 return 0; | 59 return 0; |
| 66 case DISTANCE_PANEL_CONTENT_MARGIN: | |
| 67 return kHarmonyLayoutUnit; | |
| 68 case DISTANCE_UNRELATED_CONTROL_HORIZONTAL: | 60 case DISTANCE_UNRELATED_CONTROL_HORIZONTAL: |
| 69 return kHarmonyLayoutUnit; | 61 return kHarmonyLayoutUnit; |
| 70 case DISTANCE_UNRELATED_CONTROL_HORIZONTAL_LARGE: | 62 case DISTANCE_UNRELATED_CONTROL_HORIZONTAL_LARGE: |
| 71 return kHarmonyLayoutUnit; | 63 return kHarmonyLayoutUnit; |
| 72 case DISTANCE_UNRELATED_CONTROL_VERTICAL: | 64 case DISTANCE_UNRELATED_CONTROL_VERTICAL: |
| 73 return kHarmonyLayoutUnit; | 65 return kHarmonyLayoutUnit; |
| 74 case DISTANCE_UNRELATED_CONTROL_VERTICAL_LARGE: | 66 case DISTANCE_UNRELATED_CONTROL_VERTICAL_LARGE: |
| 75 return kHarmonyLayoutUnit; | 67 return kHarmonyLayoutUnit; |
| 76 } | 68 } |
| 77 NOTREACHED(); | 69 NOTREACHED(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 102 } | 94 } |
| 103 | 95 |
| 104 return ((min_width + kHarmonyLayoutUnit - 1) / kHarmonyLayoutUnit) * | 96 return ((min_width + kHarmonyLayoutUnit - 1) / kHarmonyLayoutUnit) * |
| 105 kHarmonyLayoutUnit; | 97 kHarmonyLayoutUnit; |
| 106 } | 98 } |
| 107 | 99 |
| 108 const views::TypographyProvider& HarmonyLayoutProvider::GetTypographyProvider() | 100 const views::TypographyProvider& HarmonyLayoutProvider::GetTypographyProvider() |
| 109 const { | 101 const { |
| 110 return typography_provider_; | 102 return typography_provider_; |
| 111 } | 103 } |
| OLD | NEW |