Chromium Code Reviews| Index: ui/views/layout/views_layout_delegate.cc |
| diff --git a/ui/views/layout/views_layout_delegate.cc b/ui/views/layout/views_layout_delegate.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..66a82b732366580da56f0af9cecff686a82f647e |
| --- /dev/null |
| +++ b/ui/views/layout/views_layout_delegate.cc |
| @@ -0,0 +1,74 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ui/views/layout/views_layout_delegate.h" |
| + |
| +#include "base/logging.h" |
| +#include "base/memory/ptr_util.h" |
| +#include "ui/base/material_design/material_design_controller.h" |
| +#include "ui/views/layout/layout_constants.h" |
| +#include "ui/views/views_delegate.h" |
| + |
| +namespace views { |
| + |
| +namespace { |
| + |
|
Peter Kasting
2017/04/04 02:08:55
Nit: Remove blank line
kylix_rd
2017/04/04 20:28:23
Done.
|
| +static ViewsLayoutDelegate* layout_delegate_ = nullptr; |
|
Peter Kasting
2017/04/04 02:08:55
Nit: I'd name this |g_layout_delegate| since it's
kylix_rd
2017/04/04 20:28:23
Done.
|
| +} |
| + |
| +ViewsLayoutDelegate::ViewsLayoutDelegate() { |
| + layout_delegate_ = this; |
| +} |
| + |
| +ViewsLayoutDelegate::~ViewsLayoutDelegate() { |
| + if (this == layout_delegate_) |
| + layout_delegate_ = nullptr; |
| +} |
| + |
| +// static |
| +ViewsLayoutDelegate* ViewsLayoutDelegate::Get() { |
| + return layout_delegate_; |
| +} |
| + |
| +gfx::Insets ViewsLayoutDelegate::GetInsetsMetric(InsetsMetric metric) const { |
| + switch (metric) { |
| + case InsetsMetric::DIALOG_BUTTON: |
| + return gfx::Insets(0, kButtonHEdgeMarginNew, kButtonVEdgeMarginNew, |
| + kButtonHEdgeMarginNew); |
| + case InsetsMetric::DIALOG_FRAME_VIEW: |
| + return gfx::Insets(kPanelVertMargin, kButtonHEdgeMarginNew, 0, |
| + kButtonHEdgeMarginNew); |
| + case InsetsMetric::BUBBLE_DIALOG: |
| + return gfx::Insets(kPanelVertMargin, kPanelHorizMargin); |
| + case InsetsMetric::VECTOR_IMAGE_BUTTON: |
| + return gfx::Insets(kVectorButtonExtraTouchSize); |
| + } |
| + NOTREACHED(); |
| + return gfx::Insets(); |
| +} |
| + |
| +int ViewsLayoutDelegate::GetDistanceMetric(DistanceMetric metric) const { |
| + switch (metric) { |
| + case DistanceMetric::CLOSE_BUTTON_MARGIN: |
| + return kCloseButtonMargin; |
| + case DistanceMetric::RELATED_BUTTON_HORIZONTAL: |
| + return kRelatedButtonHSpacing; |
| + case DistanceMetric::RELATED_CONTROL_HORIZONTAL: |
| + return kRelatedControlHorizontalSpacing; |
| + case DistanceMetric::RELATED_CONTROL_VERTICAL: |
| + return kRelatedControlVerticalSpacing; |
| + case DistanceMetric::DIALOG_BUTTON_MINIMUM_WIDTH: |
| + return kDialogMinimumButtonWidth; |
| + case DistanceMetric::BUTTON_HORIZONTAL_PADDING: |
| + return kButtonHorizontalPadding; |
| + } |
| + NOTREACHED(); |
| + return 0; |
| +} |
| + |
| +const TypographyProvider& ViewsLayoutDelegate::GetTypographyProvider() const { |
| + return typography_provider_; |
| +} |
| + |
| +} // namespace views |