Skip to content

Commit

Permalink
use options.tandem everywhere except in the top-level Model and Scree…
Browse files Browse the repository at this point in the history
…nView classes

Signed-off-by: Chris Malley <[email protected]>
  • Loading branch information
pixelzoom committed Sep 28, 2018
1 parent 325af51 commit 688267d
Show file tree
Hide file tree
Showing 19 changed files with 198 additions and 107 deletions.
19 changes: 12 additions & 7 deletions js/common/view/EquationAccordionBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ define( require => {
const graphingQuadratics = require( 'GRAPHING_QUADRATICS/graphingQuadratics' );
const HSeparator = require( 'SUN/HSeparator' );
const SaveCurveControls = require( 'GRAPHING_QUADRATICS/common/view/SaveCurveControls' );
const Tandem = require( 'TANDEM/Tandem' );
const VBox = require( 'SCENERY/nodes/VBox' );

class EquationAccordionBox extends AccordionBox {
Expand All @@ -24,16 +25,20 @@ define( require => {
* @param {BooleanProperty} expandedProperty
* @param {Node} titleNode
* @param {Node} interactiveEquationNode
* @param {Tandem} tandem
* @param {Object} [options]
* @abstract
*/
constructor( model, expandedProperty, titleNode, interactiveEquationNode, tandem ) {
constructor( model, expandedProperty, titleNode, interactiveEquationNode, options ) {

const options = _.extend( {
expandedProperty: expandedProperty,
titleNode: titleNode,
tandem: tandem
}, GQConstants.ACCORDION_BOX_OPTIONS );
options = _.extend( {
tandem: Tandem.required
}, GQConstants.ACCORDION_BOX_OPTIONS, options );

assert && assert( !options.expandedProperty, 'EquationAccordionBox sets expandedProperty' );
options.expandedProperty = expandedProperty;

assert && assert( !options.titleNode, 'EquationAccordionBox sets titleNode' );
options.titleNode = titleNode;

const saveCurveControls = new SaveCurveControls(
model.saveQuadratic.bind( model ), model.eraseQuadratics.bind( model ), model.savedQuadratics.lengthProperty );
Expand Down
13 changes: 8 additions & 5 deletions js/common/view/GQScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ define( require => {
const PointToolNode = require( 'GRAPHING_QUADRATICS/common/view/PointToolNode' );
const ResetAllButton = require( 'SCENERY_PHET/buttons/ResetAllButton' );
const ScreenView = require( 'JOIST/ScreenView' );
const Tandem = require( 'TANDEM/Tandem' );
const VBox = require( 'SCENERY/nodes/VBox' );

// constants
Expand All @@ -30,14 +31,16 @@ define( require => {
* @param {Node} graphNode
* @param {Node} equationControls
* @param {Node} graphControls
* @param {Tandem} tandem
* @param {Object} options
*/
constructor( model, viewProperties, graphNode, equationControls, graphControls, tandem ) {
constructor( model, viewProperties, graphNode, equationControls, graphControls, options ) {

super( {
options = _.extend( {
layoutBounds: GQConstants.SCREEN_VIEW_LAYOUT_BOUNDS,
tandem: tandem
} );
tandem: Tandem.required
}, options );

super( options );

// Point tools moveToFront when dragged, so give them a common parent to preserve rendering order.
const pointToolsParent = new Node();
Expand Down
15 changes: 8 additions & 7 deletions js/common/view/GQViewProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@ define( require => {
const BooleanProperty = require( 'AXON/BooleanProperty' );
const GQConstants = require( 'GRAPHING_QUADRATICS/common/GQConstants' );
const graphingQuadratics = require( 'GRAPHING_QUADRATICS/graphingQuadratics' );
const Tandem = require( 'TANDEM/Tandem' );

/**
* @param {Tandem} tandem
* @param {Object} [options]
*/
class GQViewProperties {

constructor( tandem, options ) {
constructor( options ) {

options = _.extend( {
equationForm: 'standard', // see GQConstants.EQUATION_FORMS
graphContentsVisible: true,
equationsVisible: true,
coordinatesVisible: true,
equationAccordionBoxExpanded: true
equationAccordionBoxExpanded: true,
tandem: Tandem.required
}, options );

assert && assert( GQConstants.EQUATION_FORMS.includes( options.equationForm ),
Expand All @@ -37,25 +38,25 @@ define( require => {

// @public
this.graphContentsVisibleProperty = new BooleanProperty( options.graphContentsVisible, {
tandem: tandem.createTandem( 'graphContentsVisibleProperty' ),
tandem: options.tandem.createTandem( 'graphContentsVisibleProperty' ),
phetioInstanceDocumentation: 'whether the contents of the graph are visible'
} );

// @public
this.equationsVisibleProperty = new BooleanProperty( options.equationsVisible, {
tandem: tandem.createTandem( 'equationsVisibleProperty' ),
tandem: options.tandem.createTandem( 'equationsVisibleProperty' ),
phetioInstanceDocumentation: 'whether equations are visible on the graphed lines'
} );

// @public
this.coordinatesVisibleProperty = new BooleanProperty( options.coordinatesVisible, {
tandem: tandem.createTandem( 'coordinatesVisibleProperty' ),
tandem: options.tandem.createTandem( 'coordinatesVisibleProperty' ),
phetioInstanceDocumentation: 'whether coordinates are visible on points and manipulators'
} );

// @public
this.equationAccordionBoxExpandedProperty = new BooleanProperty( options.equationAccordionBoxExpanded, {
tandem: tandem.createTandem( 'equationAccordionBoxExpandedProperty' ),
tandem: options.tandem.createTandem( 'equationAccordionBoxExpandedProperty' ),
phetioInstanceDocumentation: 'whether the equation accordion box is expanded'
} );
}
Expand Down
11 changes: 8 additions & 3 deletions js/explore/view/ExploreAccordionBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,27 @@ define( require => {
const ExploreInteractiveEquationNode = require( 'GRAPHING_QUADRATICS/explore/view/ExploreInteractiveEquationNode' );
const graphingQuadratics = require( 'GRAPHING_QUADRATICS/graphingQuadratics' );
const StandardFormEquationNode = require( 'GRAPHING_QUADRATICS/standardform/view/StandardFormEquationNode' );
const Tandem = require( 'TANDEM/Tandem' );

class ExploreAccordionBox extends EquationAccordionBox {

/**
* @param {ExploreModel} model
* @param {BooleanProperty} expandedProperty
* @param {Tandem} tandem
* @param {Object} [options]
*/
constructor( model, expandedProperty, tandem ) {
constructor( model, expandedProperty, options ) {

options = _.extend( {
tandem: Tandem.required
}, options );

const titleNode = new StandardFormEquationNode();

const interactiveEquationNode = new ExploreInteractiveEquationNode(
model.quadraticProperty, model.aRange, model.bRange, model.cRange );

super( model, expandedProperty, titleNode, interactiveEquationNode, tandem );
super( model, expandedProperty, titleNode, interactiveEquationNode, options );
}
}

Expand Down
18 changes: 14 additions & 4 deletions js/explore/view/ExploreScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,24 @@ define( require => {
*/
constructor( model, tandem ) {

const viewProperties = new ExploreViewProperties( tandem.createTandem( 'viewProperties') );
const options = {
tandem: tandem
};

const viewProperties = new ExploreViewProperties( {
tandem: tandem.createTandem( 'viewProperties' )
} );

super( model,
viewProperties,
new ExploreGraphNode( model, viewProperties ),
new ExploreAccordionBox( model, viewProperties.equationAccordionBoxExpandedProperty, tandem.createTandem( 'equationAccordionBox') ),
new QuadraticTermsAccordionBox( viewProperties, tandem.createTandem( 'quadraticTermsAccordionBox') ),
tandem
new ExploreAccordionBox( model, viewProperties.equationAccordionBoxExpandedProperty, {
tandem: tandem.createTandem( 'equationAccordionBox' )
} ),
new QuadraticTermsAccordionBox( viewProperties, {
tandem: tandem.createTandem( 'quadraticTermsAccordionBox' )
} ),
options
);
}
}
Expand Down
27 changes: 16 additions & 11 deletions js/explore/view/ExploreViewProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,43 @@ define( require => {
const graphingQuadratics = require( 'GRAPHING_QUADRATICS/graphingQuadratics' );
const GQQueryParameters = require( 'GRAPHING_QUADRATICS/common/GQQueryParameters' );
const GQViewProperties = require( 'GRAPHING_QUADRATICS/common/view/GQViewProperties' );
const Tandem = require( 'TANDEM/Tandem' );

class ExploreViewProperties extends GQViewProperties {

/**
* @param {Tandem} tandem
* @param {Object} options
*/
constructor( tandem ) {
constructor( options ) {

super( tandem );
options = _.extend( {
tandem: Tandem.required
}, options );

super( options );

// @public
this.quadraticTermsAccordionBoxExpandedProperty = new BooleanProperty( true, {
tandem: tandem.createTandem( 'quadraticTermsAccordionBoxExpandedProperty' ),
phetioDocumentation: 'whether the quadratic terms accordion box is expanded'
tandem: options.tandem.createTandem( 'quadraticTermsAccordionBoxExpandedProperty' ),
phetioDocumentation: 'whether the Quadratic Terms accordion box is expanded'
} );

// @public
this.quadraticTermVisibleProperty = new BooleanProperty( GQQueryParameters.checkAll, {
tandem: tandem.createTandem( 'quadraticTermVisibleProperty' ),
phetioDocumentation: 'whether the quadratic term, y = ax^2, is visible'
tandem: options.tandem.createTandem( 'quadraticTermVisibleProperty' ),
phetioDocumentation: 'whether the quadratic term (y = ax^2) is visible'
} );

// @public
this.linearTermVisibleProperty = new BooleanProperty( GQQueryParameters.checkAll, {
tandem: tandem.createTandem( 'linearTermVisibleProperty' ),
phetioDocumentation: 'whether the linear term, y = bx, is visible'
tandem: options.tandem.createTandem( 'linearTermVisibleProperty' ),
phetioDocumentation: 'whether the linear term (y = bx) is visible'
} );

// @public
this.constantTermVisibleProperty = new BooleanProperty( GQQueryParameters.checkAll, {
tandem: tandem.createTandem( 'constantTermVisibleProperty' ),
phetioDocumentation: 'whether the constant term, y = c, is visible'
tandem: options.tandem.createTandem( 'constantTermVisibleProperty' ),
phetioDocumentation: 'whether the constant term (y = c) is visible'
} );
}

Expand Down
19 changes: 10 additions & 9 deletions js/explore/view/QuadraticTermsAccordionBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ define( require => {
const PhetFont = require( 'SCENERY_PHET/PhetFont' );
const RichText = require( 'SCENERY/nodes/RichText' );
const StringUtils = require( 'PHETCOMMON/util/StringUtils' );
const Tandem = require( 'TANDEM/Tandem' );
const Text = require( 'SCENERY/nodes/Text' );
const VBox = require( 'SCENERY/nodes/VBox' );

Expand All @@ -33,15 +34,15 @@ define( require => {

/**
* @param {ExploreViewProperties} viewProperties
* @param {Tandem} tandem
* @param {Object} [options]
*/
constructor( viewProperties, tandem, options ) {
constructor( viewProperties, options ) {

options = _.extend( {
expandedProperty: viewProperties.quadraticTermsAccordionBoxExpandedProperty,
titleAlignX: 'left',
titleXSpacing: 8
titleXSpacing: 8,
tandem: Tandem.required
}, GQConstants.ACCORDION_BOX_OPTIONS, options );

assert && assert( !options.titleNode, 'QuadraticTermsAccordionBox sets titleNode' );
Expand All @@ -61,8 +62,8 @@ define( require => {
fill: GQColors.QUADRATIC_TERM
} );
const quadraticTermCheckbox = new Checkbox( quadraticTermLabel, viewProperties.quadraticTermVisibleProperty, {
tandem: tandem.createTandem( 'quadraticTermCheckbox' ),
phetioDocumentation: 'checkbox that makes the quadratic term visible'
tandem: options.tandem.createTandem( 'quadraticTermCheckbox' ),
phetioDocumentation: 'checkbox that makes the quadratic term (y = ax^2) visible'
} );

// y = bx
Expand All @@ -76,8 +77,8 @@ define( require => {
fill: GQColors.LINEAR_TERM
} );
const linearTermCheckbox = new Checkbox( linearTermLabel, viewProperties.linearTermVisibleProperty, {
tandem: tandem.createTandem( 'linearTermCheckbox' ),
phetioDocumentation: 'checkbox that makes the linear term visible'
tandem: options.tandem.createTandem( 'linearTermCheckbox' ),
phetioDocumentation: 'checkbox that makes the linear term (y = bx) visible'
} );

// y = c
Expand All @@ -90,8 +91,8 @@ define( require => {
fill: GQColors.CONSTANT_TERM
} );
const constantTermCheckbox = new Checkbox( constantTermLabel, viewProperties.constantTermVisibleProperty, {
tandem: tandem.createTandem( 'constantTermCheckbox' ),
phetioDocumentation: 'checkbox that makes the constant term visible'
tandem: options.tandem.createTandem( 'constantTermCheckbox' ),
phetioDocumentation: 'checkbox that makes the constant term (y = c) visible'
} );

// vertical layout
Expand Down
5 changes: 5 additions & 0 deletions js/focusanddirectrix/view/FocusAndDirectrixAccordionBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ define( require => {
const FocusAndDirectrixEquationNode = require( 'GRAPHING_QUADRATICS/focusanddirectrix/view/FocusAndDirectrixEquationNode' );
const FocusAndDirectrixInteractiveEquationNode = require( 'GRAPHING_QUADRATICS/focusanddirectrix/view/FocusAndDirectrixInteractiveEquationNode' );
const graphingQuadratics = require( 'GRAPHING_QUADRATICS/graphingQuadratics' );
const Tandem = require( 'TANDEM/Tandem' );

class FocusAndDirectrixAccordionBox extends EquationAccordionBox {

Expand All @@ -23,6 +24,10 @@ define( require => {
*/
constructor( model, expandedProperty, options ) {

options = _.extend( {
tandem: Tandem.required
}, options );

const titleNode = new FocusAndDirectrixEquationNode();

const interactiveEquationNode = new FocusAndDirectrixInteractiveEquationNode(
Expand Down
21 changes: 11 additions & 10 deletions js/focusanddirectrix/view/FocusAndDirectrixGraphControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,38 @@ define( require => {
const graphingQuadratics = require( 'GRAPHING_QUADRATICS/graphingQuadratics' );
const Panel = require( 'SUN/Panel' );
const PointOnQuadraticCheckbox = require( 'GRAPHING_QUADRATICS/focusanddirectrix/view/PointOnQuadraticCheckbox' );
const Tandem = require( 'TANDEM/Tandem' );
const VBox = require( 'SCENERY/nodes/VBox' );
const VertexCheckbox = require( 'GRAPHING_QUADRATICS/common/view/VertexCheckbox' );

class FocusAndDirectrixGraphControls extends Panel {

/**
* @param {GQViewProperties} viewProperties
* @param {Tandem} tandem
* @param {Object} [options]
*/
constructor( viewProperties, tandem ) {
constructor( viewProperties, options ) {

const options = _.extend( {
tandem: tandem
}, GQConstants.PANEL_OPTIONS );
options = _.extend( {
tandem: Tandem.required
}, GQConstants.PANEL_OPTIONS, options );

// checkboxes
const vertexCheckbox = new VertexCheckbox( viewProperties.vertexVisibleProperty, {
manipulatorIcon: true,
tandem: tandem.createTandem( 'vertexCheckbox' )
tandem: options.tandem.createTandem( 'vertexCheckbox' )
} );
const focusCheckbox = new FocusCheckbox( viewProperties.focusVisibleProperty, {
tandem: tandem.createTandem( 'focusCheckbox' )
tandem: options.tandem.createTandem( 'focusCheckbox' )
} );
const directrixCheckbox = new DirectrixCheckbox( viewProperties.directrixVisibleProperty, {
tandem: tandem.createTandem( 'directrixCheckbox' )
tandem: options.tandem.createTandem( 'directrixCheckbox' )
} );
const pointOnQuadraticCheckbox = new PointOnQuadraticCheckbox( viewProperties.pointOnQuadraticVisibleProperty, {
tandem: tandem.createTandem( 'pointOnQuadraticCheckbox' )
tandem: options.tandem.createTandem( 'pointOnQuadraticCheckbox' )
} );
const coordinatesCheckbox = new CoordinatesCheckbox( viewProperties.coordinatesVisibleProperty, {
tandem: tandem.createTandem( 'coordinatesCheckbox' )
tandem: options.tandem.createTandem( 'coordinatesCheckbox' )
} );

// vertical layout
Expand Down
18 changes: 14 additions & 4 deletions js/focusanddirectrix/view/FocusAndDirectrixScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,24 @@ define( require => {
*/
constructor( model, tandem ) {

const viewProperties = new FocusAndDirectrixViewProperties( tandem.createTandem( 'viewProperties') );
const options = {
tandem: tandem
};

const viewProperties = new FocusAndDirectrixViewProperties( {
tandem: options.tandem.createTandem( 'viewProperties')
} );

super( model,
viewProperties,
new FocusAndDirectrixGraphNode( model, viewProperties ),
new FocusAndDirectrixAccordionBox( model, viewProperties.equationAccordionBoxExpandedProperty, tandem.createTandem( 'equationAccordionBox') ),
new FocusAndDirectrixGraphControls( viewProperties, tandem.createTandem( 'graphControls' ) ),
tandem
new FocusAndDirectrixAccordionBox( model, viewProperties.equationAccordionBoxExpandedProperty, {
tandem: options.tandem.createTandem( 'equationAccordionBox')
} ),
new FocusAndDirectrixGraphControls( viewProperties, {
tandem: options.tandem.createTandem( 'graphControls' )
} ),
options
);
}
}
Expand Down
Loading

0 comments on commit 688267d

Please sign in to comment.