-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NumberControl tweaker buttons should be able to match the size of the NumberDisplay #513
Comments
Would it be better to use |
Since
Yes. Unless it's OK to push this new convention into all sims, which is a question for designers.
Yes. |
I tried using this code in Wave Interference: arrowButtonOptions: {
scale: undefined
}, And was met with
Therefore it does not seem there is a simple way for pre-existing simulations to have @pixelzoom how do you recommend to proceed? |
There's no reason to set |
Here's a change set that defaults the arrow buttons to the height of the number display: Index: wave-interference/js/common/WaveInterferenceConstants.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- wave-interference/js/common/WaveInterferenceConstants.js (revision 4688cc1aa0cf83de79dc1f3c49d8e6fd53590393)
+++ wave-interference/js/common/WaveInterferenceConstants.js (date 1563227871000)
@@ -44,7 +44,6 @@
NUMBER_CONTROL_OPTIONS: {
layoutFunction: NumberControl.createLayoutFunction4( { verticalSpacing: 3 } ),
arrowButtonOptions: {
- scale: 0.65,
touchAreaXDilation: 9,
touchAreaYDilation: 10
},
Index: scenery-phet/js/WavelengthNumberControl.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- scenery-phet/js/WavelengthNumberControl.js (revision de648f0e5ac55f8a0e44e9522044706fbce0b7ae)
+++ scenery-phet/js/WavelengthNumberControl.js (date 1563227795000)
@@ -45,9 +45,6 @@
const trackHeight = options.trackHeight;
super( options.title, property, options.range, merge( {
- arrowButtonOptions: {
- scale: trackHeight * 0.0315 // roughly the height of the track
- },
titleNodeOptions: {
font: new PhetFont( 15 ),
maxWidth: 175
Index: scenery-phet/js/NumberControl.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- scenery-phet/js/NumberControl.js (revision de648f0e5ac55f8a0e44e9522044706fbce0b7ae)
+++ scenery-phet/js/NumberControl.js (date 1563228764000)
@@ -19,6 +19,7 @@
const HBox = require( 'SCENERY/nodes/HBox' );
const HSlider = require( 'SUN/HSlider' );
const inherit = require( 'PHET_CORE/inherit' );
+ const InstanceRegistry = require( 'PHET_CORE/documentation/InstanceRegistry' );
const merge = require( 'PHET_CORE/merge' );
const Node = require( 'SCENERY/nodes/Node' );
const NumberControlIO = require( 'SCENERY_PHET/NumberControlIO' );
@@ -88,12 +89,13 @@
groupFocusHighlight: true
}, options );
+ const arrowButtonScaleProvided = options.arrowButtonOptions && options.arrowButtonOptions.hasOwnProperty( 'scale' );
+
// Merge all nested options in one block.
options = merge( {
// Options propagated to ArrowButton
arrowButtonOptions: {
- scale: 0.85,
// Values chosen to match previous behavior, see https://github.com/phetsims/scenery-phet/issues/489.
// touchAreaXDilation is 1/2 of its original value because touchArea is shifted.
@@ -243,6 +245,16 @@
tandem: options.tandem.createTandem( 'rightArrowButton' )
}, options.arrowButtonOptions ) );
+ // By default, scale the ArrowButtons to have the same height as the NumberDisplay.
+ if ( !arrowButtonScaleProvided ) {
+
+ leftArrowButton.setScaleMagnitude( 1 );
+ const arrowButtonsScale = numberDisplay.height / leftArrowButton.height;
+
+ leftArrowButton.setScaleMagnitude( arrowButtonsScale );
+ rightArrowButton.setScaleMagnitude( arrowButtonsScale );
+ }
+
// arrow button touchAreas, asymmetrical, see https://github.com/phetsims/scenery-phet/issues/489
leftArrowButton.touchArea = leftArrowButton.localBounds
.dilatedXY( arrowButtonPointerAreaOptions.touchAreaXDilation, arrowButtonPointerAreaOptions.touchAreaYDilation )
@@ -333,6 +345,9 @@
numberProperty.unlink( arrowEnabledListener );
this.enabledProperty.unlink( enabledObserver );
};
+
+ // support for binder documentation, stripped out in builds and only runs when ?binder is specified
+ assert && phet.chipper.queryParameters.binder && InstanceRegistry.registerDataURL( 'scenery-phet', 'NumberControl', this );
}
/**
We cannot have some sims use one default and other sims use another default, so I think we will need to see if we can make this change for all simulations. Thanks to binder, here is a list of sims that use NumberControl: beers-law-lab: no change I'll check through them to see how different the default looks. |
When I restricted the binder search to sims that use the defaults for NumberControl, it returned this list: gas-properties gas propertiesthe change looks minor, but seems acceptable to me hookes lawtweaker buttons become slightly smaller with this change plinko probabilityrutherford scatteringAnd wave interference was requested to have the tweaker buttons have the same height as the number display, so that's a safe change. @arouinfar do these changes seem acceptable to you? Do we need other designers to sign off before I proceed? |
Couldn't help lurking and throwing my opinion in :) These changes all look mighty fine to me. Might be good to also check with |
Looks great @samreid! It's a subtle change, but I think matching tweaker height to the readout makes things look cleaner overall. |
…ight to the NumberDisplay height, see phetsims/scenery-phet#513
…ight to the NumberDisplay height, see #513
Changes pushed, @pixelzoom can you please review? |
Changes reviewed, looks good. Feel free to close if work is completed. |
Me too, no good solution comes to mind immediately. I will ruminate. |
Rumination complete :) My recommendation is to back out this change, and require the client to adjust the size of the arrow buttons. If the changes that @arouinfar identified as "cleaner overall" in #513 (comment) are worth keeping, note the arrow button sizes before reverting, and set them explicitly after reverting. |
More... I'm not sure that reverting is the best option, but it's the best I could come up with. Setting arrow button sizes explicitly will result in fixes sizes that won't adapt to change in NumberDisplay size that occur due to font size differences across platforms. But this never bothered me previously, seemed to work fine. And the improvement was described by @arouinfar as "subtle", so maybe not necessary. On the other hand... The example shown in #513 (comment) is highly unlikely to occur. So while I appreciate @KatieWoe's attention to detail in discovering this, perhaps we could just leave "as is" and everything would be fine in practice. |
Still more... So the options that I can come up with are: (1) Revert and live with it. (2) Leave as is and live with it. |
One more part of this problem. I don't see a clear way to explicitly set the height of these buttons, the API is instead centered around |
@arouinfar can you please review #513 (comment) and below? What do you recommend? |
Another solution would be to (by default) set the height of the tweaker buttons to match the height of the unscaled UPDATE: the only problem I can think of for this paradigm is that: specified values for numberDisplayOptions: {
scale: 0.5, Still, this seems preferable to any of the other proposed strategies. |
@pixelzoom can you please review? UPDATE: I also marked as blocks-publication until this is reviewed since it can impact NumberControl rendering. I spot tested a few sims (not exhaustive testing). UPDATE: I also skimmed through |
This looks good. I'd like to see a comment in the code about why we're ignoring NumberDisplay |
… display height localBounds, see #513
I added docs above. It felt a bit wordy but I wasn't sure how to improve it. @pixelzoom can you please review? |
👍 Looks good to me, not too wordy. Closing. |
In #508 (comment) I said:
@pixelzoom replied:
UPDATE: Tagging for phetsims/wave-interference#408
The text was updated successfully, but these errors were encountered: