Commit 12d3545c authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

views: fix content setting bubble width

This change:
1) Allows the text labels on checkboxes and radiobuttons to line-wrap
   instead of truncating;
2) Forces the content setting bubbles to the smallest width in Harmony
   mode.

Bug: 787755
Change-Id: I7c823bc7e0c504935cbd210893001c1ff8c060ec
Reviewed-on: https://chromium-review.googlesource.com/796452Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522119}
parent 3425c94e
......@@ -329,6 +329,20 @@ gfx::Size ContentSettingBubbleContents::CalculatePreferredSize() const {
} else {
preferred_size.set_width(std::min(preferred_width, kMaxContentsWidth));
}
// These bubbles should all be the "small" dialog width, but only when in
// Harmony mode.
ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
if (provider->IsHarmonyMode()) {
// Subtract out this dialog's margins. The margins are imposed by
// DialogClientView around this view, so this view's width plus the width of
// these margins must equal the desired width, which is
// GetSnappedDialogWidth(0).
preferred_size.set_width(provider->GetSnappedDialogWidth(0) -
margins().width());
preferred_size.set_height(GetHeightForWidth(preferred_size.width()));
}
return preferred_size;
}
......@@ -437,6 +451,7 @@ void ContentSettingBubbleContents::Init() {
views::RadioButton* radio = new views::RadioButton(*i, 0);
radio->SetEnabled(bubble_content.radio_group_enabled);
radio->set_listener(this);
radio->SetMultiLine(true);
radio_group_.push_back(radio);
layout->StartRow(0, kIndentedSingleColumnSetId);
layout->AddView(radio);
......
......@@ -147,6 +147,10 @@ void Checkbox::SetChecked(bool checked) {
UpdateImage();
}
void Checkbox::SetMultiLine(bool multi_line) {
label()->SetMultiLine(multi_line);
}
// TODO(tetsui): Remove this method and |use_md_| when MD for secondary UI
// becomes default and IsSecondaryUiMaterial() is tautology.
bool Checkbox::UseMd() const {
......
......@@ -37,6 +37,8 @@ class VIEWS_EXPORT Checkbox : public LabelButton {
virtual void SetChecked(bool checked);
bool checked() const { return checked_; }
void SetMultiLine(bool multi_line);
protected:
// Returns whether MD is enabled. Returns true if |force_md| in the
// constructor or --secondary-ui-md flag is set.
......
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