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

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

Issue 2758323002: Broke out layout metric information from ViewsDelegate to LayoutProvider (Closed)
Patch Set: Deleted LayoutDelegate and HarmonyLayoutDelegate. Created 3 years, 9 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
Index: chrome/browser/ui/views/harmony/harmony_views_layout_delegate.cc
diff --git a/chrome/browser/ui/views/harmony/harmony_views_layout_delegate.cc b/chrome/browser/ui/views/harmony/harmony_views_layout_delegate.cc
new file mode 100644
index 0000000000000000000000000000000000000000..80ac976b7c5a319ebc8462d1fd81cfc36cd9a231
--- /dev/null
+++ b/chrome/browser/ui/views/harmony/harmony_views_layout_delegate.cc
@@ -0,0 +1,107 @@
+// 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 "chrome/browser/ui/views/harmony/harmony_views_layout_delegate.h"
+
+gfx::Insets HarmonyViewsLayoutDelegate::GetInsetsMetric(
+ ChromeInsetsMetric metric) const {
+ switch (metric) {
+ case ChromeInsetsMetric::DIALOG_BUTTON:
+ case ChromeInsetsMetric::PANEL_LAYOUT:
+ case ChromeInsetsMetric::BUBBLE_DIALOG:
+ return gfx::Insets(kHarmonyLayoutUnit);
+ case ChromeInsetsMetric::DIALOG_FRAME_VIEW: {
+ constexpr int top = kHarmonyLayoutUnit;
+ constexpr int side = kHarmonyLayoutUnit;
+ // Titles are inset at the top and sides, but not at the bottom.
+ return gfx::Insets(top, side, 0, side);
+ }
+ case ChromeInsetsMetric::VECTOR_IMAGE_BUTTON:
+ return gfx::Insets(kHarmonyLayoutUnit / 4);
+ }
+ NOTREACHED();
+ return gfx::Insets();
+}
+
+int HarmonyViewsLayoutDelegate::GetDistanceMetric(
+ ChromeDistanceMetric metric) const {
+ switch (metric) {
+ case ChromeDistanceMetric::CLOSE_BUTTON_MARGIN: {
+ constexpr int kVisibleMargin = kHarmonyLayoutUnit / 2;
+ // The visible margin is based on the unpadded size, so to get the actual
+ // margin we need to subtract out the padding.
+ return kVisibleMargin - kHarmonyLayoutUnit / 4;
Peter Kasting 2017/04/04 02:08:54 Nit: Should probably refer to the VECTOR_IMAGE_BUT
+ }
+ case ChromeDistanceMetric::RELATED_BUTTON_HORIZONTAL:
Peter Kasting 2017/04/04 02:08:54 Nit: Might make sense to collapse together cases t
kylix_rd 2017/04/04 20:28:23 I thought doing about that. I was just concerned t
Peter Kasting 2017/04/05 19:30:10 Not 100% confident, but I think at most one or two
+ return kHarmonyLayoutUnit / 2;
+ case ChromeDistanceMetric::RELATED_CONTROL_HORIZONTAL:
+ return kHarmonyLayoutUnit;
+ case ChromeDistanceMetric::RELATED_CONTROL_HORIZONTAL_SMALL:
+ return kHarmonyLayoutUnit;
+ case ChromeDistanceMetric::RELATED_CONTROL_VERTICAL:
+ return kHarmonyLayoutUnit / 2;
+ case ChromeDistanceMetric::RELATED_CONTROL_VERTICAL_SMALL:
+ return kHarmonyLayoutUnit / 2;
+ case ChromeDistanceMetric::DIALOG_BUTTON_MARGIN:
+ return kHarmonyLayoutUnit;
+ case ChromeDistanceMetric::DIALOG_BUTTON_TOP:
+ return kHarmonyLayoutUnit;
+ case ChromeDistanceMetric::DIALOG_BUTTON_MINIMUM_WIDTH:
+ case ChromeDistanceMetric::BUTTON_MINIMUM_WIDTH:
+ // Minimum label size plus padding.
+ return 2 * kHarmonyLayoutUnit +
+ 2 * GetDistanceMetric(
+ ChromeDistanceMetric::BUTTON_HORIZONTAL_PADDING);
+ case ChromeDistanceMetric::BUTTON_HORIZONTAL_PADDING:
+ return kHarmonyLayoutUnit;
+ case ChromeDistanceMetric::BUTTON_MAX_LINKABLE_WIDTH:
+ return kHarmonyLayoutUnit * 8;
+ case ChromeDistanceMetric::RELATED_LABEL_HORIZONTAL:
+ return kHarmonyLayoutUnit;
+ case ChromeDistanceMetric::SUBSECTION_HORIZONTAL_INDENT:
+ return 0;
+ case ChromeDistanceMetric::PANEL_CONTENT_MARGIN:
+ return kHarmonyLayoutUnit;
+ case ChromeDistanceMetric::UNRELATED_CONTROL_HORIZONTAL:
+ return kHarmonyLayoutUnit;
+ case ChromeDistanceMetric::UNRELATED_CONTROL_HORIZONTAL_LARGE:
+ return kHarmonyLayoutUnit;
+ case ChromeDistanceMetric::UNRELATED_CONTROL_VERTICAL:
+ return kHarmonyLayoutUnit;
+ case ChromeDistanceMetric::UNRELATED_CONTROL_VERTICAL_LARGE:
+ return kHarmonyLayoutUnit;
+ }
+ NOTREACHED();
+ return 0;
+}
+views::GridLayout::Alignment
+HarmonyViewsLayoutDelegate::GetControlLabelGridAlignment() const {
+ return views::GridLayout::LEADING;
+}
+
+bool HarmonyViewsLayoutDelegate::UseExtraDialogPadding() const {
+ return false;
+}
+
+bool HarmonyViewsLayoutDelegate::ShouldShowWindowIcon() const {
+ return false;
+}
+
+bool HarmonyViewsLayoutDelegate::IsHarmonyMode() const {
+ return true;
+}
+
+int HarmonyViewsLayoutDelegate::GetDialogPreferredWidth(
+ DialogWidth width) const {
+ switch (width) {
+ case DialogWidth::SMALL:
+ return 320;
+ case DialogWidth::MEDIUM:
+ return 448;
+ case DialogWidth::LARGE:
+ return 512;
+ }
+ NOTREACHED();
+ return 0;
+}

Powered by Google App Engine
This is Rietveld 408576698