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

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

Issue 2758323002: Broke out layout metric information from ViewsDelegate to LayoutProvider (Closed)
Patch Set: Final feedback addressed 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_provider.h
diff --git a/chrome/browser/ui/views/harmony/chrome_layout_provider.h b/chrome/browser/ui/views/harmony/chrome_layout_provider.h
new file mode 100644
index 0000000000000000000000000000000000000000..d2168de065e921050db3385afdedeac5d1a19cf0
--- /dev/null
+++ b/chrome/browser/ui/views/harmony/chrome_layout_provider.h
@@ -0,0 +1,101 @@
+// 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_PROVIDER_H_
+#define CHROME_BROWSER_UI_VIEWS_HARMONY_CHROME_LAYOUT_PROVIDER_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_provider.h"
+
+enum ChromeDistanceMetric {
+ // 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.
+ DISTANCE_BUTTON_MAX_LINKABLE_WIDTH = views::VIEWS_DISTANCE_END,
+ // Default minimum width of a button.
+ DISTANCE_BUTTON_MINIMUM_WIDTH,
+ // Margin between the edge of a dialog and the left, right, or bottom of a
+ // contained button.
+ DISTANCE_DIALOG_BUTTON_MARGIN,
+ // Spacing between a dialog button and the content above it.
+ DISTANCE_DIALOG_BUTTON_TOP,
+ // Horizontal or vertical margin between the edge of a panel and the
+ // contained content.
+ DISTANCE_PANEL_CONTENT_MARGIN,
+ // Smaller horizontal spacing between other controls that are logically
+ // related.
+ DISTANCE_RELATED_CONTROL_HORIZONTAL_SMALL,
+ // Smaller vertical spacing between controls that are logically related.
+ DISTANCE_RELATED_CONTROL_VERTICAL_SMALL,
+ // Horizontal spacing between an item such as an icon or checkbox and a
+ // label related to it.
+ DISTANCE_RELATED_LABEL_HORIZONTAL,
+ // Horizontal indent of a subsection relative to related items above, e.g.
+ // checkboxes below explanatory text/headings.
+ DISTANCE_SUBSECTION_HORIZONTAL_INDENT,
+ // Horizontal spacing between controls that are logically unrelated.
+ DISTANCE_UNRELATED_CONTROL_HORIZONTAL,
+ // Larger horizontal spacing between unrelated controls.
+ DISTANCE_UNRELATED_CONTROL_HORIZONTAL_LARGE,
+ // Vertical spacing between controls that are logically unrelated.
+ DISTANCE_UNRELATED_CONTROL_VERTICAL,
+ // Larger vertical spacing between unrelated controls.
+ DISTANCE_UNRELATED_CONTROL_VERTICAL_LARGE,
+};
+
+enum class DialogWidth {
+ SMALL,
+ MEDIUM,
+ LARGE,
+};
+
+class ChromeLayoutProvider : public views::LayoutProvider {
+ public:
+ ChromeLayoutProvider() {}
+ ~ChromeLayoutProvider() override {}
+
+ static ChromeLayoutProvider* Get();
+ static std::unique_ptr<views::LayoutProvider> CreateLayoutProvider();
+
+ int GetDistanceMetric(int metric) const override;
+
+ 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:
+ DISALLOW_COPY_AND_ASSIGN(ChromeLayoutProvider);
+};
+
+#endif // CHROME_BROWSER_UI_VIEWS_HARMONY_CHROME_LAYOUT_PROVIDER_H_

Powered by Google App Engine
This is Rietveld 408576698