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

Unified Diff: chrome/browser/ui/views/harmony/chrome_layout_delegate.h

Issue 2758323002: Broke out layout metric information from ViewsDelegate to LayoutProvider (Closed)
Patch Set: Fix warning which causes one of the bots to fail 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
Index: chrome/browser/ui/views/harmony/chrome_layout_delegate.h
diff --git a/chrome/browser/ui/views/harmony/chrome_layout_delegate.h b/chrome/browser/ui/views/harmony/chrome_layout_delegate.h
new file mode 100644
index 0000000000000000000000000000000000000000..9f7639b1b3131985dac62a3037b24d1db584bd58
--- /dev/null
+++ b/chrome/browser/ui/views/harmony/chrome_layout_delegate.h
@@ -0,0 +1,121 @@
+// 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.
+
+#ifndef CHROME_BROWSER_UI_VIEWS_HARMONY_CHROME_LAYOUT_DELEGATE_H_
+#define CHROME_BROWSER_UI_VIEWS_HARMONY_CHROME_LAYOUT_DELEGATE_H_
+
+#include <memory>
+
+#include "base/macros.h"
+#include "ui/gfx/geometry/insets.h"
+#include "ui/views/layout/grid_layout.h"
+#include "ui/views/layout/layout_delegate.h"
+
+enum class ChromeInsetsMetric {
Peter Kasting 2017/04/06 08:13:36 Seems like we don't even need this class or the ch
kylix_rd 2017/04/06 16:48:19 As I worked on this patch, I saw several places in
kylix_rd 2017/04/07 18:33:36 I went ahead and removed the override for GetInset
+ BUBBLE_DIALOG = views::InsetsMetric::BUBBLE_DIALOG,
+ DIALOG_BUTTON = views::InsetsMetric::DIALOG_BUTTON,
+ DIALOG_FRAME_VIEW = views::InsetsMetric::DIALOG_FRAME_VIEW,
+ PANEL = views::InsetsMetric::PANEL,
+ VECTOR_IMAGE_BUTTON = views::InsetsMetric::VECTOR_IMAGE_BUTTON,
+};
+
+enum class ChromeDistanceMetric {
+ BUTTON_HORIZONTAL_PADDING = views::DistanceMetric::BUTTON_HORIZONTAL_PADDING,
+ CLOSE_BUTTON_MARGIN = views::DistanceMetric::CLOSE_BUTTON_MARGIN,
+ DIALOG_BUTTON_MINIMUM_WIDTH =
+ views::DistanceMetric::DIALOG_BUTTON_MINIMUM_WIDTH,
+ RELATED_BUTTON_HORIZONTAL = views::DistanceMetric::RELATED_BUTTON_HORIZONTAL,
+ RELATED_CONTROL_HORIZONTAL =
+ views::DistanceMetric::RELATED_CONTROL_HORIZONTAL,
+ RELATED_CONTROL_VERTICAL = views::DistanceMetric::RELATED_CONTROL_VERTICAL,
+ // Margin between the edge of a dialog and the left, right, or bottom of a
Peter Kasting 2017/04/06 08:13:36 Nit: Maybe blank line above this?
kylix_rd 2017/04/06 16:48:19 Done.
+ // contained button.
+ DIALOG_BUTTON_MARGIN,
+ // Spacing between a dialog button and the content above it.
+ DIALOG_BUTTON_TOP,
+ // Horizontal or vertical margin between the edge of a panel and the
+ // contained content.
+ PANEL_CONTENT_MARGIN,
+ // The maximum width a button can have and still influence the sizes of
+ // other linked buttons. This allows short buttons to have linked widths
+ // without long buttons making things overly wide.
+ BUTTON_MAX_LINKABLE_WIDTH,
+ // Default minimum width of a button.
+ BUTTON_MINIMUM_WIDTH,
+ // Smaller horizontal spacing between other controls that are logically
+ // related.
+ RELATED_CONTROL_HORIZONTAL_SMALL,
+ // Smaller vertical spacing between controls that are logically related.
+ RELATED_CONTROL_VERTICAL_SMALL,
+ // Horizontal spacing between an item such as an icon or checkbox and a
+ // label related to it.
+ RELATED_LABEL_HORIZONTAL,
+ // Horizontal indent of a subsection relative to related items above, e.g.
+ // checkboxes below explanatory text/headings.
+ SUBSECTION_HORIZONTAL_INDENT,
+ // Horizontal spacing between controls that are logically unrelated.
+ UNRELATED_CONTROL_HORIZONTAL,
+ // Larger horizontal spacing between unrelated controls.
+ UNRELATED_CONTROL_HORIZONTAL_LARGE,
+ // Vertical spacing between controls that are logically unrelated.
+ UNRELATED_CONTROL_VERTICAL,
+ // Larger vertical spacing between unrelated controls.
+ UNRELATED_CONTROL_VERTICAL_LARGE,
+};
+
+enum class DialogWidth {
+ SMALL,
+ MEDIUM,
+ LARGE,
+};
+
+class ChromeLayoutDelegate : public views::LayoutDelegate {
+ public:
+ ChromeLayoutDelegate();
+ ~ChromeLayoutDelegate() override;
+
+ static ChromeLayoutDelegate* Get();
+ static std::unique_ptr<views::LayoutDelegate> CreateLayoutDelegate();
+
+ virtual gfx::Insets GetInsetsMetric(ChromeInsetsMetric metric) const;
+ virtual int GetDistanceMetric(ChromeDistanceMetric metric) const;
+
+ const views::TypographyProvider& GetTypographyProvider() const override;
+
+ // Returns the alignment used for control labels in a GridLayout; for example,
+ // in this GridLayout:
+ // ---------------------------
+ // | Label 1 Checkbox 1 |
+ // | Label 2 Checkbox 2 |
+ // ---------------------------
+ // This value controls the alignment used for "Label 1" and "Label 2".
+ virtual views::GridLayout::Alignment GetControlLabelGridAlignment() const;
+
+ // Returns whether to use extra padding on dialogs. If this is false, content
+ // Views for dialogs should not insert extra padding at their own edges.
+ virtual bool UseExtraDialogPadding() const;
+
+ // Returns whether to show the icon next to the title text on a dialog.
+ virtual bool ShouldShowWindowIcon() const;
+
+ // DEPRECATED. Returns whether Harmony mode is enabled.
+ //
+ // Instead of using this, create a generic solution that works for all UI
+ // types, e.g. by adding a new LayoutDistance value that means what you need.
+ //
+ // TODO(pkasting): Fix callers and remove this.
+ virtual bool IsHarmonyMode() const;
+
+ // Returns the preferred width in DIPs for a dialog of the specified |width|.
+ // May return 0 if the dialog has no preferred width.
+ virtual int GetDialogPreferredWidth(DialogWidth width) const;
+
+ private:
+ gfx::Insets GetInsetsMetric(views::InsetsMetric metric) const override;
+ int GetDistanceMetric(views::DistanceMetric metric) const override;
+
+ DISALLOW_COPY_AND_ASSIGN(ChromeLayoutDelegate);
+};
+
+#endif // CHROME_BROWSER_UI_VIEWS_HARMONY_CHROME_LAYOUT_DELEGATE_H_

Powered by Google App Engine
This is Rietveld 408576698