Skip to content

Commit

Permalink
delete RulerLayer, #263
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Dec 7, 2021
1 parent 66038d3 commit eb6a696
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 71 deletions.
19 changes: 13 additions & 6 deletions js/common/view/GeometricOpticsScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import GeometricOpticsModel from '../model/GeometricOpticsModel.js';
import DebugPointNode from './DebugPointNode.js';
import FocalPointNode from './FocalPointNode.js';
import GeometricOpticsControlPanel from './GeometricOpticsControlPanel.js';
import RulersLayer from './RulersLayer.js';
import LabelsNode from './LabelsNode.js';
import LightRaysNode from './LightRaysNode.js';
import OpticalAxis from './OpticalAxis.js';
Expand All @@ -44,6 +43,7 @@ import VisibleProperties from './VisibleProperties.js';
import RaysModeEnum from '../model/RaysModeEnum.js';
import Lens from '../../lens/model/Lens.js';
import Optic from '../model/Optic.js';
import GeometricOpticsRulerNode from './GeometricOpticsRulerNode.js';

// constants
const ZOOM_RANGE = new RangeWithValue( 1, 3, 3 );
Expand Down Expand Up @@ -118,16 +118,18 @@ class GeometricOpticsScreenView extends ScreenView {
);

// scale for with the current zoom level
const absoluteZoomScaleProperty = new DerivedProperty<number>(
const zoomScaleProperty = new DerivedProperty<number>(
[ zoomLevelProperty ],
( zoomLevel: number ) => getAbsoluteZoomScale( zoomLevel )
);

// Things that are outside the Experiment Area =====================================================================

// create Rulers
const rulersLayer = new RulersLayer( model.horizontalRuler, model.verticalRuler,
zoomTransformProperty, absoluteZoomScaleProperty, this.visibleBoundsProperty );
const horizontalRulerNode = new GeometricOpticsRulerNode( model.horizontalRuler,
zoomTransformProperty, zoomScaleProperty, this.visibleBoundsProperty );
const verticalRulerNode = new GeometricOpticsRulerNode( model.verticalRuler,
zoomTransformProperty, zoomScaleProperty, this.visibleBoundsProperty );

// create control panel at the bottom of the screen
const controlPanel = new GeometricOpticsControlPanel( model.representationProperty, model.optic,
Expand All @@ -139,13 +141,14 @@ class GeometricOpticsScreenView extends ScreenView {
} );

// create toolbox at the top right corner of the screen
const toolbox = new RulersToolbox( rulersLayer, {
const toolbox = new RulersToolbox( horizontalRulerNode, verticalRulerNode, {
rightTop: erodedLayoutBounds.rightTop,
tandem: config.tandem.createTandem( 'toolbox' )
} );

// Tell the rulers where the toolbox is.
rulersLayer.setToolboxBounds( toolbox.bounds );
horizontalRulerNode.setToolboxBounds( toolbox.bounds );
verticalRulerNode.setToolboxBounds( toolbox.bounds );

// radio buttons for the shape of the optic
const opticShapeRadioButtonGroup = new OpticShapeRadioButtonGroup( model.optic, {
Expand Down Expand Up @@ -343,6 +346,10 @@ class GeometricOpticsScreenView extends ScreenView {

// Layout ================================================================================================

const rulersLayer = new Node( {
children: [ horizontalRulerNode, verticalRulerNode ]
} );

const screenViewRootNode = new Node( {
children: [
experimentAreaNode,
Expand Down
56 changes: 0 additions & 56 deletions js/common/view/RulersLayer.ts

This file was deleted.

15 changes: 6 additions & 9 deletions js/common/view/RulersToolbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,20 @@

import merge from '../../../../phet-core/js/merge.js';
import RulerNode from '../../../../scenery-phet/js/RulerNode.js';
import { SceneryEvent } from '../../../../scenery/js/imports.js';
import { DragListener } from '../../../../scenery/js/imports.js';
import { HBox } from '../../../../scenery/js/imports.js';
import { Node } from '../../../../scenery/js/imports.js';
import { DragListener, HBox, Node, SceneryEvent } from '../../../../scenery/js/imports.js';
import Panel from '../../../../sun/js/Panel.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import geometricOptics from '../../geometricOptics.js';
import RulersLayer from './RulersLayer.js';
import GeometricOpticsRulerNode from './GeometricOpticsRulerNode.js';

class RulersToolbox extends Panel {

/**
* @param rulersLayer
* @param horizontalRulerNode
* @param verticalRulerNode
* @param options
*/
constructor( rulersLayer: RulersLayer, options?: any ) {
constructor( horizontalRulerNode: GeometricOpticsRulerNode, verticalRulerNode: GeometricOpticsRulerNode, options?: any ) {

options = merge( {

Expand Down Expand Up @@ -103,8 +100,8 @@ class RulersToolbox extends Panel {
};

// Add a forwarding listener for each ruler icon, to forward drag events from the icon to its associated ruler.
addForwardingListener( horizontalRulerIconNode, rulersLayer.horizontalRulerNode );
addForwardingListener( verticalRulerIconNode, rulersLayer.verticalRulerNode );
addForwardingListener( horizontalRulerIconNode, horizontalRulerNode );
addForwardingListener( verticalRulerIconNode, verticalRulerNode );
}

public dispose(): void {
Expand Down

0 comments on commit eb6a696

Please sign in to comment.