Skip to content

Commit

Permalink
self-voicing -> voicing in many comments, see phetsims/tasks#1083
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Mar 25, 2021
1 parent 0563d6a commit 60459b6
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 86 deletions.
4 changes: 2 additions & 2 deletions js/view/CursorSpeakerModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ class CursorSpeakerModel {
// @public {BooleanProperty} - if true, content will be read to the user while interacting with various objects
this.interactiveModeProperty = new BooleanProperty( true );

// {Property.<Verbosity>} - the "interactive mode" self voicing content can be brief or more "verbose",
// {Property.<Verbosity>} - the "interactive mode" voicing content can be brief or more "verbose",
// debending on user selection
this.interactiveModeVerbosityProperty = new EnumerationProperty( Verbosity, Verbosity.VERBOSE );

// {EnumerationProperty.<Verbosity>} - the "explore mode" self voicing content can be brief or verbose, depending
// {EnumerationProperty.<Verbosity>} - the "explore mode" voicing content can be brief or verbose, depending
// on user selection
this.exploreModeVerbosityProperty = new EnumerationProperty( Verbosity, Verbosity.VERBOSE );
}
Expand Down
8 changes: 4 additions & 4 deletions js/view/FocusSpeaker.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright 2020, University of Colorado Boulder

/**
* A class that makes usually non-focusable things focusable for the self voicing prototype. Text and
* A class that makes usually non-focusable things focusable for the voicing prototype. Text and
* other non-interactive things need to have a place in the navigation order so that they can be discovered
* and read in the self-voicing feature set.
* and read in the voicing feature set.
*
* @author Jesse Greenberg
*/
Expand Down Expand Up @@ -45,13 +45,13 @@ class FocusSpeaker {
* @param targetNode
*/
makeTargetFocusable( targetNode ) {
assert && assert( targetNode.tagName === null, 'target should have no accessible content before becoming focusable for self-voicing' );
assert && assert( targetNode.tagName === null, 'target should have no accessible content before becoming focusable for voicing' );
assert && assert( targetNode.focusable === false, 'target should not be initially focusable' );

targetNode.tagName = 'div';

// these nodes have a different highlight managed by SpeakerHighlighter, which indicates what
// has self-voicing content and when the speaker is talking
// has voicing content and when the speaker is talking
targetNode.focusHighlight = 'invisible';
targetNode.focusable = true;
}
Expand Down
78 changes: 15 additions & 63 deletions js/view/ISLCObjectNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import VoicingUtterance from '../../../utterance-queue/js/VoicingUtterance.js';
import ISLCConstants from '../ISLCConstants.js';
import inverseSquareLawCommon from '../inverseSquareLawCommon.js';
import inverseSquareLawCommonStrings from '../inverseSquareLawCommonStrings.js';
import cursorSpeakerModel from './CursorSpeakerModel.js';
import DefaultDirection from './DefaultDirection.js';
import ISLCAlertManager from './ISLCAlertManager.js';
import ISLCForceArrowNode from './ISLCForceArrowNode.js';
Expand All @@ -43,13 +42,8 @@ import ISLCPullerNode from './ISLCPullerNode.js';
import PositionDescriber from './describers/PositionDescriber.js';

// constants
const selfVoicingPositionChangePatternString = inverseSquareLawCommonStrings.a11y.voicing.positionChangePattern;
const selfVoicingBiggerString = inverseSquareLawCommonStrings.a11y.voicing.bigger;
const selfVoicingSmallerString = inverseSquareLawCommonStrings.a11y.voicing.smaller;
const selfVoicingBriefNewForceNoValuesAlertString = inverseSquareLawCommonStrings.a11y.voicing.briefNewForceNoValuesAlert;
const selfVoicingBriefNewForceAlertPatternString = inverseSquareLawCommonStrings.a11y.voicing.briefNewForceAlertPattern;
const summaryInteractionHintPatternString = inverseSquareLawCommonStrings.a11y.screenSummary.summaryInteractionHintPattern;
const selfVoicingLevelsMoveSpheresHintString = inverseSquareLawCommonStrings.a11y.voicing.levels.moveSpheresHintString;
const voicingLevelsMoveSpheresHintString = inverseSquareLawCommonStrings.a11y.voicing.levels.moveSpheresHintString;
const forceArrowSizePatternString = inverseSquareLawCommonStrings.a11y.voicing.levels.forceArrowSizePattern;
const grabbedString = sceneryPhetStrings.a11y.voicing.grabbedAlert;

Expand Down Expand Up @@ -90,7 +84,7 @@ class ISLCObjectNode extends Node {

forceArrowHeight: 150, // height of arrow in view coordinates

objectColor: null, // {{string}} @required - description of sphere for self-voicing content
objectColor: null, // {{string}} @required - description of sphere for voicing content

// phet-io
tandem: Tandem.REQUIRED,
Expand Down Expand Up @@ -170,7 +164,7 @@ class ISLCObjectNode extends Node {
config.arrowNodeOptions
);

// PROTOTYPE a11y code for self-voicing features
// PROTOTYPE a11y code for voicing features
if ( phet.chipper.queryParameters.supportsVoicing ) {
const arrowHitListener = () => {
let objectResponse;
Expand All @@ -186,7 +180,7 @@ class ISLCObjectNode extends Node {
}
else {

// custom response for self voicing when force values are hidden
// custom response for voicing when force values are hidden
objectResponse = forceDescriber.getSelfVoicingQualitativeForceVectorText( config.otherObjectLabel );
}

Expand Down Expand Up @@ -232,16 +226,16 @@ class ISLCObjectNode extends Node {
// @protected - the object
this.objectCircle = new Circle( radius );

// PROTOTYPE a11y code, to support self-voicing features
// PROTOTYPE a11y code, to support voicing features
if ( phet.chipper.queryParameters.supportsVoicing ) {
assert && assert( config.objectColor, 'required param, if testing self voicing features' );
assert && assert( config.objectColor, 'required param, if testing voicing features' );

this.addInputListener( new VoicingInputListener( {
onFocusIn: () => {

// special behavior if the hit is from a keyboard
const interactionHint = selfVoicingLevelsMoveSpheresHintString;
const objectResponse = positionDescriber.getSelfVoicingDistanceDescription( config.label, config.otherObjectLabel );
const interactionHint = voicingLevelsMoveSpheresHintString;
const objectResponse = positionDescriber.getVoicingDistanceDescription( config.label, config.otherObjectLabel );

if ( phet.chipper.queryParameters.supportsVoicing ) {
const response = levelSpeakerModel.collectResponses( objectResponse, null, interactionHint );
Expand Down Expand Up @@ -305,7 +299,7 @@ class ISLCObjectNode extends Node {

// @public - so that events can be forwarded to this DragListener in the
// case of alternative input
const selfVoicingDragUtterance = new VoicingUtterance( {
const voicingDragUtterance = new VoicingUtterance( {
alertStableDelay: 500,
alertMaximumDelay: 1000,
cancelOther: false
Expand All @@ -323,8 +317,8 @@ class ISLCObjectNode extends Node {
// the initial dragging alert does not use the utterance because it must be assertive and
// should interrupt any other utterance being spoken
// special behavior if the hit is from a keyboard
const interactionHint = selfVoicingLevelsMoveSpheresHintString;
const distanceDescription = positionDescriber.getSelfVoicingDistanceDescription( config.label, config.otherObjectLabel );
const interactionHint = voicingLevelsMoveSpheresHintString;
const distanceDescription = positionDescriber.getVoicingDistanceDescription( config.label, config.otherObjectLabel );

const objectResponse = StringUtils.fillIn( '{{grabbed}}. {{response}}', {
grabbed: grabbedString,
Expand Down Expand Up @@ -355,7 +349,7 @@ class ISLCObjectNode extends Node {
object.positionProperty.set( model.snapToGrid( x ) );

if ( phet.chipper.queryParameters.supportsVoicing ) {
const distanceDescription = positionDescriber.getSelfVoicingDistanceDescriptionWithoutLabel( config.otherObjectLabel );
const distanceDescription = positionDescriber.getVoicingDistanceDescriptionWithoutLabel( config.otherObjectLabel );

// only speak something if the positions have changed during drag
if ( oldPosition !== object.positionProperty.get() ) {
Expand All @@ -372,8 +366,8 @@ class ISLCObjectNode extends Node {
previousSeparation = model.separationProperty.get();
oldPosition = object.positionProperty.get();

selfVoicingDragUtterance.alert = levelSpeakerModel.collectResponses( distanceDescription, forceChangeText );
phet.joist.sim.voicingUtteranceQueue.addToBack( selfVoicingDragUtterance );
voicingDragUtterance.alert = levelSpeakerModel.collectResponses( distanceDescription, forceChangeText );
phet.joist.sim.voicingUtteranceQueue.addToBack( voicingDragUtterance );
}
}
},
Expand Down Expand Up @@ -425,7 +419,7 @@ class ISLCObjectNode extends Node {
object.isDraggingProperty.value = false;
this.redrawForce();

const distanceDescription = positionDescriber.getSelfVoicingDistanceDescriptionWithoutLabel( config.otherObjectLabel );
const distanceDescription = positionDescriber.getVoicingDistanceDescriptionWithoutLabel( config.otherObjectLabel );

// only speak force change if it has changed
let forceChangeText = '';
Expand Down Expand Up @@ -522,48 +516,6 @@ class ISLCObjectNode extends Node {
this.pullerNode.setPull( this.model.forceProperty.get(), this.objectCircle.width / 2 );
}

/**
* PROTOTYPE CODE: For the self voicing feature set, get alerts that describe the change in mass position. Only to be read when
* "interactive" mode is enabled.
* @private
*
* @param {number} newPosition
* @param {number} oldPosition
* @param {number} newForce
* @param {number} oldForce
* @returns {string}
*/
getSelfVoicingPositionChangeAlert( newPosition, oldPosition, newForce, oldForce ) {
let vectorChangeText;

if ( cursorSpeakerModel.getInteractiveModeVerbose() ) {

// just the aria-live alert in verbose mode
vectorChangeText = newPosition !== oldPosition ? this.forceDescriber.getVectorChangeText( this.objectModel ) : this.forceDescriber.getPositionUnchangedAlertText( this.objectModel );
}
else if ( cursorSpeakerModel.getInteractiveModeBrief() ) {

// custom alert if brief mode, description dependent on whether values are shown
const changeString = newForce - oldForce > 0 ? selfVoicingBiggerString : selfVoicingSmallerString;
if ( this.model.showForceValuesProperty.get() ) {
vectorChangeText = StringUtils.fillIn( selfVoicingBriefNewForceAlertPatternString, {
change: changeString,
value: this.forceDescriber.getFormattedForce()
} );
}
else {
vectorChangeText = StringUtils.fillIn( selfVoicingBriefNewForceNoValuesAlertString, {
change: changeString
} );
}
}

return StringUtils.fillIn( selfVoicingPositionChangePatternString, {
valueText: this.getAriaValueText(),
vectorText: vectorChangeText
} );
}

/**
* @public
*/
Expand Down
12 changes: 6 additions & 6 deletions js/view/describers/ForceDescriber.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ const lighlyString = inverseSquareLawCommonStrings.a11y.pullerEffort.lightly;
const aLittleString = inverseSquareLawCommonStrings.a11y.pullerEffort.aLittle;
const aTinyBitString = inverseSquareLawCommonStrings.a11y.pullerEffort.aTinyBit;

const selfVoicingLevelsForcePatternString = inverseSquareLawCommonStrings.a11y.voicing.levels.forcePattern;
const selfVoicingQualitativeVectorPatternString = inverseSquareLawCommonStrings.a11y.voicing.levels.qualitativeVectorPattern;
const voicingLevelsForcePatternString = inverseSquareLawCommonStrings.a11y.voicing.levels.forcePattern;
const voicingQualitativeVectorPatternString = inverseSquareLawCommonStrings.a11y.voicing.levels.qualitativeVectorPattern;

const SIZE_STRINGS = [
tinyString,
Expand Down Expand Up @@ -222,7 +222,7 @@ class ForceDescriber extends ISLCDescriber {
}

/**
* Get a string that describes the force vectors, for the self voicing prototype - not used yet for
* Get a string that describes the force vectors, for the voicing prototype - not used yet for
* production code.
* @public
*
Expand All @@ -231,15 +231,15 @@ class ForceDescriber extends ISLCDescriber {
* @returns {string}
*/
getSelfVoicingForceVectorMagnitudeText( thisObjectLabel, otherObjectLabel ) {
return StringUtils.fillIn( selfVoicingLevelsForcePatternString, {
return StringUtils.fillIn( voicingLevelsForcePatternString, {
object1: thisObjectLabel,
object2: otherObjectLabel,
value: this.getFormattedForce()
} );
}

/**
* For the self voicing prototype - returns a string that describes the size of the force arrow and its direction.
* For the voicing prototype - returns a string that describes the size of the force arrow and its direction.
* Returns something like
* "Force arrow is very small, and points directly at mass 1.
*
Expand All @@ -248,7 +248,7 @@ class ForceDescriber extends ISLCDescriber {
* @returns {string}
*/
getSelfVoicingQualitativeForceVectorText( otherObjectLabel ) {
return StringUtils.fillIn( selfVoicingQualitativeVectorPatternString, {
return StringUtils.fillIn( voicingQualitativeVectorPatternString, {
size: this.getVectorSize(),
otherObject: otherObjectLabel
} );
Expand Down
22 changes: 11 additions & 11 deletions js/view/describers/PositionDescriber.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ const lastStopLeftString = inverseSquareLawCommonStrings.a11y.position.landmarks
const trackEndLeftString = inverseSquareLawCommonStrings.a11y.position.landmarks.trackEndLeft;
const trackEndRightString = inverseSquareLawCommonStrings.a11y.position.landmarks.trackEndRight;

const selfVoicingLevelsMassQuantitativePatternString = inverseSquareLawCommonStrings.a11y.voicing.levels.massQuantitativePattern;
const selfVoicingLevelsMassQualitativePatternString = inverseSquareLawCommonStrings.a11y.voicing.levels.massQualitativePattern;
const voicingLevelsMassQuantitativePatternString = inverseSquareLawCommonStrings.a11y.voicing.levels.massQuantitativePattern;
const voicingLevelsMassQualitativePatternString = inverseSquareLawCommonStrings.a11y.voicing.levels.massQualitativePattern;

const selfVoicingLevelsMassQuantitativeWithoutLabelPatternString = inverseSquareLawCommonStrings.a11y.voicing.levels.massQuantitativeWithoutLabelPattern;
const selfVoicingLevelsMassQualitativeWithoutLabelPatternString = inverseSquareLawCommonStrings.a11y.voicing.levels.massQualitativeWithoutLabelPattern;
const voicingLevelsMassQuantitativeWithoutLabelPatternString = inverseSquareLawCommonStrings.a11y.voicing.levels.massQuantitativeWithoutLabelPattern;
const voicingLevelsMassQualitativeWithoutLabelPatternString = inverseSquareLawCommonStrings.a11y.voicing.levels.massQualitativeWithoutLabelPattern;

const RELATIVE_DISTANCE_STRINGS = [
farthestFromString,
Expand Down Expand Up @@ -482,16 +482,16 @@ class PositionDescriber extends ISLCDescriber {
}

/**
* Returns a string to be used in the prototype self-voicing context. Returns something like
* Returns a string to be used in the prototype voicing context. Returns something like
* "mass 1, 4 kilometers from mass 1" (distances shown) or
* "mass 1, close to mass 1" (distances hidden) or
* "Move mass 1, 4 kilometers from mass 2 (sounding more like the PDOM, "version 2")
* @param {string} objectLabel
* @param {string} otherObjectLabel
* @public
*/
getSelfVoicingDistanceDescription( objectLabel, otherObjectLabel ) {
const patternString = this.useQuantitativeDistance ? selfVoicingLevelsMassQuantitativePatternString : selfVoicingLevelsMassQualitativePatternString;
getVoicingDistanceDescription( objectLabel, otherObjectLabel ) {
const patternString = this.useQuantitativeDistance ? voicingLevelsMassQuantitativePatternString : voicingLevelsMassQualitativePatternString;
const distanceDescription = this.useQuantitativeDistance ? this.getDistanceAndUnits() : this.getQualitativeRelativeDistanceRegion();

const objectDescription = StringUtils.fillIn( patternString, {
Expand All @@ -504,8 +504,8 @@ class PositionDescriber extends ISLCDescriber {
}

/**
* Returns a string to be used in the prototype self-voicing content, describing the distance betwseen objects. Similar
* to getSelfVoicingDistanceDescription, but does not inlucde the label to reduce verbocity. Returns something like
* Returns a string to be used in the prototype voicing content, describing the distance betwseen objects. Similar
* to getVoicingDistanceDescription, but does not inlucde the label to reduce verbocity. Returns something like
*
* "4 kilometers from mass 1" or
* "close to mass 1"
Expand All @@ -514,8 +514,8 @@ class PositionDescriber extends ISLCDescriber {
* @param {String} otherObjectLabel
* @returns {string}
*/
getSelfVoicingDistanceDescriptionWithoutLabel( otherObjectLabel ) {
const patternString = this.useQuantitativeDistance ? selfVoicingLevelsMassQuantitativeWithoutLabelPatternString : selfVoicingLevelsMassQualitativeWithoutLabelPatternString;
getVoicingDistanceDescriptionWithoutLabel( otherObjectLabel ) {
const patternString = this.useQuantitativeDistance ? voicingLevelsMassQuantitativeWithoutLabelPatternString : voicingLevelsMassQualitativeWithoutLabelPatternString;
const distanceDescription = this.useQuantitativeDistance ? this.getDistanceAndUnits() : this.getQualitativeRelativeDistanceRegion();

return StringUtils.fillIn( patternString, {
Expand Down

0 comments on commit 60459b6

Please sign in to comment.