From 0daa76e032c9a0031fbdc00756a139fb13929c73 Mon Sep 17 00:00:00 2001 From: matthewblackman Date: Thu, 4 May 2023 11:00:14 -0400 Subject: [PATCH] Make info display scene-specific - see https://github.com/phetsims/center-and-variability/issues/164 --- js/common/view/SceneView.ts | 23 ++++++++++++++++++++ js/variability/view/VariabilityScreenView.ts | 19 ---------------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/js/common/view/SceneView.ts b/js/common/view/SceneView.ts index 68addf0f..28b48128 100644 --- a/js/common/view/SceneView.ts +++ b/js/common/view/SceneView.ts @@ -14,6 +14,10 @@ import ModelViewTransform2 from '../../../../phetcommon/js/view/ModelViewTransfo import DragIndicatorArrowNode from './DragIndicatorArrowNode.js'; import PlayAreaMedianIndicatorNode from './PlayAreaMedianIndicatorNode.js'; import AccordionBox from '../../../../sun/js/AccordionBox.js'; +import InfoDialog from '../../variability/view/InfoDialog.js'; +import VariabilitySceneModel from '../../variability/model/VariabilitySceneModel.js'; +import VariabilityModel from '../../variability/model/VariabilityModel.js'; +import Multilink from '../../../../axon/js/Multilink.js'; export default class SceneView { @@ -148,6 +152,25 @@ export default class SceneView { soccerPlayerNodes.forEach( soccerPlayerNode => frontObjectLayer.addChild( soccerPlayerNode ) ); + const varModel = model as VariabilityModel; + const varSceneModel = sceneModel as VariabilitySceneModel; + + if ( varModel && varModel.isInfoShowingProperty && varModel.selectedSceneModelProperty && varSceneModel ) { + const infoDialog = new InfoDialog( varModel, varSceneModel, { + tandem: options.tandem.createTandem( 'infoDialog' ) + } ); + + Multilink.multilink( [ varModel.isInfoShowingProperty, varSceneModel.isVisibleProperty ], + ( isInfoShowing, isVisible ) => { + if ( isInfoShowing && isVisible ) { + infoDialog.show(); + } + else { + infoDialog.hide(); + } + } ); + } + model.isShowingPlayAreaMedianProperty.link( this.updateMedianNode ); } } diff --git a/js/variability/view/VariabilityScreenView.ts b/js/variability/view/VariabilityScreenView.ts index c79c1271..a745580d 100644 --- a/js/variability/view/VariabilityScreenView.ts +++ b/js/variability/view/VariabilityScreenView.ts @@ -17,12 +17,10 @@ import CenterAndVariabilityStrings from '../../CenterAndVariabilityStrings.js'; import { AlignGroup, ManualConstraint } from '../../../../scenery/js/imports.js'; import SceneRadioButtonGroup from './SceneRadioButtonGroup.js'; import VariabilityMeasureRadioButtonGroup from './VariabilityMeasureRadioButtonGroup.js'; -import InfoDialog from './InfoDialog.js'; import CAVScreenView, { CAVScreenViewOptions } from '../../common/view/CAVScreenView.js'; import VariabilityAccordionBox from './VariabilityAccordionBox.js'; import BottomRepresentationCheckboxGroup from '../../common/view/BottomRepresentationCheckboxGroup.js'; import CAVConstants from '../../common/CAVConstants.js'; -import VariabilitySceneModel from '../model/VariabilitySceneModel.js'; type SelfOptions = EmptySelfOptions; type VariabilityScreenViewOptions = SelfOptions & StrictOmit; @@ -66,23 +64,6 @@ export default class VariabilityScreenView extends CAVScreenView { this.addChild( sceneRadioButtonGroup ); this.addChild( variabilityMeasureRadioButtonGroup ); - model.sceneModels.forEach( sceneModel => { - - // TODO: Should the info dialogs be in SceneView? Probably. - // TODO: Only show the one for the selected scene - const infoDialog = new InfoDialog( model, sceneModel as VariabilitySceneModel, { - tandem: options.tandem.createTandem( 'infoDialog' ) - } ); - model.isInfoShowingProperty.link( isInfoShowing => { - if ( isInfoShowing ) { - infoDialog.show(); - } - else { - infoDialog.hide(); - } - } ); - } ); - const iconGroup = new AlignGroup(); this.setBottomCheckboxGroup( [ BottomRepresentationCheckboxGroup.getVariabilityCheckboxItem( iconGroup, model ),