From 756b8bbb52f9a7cfc5b7dbae4b5183f59b49dbda Mon Sep 17 00:00:00 2001 From: zepumph Date: Thu, 29 Jul 2021 11:10:41 -0400 Subject: [PATCH] create controlling visibleProperties for mass/diameter for all ProjectileObjectTypes in the panel, https://github.com/phetsims/projectile-motion/issues/260 --- js/lab/view/LabProjectileControlPanel.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/js/lab/view/LabProjectileControlPanel.js b/js/lab/view/LabProjectileControlPanel.js index 94fa025b..6b8dcf99 100644 --- a/js/lab/view/LabProjectileControlPanel.js +++ b/js/lab/view/LabProjectileControlPanel.js @@ -6,6 +6,7 @@ * @author Andrea Lin (PhET Interactive Simulations) */ +import BooleanProperty from '../../../../axon/js/BooleanProperty.js'; import Dimension2 from '../../../../dot/js/Dimension2.js'; import Utils from '../../../../dot/js/Utils.js'; import merge from '../../../../phet-core/js/merge.js'; @@ -83,6 +84,18 @@ class LabProjectileControlPanel extends Node { // @private; this.textDisplayWidth = options.textDisplayWidth * 1.4; + // @private - toggle the visibility of all ProjectileObjectType mass NumberControls with a single Property. Created + // for PhET-iO. + this.massNumberControlsVisibleProperty = new BooleanProperty( true, { + tandem: options.tandem.createTandem( 'massNumberControlsVisibleProperty' ) + } ); + + // @private - toggle the visibility of all ProjectileObjectType diameter NumberControls with a single Property. Created + // for PhET-iO. + this.diameterNumberControlsVisibleProperty = new BooleanProperty( true, { + tandem: options.tandem.createTandem( 'diameterNumberControlsVisibleProperty' ) + } ); + // maxWidth empirically determined for labels in the dropdown const itemNodeOptions = merge( {}, LABEL_OPTIONS, { maxWidth: 170 } ); @@ -373,6 +386,16 @@ class LabProjectileControlPanel extends Node { dragCoefficientText.text = `${dragCoefficientString}: ${Utils.toFixed( dragCoefficient, 2 )}`; } ); + + // One direction of control. Instead of linking both to each other. This allows a single, global control to switch + // all types' visibility at once, while also allowing a single numberControl the flexibility to hide itself. + this.massNumberControlsVisibleProperty.link( visible => { + massNumberControl.visibleProperty.value = visible; + } ); + this.diameterNumberControlsVisibleProperty.link( visible => { + diameterNumberControl.visibleProperty.value = visible; + } ); + return new ProjectileObjectTypeControl( massNumberControl, diameterNumberControl,