Skip to content

Commit

Permalink
Setting the NumberControl tick labels
Browse files Browse the repository at this point in the history
  • Loading branch information
AgustinVallejo committed Mar 21, 2023
1 parent f438f70 commit 9a1930e
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions js/common/view/MySolarSystemControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @author Agustín Vallejo
*/

import { HBox, HSeparator, Node, RichText, VBox, VBoxOptions } from '../../../../scenery/js/imports.js';
import { HBox, HSeparator, Node, RichText, Text, VBox, VBoxOptions } from '../../../../scenery/js/imports.js';
import WithRequired from '../../../../phet-core/js/types/WithRequired.js';
import { EmptySelfOptions } from '../../../../phet-core/js/optionize.js';
import mySolarSystem from '../../mySolarSystem.js';
Expand All @@ -15,7 +15,8 @@ import createVisibilityInformationCheckboxes from '../../../../solar-system-comm
import createArrowsVisibilityCheckboxes from '../../../../solar-system-common/js/view/createArrowsVisibilityCheckboxes.js';
import createOrbitalInformationCheckboxes from './createOrbitalInformationCheckboxes.js';
import MySolarSystemModel from '../model/MySolarSystemModel.js';
import HSlider from '../../../../sun/js/HSlider.js';
import NumberControl from '../../../../scenery-phet/js/NumberControl.js';
import SolarSystemCommonColors from '../../../../solar-system-common/js/SolarSystemCommonColors.js';

type SelfOptions = EmptySelfOptions;

Expand All @@ -40,9 +41,22 @@ export default class MySolarSystemControls extends VBox {
spacing: 0,
enabledProperty: model.gravityVisibleProperty,
children: [
new RichText( `Scale: x10<sup>${model.forceScaleProperty.range.min}</sup>`, SolarSystemCommonConstants.TEXT_OPTIONS ),
new HSlider( model.forceScaleProperty, model.forceScaleProperty.range ),
new RichText( `x10<sup>${model.forceScaleProperty.range.max}</sup>`, SolarSystemCommonConstants.TEXT_OPTIONS )
new Text( 'Scale:', SolarSystemCommonConstants.TEXT_OPTIONS ),
// new HSlider( model.forceScaleProperty, model.forceScaleProperty.range ),
// new RichText( `x10<sup>${model.forceScaleProperty.range.max}</sup>`, SolarSystemCommonConstants.TEXT_OPTIONS )
new NumberControl( 'Scale', model.forceScaleProperty, model.forceScaleProperty.range, {
arrowButtonOptions: { visible: false },
sliderOptions: {
constrainValue: ( power: number ) => Math.abs( power ) < 0.5 ? 0 : power,
majorTickStroke: SolarSystemCommonColors.foregroundProperty,
majorTickLength: 8,
trackFillEnabled: SolarSystemCommonColors.foregroundProperty,
majorTicks: [
{ value: -2, label: new RichText( 'x10<sup>-2</sup', SolarSystemCommonConstants.TEXT_OPTIONS ) },
{ value: 8, label: new RichText( 'x10<sup>8</sup', SolarSystemCommonConstants.TEXT_OPTIONS ) }
]
}
} )
]
} ),
new HSeparator( SolarSystemCommonConstants.HSEPARATOR_OPTIONS ),
Expand Down

1 comment on commit 9a1930e

@AgustinVallejo
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.