Skip to content

Commit

Permalink
updateElementName should not support layout, #90
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Jul 31, 2023
1 parent a8badaf commit 03104f2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
9 changes: 5 additions & 4 deletions js/chart-intro/view/ChartIntroScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,17 @@ class ChartIntroScreenView extends BANScreenView<ChartIntroModel> {
this.periodicTableAndIsotopeSymbol.right = this.resetAllButton.right;
this.addChild( this.periodicTableAndIsotopeSymbol );

this.elementName.centerX = this.doubleArrowButtons.centerX;
this.elementName.top = this.nucleonCountPanel.top;
this.elementName.boundsProperty.link( () => {
this.elementName.centerX = this.doubleArrowButtons.centerX;
this.elementName.top = this.nucleonCountPanel.top;
} );

this.nucleonCountPanel.left = this.layoutBounds.left + 20;

// Hook up update listeners.
Multilink.multilink( [ model.particleAtom.protonCountProperty, model.particleAtom.neutronCountProperty, model.doesNuclideExistBooleanProperty ],
( protonCount: number, neutronCount: number, doesNuclideExist: boolean ) =>
BANScreenView.updateElementName( this.elementName, protonCount, neutronCount, doesNuclideExist,
this.doubleArrowButtons.centerX )
BANScreenView.updateElementName( this.elementName, protonCount, neutronCount, doesNuclideExist )
);

// create and add the 'Nuclear Shell Model' title
Expand Down
7 changes: 1 addition & 6 deletions js/common/view/BANScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -751,8 +751,7 @@ abstract class BANScreenView<M extends BANModel<ParticleAtom | ParticleNucleus>>
* TODO: support dynamic locale for this whole function, https://github.com/phetsims/build-a-nucleus/issues/90
*
*/
public static updateElementName( elementNameText: Text, protonCount: number, neutronCount: number,
doesNuclideExist: boolean, centerX: number, centerY?: number ): void {
public static updateElementName( elementNameText: Text, protonCount: number, neutronCount: number, doesNuclideExist: boolean ): void {
let name = AtomIdentifier.getName( protonCount );
const massNumber = protonCount + neutronCount;

Expand Down Expand Up @@ -793,10 +792,6 @@ abstract class BANScreenView<M extends BANModel<ParticleAtom | ParticleNucleus>>
name += ' - ' + massNumber.toString();
}
elementNameText.string = name;
elementNameText.centerX = centerX;
if ( centerY ) {
elementNameText.centerY = centerY;
}
}

/**
Expand Down
8 changes: 4 additions & 4 deletions js/decay/view/DecayScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,15 @@ class DecayScreenView extends BANScreenView<DecayModel> {
};
model.doesNuclideExistBooleanProperty.link( updateStabilityIndicatorVisibility );

// TODO: move elementName to BANScreenView bc text node the same, just positioning different https://github.com/phetsims/build-a-nucleus/issues/93

this.elementName.center = this.stabilityIndicator.center.plusXY( 0, 60 );
this.elementName.boundsProperty.link( () => {
this.elementName.center = this.stabilityIndicator.center.plusXY( 0, 60 );
} );
this.nucleonCountPanel.left = availableDecaysPanel.left;

// Hook up update listeners.
Multilink.multilink( [ model.particleAtom.protonCountProperty, model.particleAtom.neutronCountProperty, model.doesNuclideExistBooleanProperty ],
( protonCount: number, neutronCount: number, doesNuclideExist: boolean ) =>
BANScreenView.updateElementName( this.elementName, protonCount, neutronCount, doesNuclideExist, this.stabilityIndicator.centerX )
BANScreenView.updateElementName( this.elementName, protonCount, neutronCount, doesNuclideExist )
);

// only show the emptyAtomCircle if less than 2 particles are in the atom. We still want to show it when there's
Expand Down
6 changes: 5 additions & 1 deletion js/decay/view/HalfLifeNumberLineNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ class HalfLifeNumberLineNode extends Node {
maxWidth: BANConstants.ELEMENT_NAME_MAX_WIDTH
} );
this.halfLifeDisplayNode.insertChild( 0, elementName );
const desiredCenterX = this.halfLifeDisplayNode.centerX;
this.halfLifeDisplayNode.boundsProperty.link( () => {
this.halfLifeDisplayNode.centerX = desiredCenterX;
} );

// Hook up update listeners.
Multilink.multilink( [
Expand All @@ -233,7 +237,7 @@ class HalfLifeNumberLineNode extends Node {
options.doesNuclideExistBooleanProperty
],
( protonCount, neutronCount, doesNuclideExist ) => BANScreenView.updateElementName( elementName,
protonCount, neutronCount, doesNuclideExist, this.halfLifeDisplayNode.centerX )
protonCount, neutronCount, doesNuclideExist )
);
}

Expand Down

0 comments on commit 03104f2

Please sign in to comment.