Skip to content

Commit

Permalink
PhET-iO instrumentation for preferences controls related to speech sy…
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Dec 10, 2024
1 parent 59fa273 commit b1f6c81
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 15 deletions.
28 changes: 20 additions & 8 deletions js/common/view/AutoHearControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,48 @@ import PreferencesControl from '../../../../joist/js/preferences/PreferencesCont
import PreferencesDialog from '../../../../joist/js/preferences/PreferencesDialog.js';
import PreferencesDialogConstants from '../../../../joist/js/preferences/PreferencesDialogConstants.js';
import PhetFont from '../../../../scenery-phet/js/PhetFont.js';
import { Color, Node, Path, Text, TextOptions, VBox } from '../../../../scenery/js/imports.js';
import { Color, Node, NodeOptions, Path, Text, TextOptions, VBox } from '../../../../scenery/js/imports.js';
import exclamationTriangleSolidShape from '../../../../sherpa/js/fontawesome-5/exclamationTriangleSolidShape.js';
import ToggleSwitch from '../../../../sun/js/ToggleSwitch.js';
import ToggleSwitch, { ToggleSwitchOptions } from '../../../../sun/js/ToggleSwitch.js';
import numberSuiteCommon from '../../numberSuiteCommon.js';
import NumberSuiteCommonStrings from '../../NumberSuiteCommonStrings.js';
import NumberSuiteCommonConstants from '../NumberSuiteCommonConstants.js';
import Property from '../../../../axon/js/Property.js';
import optionize, { combineOptions, EmptySelfOptions } from '../../../../phet-core/js/optionize.js';
import Tandem from '../../../../tandem/js/Tandem.js';

const MISSING_VOICE_WARNING_TEXT_OPTIONS: TextOptions = {
font: new PhetFont( 14 ),
maxWidth: PreferencesDialog.CONTENT_MAX_WIDTH
};

type SelfOptions = EmptySelfOptions;

type AutoHearControlOptions = SelfOptions & NodeOptions;

export default class AutoHearControl extends Node {

public constructor(
autoHearEnabledProperty: Property<boolean>,
hasVoiceProperty: TReadOnlyProperty<boolean>,
labelStringProperty: TReadOnlyProperty<string>,
descriptionStringProperty: TReadOnlyProperty<string>,
visible = true
providedOptions?: AutoHearControlOptions
) {

super( {
visible: visible,
isDisposable: false
} );
const options = optionize<AutoHearControlOptions, SelfOptions, NodeOptions>()( {

// NodeOptions
isDisposable: false,
tandem: Tandem.OPT_OUT
}, providedOptions );

super( options );

const toggleSwitch = new ToggleSwitch( autoHearEnabledProperty, false, true,
PreferencesDialogConstants.TOGGLE_SWITCH_OPTIONS );
combineOptions<ToggleSwitchOptions>( {}, PreferencesDialogConstants.TOGGLE_SWITCH_OPTIONS, {
tandem: options.tandem.createTandem( 'toggleSwitch' )
} ) );

const control = new PreferencesControl( {
labelNode: new Text( labelStringProperty, PreferencesDialogConstants.CONTROL_LABEL_OPTIONS ),
Expand Down
7 changes: 5 additions & 2 deletions js/common/view/LanguageAndVoiceControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import PhetFont from '../../../../scenery-phet/js/PhetFont.js';
import { Color, HBox, HBoxOptions, ManualConstraint, Node, RichText, RichTextOptions, Text, TextOptions, VBox } from '../../../../scenery/js/imports.js';
import Carousel, { CarouselItem, CarouselOptions } from '../../../../sun/js/Carousel.js';
import PageControl from '../../../../sun/js/PageControl.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import numberSuiteCommon from '../../numberSuiteCommon.js';
import NumberSuiteCommonStrings from '../../NumberSuiteCommonStrings.js';
import CarouselItemNode from './CarouselItemNode.js';
Expand All @@ -31,7 +32,8 @@ const CAROUSEL_OPTIONS: CarouselOptions = {
itemsPerPage: 10,
spacing: 6,
margin: 5,
orientation: 'vertical'
orientation: 'vertical',
tandem: Tandem.OPT_OUT
};
const LABEL_Y_SPACING = 10;

Expand Down Expand Up @@ -110,7 +112,8 @@ export default class LanguageAndVoiceControl extends HBox {
dotMouseAreaDilation: 5,

// Hide pageControl if there's only one page.
visibleProperty: new DerivedProperty( [ languageCarousel.numberOfPagesProperty ], numberOfPages => numberOfPages > 1 )
visibleProperty: new DerivedProperty( [ languageCarousel.numberOfPagesProperty ], numberOfPages => numberOfPages > 1 ),
tandem: Tandem.OPT_OUT
} );

const voiceControlVBox = new VBox( {
Expand Down
15 changes: 10 additions & 5 deletions js/common/view/SecondLanguageControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ import localeProperty, { LocaleProperty } from '../../../../joist/js/i18n/locale
import PreferencesControl from '../../../../joist/js/preferences/PreferencesControl.js';
import PreferencesDialog from '../../../../joist/js/preferences/PreferencesDialog.js';
import PreferencesDialogConstants from '../../../../joist/js/preferences/PreferencesDialogConstants.js';
import optionize, { EmptySelfOptions } from '../../../../phet-core/js/optionize.js';
import optionize, { combineOptions, EmptySelfOptions } from '../../../../phet-core/js/optionize.js';
import StrictOmit from '../../../../phet-core/js/types/StrictOmit.js';
import PhetFont from '../../../../scenery-phet/js/PhetFont.js';
import { allowLinksProperty, RichText, Text, VBox, VBoxOptions } from '../../../../scenery/js/imports.js';
import ToggleSwitch from '../../../../sun/js/ToggleSwitch.js';
import ToggleSwitch, { ToggleSwitchOptions } from '../../../../sun/js/ToggleSwitch.js';
import numberSuiteCommon from '../../numberSuiteCommon.js';
import NumberSuiteCommonStrings from '../../NumberSuiteCommonStrings.js';
import NumberSuiteCommonConstants from '../NumberSuiteCommonConstants.js';
import LanguageAndVoiceControl from './LanguageAndVoiceControl.js';
import NumberSuiteCommonUtteranceQueue from './NumberSuiteCommonUtteranceQueue.js';
import Property from '../../../../axon/js/Property.js';
import Tandem from '../../../../tandem/js/Tandem.js';

type SelfOptions = EmptySelfOptions;
type SecondLanguageControlOptions = SelfOptions & StrictOmit<VBoxOptions, 'children'>;
Expand All @@ -44,7 +45,8 @@ export default class SecondLanguageControl extends VBox {
isDisposable: false,
excludeInvisibleChildrenFromBounds: false,
align: 'left',
spacing: NumberSuiteCommonConstants.PREFERENCES_VBOX_SPACING
spacing: NumberSuiteCommonConstants.PREFERENCES_VBOX_SPACING,
tandem: Tandem.OPT_OUT
}, providedOptions );

const labelText = new Text( NumberSuiteCommonStrings.secondLanguageStringProperty,
Expand All @@ -54,7 +56,9 @@ export default class SecondLanguageControl extends VBox {
PreferencesDialogConstants.CONTROL_DESCRIPTION_OPTIONS );

const toggleSwitch = new ToggleSwitch( secondLocaleEnabledProperty, false, true,
PreferencesDialogConstants.TOGGLE_SWITCH_OPTIONS );
combineOptions<ToggleSwitchOptions>( {}, PreferencesDialogConstants.TOGGLE_SWITCH_OPTIONS, {
tandem: options.tandem.createTandem( 'toggleSwitch' )
} ) );

// Control for showing or hiding the languageAndVoiceControl
const preferencesControl = new PreferencesControl( {
Expand All @@ -70,7 +74,8 @@ export default class SecondLanguageControl extends VBox {

// Control for choosing a second language and associated voice
const languageAndVoiceControl = new LanguageAndVoiceControl( secondLocaleProperty, secondVoiceProperty, utteranceQueue, {
visibleProperty: secondLocaleEnabledProperty
visibleProperty: secondLocaleEnabledProperty,
tandem: Tandem.OPT_OUT
} );

options.children = [
Expand Down

0 comments on commit b1f6c81

Please sign in to comment.