diff --git a/js/gravity-force-lab/view/GravityForceLabScreenView.js b/js/gravity-force-lab/view/GravityForceLabScreenView.js index 99d3466d..818a4bf8 100644 --- a/js/gravity-force-lab/view/GravityForceLabScreenView.js +++ b/js/gravity-force-lab/view/GravityForceLabScreenView.js @@ -28,10 +28,10 @@ define( require => { const ISLCA11yStrings = require( 'INVERSE_SQUARE_LAW_COMMON/ISLCA11yStrings' ); const ISLCCheckboxPanel = require( 'INVERSE_SQUARE_LAW_COMMON/view/ISLCCheckboxPanel' ); const ISLCGridNode = require( 'INVERSE_SQUARE_LAW_COMMON/view/ISLCGridNode' ); - const ISLCRulerRegionsNode = require( 'INVERSE_SQUARE_LAW_COMMON/view/ISLCRulerRegionsNode' ); const ISLCObjectEnum = require( 'INVERSE_SQUARE_LAW_COMMON/view/ISLCObjectEnum' ); const ISLCQueryParameters = require( 'INVERSE_SQUARE_LAW_COMMON/ISLCQueryParameters' ); const ISLCRulerNode = require( 'INVERSE_SQUARE_LAW_COMMON/view/ISLCRulerNode' ); + const ISLCRulerRegionsNode = require( 'INVERSE_SQUARE_LAW_COMMON/view/ISLCRulerRegionsNode' ); const MassControl = require( 'GRAVITY_FORCE_LAB/gravity-force-lab/view/MassControl' ); const MassDescriber = require( 'GRAVITY_FORCE_LAB/gravity-force-lab/view/describers/MassDescriber' ); const MassNode = require( 'GRAVITY_FORCE_LAB/gravity-force-lab/view/MassNode' ); @@ -240,16 +240,26 @@ define( require => { tandem: tandem.createTandem( 'resetAllButton' ) } ); + // positioning the nodes + // Do this before the ruler, so the ruler can have the correct region positions + resetAllButton.bottom = this.layoutBounds.bottom - 7.4; + parameterControlPanel.right = resetAllButton.right = this.layoutBounds.width - 15; + parameterControlPanel.bottom = resetAllButton.top - 13.5; + massControl2.top = massControl1.top = parameterControlPanel.top; + massControl2.right = parameterControlPanel.left - 45; + massControl1.right = massControl2.left - 45; + // create down here because it needs locations of other items in the screen view const rulerRegionPositions = [ mass2Node.top, mass1Node.top, - mass1Node.localToGlobalPoint( new Vector2( 0, mass1Node.dragNode.top ) ).y, - mass1Node.center.x, + mass1Node.localToGlobalPoint( mass1Node.centerPoint.center ).y -20, + mass1Node.localToGlobalPoint( mass1Node.centerPoint.center ).y +20, mass1Node.localToGlobalPoint( new Vector2( 0, mass1Node.dragNode.bottom ) ).y, massControl1.top, this.layoutBounds.bottom ]; + const rulerDescriber = new GravityForceLabRulerDescriber( model.rulerPositionProperty, modelViewTransform, rulerRegionPositions, positionDescriber ); @@ -302,16 +312,6 @@ define( require => { resetAllButton ]; - // positioning the nodes - parameterControlPanel.right = this.layoutBounds.width - 15; - parameterControlPanel.top = gravityForceLabRuler.bottom + 15; - massControl2.right = parameterControlPanel.left - 45; - massControl2.top = parameterControlPanel.top; - massControl1.right = massControl2.left - 45; - massControl1.top = parameterControlPanel.top; - resetAllButton.right = parameterControlPanel.right; - resetAllButton.top = parameterControlPanel.bottom + 13.5; - if ( SHOW_GRID ) { const gridNode = new ISLCGridNode( GravityForceLabConstants.LOCATION_SNAP_VALUE, diff --git a/js/gravity-force-lab/view/describers/GravityForceLabRulerDescriber.js b/js/gravity-force-lab/view/describers/GravityForceLabRulerDescriber.js index 8c9f316c..a8d084d6 100644 --- a/js/gravity-force-lab/view/describers/GravityForceLabRulerDescriber.js +++ b/js/gravity-force-lab/view/describers/GravityForceLabRulerDescriber.js @@ -11,6 +11,7 @@ define( require => { // modules const gravityForceLab = require( 'GRAVITY_FORCE_LAB/gravityForceLab' ); const GravityForceLabA11yStrings = require( 'GRAVITY_FORCE_LAB/gravity-force-lab/GravityForceLabA11yStrings' ); + const ISLCQueryParameters = require( 'INVERSE_SQUARE_LAW_COMMON/ISLCQueryParameters' ); const Range = require( 'DOT/Range' ); const StringUtils = require( 'PHETCOMMON/util/StringUtils' ); @@ -44,6 +45,7 @@ define( require => { // These regions are treated differently, as they are in the range that suggests pedagogically relevant interaction. const TARGET_REGIONS_RANGE = new Range( RULER_VERTICAL_REGIONS.indexOf( justAboveCentersString ), RULER_VERTICAL_REGIONS.indexOf( justBelowCentersString ) ); + const SHOW_RULER_REGIONS = ISLCQueryParameters.showRulerRegions; /** */ @@ -58,6 +60,9 @@ define( require => { this.positionDescriber = positionDescriber; this.viewYPositions = viewYPositions; this.grabbedCount = 0; + + // Don't need to unlink + SHOW_RULER_REGIONS && this.rulerPositionProperty.link( () => console.log( this.getCurrentVerticalRegion() ) ); } /**