From 4ee2f8ee4c0086e54c008b9835b7c3d3fe3c4f6e Mon Sep 17 00:00:00 2001 From: Sam Reid Date: Sat, 27 Aug 2022 11:09:14 -0600 Subject: [PATCH] Pad bounds if icon is too short, see https://github.com/phetsims/collision-lab/issues/217 --- js/common/view/CollisionLabIconFactory.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/js/common/view/CollisionLabIconFactory.js b/js/common/view/CollisionLabIconFactory.js index d486bf6..928b0dd 100644 --- a/js/common/view/CollisionLabIconFactory.js +++ b/js/common/view/CollisionLabIconFactory.js @@ -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 );