-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generalized ToggleNode to handle an arbitrary number of values, see #360
- Loading branch information
Showing
5 changed files
with
120 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2013-2017, University of Colorado Boulder | ||
|
||
/** | ||
* Shows one node if the property is true or another node if the property is false. Used to indicate boolean state. | ||
* This is a convenience API for true/false nodes, see SelectedNode for the general case. | ||
* | ||
* @author Sam Reid (PhET Interactive Simulations) | ||
* @author Chris Malley (PixelZoom, Inc.) | ||
*/ | ||
define( function( require ) { | ||
'use strict'; | ||
|
||
// modules | ||
var inherit = require( 'PHET_CORE/inherit' ); | ||
var ToggleNode = require( 'SUN/ToggleNode' ); | ||
var sun = require( 'SUN/sun' ); | ||
|
||
/** | ||
* @param {Node} trueNode | ||
* @param {Node} falseNode | ||
* @param {Property.<boolean>} booleanProperty | ||
* @param {Object} [options] | ||
* @constructor | ||
*/ | ||
function BooleanToggleNode( trueNode, falseNode, booleanProperty, options ) { | ||
|
||
options = _.extend( { | ||
|
||
// For compatibility with prior usage, we align the x coordinate | ||
alignChildren: ToggleNode.HORIZONTAL | ||
}, options ); | ||
|
||
ToggleNode.call( this, [ | ||
{ value: true, node: trueNode }, | ||
{ value: false, node: falseNode } | ||
], booleanProperty, options ); | ||
} | ||
|
||
sun.register( 'BooleanToggleNode', BooleanToggleNode ); | ||
|
||
return inherit( ToggleNode, BooleanToggleNode ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters