Skip to content

Commit

Permalink
i18n layout support, #62
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Jul 17, 2017
1 parent d4aa40d commit 12e9c4b
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions js/ohms-law/view/SliderUnit.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ define( function( require ) {
var ohmsLaw = require( 'OHMS_LAW/ohmsLaw' );
var OhmsLawConstants = require( 'OHMS_LAW/ohms-law/OhmsLawConstants' );

// TODO: make dynamic;
var MAX_TEXT_WIDTH = 104; // empirically determined

/**
* @param {Property.<number>} property
* @param {RangeWithValue} range
Expand All @@ -43,19 +40,36 @@ define( function( require ) {

Node.call( this );

var slider = new HSlider( property, range, {
trackFillEnabled: 'black',
thumbFillEnabled: '#c3c4c5',
thumbFillHighlighted: '#dedede',
rotation: -Math.PI / 2,

trackSize: new Dimension2( OhmsLawConstants.SLIDER_HEIGHT, 4 ),
x: 0,
keyboardStep: options.keyboardStep,
shiftKeyboardStep: options.shiftKeyboardStep,
numberDecimalPlaces: options.numberDecimalPlaces,
tandem: tandem.createTandem( 'slider' )
} );

// Set the maximum width that text can be in the slider unit based on the width of the HSlider.
var maxTextWidth = slider.width * 2;

var symbolText = new Text( symbolString, {
font: OhmsLawConstants.SYMBOL_FONT,
fill: OhmsLawConstants.BLUE_COLOR,
centerX: 0,
maxWidth: MAX_TEXT_WIDTH,
maxWidth: maxTextWidth,
tandem: tandem.createTandem( 'symbolText' )
} );

var nameText = new Text( nameString, {
font: OhmsLawConstants.NAME_FONT,
fill: OhmsLawConstants.BLUE_COLOR,
centerX: 0,
maxWidth: MAX_TEXT_WIDTH,
maxWidth: maxTextWidth,
tandem: tandem.createTandem( 'nameText' )
} );

Expand All @@ -65,20 +79,6 @@ define( function( require ) {
children: [ symbolText, nameText ]
} );

var slider = new HSlider( property, range, {
trackFillEnabled: 'black',
thumbFillEnabled: '#c3c4c5',
thumbFillHighlighted: '#dedede',
rotation: -Math.PI / 2,

trackSize: new Dimension2( OhmsLawConstants.SLIDER_HEIGHT, 4 ),
x: 0,
keyboardStep: options.keyboardStep,
shiftKeyboardStep: options.shiftKeyboardStep,
numberDecimalPlaces: options.numberDecimalPlaces,
tandem: tandem.createTandem( 'slider' )
} );

var valueText = new Text( Util.toFixed( range.max, options.numberDecimalPlaces ), {
font: OhmsLawConstants.READOUT_FONT,
fill: OhmsLawConstants.BLACK_COLOR,
Expand All @@ -90,7 +90,7 @@ define( function( require ) {
font: OhmsLawConstants.UNIT_FONT,
fill: OhmsLawConstants.BLUE_COLOR,
left: valueText.right / 2,
maxWidth: MAX_TEXT_WIDTH,
maxWidth: maxTextWidth / 2,
tandem: tandem.createTandem( 'unitText' )
} );

Expand Down

0 comments on commit 12e9c4b

Please sign in to comment.