From 6010dba5735fbbb0be0649e26d8f75d98b814fcb Mon Sep 17 00:00:00 2001 From: Sam Reid Date: Mon, 15 Apr 2024 09:57:19 -0600 Subject: [PATCH] Use ResetAllButton.isResettingAllProperty, see https://github.com/phetsims/projectile-data-lab/issues/290 (cherry picked from commit d9a59d5910d845ac8001fb2d29840402447fdc4d) --- js/common/model/isResettingAllProperty.ts | 25 ----------------------- js/common/view/PDLScreenView.ts | 5 ----- js/measures/view/IntervalToolNode.ts | 8 ++++---- 3 files changed, 4 insertions(+), 34 deletions(-) delete mode 100644 js/common/model/isResettingAllProperty.ts diff --git a/js/common/model/isResettingAllProperty.ts b/js/common/model/isResettingAllProperty.ts deleted file mode 100644 index 2cbe39a9..00000000 --- a/js/common/model/isResettingAllProperty.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2024, University of Colorado Boulder - -/** - * isResettingAllProperty is a global Property that is true while a 'reset all' is in progress. - * It is intended to be added to the ResetAllButton in a ScreenView like this: - * - * new ResetAllButton( { - * listener: () => { - * isResettingAllProperty.value = true; - * ... // Reset things here. - * isResettingAllProperty.value = false; - * } - * } ); - * - * @author Chris Malley (PixelZoom, Inc.) - */ - -import projectileDataLab from '../../projectileDataLab.js'; -import BooleanProperty from '../../../../axon/js/BooleanProperty.js'; - -const isResettingAllProperty = new BooleanProperty( false ); - -projectileDataLab.register( 'isResettingAllProperty', isResettingAllProperty ); - -export default isResettingAllProperty; \ No newline at end of file diff --git a/js/common/view/PDLScreenView.ts b/js/common/view/PDLScreenView.ts index f1b5c614..aa2322b0 100644 --- a/js/common/view/PDLScreenView.ts +++ b/js/common/view/PDLScreenView.ts @@ -35,7 +35,6 @@ import FieldSignNode from './FieldSignNode.js'; import EraserButton from '../../../../scenery-phet/js/buttons/EraserButton.js'; import PDLPreferences from '../PDLPreferences.js'; import DerivedProperty from '../../../../axon/js/DerivedProperty.js'; -import isResettingAllProperty from '../model/isResettingAllProperty.js'; import Multilink from '../../../../axon/js/Multilink.js'; type SelfOptions = { @@ -125,13 +124,9 @@ export default abstract class PDLScreenView extends ScreenView this.resetAllButton = new ResetAllButton( { tandem: options.tandem.createTandem( 'resetAllButton' ), listener: () => { - isResettingAllProperty.value = true; - this.interruptSubtreeInput(); // cancel interactions that may be in progress model.reset(); this.reset(); - - isResettingAllProperty.value = false; }, phetioFeatured: true } ); diff --git a/js/measures/view/IntervalToolNode.ts b/js/measures/view/IntervalToolNode.ts index 2bfb21af..7336e346 100644 --- a/js/measures/view/IntervalToolNode.ts +++ b/js/measures/view/IntervalToolNode.ts @@ -39,8 +39,8 @@ import AccessibleSlider, { AccessibleSliderOptions } from '../../../../sun/js/ac import Bounds2 from '../../../../dot/js/Bounds2.js'; import DynamicProperty from '../../../../axon/js/DynamicProperty.js'; import TReadOnlyProperty from '../../../../axon/js/TReadOnlyProperty.js'; -import isResettingAllProperty from '../../common/model/isResettingAllProperty.js'; import Multilink from '../../../../axon/js/Multilink.js'; +import ResetAllButton from '../../../../scenery-phet/js/buttons/ResetAllButton.js'; const edgeFilter = new BiquadFilterNode( phetAudioContext, { type: 'lowpass', @@ -487,7 +487,7 @@ export default class IntervalToolNode extends Node { // When dragging an edge or resetting, update the drag bounds of the center so that it can't go out of bounds with the new separation. Multilink.multilink( [ intervalTool.edge1Property, intervalTool.edge2Property, this.isCenterDraggingProperty, - this.isEdge1DraggingProperty, this.isEdge2DraggingProperty, isResettingAllProperty ], + this.isEdge1DraggingProperty, this.isEdge2DraggingProperty, ResetAllButton.isResettingAllProperty ], ( edge1, edge2, isCenterDragging, isEdge1Dragging, isEdge2Dragging, isResettingAll ) => { const isDraggingEdgeOnly = ( isEdge1Dragging || isEdge2Dragging ) && !isCenterDragging; if ( isDraggingEdgeOnly || isResettingAll ) { @@ -524,7 +524,7 @@ export default class IntervalToolNode extends Node { const createEdgeSonificationListener = ( otherEdgeProperty: { value: number } ) => { return ( newValue: number, oldValue: number ) => { - if ( isResettingAllProperty.value ) { + if ( ResetAllButton.isResettingAllProperty.value ) { return; } @@ -563,7 +563,7 @@ export default class IntervalToolNode extends Node { } ); centerPositionSonificationProperty.lazyLink( ( newValue: number, oldValue: number ) => { - if ( this.isCenterDraggingProperty.value && !isResettingAllProperty.value ) { + if ( this.isCenterDraggingProperty.value && !ResetAllButton.isResettingAllProperty.value ) { centerValueChangeSoundPlayer.playSoundIfThresholdReached( newValue, oldValue ); } } );