Skip to content

Commit

Permalink
Attempt 2 fix for #325
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisklus committed Apr 9, 2020
1 parent ab786b1 commit 4b5c67c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
5 changes: 3 additions & 2 deletions js/common/view/BeakerView.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import PhetFont from '../../../../scenery-phet/js/PhetFont.js';
import Node from '../../../../scenery/js/nodes/Node.js';
import Path from '../../../../scenery/js/nodes/Path.js';
import Rectangle from '../../../../scenery/js/nodes/Rectangle.js';
import Text from '../../../../scenery/js/nodes/Text.js';
import RichText from '../../../../scenery/js/nodes/RichText.js';
import PhetioObject from '../../../../tandem/js/PhetioObject.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import BooleanIO from '../../../../tandem/js/types/BooleanIO.js';
Expand Down Expand Up @@ -211,11 +211,12 @@ class BeakerView extends PhetioObject {
this.backNode.pickable = false;

// add the label, positioning it just below the front, top water line
const labelNode = new Text( options.label, {
const labelNode = new RichText( options.label, {
font: LABEL_FONT,
maxWidth: beakerBounds.width * 0.7, // empirically determined to look nice
tandem: options.tandem.createTandem( 'labelNode' )
} );
console.log( 'Trying RichText' );
labelNode.translation = new Vector2(
beakerBounds.centerX - labelNode.bounds.width / 2,
beakerBounds.maxY - beakerBounds.height * beaker.fluidProportionProperty.value + topEllipse.bounds.height * 1.1
Expand Down
24 changes: 8 additions & 16 deletions js/intro/view/EFACIntroScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import Dimension2 from '../../../../dot/js/Dimension2.js';
import Utils from '../../../../dot/js/Utils.js';
import Vector2 from '../../../../dot/js/Vector2.js';
import ScreenView from '../../../../joist/js/ScreenView.js';
import merge from '../../../../phet-core/js/merge.js';
import ModelViewTransform2 from '../../../../phetcommon/js/view/ModelViewTransform2.js';
import flameImage from '../../../../scenery-phet/images/flame_png.js';
import ResetAllButton from '../../../../scenery-phet/js/buttons/ResetAllButton.js';
Expand Down Expand Up @@ -54,8 +53,8 @@ import EFACTemperatureAndColorSensorNode from '../../common/view/EFACTemperature
import EnergyChunkLayer from '../../common/view/EnergyChunkLayer.js';
import EnergyChunkNode from '../../common/view/EnergyChunkNode.js';
import SkyNode from '../../common/view/SkyNode.js';
import energyFormsAndChanges from '../../energyFormsAndChanges.js';
import energyFormsAndChangesStrings from '../../energyFormsAndChangesStrings.js';
import energyFormsAndChanges from '../../energyFormsAndChanges.js';
import efacPositionConstrainer from '../model/efacPositionConstrainer.js';
import AirNode from './AirNode.js';
import BeakerContainerView from './BeakerContainerView.js';
Expand All @@ -64,6 +63,7 @@ import BlockNode from './BlockNode.js';
const energySymbolsString = energyFormsAndChangesStrings.energySymbols;
const linkHeatersString = energyFormsAndChangesStrings.linkHeaters;
const oliveOilString = energyFormsAndChangesStrings.oliveOil;
const waterString = energyFormsAndChangesStrings.water;

// constants
const EDGE_INSET = 10; // screen edge padding, in screen coordinates
Expand Down Expand Up @@ -432,22 +432,16 @@ class EFACIntroScreenView extends ScreenView {

// @private {PhetioGroup.<BeakerContainerView>}
this.beakerViews = new PhetioGroup( ( tandem, beaker ) => {
let options = {
tandem: tandem,
phetioDynamicElement: true
};
if ( beaker.beakerType === BeakerType.OLIVE_OIL ) {
options = merge( {
label: oliveOilString
}, options );
}

const label = beaker.beakerType === BeakerType.WATER ? waterString : oliveOilString;
return new BeakerContainerView(
beaker,
model,
modelViewTransform,
constrainMovableElementMotion,
options
constrainMovableElementMotion, {
label: label,
tandem: tandem,
phetioDynamicElement: true
}
);
},
[ model.beakers.archetype ], {
Expand All @@ -456,8 +450,6 @@ class EFACIntroScreenView extends ScreenView {
supportsDynamicState: false
} );

console.log( 'Trying using water\'s default option' );

const beakerListener = addedBeaker => {
const beakerView = this.beakerViews.createCorrespondingGroupMember( addedBeaker, addedBeaker );

Expand Down

0 comments on commit 4b5c67c

Please sign in to comment.