Skip to content

Commit

Permalink
Pad bounds if icon is too short, see #217
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Aug 27, 2022
1 parent e7aba61 commit 4ee2f8e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions js/common/view/CollisionLabIconFactory.js
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ import AssertUtils from '../../../../phetcommon/js/AssertUtils.js';
import ArrowNode from '../../../../scenery-phet/js/ArrowNode.js';
import PhetFont from '../../../../scenery-phet/js/PhetFont.js';
import XNode from '../../../../scenery-phet/js/XNode.js';
import { Circle, Color, Node, PaintDef, Path, Spacer, Text } from '../../../../scenery/js/imports.js';
import { Rectangle, Circle, Color, Node, PaintDef, Path, Spacer, Text } from '../../../../scenery/js/imports.js';
import undoSolidShape from '../../../../sherpa/js/fontawesome-5/undoSolidShape.js';
import collisionLab from '../../collisionLab.js';
import collisionLabStrings from '../../collisionLabStrings.js';
@@ -190,10 +190,16 @@ const CollisionLabIconFactory = {

// For the 'Custom' preset, the icon is just a Text instance that displays 'Custom'.
if ( inelasticPreset === InelasticPreset.CUSTOM ) {
return new Text( collisionLabStrings.custom, {
const text = new Text( collisionLabStrings.custom, {
font: CollisionLabConstants.CONTROL_FONT,
maxWidth: 120 // constrain width for i18n, determined empirically
} );
if ( text.height < 10 ) {
return new Rectangle( 0, 0, text.width, 10, {
children: [ text ]
} );
}
return text;
}
else {
return createBallSystemSnapshotIcon( inelasticPreset.ballStates );

0 comments on commit 4ee2f8e

Please sign in to comment.