Chromium Code Reviews| 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..c3c8d118b40279a2ce250cd380cea3bef171ecc2 |
| --- /dev/null |
| +++ b/chrome/browser/ui/views/harmony/chrome_views_layout_delegate.h |
| @@ -0,0 +1,143 @@ |
| +// 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), |
|
Peter Kasting
2017/03/30 00:49:04
I still am not comfortable moving forward with thi
kylix_rd
2017/03/30 19:34:07
I'm still mulling this over as well. I'm leaving i
Peter Kasting
2017/03/30 19:40:02
SGTM.
|
| + // 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, |
| + // 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 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_ |