-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switching to optionsNode for global options. see #154
- Loading branch information
1 parent
5b9874f
commit 3dbc031
Showing
3 changed files
with
9 additions
and
34 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 |
---|---|---|
|
@@ -3,54 +3,26 @@ | |
/** | ||
* Shows an Options dialog that consists of sim-global options. | ||
* | ||
* Options are provided as 'globalOptions' inside a sim's options. | ||
* | ||
* @author Jonathan Olson <[email protected]> | ||
*/ | ||
define( function( require ) { | ||
'use strict'; | ||
|
||
// modules | ||
var VBox = require( 'SCENERY/nodes/VBox' ); | ||
var Text = require( 'SCENERY/nodes/Text' ); | ||
var inherit = require( 'PHET_CORE/inherit' ); | ||
var PhetFont = require( 'SCENERY_PHET/PhetFont' ); | ||
var CheckBox = require( 'SUN/CheckBox' ); | ||
var Dialog = require( 'JOIST/Dialog' ); | ||
|
||
// strings | ||
var optionsTitleString = require( 'string!JOIST/options.title' ); | ||
|
||
/** | ||
* The options should be an array of item objects, which all have item.type. The following types are available: | ||
* | ||
* { // 'boolean' will show up as a labeled CheckBox | ||
* type: 'boolean', | ||
* label: 'Some Option', | ||
* property: someBooleanProperty | ||
* } | ||
* | ||
* @param {Array} options | ||
* @param {Node} optionsNode | ||
* @constructor | ||
*/ | ||
function OptionsDialog( options ) { | ||
|
||
var children = []; | ||
for ( var i = 0; i < options.length; i++ ) { | ||
var option = options[i]; | ||
|
||
switch( option.type ) { | ||
case 'boolean': | ||
children.push( new CheckBox( new Text( option.label, { font: new PhetFont( 15 ) } ), option.property, {} ) ); | ||
break; | ||
default: | ||
throw new Error( 'unknown option type: ' + option.type ); | ||
} | ||
} | ||
|
||
var content = new VBox( { align: 'left', spacing: 10, children: children } ); | ||
|
||
Dialog.call( this, content, { | ||
function OptionsDialog( optionsNode ) { | ||
Dialog.call( this, optionsNode, { | ||
title: new Text( optionsTitleString, { font: new PhetFont( 30 ) } ), | ||
titleAlign: 'center', | ||
modal: true, | ||
|
@@ -60,5 +32,8 @@ define( function( require ) { | |
|
||
inherit( Dialog, OptionsDialog ); | ||
|
||
OptionsDialog.DEFAULT_FONT = new PhetFont( 15 ); | ||
OptionsDialog.DEFAULT_SPACING = 10; | ||
|
||
return OptionsDialog; | ||
} ); |
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