| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/views/layout/views_layout_delegate.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "base/memory/ptr_util.h" |
| 9 #include "ui/base/material_design/material_design_controller.h" |
| 10 #include "ui/views/layout/layout_constants.h" |
| 11 #include "ui/views/views_delegate.h" |
| 12 |
| 13 namespace views { |
| 14 |
| 15 namespace { |
| 16 |
| 17 static ViewsLayoutDelegate* layout_delegate_ = nullptr; |
| 18 } |
| 19 |
| 20 ViewsLayoutDelegate::ViewsLayoutDelegate() { |
| 21 DCHECK(!layout_delegate_); |
| 22 layout_delegate_ = this; |
| 23 } |
| 24 |
| 25 ViewsLayoutDelegate::~ViewsLayoutDelegate() { |
| 26 DCHECK_EQ(this, layout_delegate_); |
| 27 layout_delegate_ = nullptr; |
| 28 } |
| 29 |
| 30 // static |
| 31 ViewsLayoutDelegate* ViewsLayoutDelegate::Get() { |
| 32 return layout_delegate_; |
| 33 } |
| 34 |
| 35 gfx::Insets ViewsLayoutDelegate::GetInsetsMetric(InsetsMetric metric) const { |
| 36 switch (metric) { |
| 37 case InsetsMetric::DIALOG_BUTTON: |
| 38 return gfx::Insets(0, kButtonHEdgeMarginNew, kButtonVEdgeMarginNew, |
| 39 kButtonHEdgeMarginNew); |
| 40 case InsetsMetric::DIALOG_FRAME_VIEW: |
| 41 return gfx::Insets(kPanelVertMargin, kButtonHEdgeMarginNew, 0, |
| 42 kButtonHEdgeMarginNew); |
| 43 case InsetsMetric::BUBBLE_DIALOG: |
| 44 return gfx::Insets(kPanelVertMargin, kPanelHorizMargin); |
| 45 } |
| 46 NOTREACHED(); |
| 47 return gfx::Insets(); |
| 48 } |
| 49 |
| 50 int ViewsLayoutDelegate::GetDistanceMetric(DistanceMetric metric) const { |
| 51 switch (metric) { |
| 52 case DistanceMetric::CLOSE_BUTTON_MARGIN: |
| 53 return kCloseButtonMargin; |
| 54 case DistanceMetric::RELATED_BUTTON_HORIZONTAL: |
| 55 return kRelatedButtonHSpacing; |
| 56 case DistanceMetric::RELATED_CONTROL_HORIZONTAL: |
| 57 return kRelatedControlHorizontalSpacing; |
| 58 case DistanceMetric::RELATED_CONTROL_VERTICAL: |
| 59 return kRelatedControlVerticalSpacing; |
| 60 case DistanceMetric::DIALOG_BUTTON_MINIMUM_WIDTH: |
| 61 return kDialogMinimumButtonWidth; |
| 62 case DistanceMetric::BUTTON_HORIZONTAL_PADDING: |
| 63 return kButtonHorizontalPadding; |
| 64 } |
| 65 NOTREACHED(); |
| 66 return 0; |
| 67 } |
| 68 |
| 69 const TypographyProvider& ViewsLayoutDelegate::GetTypographyProvider() const { |
| 70 return typography_provider_; |
| 71 } |
| 72 |
| 73 } // namespace views |
| OLD | NEW |