Commit 44ec2a4f authored by kylixrd's avatar kylixrd Committed by Commit bot

Convert Register Protocol Handler dialog for Harmony/Material Design

NOTE: this CL only addresses the primary content of the referenced issue. The other issue regarding the wrapping of text should be a separate issue and confined to the implementing views/controls.

BUG=652024

Review-Url: https://codereview.chromium.org/2571613002
Cr-Commit-Position: refs/heads/master@{#442683}
parent e5410705
...@@ -548,16 +548,27 @@ int ChromeViewsDelegate::GetDialogRelatedButtonHorizontalSpacing() { ...@@ -548,16 +548,27 @@ int ChromeViewsDelegate::GetDialogRelatedButtonHorizontalSpacing() {
return ViewsDelegate::GetDialogRelatedButtonHorizontalSpacing(); return ViewsDelegate::GetDialogRelatedButtonHorizontalSpacing();
} }
int ChromeViewsDelegate::GetDialogRelatedControlVerticalSpacing() {
if (ui::MaterialDesignController::IsSecondaryUiMaterial())
return HarmonyLayoutDelegate::kHarmonyLayoutUnit / 2;
return ViewsDelegate::GetDialogRelatedControlVerticalSpacing();
}
gfx::Insets ChromeViewsDelegate::GetDialogFrameViewInsets() { gfx::Insets ChromeViewsDelegate::GetDialogFrameViewInsets() {
if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { if (ui::MaterialDesignController::IsSecondaryUiMaterial())
// Titles are inset at the top and sides, but not at the bottom. // Titles are inset at the top and sides, but not at the bottom.
return gfx::Insets(HarmonyLayoutDelegate::kHarmonyLayoutUnit, return gfx::Insets(HarmonyLayoutDelegate::kHarmonyLayoutUnit,
HarmonyLayoutDelegate::kHarmonyLayoutUnit, 0, HarmonyLayoutDelegate::kHarmonyLayoutUnit, 0,
HarmonyLayoutDelegate::kHarmonyLayoutUnit); HarmonyLayoutDelegate::kHarmonyLayoutUnit);
}
return ViewsDelegate::GetDialogFrameViewInsets(); return ViewsDelegate::GetDialogFrameViewInsets();
} }
gfx::Insets ChromeViewsDelegate::GetBubbleDialogMargins() {
if (ui::MaterialDesignController::IsSecondaryUiMaterial())
return gfx::Insets(HarmonyLayoutDelegate::kHarmonyLayoutUnit);
return ViewsDelegate::GetBubbleDialogMargins();
}
#if !defined(USE_ASH) #if !defined(USE_ASH)
views::Widget::InitParams::WindowOpacity views::Widget::InitParams::WindowOpacity
ChromeViewsDelegate::GetOpacityForInitParams( ChromeViewsDelegate::GetOpacityForInitParams(
......
...@@ -64,7 +64,9 @@ class ChromeViewsDelegate : public views::ViewsDelegate { ...@@ -64,7 +64,9 @@ class ChromeViewsDelegate : public views::ViewsDelegate {
gfx::Insets GetDialogButtonInsets() override; gfx::Insets GetDialogButtonInsets() override;
int GetDialogRelatedButtonHorizontalSpacing() override; int GetDialogRelatedButtonHorizontalSpacing() override;
int GetDialogRelatedControlVerticalSpacing() override;
gfx::Insets GetDialogFrameViewInsets() override; gfx::Insets GetDialogFrameViewInsets() override;
gfx::Insets GetBubbleDialogMargins() override;
private: private:
#if defined(OS_WIN) #if defined(OS_WIN)
......
...@@ -18,17 +18,20 @@ ...@@ -18,17 +18,20 @@
#include "chrome/browser/plugins/plugin_metadata.h" #include "chrome/browser/plugins/plugin_metadata.h"
#include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
#include "chrome/browser/ui/layout_constants.h" #include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/views/harmony/layout_delegate.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "content/public/browser/plugin_service.h" #include "content/public/browser/plugin_service.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "ui/base/cursor/cursor.h" #include "ui/base/cursor/cursor.h"
#include "ui/base/default_style.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/simple_menu_model.h" #include "ui/base/models/simple_menu_model.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/font_list.h" #include "ui/gfx/font_list.h"
#include "ui/gfx/text_utils.h" #include "ui/gfx/text_utils.h"
#include "ui/views/controls/button/label_button_border.h"
#include "ui/views/controls/button/md_text_button.h" #include "ui/views/controls/button/md_text_button.h"
#include "ui/views/controls/button/menu_button.h" #include "ui/views/controls/button/menu_button.h"
#include "ui/views/controls/button/radio_button.h" #include "ui/views/controls/button/radio_button.h"
...@@ -181,11 +184,16 @@ ContentSettingBubbleContents::~ContentSettingBubbleContents() { ...@@ -181,11 +184,16 @@ ContentSettingBubbleContents::~ContentSettingBubbleContents() {
gfx::Size ContentSettingBubbleContents::GetPreferredSize() const { gfx::Size ContentSettingBubbleContents::GetPreferredSize() const {
gfx::Size preferred_size(views::View::GetPreferredSize()); gfx::Size preferred_size(views::View::GetPreferredSize());
int preferred_width = int preferred_width = LayoutDelegate::Get()->GetDialogPreferredWidth(
(!content_setting_bubble_model_->bubble_content().domain_lists.empty() && LayoutDelegate::DialogWidthType::SMALL);
(kMinMultiLineContentsWidth > preferred_size.width())) if (!preferred_width)
? kMinMultiLineContentsWidth preferred_width = (!content_setting_bubble_model_->bubble_content()
: preferred_size.width(); .domain_lists.empty() &&
(kMinMultiLineContentsWidth > preferred_size.width()))
? kMinMultiLineContentsWidth
: preferred_size.width();
else
preferred_width -= margins().width();
if (content_setting_bubble_model_->AsSubresourceFilterBubbleModel()) { if (content_setting_bubble_model_->AsSubresourceFilterBubbleModel()) {
preferred_size.set_width(std::min(preferred_width, preferred_size.set_width(std::min(preferred_width,
kMaxDefaultContentsWidth)); kMaxDefaultContentsWidth));
...@@ -200,12 +208,24 @@ void ContentSettingBubbleContents::Init() { ...@@ -200,12 +208,24 @@ void ContentSettingBubbleContents::Init() {
GridLayout* layout = new views::GridLayout(this); GridLayout* layout = new views::GridLayout(this);
SetLayoutManager(layout); SetLayoutManager(layout);
const LayoutDelegate* layout_delegate = LayoutDelegate::Get();
const int related_control_horizontal_spacing =
layout_delegate->GetLayoutDistance(
LayoutDelegate::LayoutDistanceType::
RELATED_CONTROL_HORIZONTAL_SPACING);
const int related_control_vertical_spacing =
layout_delegate->GetLayoutDistance(
LayoutDelegate::LayoutDistanceType::RELATED_CONTROL_VERTICAL_SPACING);
const int unrelated_control_vertical_spacing =
layout_delegate->GetLayoutDistance(
LayoutDelegate::LayoutDistanceType::
UNRELATED_CONTROL_VERTICAL_SPACING);
const int kSingleColumnSetId = 0; const int kSingleColumnSetId = 0;
views::ColumnSet* column_set = layout->AddColumnSet(kSingleColumnSetId); views::ColumnSet* column_set = layout->AddColumnSet(kSingleColumnSetId);
column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
GridLayout::USE_PREF, 0, 0); GridLayout::USE_PREF, 0, 0);
column_set->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing); column_set->AddPaddingColumn(0, related_control_horizontal_spacing);
column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
GridLayout::USE_PREF, 0, 0); GridLayout::USE_PREF, 0, 0);
...@@ -217,6 +237,11 @@ void ContentSettingBubbleContents::Init() { ...@@ -217,6 +237,11 @@ void ContentSettingBubbleContents::Init() {
views::Label* title_label = new views::Label(bubble_content.title); views::Label* title_label = new views::Label(bubble_content.title);
title_label->SetMultiLine(true); title_label->SetMultiLine(true);
title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
if (layout_delegate->IsHarmonyMode()) {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
title_label->SetFontList(
rb.GetFontListWithDelta(ui::kTitleFontSizeDelta));
}
layout->StartRow(0, kSingleColumnSetId); layout->StartRow(0, kSingleColumnSetId);
layout->AddView(title_label); layout->AddView(title_label);
bubble_content_empty = false; bubble_content_empty = false;
...@@ -224,7 +249,7 @@ void ContentSettingBubbleContents::Init() { ...@@ -224,7 +249,7 @@ void ContentSettingBubbleContents::Init() {
if (!bubble_content.message.empty()) { if (!bubble_content.message.empty()) {
views::Label* message_label = new views::Label(bubble_content.message); views::Label* message_label = new views::Label(bubble_content.message);
layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); layout->AddPaddingRow(0, unrelated_control_vertical_spacing);
message_label->SetMultiLine(true); message_label->SetMultiLine(true);
message_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); message_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
layout->StartRow(0, kSingleColumnSetId); layout->StartRow(0, kSingleColumnSetId);
...@@ -248,8 +273,8 @@ void ContentSettingBubbleContents::Init() { ...@@ -248,8 +273,8 @@ void ContentSettingBubbleContents::Init() {
layout->AddColumnSet(kItemListColumnSetId); layout->AddColumnSet(kItemListColumnSetId);
item_list_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 0, item_list_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 0,
GridLayout::USE_PREF, 0, 0); GridLayout::USE_PREF, 0, 0);
item_list_column_set->AddPaddingColumn( item_list_column_set->AddPaddingColumn(0,
0, views::kRelatedControlHorizontalSpacing); related_control_horizontal_spacing);
item_list_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, item_list_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
GridLayout::USE_PREF, 0, 0); GridLayout::USE_PREF, 0, 0);
...@@ -257,7 +282,7 @@ void ContentSettingBubbleContents::Init() { ...@@ -257,7 +282,7 @@ void ContentSettingBubbleContents::Init() {
for (const ContentSettingBubbleModel::ListItem& list_item : for (const ContentSettingBubbleModel::ListItem& list_item :
bubble_content.list_items) { bubble_content.list_items) {
if (!bubble_content_empty) if (!bubble_content_empty)
layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); layout->AddPaddingRow(0, related_control_vertical_spacing);
layout->StartRow(0, kItemListColumnSetId); layout->StartRow(0, kItemListColumnSetId);
if (list_item.has_link) { if (list_item.has_link) {
views::Link* link = new views::Link(base::UTF8ToUTF16(list_item.title)); views::Link* link = new views::Link(base::UTF8ToUTF16(list_item.title));
...@@ -281,7 +306,9 @@ void ContentSettingBubbleContents::Init() { ...@@ -281,7 +306,9 @@ void ContentSettingBubbleContents::Init() {
// Insert a column set with greater indent. // Insert a column set with greater indent.
views::ColumnSet* indented_single_column_set = views::ColumnSet* indented_single_column_set =
layout->AddColumnSet(indented_kSingleColumnSetId); layout->AddColumnSet(indented_kSingleColumnSetId);
indented_single_column_set->AddPaddingColumn(0, views::kCheckboxIndent); indented_single_column_set->AddPaddingColumn(
0, layout_delegate->GetLayoutDistance(
LayoutDelegate::LayoutDistanceType::CHECKBOX_INDENT));
indented_single_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, indented_single_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL,
1, GridLayout::USE_PREF, 0, 0); 1, GridLayout::USE_PREF, 0, 0);
...@@ -289,7 +316,7 @@ void ContentSettingBubbleContents::Init() { ...@@ -289,7 +316,7 @@ void ContentSettingBubbleContents::Init() {
bubble_content.radio_group; bubble_content.radio_group;
if (!radio_group.radio_items.empty()) { if (!radio_group.radio_items.empty()) {
if (!bubble_content_empty) if (!bubble_content_empty)
layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); layout->AddPaddingRow(0, related_control_vertical_spacing);
for (ContentSettingBubbleModel::RadioItems::const_iterator i( for (ContentSettingBubbleModel::RadioItems::const_iterator i(
radio_group.radio_items.begin()); radio_group.radio_items.begin());
i != radio_group.radio_items.end(); ++i) { i != radio_group.radio_items.end(); ++i) {
...@@ -297,6 +324,14 @@ void ContentSettingBubbleContents::Init() { ...@@ -297,6 +324,14 @@ void ContentSettingBubbleContents::Init() {
new views::RadioButton(base::UTF8ToUTF16(*i), 0); new views::RadioButton(base::UTF8ToUTF16(*i), 0);
radio->SetEnabled(bubble_content.radio_group_enabled); radio->SetEnabled(bubble_content.radio_group_enabled);
radio->set_listener(this); radio->set_listener(this);
if (layout_delegate->IsHarmonyMode()) {
std::unique_ptr<views::LabelButtonBorder> border =
radio->CreateDefaultBorder();
gfx::Insets insets = border->GetInsets();
border->set_insets(
gfx::Insets(insets.top(), 0, insets.bottom(), insets.right()));
radio->SetBorder(std::move(border));
}
radio_group_.push_back(radio); radio_group_.push_back(radio);
layout->StartRow(0, indented_kSingleColumnSetId); layout->StartRow(0, indented_kSingleColumnSetId);
layout->AddView(radio); layout->AddView(radio);
...@@ -313,11 +348,12 @@ void ContentSettingBubbleContents::Init() { ...@@ -313,11 +348,12 @@ void ContentSettingBubbleContents::Init() {
const int kMediaMenuColumnSetId = 4; const int kMediaMenuColumnSetId = 4;
views::ColumnSet* menu_column_set = views::ColumnSet* menu_column_set =
layout->AddColumnSet(kMediaMenuColumnSetId); layout->AddColumnSet(kMediaMenuColumnSetId);
menu_column_set->AddPaddingColumn(0, views::kCheckboxIndent); menu_column_set->AddPaddingColumn(
0, layout_delegate->GetLayoutDistance(
LayoutDelegate::LayoutDistanceType::CHECKBOX_INDENT));
menu_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 0, menu_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 0,
GridLayout::USE_PREF, 0, 0); GridLayout::USE_PREF, 0, 0);
menu_column_set->AddPaddingColumn( menu_column_set->AddPaddingColumn(0, related_control_horizontal_spacing);
0, views::kRelatedControlHorizontalSpacing);
menu_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, menu_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
GridLayout::USE_PREF, 0, 0); GridLayout::USE_PREF, 0, 0);
...@@ -325,7 +361,7 @@ void ContentSettingBubbleContents::Init() { ...@@ -325,7 +361,7 @@ void ContentSettingBubbleContents::Init() {
bubble_content.media_menus.begin()); bubble_content.media_menus.begin());
i != bubble_content.media_menus.end(); ++i) { i != bubble_content.media_menus.end(); ++i) {
if (!bubble_content_empty) if (!bubble_content_empty)
layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); layout->AddPaddingRow(0, related_control_vertical_spacing);
layout->StartRow(0, kMediaMenuColumnSetId); layout->StartRow(0, kMediaMenuColumnSetId);
views::Label* label = views::Label* label =
...@@ -376,18 +412,20 @@ void ContentSettingBubbleContents::Init() { ...@@ -376,18 +412,20 @@ void ContentSettingBubbleContents::Init() {
custom_link_->SetEnabled(bubble_content.custom_link_enabled); custom_link_->SetEnabled(bubble_content.custom_link_enabled);
custom_link_->set_listener(this); custom_link_->set_listener(this);
if (!bubble_content_empty) if (!bubble_content_empty)
layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); layout->AddPaddingRow(0, related_control_vertical_spacing);
layout->StartRow(0, kSingleColumnSetId); layout->StartRow(0, kSingleColumnSetId);
layout->AddView(custom_link_); layout->AddView(custom_link_);
bubble_content_empty = false; bubble_content_empty = false;
} }
if (!bubble_content_empty) { if (!bubble_content_empty) {
layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); if (!layout_delegate->IsHarmonyMode()) {
layout->StartRow(0, kSingleColumnSetId); layout->AddPaddingRow(0, related_control_vertical_spacing);
layout->AddView(new views::Separator(views::Separator::HORIZONTAL), 1, 1, layout->StartRow(0, kSingleColumnSetId);
GridLayout::FILL, GridLayout::FILL); layout->AddView(new views::Separator(views::Separator::HORIZONTAL), 1, 1,
layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); GridLayout::FILL, GridLayout::FILL);
}
layout->AddPaddingRow(0, related_control_vertical_spacing);
} }
} }
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include "ui/views/controls/label.h" #include "ui/views/controls/label.h"
#include "ui/views/controls/textfield/textfield.h" #include "ui/views/controls/textfield/textfield.h"
#include "ui/views/layout/grid_layout.h" #include "ui/views/layout/grid_layout.h"
#include "ui/views/layout/layout_constants.h"
#include "ui/views/window/dialog_delegate.h" #include "ui/views/window/dialog_delegate.h"
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
...@@ -148,8 +147,11 @@ void CookieInfoView::Init() { ...@@ -148,8 +147,11 @@ void CookieInfoView::Init() {
expires_value_field_ = new views::Textfield; expires_value_field_ = new views::Textfield;
views::GridLayout* layout = new views::GridLayout(this); views::GridLayout* layout = new views::GridLayout(this);
layout->SetInsets(0, views::kButtonHEdgeMarginNew, layout->SetInsets(
0, views::kButtonHEdgeMarginNew); 0, LayoutDelegate::Get()->GetLayoutDistance(
LayoutDelegate::LayoutDistanceType::BUTTON_HEDGE_MARGIN_NEW),
0, LayoutDelegate::Get()->GetLayoutDistance(
LayoutDelegate::LayoutDistanceType::BUTTON_HEDGE_MARGIN_NEW));
SetLayoutManager(layout); SetLayoutManager(layout);
int three_column_layout_id = 0; int three_column_layout_id = 0;
...@@ -157,7 +159,9 @@ void CookieInfoView::Init() { ...@@ -157,7 +159,9 @@ void CookieInfoView::Init() {
column_set->AddColumn(LayoutDelegate::Get()->GetControlLabelGridAlignment(), column_set->AddColumn(LayoutDelegate::Get()->GetControlLabelGridAlignment(),
views::GridLayout::CENTER, 0, views::GridLayout::CENTER, 0,
views::GridLayout::USE_PREF, 0, 0); views::GridLayout::USE_PREF, 0, 0);
column_set->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing); column_set->AddPaddingColumn(0, LayoutDelegate::Get()->GetLayoutDistance(
LayoutDelegate::LayoutDistanceType::
RELATED_CONTROL_HORIZONTAL_SPACING));
column_set->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER, column_set->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER,
0, views::GridLayout::USE_PREF, 0, 0); 0, views::GridLayout::USE_PREF, 0, 0);
column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER,
......
...@@ -17,6 +17,8 @@ HarmonyLayoutDelegate* HarmonyLayoutDelegate::Get() { ...@@ -17,6 +17,8 @@ HarmonyLayoutDelegate* HarmonyLayoutDelegate::Get() {
int HarmonyLayoutDelegate::GetLayoutDistance(LayoutDistanceType type) const { int HarmonyLayoutDelegate::GetLayoutDistance(LayoutDistanceType type) const {
switch (type) { switch (type) {
case LayoutDistanceType::PANEL_HORIZ_MARGIN:
return kHarmonyLayoutUnit;
case LayoutDistanceType::PANEL_VERT_MARGIN: case LayoutDistanceType::PANEL_VERT_MARGIN:
return kHarmonyLayoutUnit; return kHarmonyLayoutUnit;
case LayoutDistanceType::RELATED_BUTTON_HORIZONTAL_SPACING: case LayoutDistanceType::RELATED_BUTTON_HORIZONTAL_SPACING:
...@@ -33,6 +35,8 @@ int HarmonyLayoutDelegate::GetLayoutDistance(LayoutDistanceType type) const { ...@@ -33,6 +35,8 @@ int HarmonyLayoutDelegate::GetLayoutDistance(LayoutDistanceType type) const {
return kHarmonyLayoutUnit; return kHarmonyLayoutUnit;
case LayoutDistanceType::BUTTON_HEDGE_MARGIN_NEW: case LayoutDistanceType::BUTTON_HEDGE_MARGIN_NEW:
return kHarmonyLayoutUnit; return kHarmonyLayoutUnit;
case LayoutDistanceType::CHECKBOX_INDENT:
return 0;
} }
NOTREACHED(); NOTREACHED();
return 0; return 0;
......
...@@ -22,6 +22,8 @@ LayoutDelegate* LayoutDelegate::Get() { ...@@ -22,6 +22,8 @@ LayoutDelegate* LayoutDelegate::Get() {
int LayoutDelegate::GetLayoutDistance(LayoutDistanceType type) const { int LayoutDelegate::GetLayoutDistance(LayoutDistanceType type) const {
switch (type) { switch (type) {
case LayoutDistanceType::PANEL_HORIZ_MARGIN:
return views::kPanelHorizMargin;
case LayoutDistanceType::PANEL_VERT_MARGIN: case LayoutDistanceType::PANEL_VERT_MARGIN:
return views::kPanelVertMargin; return views::kPanelVertMargin;
case LayoutDistanceType::RELATED_BUTTON_HORIZONTAL_SPACING: case LayoutDistanceType::RELATED_BUTTON_HORIZONTAL_SPACING:
...@@ -38,6 +40,8 @@ int LayoutDelegate::GetLayoutDistance(LayoutDistanceType type) const { ...@@ -38,6 +40,8 @@ int LayoutDelegate::GetLayoutDistance(LayoutDistanceType type) const {
return views::kButtonVEdgeMarginNew; return views::kButtonVEdgeMarginNew;
case LayoutDistanceType::BUTTON_HEDGE_MARGIN_NEW: case LayoutDistanceType::BUTTON_HEDGE_MARGIN_NEW:
return views::kButtonHEdgeMarginNew; return views::kButtonHEdgeMarginNew;
case LayoutDistanceType::CHECKBOX_INDENT:
return views::kCheckboxIndent;
} }
NOTREACHED(); NOTREACHED();
return 0; return 0;
......
...@@ -10,14 +10,28 @@ ...@@ -10,14 +10,28 @@
class LayoutDelegate { class LayoutDelegate {
public: public:
enum class LayoutDistanceType { enum class LayoutDistanceType {
// Left or right margin.
PANEL_HORIZ_MARGIN,
// Top or bottom margin.
PANEL_VERT_MARGIN, PANEL_VERT_MARGIN,
// Horizontal spacing between controls that are logically related.
RELATED_CONTROL_HORIZONTAL_SPACING, RELATED_CONTROL_HORIZONTAL_SPACING,
// Vertical spacing between controls that are logically related.
RELATED_CONTROL_VERTICAL_SPACING, RELATED_CONTROL_VERTICAL_SPACING,
// Horizontal spacing between buttons that are logically related.
RELATED_BUTTON_HORIZONTAL_SPACING, RELATED_BUTTON_HORIZONTAL_SPACING,
// Vertical spacing between controls that are logically unrelated.
UNRELATED_CONTROL_VERTICAL_SPACING, UNRELATED_CONTROL_VERTICAL_SPACING,
// Larger vertical spacing between unrelated controls.
UNRELATED_CONTROL_LARGE_VERTICAL_SPACING, UNRELATED_CONTROL_LARGE_VERTICAL_SPACING,
// Vertical spacing between the edge of the window and the
// top or bottom of a button.
BUTTON_HEDGE_MARGIN_NEW, BUTTON_HEDGE_MARGIN_NEW,
// Horizontal spacing between the edge of the window and the
// left or right of a button.
BUTTON_VEDGE_MARGIN_NEW, BUTTON_VEDGE_MARGIN_NEW,
// Indent of checkboxes relative to related text.
CHECKBOX_INDENT,
}; };
enum class DialogWidthType { enum class DialogWidthType {
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "chrome/browser/ui/views/layout_utils.h" #include "chrome/browser/ui/views/layout_utils.h"
#include "chrome/browser/ui/views/harmony/layout_delegate.h" #include "chrome/browser/ui/views/harmony/layout_delegate.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/view.h" #include "ui/views/view.h"
namespace layout_utils { namespace layout_utils {
......
...@@ -59,8 +59,8 @@ LoginView::LoginView(const base::string16& authority, ...@@ -59,8 +59,8 @@ LoginView::LoginView(const base::string16& authority,
column_set->AddColumn(layout_delegate->GetControlLabelGridAlignment(), column_set->AddColumn(layout_delegate->GetControlLabelGridAlignment(),
GridLayout::CENTER, 0, GridLayout::USE_PREF, 0, 0); GridLayout::CENTER, 0, GridLayout::USE_PREF, 0, 0);
column_set->AddPaddingColumn(0, layout_delegate->GetLayoutDistance( column_set->AddPaddingColumn(0, layout_delegate->GetLayoutDistance(
LayoutDelegate::LayoutDistanceType:: LayoutDelegate::LayoutDistanceType::
RELATED_CONTROL_HORIZONTAL_SPACING)); RELATED_CONTROL_HORIZONTAL_SPACING));
column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
GridLayout::USE_PREF, 0, 0); GridLayout::USE_PREF, 0, 0);
if (layout_delegate->UseExtraDialogPadding()) if (layout_delegate->UseExtraDialogPadding())
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "ui/accessibility/ax_node_data.h" #include "ui/accessibility/ax_node_data.h"
#include "ui/base/default_style.h"
#include "ui/base/material_design/material_design_controller.h" #include "ui/base/material_design/material_design_controller.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/color_utils.h" #include "ui/gfx/color_utils.h"
...@@ -15,6 +16,7 @@ ...@@ -15,6 +16,7 @@
#include "ui/views/focus/view_storage.h" #include "ui/views/focus/view_storage.h"
#include "ui/views/layout/layout_constants.h" #include "ui/views/layout/layout_constants.h"
#include "ui/views/style/platform_style.h" #include "ui/views/style/platform_style.h"
#include "ui/views/views_delegate.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_observer.h" #include "ui/views/widget/widget_observer.h"
#include "ui/views/window/dialog_client_view.h" #include "ui/views/window/dialog_client_view.h"
...@@ -102,8 +104,11 @@ ClientView* BubbleDialogDelegateView::CreateClientView(Widget* widget) { ...@@ -102,8 +104,11 @@ ClientView* BubbleDialogDelegateView::CreateClientView(Widget* widget) {
NonClientFrameView* BubbleDialogDelegateView::CreateNonClientFrameView( NonClientFrameView* BubbleDialogDelegateView::CreateNonClientFrameView(
Widget* widget) { Widget* widget) {
ViewsDelegate* views_delegate = ViewsDelegate::GetInstance();
BubbleFrameView* frame = new BubbleFrameView( BubbleFrameView* frame = new BubbleFrameView(
gfx::Insets(kPanelVertMargin, kPanelHorizMargin, 0, kPanelHorizMargin), views_delegate ? views_delegate->GetDialogFrameViewInsets()
: gfx::Insets(kPanelVertMargin, kPanelHorizMargin, 0,
kPanelHorizMargin),
margins()); margins());
// Note: In CreateBubble, the call to SizeToContents() will cause // Note: In CreateBubble, the call to SizeToContents() will cause
// the relayout that this call requires. // the relayout that this call requires.
...@@ -212,13 +217,13 @@ BubbleDialogDelegateView::BubbleDialogDelegateView(View* anchor_view, ...@@ -212,13 +217,13 @@ BubbleDialogDelegateView::BubbleDialogDelegateView(View* anchor_view,
mirror_arrow_in_rtl_(PlatformStyle::kMirrorBubbleArrowInRTLByDefault), mirror_arrow_in_rtl_(PlatformStyle::kMirrorBubbleArrowInRTLByDefault),
shadow_(BubbleBorder::SMALL_SHADOW), shadow_(BubbleBorder::SMALL_SHADOW),
color_explicitly_set_(false), color_explicitly_set_(false),
margins_(kPanelVertMargin,
kPanelHorizMargin,
kPanelVertMargin,
kPanelHorizMargin),
accept_events_(true), accept_events_(true),
adjust_if_offscreen_(true), adjust_if_offscreen_(true),
parent_window_(NULL) { parent_window_(NULL) {
margins_ = ViewsDelegate::GetInstance()
? ViewsDelegate::GetInstance()->GetBubbleDialogMargins()
: gfx::Insets(kPanelVertMargin, kPanelHorizMargin,
kPanelVertMargin, kPanelHorizMargin);
if (anchor_view) if (anchor_view)
SetAnchorView(anchor_view); SetAnchorView(anchor_view);
UpdateColorsFromTheme(GetNativeTheme()); UpdateColorsFromTheme(GetNativeTheme());
...@@ -235,6 +240,8 @@ gfx::Rect BubbleDialogDelegateView::GetBubbleBounds() { ...@@ -235,6 +240,8 @@ gfx::Rect BubbleDialogDelegateView::GetBubbleBounds() {
const gfx::FontList& BubbleDialogDelegateView::GetTitleFontList() const { const gfx::FontList& BubbleDialogDelegateView::GetTitleFontList() const {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
if (ui::MaterialDesignController::IsSecondaryUiMaterial())
return rb.GetFontListWithDelta(ui::kTitleFontSizeDelta);
return rb.GetFontList(ui::ResourceBundle::MediumFont); return rb.GetFontList(ui::ResourceBundle::MediumFont);
} }
......
...@@ -58,7 +58,7 @@ const int kUnrelatedControlLargeVerticalSpacing = 30; ...@@ -58,7 +58,7 @@ const int kUnrelatedControlLargeVerticalSpacing = 30;
// top or bottom of a button. // top or bottom of a button.
const int kButtonVEdgeMargin = 9; const int kButtonVEdgeMargin = 9;
// Vertical spacing between the edge of the window and the // Horizontal spacing between the edge of the window and the
// left or right of a button. // left or right of a button.
const int kButtonHEdgeMargin = 13; const int kButtonHEdgeMargin = 13;
...@@ -66,7 +66,7 @@ const int kButtonHEdgeMargin = 13; ...@@ -66,7 +66,7 @@ const int kButtonHEdgeMargin = 13;
// top or bottom of a button (when using new style dialogs). // top or bottom of a button (when using new style dialogs).
const int kButtonVEdgeMarginNew = 20; const int kButtonVEdgeMarginNew = 20;
// Vertical spacing between the edge of the window and the // Horizontal spacing between the edge of the window and the
// left or right of a button (when using new style dialogs). // left or right of a button (when using new style dialogs).
const int kButtonHEdgeMarginNew = 20; const int kButtonHEdgeMarginNew = 20;
......
...@@ -135,11 +135,19 @@ int ViewsDelegate::GetDialogRelatedButtonHorizontalSpacing() { ...@@ -135,11 +135,19 @@ int ViewsDelegate::GetDialogRelatedButtonHorizontalSpacing() {
return kRelatedButtonHSpacing; return kRelatedButtonHSpacing;
} }
int ViewsDelegate::GetDialogRelatedControlVerticalSpacing() {
return kRelatedControlVerticalSpacing;
}
gfx::Insets ViewsDelegate::GetDialogFrameViewInsets() { gfx::Insets ViewsDelegate::GetDialogFrameViewInsets() {
return gfx::Insets(kPanelVertMargin, kButtonHEdgeMarginNew, 0, return gfx::Insets(kPanelVertMargin, kButtonHEdgeMarginNew, 0,
kButtonHEdgeMarginNew); kButtonHEdgeMarginNew);
} }
gfx::Insets ViewsDelegate::GetBubbleDialogMargins() {
return gfx::Insets(kPanelVertMargin, kPanelHorizMargin);
}
ViewsDelegate::ViewsDelegate() ViewsDelegate::ViewsDelegate()
: views_tsc_factory_(new ViewsTouchEditingControllerFactory) { : views_tsc_factory_(new ViewsTouchEditingControllerFactory) {
DCHECK(!views_delegate); DCHECK(!views_delegate);
......
...@@ -205,9 +205,16 @@ class VIEWS_EXPORT ViewsDelegate { ...@@ -205,9 +205,16 @@ class VIEWS_EXPORT ViewsDelegate {
// dialog layout. // dialog layout.
virtual int GetDialogRelatedButtonHorizontalSpacing(); virtual int GetDialogRelatedButtonHorizontalSpacing();
// Returns the spacing between a pair of related vertical controls, used for
// dialog layout.
virtual int GetDialogRelatedControlVerticalSpacing();
// Returns the insets that should be applied around a dialog's frame view. // Returns the insets that should be applied around a dialog's frame view.
virtual gfx::Insets GetDialogFrameViewInsets(); virtual gfx::Insets GetDialogFrameViewInsets();
// Returns the margins that should be applied around a bubble dialog.
virtual gfx::Insets GetBubbleDialogMargins();
protected: protected:
ViewsDelegate(); ViewsDelegate();
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "ui/base/material_design/material_design_controller.h" #include "ui/base/material_design/material_design_controller.h"
#include "ui/events/keycodes/keyboard_codes.h" #include "ui/events/keycodes/keyboard_codes.h"
#include "ui/views/background.h" #include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/controls/button/blue_button.h" #include "ui/views/controls/button/blue_button.h"
#include "ui/views/controls/button/custom_button.h" #include "ui/views/controls/button/custom_button.h"
#include "ui/views/controls/button/label_button.h" #include "ui/views/controls/button/label_button.h"
...@@ -68,14 +69,15 @@ void LayoutButton(LabelButton* button, ...@@ -68,14 +69,15 @@ void LayoutButton(LabelButton* button,
DialogClientView::DialogClientView(Widget* owner, View* contents_view) DialogClientView::DialogClientView(Widget* owner, View* contents_view)
: ClientView(owner, contents_view), : ClientView(owner, contents_view),
button_row_insets_(0,
kButtonHEdgeMarginNew,
kButtonVEdgeMarginNew,
kButtonHEdgeMarginNew),
ok_button_(nullptr), ok_button_(nullptr),
cancel_button_(nullptr), cancel_button_(nullptr),
extra_view_(nullptr), extra_view_(nullptr),
delegate_allowed_close_(false) { delegate_allowed_close_(false) {
button_row_insets_ =
ViewsDelegate::GetInstance()
? ViewsDelegate::GetInstance()->GetDialogButtonInsets()
: gfx::Insets(0, kButtonHEdgeMarginNew, kButtonVEdgeMarginNew,
kButtonHEdgeMarginNew);
// Doing this now ensures this accelerator will have lower priority than // Doing this now ensures this accelerator will have lower priority than
// one set by the contents view. // one set by the contents view.
AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE));
...@@ -159,14 +161,21 @@ gfx::Size DialogClientView::GetPreferredSize() const { ...@@ -159,14 +161,21 @@ gfx::Size DialogClientView::GetPreferredSize() const {
// Initialize the size to fit the buttons and extra view row. // Initialize the size to fit the buttons and extra view row.
int extra_view_padding = 0; int extra_view_padding = 0;
if (!GetDialogDelegate()->GetExtraViewPadding(&extra_view_padding)) if (!GetDialogDelegate()->GetExtraViewPadding(&extra_view_padding))
extra_view_padding = kRelatedButtonHSpacing; extra_view_padding = ViewsDelegate::GetInstance()
? ViewsDelegate::GetInstance()
->GetDialogRelatedButtonHorizontalSpacing()
: kRelatedButtonHSpacing;
gfx::Size size( gfx::Size size(
(ok_button_ ? ok_button_->GetPreferredSize().width() : 0) + (ok_button_ ? ok_button_->GetPreferredSize().width() : 0) +
(cancel_button_ ? cancel_button_->GetPreferredSize().width() : 0) + (cancel_button_ ? cancel_button_->GetPreferredSize().width() : 0) +
(cancel_button_ && ok_button_ ? kRelatedButtonHSpacing : 0) + (cancel_button_ && ok_button_
? (ViewsDelegate::GetInstance()
? ViewsDelegate::GetInstance()
->GetDialogRelatedButtonHorizontalSpacing()
: kRelatedButtonHSpacing) : 0) +
(ShouldShow(extra_view_) ? extra_view_->GetPreferredSize().width() : 0) + (ShouldShow(extra_view_) ? extra_view_->GetPreferredSize().width() : 0) +
(ShouldShow(extra_view_) && has_dialog_buttons() ? (ShouldShow(extra_view_) && has_dialog_buttons() ? extra_view_padding
extra_view_padding : 0), : 0),
0); 0);
int buttons_height = GetButtonsAndExtraViewRowHeight(); int buttons_height = GetButtonsAndExtraViewRowHeight();
...@@ -367,10 +376,13 @@ int DialogClientView::GetButtonsAndExtraViewRowTopPadding() const { ...@@ -367,10 +376,13 @@ int DialogClientView::GetButtonsAndExtraViewRowTopPadding() const {
// Some subclasses of DialogClientView, in order to do their own layout, set // Some subclasses of DialogClientView, in order to do their own layout, set
// button_row_insets_ to gfx::Insets(). To avoid breaking behavior of those // button_row_insets_ to gfx::Insets(). To avoid breaking behavior of those
// dialogs, supplying 0 for the top inset of the row falls back to // dialogs, supplying 0 for the top inset of the row falls back to
// ViewsDelegate::GetRelatedControlVerticalSpacing or
// kRelatedControlVerticalSpacing. // kRelatedControlVerticalSpacing.
// TODO(ellyjones): Figure out a more principled way to approach that issue.
if (!spacing) if (!spacing)
spacing = kRelatedControlVerticalSpacing; spacing = ViewsDelegate::GetInstance()
? ViewsDelegate::GetInstance()
->GetDialogRelatedControlVerticalSpacing()
: kRelatedControlVerticalSpacing;
return spacing; return spacing;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment