Skip to content

Commit

Permalink
create controlling visibleProperties for mass/diameter for all Projec…
Browse files Browse the repository at this point in the history
…tileObjectTypes in the panel, #260
  • Loading branch information
zepumph committed Jul 29, 2021
1 parent 29177d5 commit 756b8bb
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions js/lab/view/LabProjectileControlPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 } );

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 756b8bb

Please sign in to comment.