Skip to content

Commit

Permalink
Fix ruler regions, log regions when showing ruler regions, #185
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Nov 5, 2019
1 parent 076aa5c commit 7335a41
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
26 changes: 13 additions & 13 deletions js/gravity-force-lab/view/GravityForceLabScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down Expand Up @@ -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 );

Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' );

Expand Down Expand Up @@ -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;

/**
*/
Expand All @@ -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() ) );
}

/**
Expand Down

0 comments on commit 7335a41

Please sign in to comment.