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

Unified Diff: chrome/browser/ui/views/harmony/layout_delegate.cc

Issue 2485083003: views: add layout delegates (Closed)
Patch Set: fix msvc compile Created 4 years, 1 month 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 | « chrome/browser/ui/views/harmony/layout_delegate.h ('k') | chrome/browser/ui/views/layout_utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/harmony/layout_delegate.cc
diff --git a/chrome/browser/ui/views/harmony/layout_delegate.cc b/chrome/browser/ui/views/harmony/layout_delegate.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a338845c02d6373c735eafebab8602d547e827bb
--- /dev/null
+++ b/chrome/browser/ui/views/harmony/layout_delegate.cc
@@ -0,0 +1,53 @@
+// Copyright 2016 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 "chrome/browser/ui/views/harmony/layout_delegate.h"
+
+#include "base/lazy_instance.h"
+#include "base/logging.h"
+#include "chrome/browser/ui/views/harmony/harmony_layout_delegate.h"
+#include "ui/base/material_design/material_design_controller.h"
+#include "ui/views/layout/layout_constants.h"
+
+static base::LazyInstance<LayoutDelegate> layout_delegate_ =
+ LAZY_INSTANCE_INITIALIZER;
+
+// static
+LayoutDelegate* LayoutDelegate::Get() {
+ return ui::MaterialDesignController::IsSecondaryUiMaterial()
+ ? HarmonyLayoutDelegate::Get()
+ : layout_delegate_.Pointer();
+}
+
+int LayoutDelegate::GetLayoutDistance(LayoutDistanceType type) const {
+ switch (type) {
+ case LayoutDistanceType::PANEL_VERT_MARGIN:
+ return views::kPanelVertMargin;
+ case LayoutDistanceType::RELATED_BUTTON_HORIZONTAL_SPACING:
+ return views::kRelatedButtonHSpacing;
+ case LayoutDistanceType::RELATED_CONTROL_HORIZONTAL_SPACING:
+ return views::kRelatedControlHorizontalSpacing;
+ case LayoutDistanceType::RELATED_CONTROL_VERTICAL_SPACING:
+ return views::kRelatedControlVerticalSpacing;
+ case LayoutDistanceType::UNRELATED_CONTROL_VERTICAL_SPACING:
+ return views::kUnrelatedControlVerticalSpacing;
+ case LayoutDistanceType::UNRELATED_CONTROL_LARGE_VERTICAL_SPACING:
+ return views::kUnrelatedControlLargeVerticalSpacing;
+ case LayoutDistanceType::BUTTON_VEDGE_MARGIN_NEW:
+ return views::kButtonVEdgeMarginNew;
+ case LayoutDistanceType::BUTTON_HEDGE_MARGIN_NEW:
+ return views::kButtonHEdgeMarginNew;
+ }
+ NOTREACHED();
+ return 0;
+}
+
+views::GridLayout::Alignment LayoutDelegate::GetControlLabelGridAlignment()
+ const {
+ return views::kControlLabelGridAlignment;
+}
+
+bool LayoutDelegate::UseExtraDialogPadding() const {
+ return true;
+}
« no previous file with comments | « chrome/browser/ui/views/harmony/layout_delegate.h ('k') | chrome/browser/ui/views/layout_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698