Skip to content

Commit

Permalink
make disposal support (or lack thereof) explicit, see #336
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Jul 14, 2023
1 parent a0750a4 commit 75b6e50
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 5 deletions.
2 changes: 2 additions & 0 deletions js/common/view/GreenhouseEffectObservationWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class GreenhouseEffectObservationWindow extends Node {
// https://github.com/phetsims/phet-core/issues/128
const options = optionize<GreenhouseEffectObservationWindowOptions, StrictOmit<SelfOptions, 'fluxMeterNodeOptions'>, NodeOptions>()( {

isDisposable: false,

// default position in the GreenhouseEffect sim
left: GreenhouseEffectConstants.SCREEN_VIEW_X_MARGIN,
top: GreenhouseEffectConstants.SCREEN_VIEW_Y_MARGIN,
Expand Down
1 change: 1 addition & 0 deletions js/common/view/GreenhouseEffectScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class GreenhouseEffectScreenView extends ScreenView {
providedOptions: GreenhouseEffectScreenViewOptions ) {

const options = optionize<GreenhouseEffectScreenViewOptions, SelfOptions, ScreenViewOptions>()( {
isDisposable: false,
useClippingFrame: false,
energyLegendOptions: { tandem: providedOptions.tandem.createTandem( 'energyLegend' ) }
}, providedOptions );
Expand Down
3 changes: 2 additions & 1 deletion js/layer-model/LayerModelScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class LayerModelScreen extends Screen<LayerModelModel, LayerModelScreenView> {
maxDT: GreenhouseEffectConstants.MAX_DT,
tandem: tandem,
name: GreenhouseEffectStrings.screen.layerModelStringProperty,
createKeyboardHelpNode: () => new GreenhouseEffectKeyboardHelpContent( { includeFluxMeterHelp: true } )
createKeyboardHelpNode: () => new GreenhouseEffectKeyboardHelpContent( { includeFluxMeterHelp: true } ),
isDisposable: false
};

super(
Expand Down
6 changes: 6 additions & 0 deletions js/layer-model/view/InfraredAbsorbanceSoundPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import SoundGenerator from '../../../../tambo/js/sound-generators/SoundGenerator
import TSoundPlayer from '../../../../tambo/js/TSoundPlayer.js';
import layerModelBaseSliderSound_mp3 from '../../../sounds/layerModelBaseSliderSound_mp3.js';
import phetAudioContext from '../../../../tambo/js/phetAudioContext.js';
import Disposable from '../../../../axon/js/Disposable.js';

class InfraredAbsorbanceSoundPlayer extends SoundGenerator implements TSoundPlayer {

Expand Down Expand Up @@ -85,6 +86,11 @@ class InfraredAbsorbanceSoundPlayer extends SoundGenerator implements TSoundPlay
this.middleSoundClip.stop();
this.boundarySoundClip.stop();
}

// This is intended to exist for the life of the sim, so disposal is not supported.
public override dispose(): void {
Disposable.assertNotDisposable();
}
}

greenhouseEffect.register( 'InfraredAbsorbanceSoundPlayer', InfraredAbsorbanceSoundPlayer );
Expand Down
1 change: 1 addition & 0 deletions js/layer-model/view/InfraredPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default class InfraredPanel extends Panel {
yMargin: PANEL_MARGIN,
align: 'center' as const,
fill: GreenhouseEffectColors.controlPanelBackgroundColorProperty,
isDisposable: false,

// pdom
tagName: 'div',
Expand Down
6 changes: 6 additions & 0 deletions js/layer-model/view/NumberOfLayersSoundPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import twoAbsorbingLayers_mp3 from '../../../sounds/twoAbsorbingLayers_mp3.js';
import threeAbsorbingLayers_mp3 from '../../../sounds/threeAbsorbingLayers_mp3.js';
import TSoundPlayer from '../../../../tambo/js/TSoundPlayer.js';
import TRangedProperty from '../../../../axon/js/TRangedProperty.js';
import Disposable from '../../../../axon/js/Disposable.js';

class NumberOfLayersSoundPlayer extends SoundGenerator implements TSoundPlayer {

Expand Down Expand Up @@ -56,6 +57,11 @@ class NumberOfLayersSoundPlayer extends SoundGenerator implements TSoundPlayer {
public stop(): void {
// Nothing to do in this case.
}

// This is intended to exist for the life of the sim, so disposal is not supported.
public override dispose(): void {
Disposable.assertNotDisposable();
}
}

greenhouseEffect.register( 'NumberOfLayersSoundPlayer', NumberOfLayersSoundPlayer );
Expand Down
3 changes: 2 additions & 1 deletion js/layer-model/view/ShowTemperatureCheckbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class ShowTemperatureCheckbox extends Checkbox {
} );

const options = optionize<ShowTemperatureCheckboxOptions, SelfOptions, CheckboxOptions>()( {
boxWidth: 15
boxWidth: 15,
isDisposable: false
}, providedOptions );

super( property, thermometerIcon, options );
Expand Down
3 changes: 2 additions & 1 deletion js/layer-model/view/SolarIntensityControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export default class SolarIntensityControl extends VBox {
maxSoundPlayer: solarIntensitySoundPlayer
},
tandem: tandem.createTandem( 'slider' ),
phetioVisiblePropertyInstrumented: false
phetioVisiblePropertyInstrumented: false,
isDisposable: false
} )
);

Expand Down
6 changes: 6 additions & 0 deletions js/layer-model/view/SolarIntensitySoundPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import phetAudioContext from '../../../../tambo/js/phetAudioContext.js';
import TSoundPlayer from '../../../../tambo/js/TSoundPlayer.js';
import SoundGenerator from '../../../../tambo/js/sound-generators/SoundGenerator.js';
import TRangedProperty from '../../../../axon/js/TRangedProperty.js';
import Disposable from '../../../../axon/js/Disposable.js';

class SolarIntensitySoundPlayer extends SoundGenerator implements TSoundPlayer {

Expand Down Expand Up @@ -88,6 +89,11 @@ class SolarIntensitySoundPlayer extends SoundGenerator implements TSoundPlayer {
this.middleSoundClip.stop();
this.boundarySoundClip.stop();
}

// This is intended to exist for the life of the sim, and disposal is not supported.
public override dispose(): void {
Disposable.assertNotDisposable();
}
}

greenhouseEffect.register( 'SolarIntensitySoundPlayer', SolarIntensitySoundPlayer );
Expand Down
1 change: 1 addition & 0 deletions js/layer-model/view/SunlightPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default class SunlightPanel extends Panel {
yMargin: PANEL_MARGIN,
align: 'center' as const,
fill: GreenhouseEffectColors.controlPanelBackgroundColorProperty,
isDisposable: false,

// pdom
tagName: 'div',
Expand Down
1 change: 1 addition & 0 deletions js/layer-model/view/SurfaceAlbedoControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default class SurfaceAlbedoControl extends VBox {
middleMovingUpSoundPlayer: surfaceAlbedoSoundPlayer,
middleMovingDownSoundPlayer: surfaceAlbedoSoundPlayer
},
isDisposable: false,
tandem: tandem.createTandem( 'slider' ),
phetioVisiblePropertyInstrumented: false
} )
Expand Down
6 changes: 6 additions & 0 deletions js/layer-model/view/SurfaceAlbedoSoundPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import TSoundPlayer from '../../../../tambo/js/TSoundPlayer.js';
import phetAudioContext from '../../../../tambo/js/phetAudioContext.js';
import emptyApartmentBedroom06Resampled_mp3 from '../../../../tambo/sounds/emptyApartmentBedroom06Resampled_mp3.js';
import TRangedProperty from '../../../../axon/js/TRangedProperty.js';
import Disposable from '../../../../axon/js/Disposable.js';

class SurfaceAlbedoSoundPlayer extends SoundGenerator implements TSoundPlayer {

Expand Down Expand Up @@ -80,6 +81,11 @@ class SurfaceAlbedoSoundPlayer extends SoundGenerator implements TSoundPlayer {
this.primarySoundClip.stop();
this.boundarySoundClip.stop();
}

// This is intended to exist for the life of the sim, and disposal is not supported.
public override dispose(): void {
Disposable.assertNotDisposable();
}
}

greenhouseEffect.register( 'SurfaceAlbedoSoundPlayer', SurfaceAlbedoSoundPlayer );
Expand Down
5 changes: 3 additions & 2 deletions js/layer-model/view/TemperatureUnitsControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ class TemperatureUnitsControl extends VBox {

// Put the label and radio buttons together in the VBox.
super( {
tandem: tandem,
children: [ text, temperatureUnitsRadioButtonGroup ],
align: 'left',
spacing: 3,
visiblePropertyOptions: {
phetioFeatured: true // see https://github.com/phetsims/greenhouse-effect/issues/318
}
},
tandem: tandem,
isDisposable: false
} );
}
}
Expand Down

0 comments on commit 75b6e50

Please sign in to comment.