Skip to content

Commit

Permalink
Move info button to Variability screen, see #153
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Apr 25, 2023
1 parent d0baf2d commit bb48e91
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 36 deletions.
31 changes: 1 addition & 30 deletions js/common/view/CAVAccordionBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import Bounds2 from '../../../../dot/js/Bounds2.js';
import StrictOmit from '../../../../phet-core/js/types/StrictOmit.js';
import { ManualConstraint, Node, Rectangle } from '../../../../scenery/js/imports.js';
import { Node, Rectangle } from '../../../../scenery/js/imports.js';
import AccordionBox, { AccordionBoxOptions } from '../../../../sun/js/AccordionBox.js';
import CAVConstants from '../CAVConstants.js';
import optionize from '../../../../phet-core/js/optionize.js';
Expand All @@ -18,15 +18,11 @@ import CAVModel from '../model/CAVModel.js';
import ValueReadoutsNode from './ValueReadoutsNode.js';
import { Shape } from '../../../../kite/js/imports.js';
import PickRequired from '../../../../phet-core/js/types/PickRequired.js';
import InfoButton from '../../../../scenery-phet/js/buttons/InfoButton.js';
import TReadOnlyProperty from '../../../../axon/js/TReadOnlyProperty.js';
import VariabilityModel from '../../variability/model/VariabilityModel.js';

type SelfOptions = {
valueReadoutsNode: ValueReadoutsNode | null;
contentNodeOffsetY: number;
leftMargin: number;
infoShowingProperty: TReadOnlyProperty<boolean> | null;
};
export type CAVAccordionBoxOptions =
SelfOptions
Expand Down Expand Up @@ -102,31 +98,6 @@ export default class CAVAccordionBox extends AccordionBox {
super( backgroundNode, options );

model.resetEmitter.addListener( () => this.reset() );

if ( options.infoShowingProperty ) {
const infoButton = new InfoButton( {
iconFill: 'cornflowerblue',
scale: 0.5,
rightTop: backgroundNode.rightTop.plusXY( -5, 5 ),
touchAreaDilation: 5,
tandem: options.tandem.createTandem( 'infoButton' ),
listener: () => {

// TODO: cast?
( model as VariabilityModel ).isInfoShowingProperty.value = true;
}
} );
backgroundNode.addChild( infoButton );

// NOTE: this overlaps the accordion box top panel
ManualConstraint.create( this, [ backgroundNode, infoButton ],
( backgroundWrapper, infoButtonWrapper ) => {

// TODO: Is it a faux pas to move outside of the wrapper bounds? I couldn't figure how to be a child of the accordion
// box content, but overlap the title bar
infoButtonWrapper.rightTop = backgroundWrapper.rightTop.plusXY( 3, -35 );
} );
}
}
}

Expand Down
3 changes: 1 addition & 2 deletions js/mean-and-median/view/MeanAndMedianScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ export default class MeanAndMedianScreenView extends CAVScreenView {
contentNodeOffsetY: 0,
top: top,
valueReadoutsNode: new ValueReadoutsNode( model ),
centerX: layoutBounds.centerX,
infoShowingProperty: null
centerX: layoutBounds.centerX
} );
}, options );

Expand Down
3 changes: 1 addition & 2 deletions js/median/view/MedianScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ export default class MedianScreenView extends CAVScreenView {
contentNodeOffsetY: -6,
top: top,
valueReadoutsNode: null,
centerX: layoutBounds.centerX,
infoShowingProperty: null
centerX: layoutBounds.centerX
} );
}, options );
}
Expand Down
28 changes: 26 additions & 2 deletions js/variability/view/VariabilityScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import CAVAccordionBox from '../../common/view/CAVAccordionBox.js';
import VariabilityReadoutsNode from './VariabilityReadoutsNode.js';
import PhetFont from '../../../../scenery-phet/js/PhetFont.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import InfoButton from '../../../../scenery-phet/js/buttons/InfoButton.js';

// TODO: Copied from somewhere. What's the best pattern?
const TEXT_OPTIONS = {
Expand Down Expand Up @@ -79,6 +80,21 @@ export default class VariabilityScreenView extends CAVScreenView {
tandem: tandem.createTandem( 'plotNode' )
} );

const infoButton = new InfoButton( {
iconFill: 'cornflowerblue',
scale: 0.5,
touchAreaDilation: 5,
tandem: options.tandem.createTandem( 'infoButton' ),
listener: () => {
model.isInfoShowingProperty.value = true;
},
top: 0,

// TODO: How to position this properly?
right: accordionBoxContents.width + 130
} );
accordionBoxContents.addChild( infoButton );

afterInit = () => { // NOTE: This assumes that the NumberLineNode in the play area and in the dot plot have the same characteristics:
// * Same font
// * Same offset and scale
Expand All @@ -94,6 +110,15 @@ export default class VariabilityScreenView extends CAVScreenView {
( variabilityRadioButtonGroupWrapper, accordionBoxWrapper ) => {
variabilityRadioButtonGroupWrapper.top = accordionBoxWrapper.top;
} );

// NOTE: this overlaps the accordion box top panel
// ManualConstraint.create( this, [ accordionBoxContents, infoButton ],
// ( backgroundWrapper, infoButtonWrapper ) => {
//
// // TODO: Is it a faux pas to move outside of the wrapper bounds? I couldn't figure how to be a child of the accordion
// // box content, but overlap the title bar
// infoButtonWrapper.rightTop = backgroundWrapper.rightTop.plusXY( 3, -35 );
// } );
};
return new CAVAccordionBox( model, accordionBoxContents, new ToggleNode( model.selectedVariabilityProperty, [ {
value: VariabilityMeasure.RANGE,
Expand Down Expand Up @@ -124,8 +149,7 @@ export default class VariabilityScreenView extends CAVScreenView {
contentNodeOffsetY: 0,
top: top,
valueReadoutsNode: new VariabilityReadoutsNode( model ),
right: layoutBounds.right - CAVConstants.SCREEN_VIEW_X_MARGIN,
infoShowingProperty: model.isInfoShowingProperty
right: layoutBounds.right - CAVConstants.SCREEN_VIEW_X_MARGIN
} );

}, options );
Expand Down

0 comments on commit bb48e91

Please sign in to comment.