Skip to content

Commit

Permalink
Standardize options, see: #67
Browse files Browse the repository at this point in the history
  • Loading branch information
marlitas committed Aug 25, 2022
1 parent 89851b6 commit 2025b41
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 22 deletions.
18 changes: 12 additions & 6 deletions js/common/view/MeanShareAndBalanceScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ export default class MeanShareAndBalanceScreenView extends ScreenView {
super( options );

this.questionBar = new QuestionBar( this.layoutBounds, this.visibleBoundsProperty, {
tandem: options.tandem.createTandem( 'questionBar' ),
labelText: questionBarText.value,
barFill: questionBarColor
barFill: questionBarColor,

// phet-io
tandem: options.tandem.createTandem( 'questionBar' )
} );

const playAreaBounds = new Bounds2( this.layoutBounds.minX, this.layoutBounds.minY + this.questionBar.height,
Expand All @@ -71,10 +73,12 @@ export default class MeanShareAndBalanceScreenView extends ScreenView {
new Property( MeanShareAndBalanceConstants.NUMBER_SPINNER_RANGE ),
{
arrowsPosition: 'leftRight',
tandem: options.tandem.createTandem( 'numberSpinner' ),
layoutOptions: {
align: 'left'
}
},

// phet-io
tandem: options.tandem.createTandem( 'numberSpinner' )
}
);

Expand All @@ -91,9 +95,11 @@ export default class MeanShareAndBalanceScreenView extends ScreenView {
model.reset();
this.reset();
},
tandem: options.tandem.createTandem( 'resetAllButton' ),
right: this.layoutBounds.maxX - MeanShareAndBalanceConstants.SCREEN_VIEW_X_MARGIN,
bottom: this.layoutBounds.maxY - MeanShareAndBalanceConstants.SCREEN_VIEW_Y_MARGIN
bottom: this.layoutBounds.maxY - MeanShareAndBalanceConstants.SCREEN_VIEW_Y_MARGIN,

// phet-io
tandem: options.tandem.createTandem( 'resetAllButton' )
} );

this.controlsVBox = new VBox( {
Expand Down
15 changes: 11 additions & 4 deletions js/intro/model/IntroModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,19 @@ export default class IntroModel extends MeanShareAndBalanceModel {
super( options );

this.meanPredictionProperty = new NumberProperty( 0, {
range: MeanShareAndBalanceConstants.WATER_LEVEL_RANGE,

// phet-io
tandem: options.tandem.createTandem( 'meanPredictionProperty' ),
phetioDocumentation: 'Indicates where the user predicted the mean would be, or the default value at startup',
range: MeanShareAndBalanceConstants.WATER_LEVEL_RANGE
phetioDocumentation: 'Indicates where the user predicted the mean would be, or the default value at startup'
} );

this.numberOfCupsProperty = new NumberProperty( MeanShareAndBalanceConstants.INITIAL_NUMBER_OF_CUPS, {
tandem: options.tandem.createTandem( 'numberOfCupsProperty' ),
numberType: 'Integer',
range: this.numberOfCupsRange
range: this.numberOfCupsRange,

// phetio
tandem: options.tandem.createTandem( 'numberOfCupsProperty' )
} );

this.arePipesOpenProperty = new BooleanProperty( false, {
Expand Down Expand Up @@ -97,6 +101,8 @@ export default class IntroModel extends MeanShareAndBalanceModel {
const pipe = new Pipe( this.arePipesOpenProperty, {
position: position2D,
isActive: i === 0,

// phet-io
tandem: options.tandem.createTandem( `pipe${i}` )
} );
this.pipeArray.push( pipe );
Expand All @@ -117,6 +123,7 @@ export default class IntroModel extends MeanShareAndBalanceModel {
return mean;
},
{
// phet-io
tandem: options.tandem.createTandem( 'meanProperty' ),
phetioDocumentation: 'The ground-truth water-level mean.',
phetioValueType: NumberIO
Expand Down
2 changes: 2 additions & 0 deletions js/intro/model/Pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export default class Pipe extends PhetioObject {
public constructor( arePipesOpenProperty: Property<boolean>, providedOptions?: PipeOptions ) {
const options = optionize<PipeOptions, SelfOptions, PhetioObjectOptions>()( {
isActive: false,

// phet-io
phetioType: Pipe.PipeIO
}, providedOptions );

Expand Down
3 changes: 3 additions & 0 deletions js/intro/model/WaterCup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export default class WaterCup {
}, providedOptions );

this.isActiveProperty = new BooleanProperty( options.isActive, {
// phet-io
tandem: tandem.createTandem( 'isActiveProperty' ),
phetioReadOnly: true
} );
Expand All @@ -74,6 +75,8 @@ export default class WaterCup {
} );
this.waterLevelProperty = new NumberProperty( options.waterLevel, combineOptions<NumberPropertyOptions>( {
range: new Range( MeanShareAndBalanceConstants.WATER_LEVEL_RANGE_MIN, MeanShareAndBalanceConstants.WATER_LEVEL_RANGE_MAX ),

// phet-io
tandem: tandem.createTandem( 'waterLevelProperty' )
}, options.waterLevelPropertyOptions ) );

Expand Down
18 changes: 12 additions & 6 deletions js/intro/view/IntroControlPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,24 @@ export default class IntroControlPanel extends Node {
const introOptionsCheckboxGroup = new VerticalCheckboxGroup( [ {
node: predictMeanText,
property: predictMeanVisibleProperty,
tandem: introOptionsCheckboxGroupTandem.createTandem( 'predictMeanCheckbox' ),
options: { accessibleName: meanShareAndBalanceStrings.predictMean }
options: { accessibleName: meanShareAndBalanceStrings.predictMean },

// phet-io
tandem: introOptionsCheckboxGroupTandem.createTandem( 'predictMeanCheckbox' )
}, {
node: meanText,
property: meanVisibleProperty,
tandem: introOptionsCheckboxGroupTandem.createTandem( 'meanCheckbox' ),
options: { accessibleName: meanShareAndBalanceStrings.mean }
options: { accessibleName: meanShareAndBalanceStrings.mean },

// phet-io
tandem: introOptionsCheckboxGroupTandem.createTandem( 'meanCheckbox' )
}, {
node: tickMarksText,
property: tickMarksVisibleProperty,
tandem: introOptionsCheckboxGroupTandem.createTandem( 'tickMarksCheckbox' ),
options: { accessibleName: meanShareAndBalanceStrings.tickMarks }
options: { accessibleName: meanShareAndBalanceStrings.tickMarks },

// phet-io
tandem: introOptionsCheckboxGroupTandem.createTandem( 'tickMarksCheckbox' )
} ], {

checkboxOptions: {
Expand Down
10 changes: 8 additions & 2 deletions js/intro/view/IntroScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@ export default class IntroScreenView extends MeanShareAndBalanceScreenView {
super( model, meanShareAndBalanceStrings.introQuestionProperty, MeanShareAndBalanceColors.introQuestionBarColorProperty, model.numberOfCupsProperty, options );

this.predictMeanVisibleProperty = new BooleanProperty( false, {
// phet-io
tandem: options.tandem.createTandem( 'predictMeanVisibleProperty' )
} );
this.meanVisibleProperty = new BooleanProperty( false, {
// phet-io
tandem: options.tandem.createTandem( 'meanVisibleProperty' )
} );
this.tickMarksVisibleProperty = new BooleanProperty( false, {
// phet-io
tandem: options.tandem.createTandem( 'tickMarksVisibleProperty' )
} );

Expand All @@ -67,6 +70,7 @@ export default class IntroScreenView extends MeanShareAndBalanceScreenView {
// Constant range
enabledRangeProperty: new Property( model.dragRange ),

// phet-io
tandem: options.tandem.createTandem( 'predictMeanSlider' ),
phetioDocumentation: 'Line user can drag to predict water level mean.'
}
Expand Down Expand Up @@ -120,10 +124,12 @@ export default class IntroScreenView extends MeanShareAndBalanceScreenView {
const pipeSwitch = new ABSwitch( model.arePipesOpenProperty,
false, new ValveNode( new Vector2( 0, 0 ), new Property( 0 ), options.tandem.createTandem( 'closedValveIcon' ) ),
true, new ValveNode( new Vector2( 0, 0 ), new Property( Math.PI / 2 ), options.tandem.createTandem( 'openValveIcon' ) ), {
tandem: options.tandem.createTandem( 'pipeSwitch' ),
toggleSwitchOptions: {
size: new Dimension2( 40, 20 )
}
},

// phet-io
tandem: options.tandem.createTandem( 'pipeSwitch' )
} );
this.dataStateVBox.addChild( pipeSwitch );

Expand Down
2 changes: 2 additions & 0 deletions js/intro/view/PipeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export default class PipeNode extends Node {
pipe.isCurrentlyClickedProperty.set( true );
pipe.isCurrentlyClickedProperty.set( false );
},

// phet-io
tandem: options.tandem.createTandem( 'valveRotationFireListener' )
} );
this.valveNode.addInputListener( this.valveRotationFireListener );
Expand Down
2 changes: 2 additions & 0 deletions js/intro/view/PredictMeanSlider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export default class PredictMeanSlider extends AccessibleSlider( Node, 0 ) {
this.dragListener = new DragListener( {
positionProperty: predictMeanPositionProperty,
transform: modelViewTransform,

// phet-io
tandem: options.tandem.createTandem( 'dragListener' )
} );

Expand Down
2 changes: 2 additions & 0 deletions js/intro/view/ValveNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export default class ValveNode extends Node {
tagName: 'button',
x: parentCenter.x,
y: parentCenter.y,

// phet-io
tandem: tandem.createTandem( 'valveNode' )
} );

Expand Down
2 changes: 2 additions & 0 deletions js/intro/view/WaterCup2DNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export default class WaterCup2DNode extends Node {
MeanShareAndBalanceConstants.CUP_HEIGHT,
{
visibleProperty: isShowingTickMarksProperty,

// phet-io
tandem: options.tandem.createTandem( 'tickMarks' )
}
);
Expand Down
6 changes: 4 additions & 2 deletions js/intro/view/WaterCup3DNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ export default class WaterCup3DNode extends Node {
} );

this.waterLevelTriangle = new WaterLevelTriangleSlider( waterCup.waterLevelProperty, waterCup.enabledRangeProperty, beakerHeight, {
tandem: options.tandem.createTandem( 'waterLevelTriangle' ),
left: MeanShareAndBalanceConstants.CUP_WIDTH * MeanShareAndBalanceConstants.WATER_LEVEL_DEFAULT,
top: waterCupNode.top + waterCupNode.yRadiusOfEnds + beakerLineWidth / 2
top: waterCupNode.top + waterCupNode.yRadiusOfEnds + beakerLineWidth / 2,

// phet-io
tandem: options.tandem.createTandem( 'waterLevelTriangle' )
} );

this.addChild( waterCupNode );
Expand Down
1 change: 1 addition & 0 deletions js/leveling-out/model/Chocolate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default class Chocolate extends PhetioObject {

public constructor( providedOptions: ChocolateOptions ) {
const options = optionize<ChocolateOptions, EmptySelfOptions, PhetioObjectOptions>()( {
// phet-io
phetioType: Chocolate.ChocolateIO
}, providedOptions );
super( options );
Expand Down
7 changes: 5 additions & 2 deletions js/leveling-out/model/LevelingOutModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ export default class LevelingOutModel extends MeanShareAndBalanceModel {
super( options );

this.numberOfPeopleProperty = new NumberProperty( MeanShareAndBalanceConstants.INITIAL_NUMBER_OF_PEOPLE, {
tandem: options.tandem.createTandem( 'numberOfPeopleProperty' ),
numberType: 'Integer',
range: this.numberOfPeopleRange
range: this.numberOfPeopleRange,

// phet-io
tandem: options.tandem.createTandem( 'numberOfPeopleProperty' )
} );

this.isMeanAccordionExpandedProperty = new BooleanProperty( false, {
// phet-io
tandem: options.tandem.createTandem( 'isMeanAccordionExpandedProperty' )
} );

Expand Down
4 changes: 4 additions & 0 deletions js/leveling-out/view/LevelingOutScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export default class LevelingOutScreenView extends MeanShareAndBalanceScreenView
const meanAccordionBox = new AccordionBox( meanNode, {
titleNode: new Text( 'Mean', { fontSize: 15, maxWidth: MeanShareAndBalanceConstants.MAX_CONTROLS_TEXT_WIDTH } ),
expandedProperty: model.isMeanAccordionExpandedProperty,

// phet-io
tandem: options.tandem.createTandem( 'meanAccordionBox' )
} );

Expand All @@ -48,6 +50,8 @@ export default class LevelingOutScreenView extends MeanShareAndBalanceScreenView
model.numberOfPeopleProperty,
new Property( model.numberOfPeopleRange ), {
arrowsPosition: 'leftRight',

// phet-io
tandem: options.tandem.createTandem( 'numberOfPeopleNumberSpinner' )
} );

Expand Down

0 comments on commit 2025b41

Please sign in to comment.