Skip to content

Commit

Permalink
Reset Molecule3DDialog.viewStyleProperty when the ResetAllButton is c…
Browse files Browse the repository at this point in the history
…licked. #191
  • Loading branch information
Denz1994 committed Jun 9, 2020
1 parent 0d19dc1 commit 3d25e8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
6 changes: 4 additions & 2 deletions js/common/view/BAMScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class BAMScreenView extends ScreenView {
this.updateRefillButton = () => {
this.refillButton.enabled = !this.bamModel.currentCollectionProperty.value.currentKitProperty.value.allBucketsFilled();
};

// @public {ResetAllButton} Create a reset all button. Position of button is adjusted on "Larger" Screen.
this.resetAllButton = new ResetAllButton( {
listener: () => {
Expand All @@ -131,6 +132,7 @@ class BAMScreenView extends ScreenView {
kitPanel.reset();
if ( this.dialog instanceof Molecule3DDialog ) {
this.dialog.isPlayingProperty.reset();
this.dialog.viewStyleProperty.reset();
}
this.updateRefillButton();

Expand All @@ -141,8 +143,8 @@ class BAMScreenView extends ScreenView {
},
right: this.layoutBounds.right - BAMConstants.VIEW_PADDING / 2,
bottom: kitPanel.bottom + BAMConstants.VIEW_PADDING / 4
} )
;
} );

this.resetAllButton.touchArea = this.resetAllButton.bounds.dilated( 7 );
this.addChild( this.resetAllButton );
this.resetAllButton.moveToBack();
Expand Down
13 changes: 6 additions & 7 deletions js/common/view/view3d/Molecule3DDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ class Molecule3DDialog extends Dialog {
// @public {BooleanProperty}
this.userControlledProperty = new BooleanProperty( false );

// View styles for space filled and ball and stick views.
const viewStyleProperty = new EnumerationProperty( ViewStyle, ViewStyle.SPACE_FILL );
//REVIEW: playPauseButton could use a bigger touch area? Maybe the other buttons too in this dialog.
// @public {EnumerationProperty} View styles for space filled and ball and stick views.
this.viewStyleProperty = new EnumerationProperty( ViewStyle, ViewStyle.SPACE_FILL );
const playPauseButton = new PlayPauseButton( this.isPlayingProperty, {
radius: 15,
valueOffSoundPlayer: Playable.NO_SOUND,
Expand Down Expand Up @@ -201,7 +200,7 @@ class Molecule3DDialog extends Dialog {
// Listener to change the view style to the space filled representation
spaceFilledIcon.addInputListener( new PressListener( {
press: () => {
viewStyleProperty.value = ViewStyle.SPACE_FILL;
this.viewStyleProperty.value = ViewStyle.SPACE_FILL;
}
} ) );

Expand All @@ -219,7 +218,7 @@ class Molecule3DDialog extends Dialog {
// Updates the view style to the ball and stick representation
ballAndStickIcon.addInputListener( new PressListener( {
press: () => {
viewStyleProperty.value = ViewStyle.BALL_AND_STICK;
this.viewStyleProperty.value = ViewStyle.BALL_AND_STICK;
}
} ) );

Expand All @@ -232,7 +231,7 @@ class Molecule3DDialog extends Dialog {
moleculeScene.add( moleculeContainer );

// Handle the each 3D representation based on the current view style
Property.multilink( [ viewStyleProperty, completeMoleculeProperty ], ( viewStyle, completeMolecule ) => {
Property.multilink( [ this.viewStyleProperty, completeMoleculeProperty ], ( viewStyle, completeMolecule ) => {
if ( completeMolecule ) {

// Remove all previous mesh elements if they exists from a previous build
Expand Down Expand Up @@ -263,7 +262,7 @@ class Molecule3DDialog extends Dialog {
} ];

// Create the icons for scene selection
const sceneRadioButtonGroup = new RadioButtonGroup( viewStyleProperty, toggleButtonsContent, {
const sceneRadioButtonGroup = new RadioButtonGroup( this.viewStyleProperty, toggleButtonsContent, {
buttonContentXMargin: 5,
buttonContentYMargin: -8, // Trimming of part of the icon node is acceptable in this case.
baseColor: 'black',
Expand Down

0 comments on commit 3d25e8a

Please sign in to comment.