phetsims / sun

User-interface components for PhET simulations, built on top of Scenery.
MIT License
4 stars 12 forks source link

Layout of ABSwitch does not support dynamic labels. #770

Closed pixelzoom closed 2 years ago

pixelzoom commented 2 years ago

I'm still seeing this problem in MOTHA. The UI component shown below is an ABSwitch, and it's text labels have been changed via Studio. Note the overlap of the left label with the switch.

screenshot_1701

To reproduce in Studio, the phetio IDs are:

modelsOfTheHydrogenAtom.spectraScreen.view.experimentPredictionSwitch.experimentNode.textProperty modelsOfTheHydrogenAtom.spectraScreen.view.experimentPredictionSwitch.predictionNode.textProperty

Looking at ABSwitch, the problem is that it does not use an HBox for layout. It has it's own layout code, which does not support dynamic layout. So the fix is likely to use HBox.

pixelzoom commented 2 years ago

Sims that use ABSwitch or a subclass:

† uses centerOnButton option

pixelzoom commented 2 years ago

In the above commits:

Usages were modified as needed, and all sims identified in https://github.com/phetsims/sun/issues/770#issuecomment-1163459590 were tested.

Since this was all pretty trivial, and everyone is busy, I'm going to forgo review. I've done a PSA to Slack#developer. Closing.