| 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 "ui/views/layout/layout_provider.h" | 5 #include "ui/views/layout/layout_provider.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "ui/base/material_design/material_design_controller.h" | 9 #include "ui/base/material_design/material_design_controller.h" |
| 10 #include "ui/views/layout/layout_constants.h" | 10 #include "ui/views/layout/layout_constants.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 case DistanceMetric::DISTANCE_BUTTON_HORIZONTAL_PADDING: | 79 case DistanceMetric::DISTANCE_BUTTON_HORIZONTAL_PADDING: |
| 80 return kButtonHorizontalPadding; | 80 return kButtonHorizontalPadding; |
| 81 case DistanceMetric::DISTANCE_BUTTON_MAX_LINKABLE_WIDTH: | 81 case DistanceMetric::DISTANCE_BUTTON_MAX_LINKABLE_WIDTH: |
| 82 return 0; | 82 return 0; |
| 83 case DistanceMetric::DISTANCE_CLOSE_BUTTON_MARGIN: | 83 case DistanceMetric::DISTANCE_CLOSE_BUTTON_MARGIN: |
| 84 return kCloseButtonMargin; | 84 return kCloseButtonMargin; |
| 85 case DistanceMetric::DISTANCE_RELATED_BUTTON_HORIZONTAL: | 85 case DistanceMetric::DISTANCE_RELATED_BUTTON_HORIZONTAL: |
| 86 return kRelatedButtonHSpacing; | 86 return kRelatedButtonHSpacing; |
| 87 case DistanceMetric::DISTANCE_RELATED_CONTROL_HORIZONTAL: | 87 case DistanceMetric::DISTANCE_RELATED_CONTROL_HORIZONTAL: |
| 88 return kRelatedControlHorizontalSpacing; | 88 return kRelatedControlHorizontalSpacing; |
| 89 case DistanceMetric::DISTANCE_BUBBLE_BUTTON_TOP_MARGIN: |
| 89 case DistanceMetric::DISTANCE_RELATED_CONTROL_VERTICAL: | 90 case DistanceMetric::DISTANCE_RELATED_CONTROL_VERTICAL: |
| 90 return kRelatedControlVerticalSpacing; | 91 return kRelatedControlVerticalSpacing; |
| 91 case DISTANCE_DIALOG_BUTTON_BOTTOM_MARGIN: | 92 case DISTANCE_DIALOG_BUTTON_BOTTOM_MARGIN: |
| 92 return views::kButtonVEdgeMarginNew; | 93 return views::kButtonVEdgeMarginNew; |
| 93 case DistanceMetric::DISTANCE_DIALOG_BUTTON_MINIMUM_WIDTH: | 94 case DistanceMetric::DISTANCE_DIALOG_BUTTON_MINIMUM_WIDTH: |
| 94 return kDialogMinimumButtonWidth; | 95 return kDialogMinimumButtonWidth; |
| 95 case DISTANCE_DIALOG_CONTENTS_HORIZONTAL_MARGIN: | 96 case DISTANCE_DIALOG_CONTENTS_HORIZONTAL_MARGIN: |
| 96 return kButtonHEdgeMarginNew; | 97 return kButtonHEdgeMarginNew; |
| 97 } | 98 } |
| 98 NOTREACHED(); | 99 NOTREACHED(); |
| 99 return 0; | 100 return 0; |
| 100 } | 101 } |
| 101 | 102 |
| 102 const TypographyProvider& LayoutProvider::GetTypographyProvider() const { | 103 const TypographyProvider& LayoutProvider::GetTypographyProvider() const { |
| 103 return typography_provider_; | 104 return typography_provider_; |
| 104 } | 105 } |
| 105 | 106 |
| 106 int LayoutProvider::GetSnappedDialogWidth(int min_width) const { | 107 int LayoutProvider::GetSnappedDialogWidth(int min_width) const { |
| 107 // This is an arbitrary value, but it's a good arbitrary value. Some dialogs | 108 // This is an arbitrary value, but it's a good arbitrary value. Some dialogs |
| 108 // have very small widths for their contents views, which causes ugly | 109 // have very small widths for their contents views, which causes ugly |
| 109 // title-wrapping where a two-word title is split across multiple lines or | 110 // title-wrapping where a two-word title is split across multiple lines or |
| 110 // similar. To prevent that, forbid any snappable dialog from being narrower | 111 // similar. To prevent that, forbid any snappable dialog from being narrower |
| 111 // than this value. In principle it's possible to factor in the title width | 112 // than this value. In principle it's possible to factor in the title width |
| 112 // here, but it is not really worth the complexity. | 113 // here, but it is not really worth the complexity. |
| 113 return std::max(min_width, 320); | 114 return std::max(min_width, 320); |
| 114 } | 115 } |
| 115 | 116 |
| 116 } // namespace views | 117 } // namespace views |
| OLD | NEW |