Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Unified Diff: ui/views/layout/layout_provider.cc

Issue 2758323002: Broke out layout metric information from ViewsDelegate to LayoutProvider (Closed)
Patch Set: Final feedback addressed Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/layout/layout_provider.h ('k') | ui/views/mus/aura_init.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/layout/layout_provider.cc
diff --git a/ui/views/layout/layout_provider.cc b/ui/views/layout/layout_provider.cc
new file mode 100644
index 0000000000000000000000000000000000000000..926916d16883e0ef5fc29aeb90400eae960e9b71
--- /dev/null
+++ b/ui/views/layout/layout_provider.cc
@@ -0,0 +1,77 @@
+// 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/layout_provider.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 {
+LayoutProvider* g_layout_delegate = nullptr;
+}
+
+LayoutProvider::LayoutProvider() {
+ g_layout_delegate = this;
+}
+
+LayoutProvider::~LayoutProvider() {
+ if (this == g_layout_delegate)
+ g_layout_delegate = nullptr;
+}
+
+// static
+LayoutProvider* LayoutProvider::Get() {
+ return g_layout_delegate;
+}
+
+gfx::Insets LayoutProvider::GetInsetsMetric(int metric) const {
+ DCHECK_LT(metric, VIEWS_INSETS_MAX);
+ switch (metric) {
+ case InsetsMetric::INSETS_DIALOG_BUTTON:
+ return gfx::Insets(0, kButtonHEdgeMarginNew, kButtonVEdgeMarginNew,
+ kButtonHEdgeMarginNew);
+ case InsetsMetric::INSETS_DIALOG_TITLE:
+ return gfx::Insets(kPanelVertMargin, kButtonHEdgeMarginNew, 0,
+ kButtonHEdgeMarginNew);
+ case InsetsMetric::INSETS_BUBBLE_CONTENTS:
+ return gfx::Insets(kPanelVertMargin, kPanelHorizMargin);
+ case InsetsMetric::INSETS_PANEL:
+ return gfx::Insets(kPanelVertMargin, kButtonHEdgeMarginNew);
+ case InsetsMetric::INSETS_VECTOR_IMAGE_BUTTON:
+ return gfx::Insets(kVectorButtonExtraTouchSize);
+ }
+ NOTREACHED();
+ return gfx::Insets();
+}
+
+int LayoutProvider::GetDistanceMetric(int metric) const {
+ DCHECK_GE(metric, VIEWS_INSETS_MAX);
+ switch (metric) {
+ case DistanceMetric::DISTANCE_CLOSE_BUTTON_MARGIN:
+ return kCloseButtonMargin;
+ case DistanceMetric::DISTANCE_RELATED_BUTTON_HORIZONTAL:
+ return kRelatedButtonHSpacing;
+ case DistanceMetric::DISTANCE_RELATED_CONTROL_HORIZONTAL:
+ return kRelatedControlHorizontalSpacing;
+ case DistanceMetric::DISTANCE_RELATED_CONTROL_VERTICAL:
+ return kRelatedControlVerticalSpacing;
+ case DistanceMetric::DISTANCE_DIALOG_BUTTON_MINIMUM_WIDTH:
+ return kDialogMinimumButtonWidth;
+ case DistanceMetric::DISTANCE_BUTTON_HORIZONTAL_PADDING:
+ return kButtonHorizontalPadding;
+ }
+ NOTREACHED();
+ return 0;
+}
+
+const TypographyProvider& LayoutProvider::GetTypographyProvider() const {
+ return typography_provider_;
+}
+
+} // namespace views
« no previous file with comments | « ui/views/layout/layout_provider.h ('k') | ui/views/mus/aura_init.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698