Skip to content

Commit

Permalink
Make info display scene-specific - see #164
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-blackman committed May 4, 2023
1 parent 92aa3b1 commit 0daa76e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
23 changes: 23 additions & 0 deletions js/common/view/SceneView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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 );
}
}
Expand Down
19 changes: 0 additions & 19 deletions js/variability/view/VariabilityScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<CAVScreenViewOptions, 'questionBarOptions'>;
Expand Down Expand Up @@ -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 ),
Expand Down

0 comments on commit 0daa76e

Please sign in to comment.