Skip to content

Commit

Permalink
make EnergyCheckbox hideable via PhET-iO, #69
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Dec 26, 2022
1 parent 76ff711 commit 23fae38
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion js/energy/view/EnergyCheckbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Shape } from '../../../../kite/js/imports.js';

type SelfOptions = EmptySelfOptions;

type EnergyCheckboxOptions = SelfOptions & PickRequired<CheckboxOptions, 'tandem' | 'enabledProperty'>;
type EnergyCheckboxOptions = SelfOptions & PickRequired<CheckboxOptions, 'tandem' | 'visibleProperty' | 'enabledProperty'>;

export default class EnergyCheckbox extends Checkbox {

Expand Down
12 changes: 8 additions & 4 deletions js/energy/view/EnergyVisibilityPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import DerivedProperty from '../../../../axon/js/DerivedProperty.js';
import merge from '../../../../phet-core/js/merge.js';
import { HBox, HSeparator, HStrut, VBox } from '../../../../scenery/js/imports.js';
import { HSeparator, VBox } from '../../../../scenery/js/imports.js';
import Panel from '../../../../sun/js/Panel.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import HookesLawColors from '../../common/HookesLawColors.js';
Expand Down Expand Up @@ -47,6 +47,12 @@ export default class EnergyVisibilityPanel extends Panel {
tandem: options.tandem.createTandem( 'energyCheckbox' )
} );

const energyCheckboxWrapper = new VBox( {
children: [ energyCheckbox ],
layoutOptions: { leftMargin: 25 }, // indented from check boxes
visibleProperty: energyGraphRadioButtonGroup.getButton( EnergyGraph.FORCE_PLOT ).visibleProperty
} );

const appliedForceCheckbox = new VectorCheckbox( properties.appliedForceVectorVisibleProperty,
HookesLawStrings.appliedForceStringProperty, {
vectorType: 'force',
Expand Down Expand Up @@ -81,9 +87,7 @@ export default class EnergyVisibilityPanel extends Panel {
const content = new VBox( {
children: [
energyGraphRadioButtonGroup,

// "Energy" checkbox indented below energyGraphRadioButtonGroup
new HBox( { children: [ new HStrut( 25 ), energyCheckbox ] } ),
energyCheckboxWrapper,
new HSeparator( HookesLawConstants.HSEPARATOR_OPTIONS ),
appliedForceCheckbox,
displacementCheckbox,
Expand Down

0 comments on commit 23fae38

Please sign in to comment.