New issue
Advanced search Search tips

Issue 766069 link

Starred by 1 user

Issue metadata

Status: Archived
Owner: ----
Closed: Sep 13
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Chrome , Mac
Pri: 3
Type: Bug



Sign in to add a comment

A wide views::DialogClientView button row (or wide title) can't cause the dialog's content view to *reduce* its height

Project Member Reported by tapted@chromium.org, Sep 18 2017

Issue description

Chrome Version       : 63ish

This is hard to describe. So here's a "picture": Consider,


 Dialog Title
 
 This is a long multiline string. It
 would normally wrap like this except,
 in this locale, the button row came
 out really long. However the *height*
 of this label is determined first. So
 it will always have 6 lines of height.

 |Something a lot longer than OK| |Cancel might be changed too|



tl'dr. The result we end up with is:


 Dialog Title

 [empty space]
 This is a long multiline string. It would normally wrap like
 this except, in this locale, the button row came out really
 long. However the *height* of this label is determined first.
 So it will always have 6 lines of height.
 [empty space]

 |Something a lot longer than OK| |Cancel might be changed too|



The width of the dialog is predominantly determined by a function of 
 - std::max(button_row_width, kPreferredTextWidth); or
 - std::max(button_row_width, gfx::Font::GetExpectedTextWidth(kLocalizedTextLength));


(aside: kLocalizedTextLength *can* be localized, but I don't think it ever is..).

Note that specifying 0 doesn't work. Some concept of "width" needs to be fed into the message string _first_, otherwise it tries to put the string entirely on one line.

The problem with all of these approaches is that the label needs to first be "locked in" to report a correct GetPreferredSize. DialogClientView never asks the "real" ClientView for its GetHeightForWidth(..) once it has determined how wide the button row needs to be. Likewise, BubbleFrameView never asks for a new bounds/height once it has determined the real bubble width in GetFrameWidthForClientWidth().



I suspect the realistic fix for this is to say "Buttons should never have really long labels". Under any locale. If they do, currently the dialog gets extra vertical white space, but it's not a disaster. (Also keeping labels "short" gets harder with increased font sizes).


With dialog width snapping for Harmony, this problem is now more likely to manifest, since a wide button row will now be "rounded up" to the next largest dialog width, increasing the chance that re-wrapping the text will lose a line (or more).

Width-snapping also means that approaches like using width=Font::GetExpectedTextWidth(something-larger-if-a-dialog-has-long-button-labels) are rarely suitable. Because
 a) Ensuring "most cases" get the dialog width UX want becomes less likely, since it may bump up into a larger width
 b) Width-snapping becomes *guaranteed*. I.e., it always must increase. Which has repercussions for this specific Issue.


For an algorithmic fix... Maybe we need to feed some kind of "preferred" width into views::Label, or a LayoutManager, and perhaps plumb it all the way into into View::GetPreferredWidth() (or adopt a convention that a zero-height returned by CalculatePreferredSize, means "always consult GetHeightForWidth()").

Alternatively, perhaps allowing the ClientView to participate directly in calculations like BubbleFrameView::GetFrameWidthForClientWidth().

And really it would be nice to avoid a "fix" that makes writing specific dialogs more complicated (i.e. requiring each dialog to do more than just set a LayoutManager and preferred width).


For now, I think it's just important to avoid relying heavily on the width-snapping for dialogs with multiline text. Worded as a guideline, we could say,

"The width of a dialog should always be predominantly determined by WidgetDelegate::GetContentsView()->GetPreferredSize().width(). If width-snapping or the button row causes the contents view to get a different width it's probably a bug. The width may need to be locale-specific when button label widths are long vary significantly." Under harmony, this width should be 288, 416 or 480.


This guideline doesn't really cater for large font sizes. That's when Font::GetExpectedTextWidth() was more useful. A "guide" width that we use for all dialogs to determine which of 288, 416 or 480 should be chosen for {small, medium, large} dialogs might be the way to resolve this.
 
bulgarian_16pt_no_button.png
75.2 KB View Download
bulgarian_16pt_with_button.png
92.0 KB View Download
Labels: Proj-HarmonyDialogs
I think the right answer here is that most dialogs should implement functionality akin to:

GetPreferredWidth()
GetHeightForWidth()

And final layout should involve calling the first, snapping/adjusting it, then passing it to the second to get the final height.

As to how GetPreferredWidth()-like functionality is declared in the API, there are a couple possibilities:

(1) Use the existing GetPreferredSize() method, the caller always ignores the height.
(2) Use the existing GetPreferredSize() method, the caller ignores the height if it's zero, or uses it exactly (not calling back to GetHeightForWidth()) if it's nonzero.
(3) Add a new GetPreferredWidth() method.
(4) One of the above, but also add some kind of bool- or enum-returning function that tells callers how to compute heights.

I think (4) is unnecessarily complicated.  Any of the others would work.

Fixing this should happen after Harmony phase 1, but shouldn't be delayed indefinitely, because not fixing it creates incentive to size dialog components (like labels) more inflexibly.

Comment 2 by pbos@chromium.org, Nov 3 2017

Cc: pbos@chromium.org
Status: Archived (was: Available)
Archiving old bugs that haven't been actively assigned in over 180 days.

If you feel this issue should still be addressed, feel free to reopen it or to file a new issue. Thanks!
Archiving old bugs that haven't been actively assigned in over 180 days.

If you feel this issue should still be addressed, feel free to reopen it or to file a new issue. Thanks!

Sign in to add a comment