Skip to content

Commit

Permalink
add 'Current Speed Scale' control for electromagnet, #66
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Apr 16, 2024
1 parent 9f657f7 commit 4b7f700
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
20 changes: 16 additions & 4 deletions js/common/view/FELDeveloperAccordionBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import Utils from '../../../../dot/js/Utils.js';
import Dimension2 from '../../../../dot/js/Dimension2.js';
import ResetButton from '../../../../scenery-phet/js/buttons/ResetButton.js';
import PickupCoil from '../model/PickupCoil.js';
import Electromagnet from '../model/Electromagnet.js';

// Developer controls are styled independently of controls in the UI, so that we can cram more of them in.
const CONTROL_FONT_SIZE = 12;
Expand Down Expand Up @@ -80,10 +81,6 @@ export default class FELDeveloperAccordionBox extends AccordionBox {
return new FELDeveloperNumberControl( 'Field Scale:', property, 2 /* decimalPlaces */ );
}

protected static createElectromagnetShapeCheckbox( property: Property<boolean> ): Checkbox {
return new FELDeveloperCheckbox( 'Electromagnet Shape', property );
}

/**
* Creates the set of controls related to the pickup coil.
*/
Expand All @@ -101,6 +98,21 @@ export default class FELDeveloperAccordionBox extends AccordionBox {
]
} );
}

/**
* Creates the set of controls related to the electromagnet.
*/
protected static createElectromagnetControls( electromagnet: Electromagnet ): VBox {
return new VBox( {
align: 'left',
spacing: VBOX_SPACING,
children: [
new Text( 'Electromagnet', SUBTITLE_OPTIONS ),
new FELDeveloperNumberControl( 'Current Speed Scale:', electromagnet.coil.currentSpeedScaleProperty, 1 /* decimalPlaces */ ),
new FELDeveloperCheckbox( 'Electromagnet Shape', electromagnet.shapeVisibleProperty )
]
} );
}
}

class FELDeveloperCheckbox extends Checkbox {
Expand Down
5 changes: 3 additions & 2 deletions js/electromagnet/view/ElectromagnetDeveloperAccordionBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import faradaysElectromagneticLab from '../../faradaysElectromagneticLab.js';
import { VBox } from '../../../../scenery/js/imports.js';
import { HSeparator, VBox } from '../../../../scenery/js/imports.js';
import FELDeveloperAccordionBox from '../../common/view/FELDeveloperAccordionBox.js';
import Electromagnet from '../../common/model/Electromagnet.js';

Expand All @@ -22,7 +22,8 @@ export default class ElectromagnetDeveloperAccordionBox extends FELDeveloperAcco
spacing: 10,
children: [
FELDeveloperAccordionBox.createFieldScaleControl( electromagnet.fieldScaleProperty ),
FELDeveloperAccordionBox.createElectromagnetShapeCheckbox( electromagnet.shapeVisibleProperty )
new HSeparator(),
FELDeveloperAccordionBox.createElectromagnetControls( electromagnet )
]
} );

Expand Down
3 changes: 2 additions & 1 deletion js/transformer/view/TransformerDeveloperAccordionBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export default class TransformerDeveloperAccordionBox extends FELDeveloperAccord
spacing: 10,
children: [
FELDeveloperAccordionBox.createFieldScaleControl( transformer.electromagnet.fieldScaleProperty ),
FELDeveloperAccordionBox.createElectromagnetShapeCheckbox( transformer.electromagnet.shapeVisibleProperty ),
new HSeparator(),
FELDeveloperAccordionBox.createElectromagnetControls( transformer.electromagnet ),
new HSeparator(),
FELDeveloperAccordionBox.createPickupCoilControls( transformer.pickupCoil )
]
Expand Down

0 comments on commit 4b7f700

Please sign in to comment.