Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HSlider doesn't play well with panels that expand for i18n #378

Closed
arouinfar opened this issue Aug 15, 2018 · 3 comments
Closed

HSlider doesn't play well with panels that expand for i18n #378

arouinfar opened this issue Aug 15, 2018 · 3 comments
Assignees

Comments

@arouinfar
Copy link
Contributor

arouinfar commented Aug 15, 2018

A common strategy for i18n is to allow panels to expand by some amount before scaling down the contents/strings within.

Masses and Springs contains a panel with some pretty long strings, so I requested this behavior, which ended up leading to a bit of refactoring, and ultimately required that the default panel width itself be wider, as @Denz1994 explained in phetsims/masses-and-springs#308 (comment):

After further investigation, there are a few things to consider. The contents of the panel is already being scaled because the panel is too small for the default sizes of the contents (hSlider in particular). If we change the maxWidth of the panel it will change the scale of its contents automatically because the contents will have more space to expand to its default size.

Other relevant MAS i18n issues include:
phetsims/masses-and-springs#293
phetsims/masses-and-springs#313

I found this pretty surprising, given that there are many other expanding panels containing HSlider or numberControl (examples below), and that the panel widths in MAS rc.2 weren't particularly small. In the case of MAS, I was okay with making the default widths a bit wider, but there are likely other sims where I wouldn't want to make the default widths larger because it would be too visually heavy or crowded.

I was hoping that the devs could look into this and see if there is a more general solution than giving panels with HSlider a larger default width, so @ariel-phet recommended I open this issue.

Bending Light
screen shot 2018-08-15 at 11 54 56 am
screen shot 2018-08-15 at 11 55 04 am

Rutherford Scattering
screen shot 2018-08-15 at 11 54 28 am
screen shot 2018-08-15 at 11 54 35 am

CCK:DC
screen shot 2018-08-15 at 11 55 24 am
screen shot 2018-08-15 at 11 55 32 am

Here's a comparison of MAS rc.2 (original panel widths) and rc.3 (larger default panel widths):
screen shot 2018-08-15 at 12 10 43 pm
screen shot 2018-08-15 at 12 10 54 pm

@ariel-phet I know you had talked about this with @Denz1994, so can you add a bit onto this issue? I'm not sure if I've adequately described things for the devs. Also not sure if the title is appropriate or not.

@Denz1994
Copy link
Contributor

A generalization of this behavior extends to Panels whose content has default sizes that are larger than the Panel. This behavior was also present in the VerticalCheckboxGroup above the gravity slider.

The current solution involves making the Panel larger so the content fits its default size. There is room for discussion on a general solution.

@pixelzoom
Copy link
Contributor

pixelzoom commented Aug 22, 2018

I don't understand what the problem is here. Developers can set (and should be setting) independent maxWidth values for all of the text elements in HSlider and NumberControl. That includes title, tick labels, etc. Additionally, they may set maxWidth on the entire UIComponent. So unless you decide the you need more width to accommodate English (or translated) strings, there's no need to make a Panel wider.

@Denz1994
Copy link
Contributor

Considering the above comments from @pixelzoom and further discussion with @jonathanolson, I should not be using maxWidths to size texts or nodes. Instead, they should be sized using font, scale, etc. and then a maxWidth should be applied.

There isn't anything that needs to be added to common code but instead, this revised approach should be taken in the future to negate the need to refactor sim code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants