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

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

Issue 2758323002: Broke out layout metric information from ViewsDelegate to LayoutProvider (Closed)
Patch Set: Fix Bookmark and Global error unittests 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/chrome_views_layout_delegate.h
diff --git a/chrome/browser/ui/views/harmony/chrome_views_layout_delegate.h b/chrome/browser/ui/views/harmony/chrome_views_layout_delegate.h
new file mode 100644
index 0000000000000000000000000000000000000000..b8b29da5985e16058a4c30e1688df90631e642fa
--- /dev/null
+++ b/chrome/browser/ui/views/harmony/chrome_views_layout_delegate.h
@@ -0,0 +1,138 @@
+// 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_VIEWS_LAYOUT_DELEGATE_H_
+#define CHROME_BROWSER_UI_VIEWS_HARMONY_CHROME_VIEWS_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/views_layout_delegate.h"
+
+enum class ChromeInsetsMetric {
+ // The margins that should be applied around a bubble dialog.
+ BUBBLE_DIALOG = static_cast<int>(views::InsetsMetric::BUBBLE_DIALOG),
+ // The insets that should be applied around a DialogClientView. Note that
+ // the top inset is used for the distance between the buttons and the
+ // DialogClientView's content view.
+ DIALOG_BUTTON = static_cast<int>(views::InsetsMetric::DIALOG_BUTTON),
+ // The insets that should be applied around a dialog's frame view.
+ DIALOG_FRAME_VIEW = static_cast<int>(views::InsetsMetric::DIALOG_FRAME_VIEW),
+ // The insets applied around a content panel
+ PANEL_LAYOUT,
+};
+
+enum class ChromeDistanceMetric {
+ // The default padding to add on each side of a button's label.
+ BUTTON_HORIZONTAL_PADDING =
+ static_cast<int>(views::DistanceMetric::BUTTON_HORIZONTAL_PADDING),
+ // The distance between a dialog's edge and the close button in the upper
+ // trailing corner.
+ CLOSE_BUTTON_MARGIN =
+ static_cast<int>(views::DistanceMetric::CLOSE_BUTTON_MARGIN),
+ // The default minimum width of a dialog button.
+ DIALOG_BUTTON_MINIMUM_WIDTH =
+ static_cast<int>(views::DistanceMetric::DIALOG_BUTTON_MINIMUM_WIDTH),
+ // The spacing between a pair of related horizontal buttons, used for
+ // dialog layout.
+ RELATED_BUTTON_HORIZONTAL =
+ static_cast<int>(views::DistanceMetric::RELATED_BUTTON_HORIZONTAL),
+ // Horizontal spacing between controls that are logically related.
+ RELATED_CONTROL_HORIZONTAL =
+ static_cast<int>(views::DistanceMetric::RELATED_CONTROL_HORIZONTAL),
+ // The spacing between a pair of related vertical controls, used for
+ // dialog layout.
+ RELATED_CONTROL_VERTICAL =
+ static_cast<int>(views::DistanceMetric::RELATED_CONTROL_VERTICAL),
+ // Margin between the edge of a dialog and the left, right, or bottom of a
+ // contained button.
+ DIALOG_BUTTON_MARGIN,
+ /* // Minimum width of a dialog button.
+ DIALOG_BUTTON_MINIMUM_WIDTH,
+ // Spacing between a dialog button and the content above it.
+ DIALOG_BUTTON_TOP_SPACING,
+ // Horizontal or vertical margin between the edge of a dialog and the close
+ // button in the upper trailing corner.
+ DIALOG_CLOSE_BUTTON_MARGIN,*/
+ // 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,
+ // 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 ChromeViewsLayoutDelegate : public views::ViewsLayoutDelegate {
+ public:
+ ChromeViewsLayoutDelegate();
+ ~ChromeViewsLayoutDelegate() override;
+
+ static ChromeViewsLayoutDelegate* Get();
+ static std::unique_ptr<views::ViewsLayoutDelegate> 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;
+
+ int GetDefaultDistanceMetric(views::DistanceMetric metric) const;
+
+ private:
+ gfx::Insets GetInsetsMetric(views::InsetsMetric metric) const override;
+ int GetDistanceMetric(views::DistanceMetric metric) const override;
+
+ DISALLOW_COPY_AND_ASSIGN(ChromeViewsLayoutDelegate);
+};
+
+#endif // CHROME_BROWSER_UI_VIEWS_HARMONY_CHROME_VIEWS_LAYOUT_DELEGATE_H_

Powered by Google App Engine
This is Rietveld 408576698