-
Notifications
You must be signed in to change notification settings - Fork 12
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
enabledAppearanceStrategy will blow away these options set by client #1173
Comments
If we want to set opacity on a LayoutBox, then this is how we need to set it currently: const x = new LayoutBox( {
enabledAppearanceStrategy(enabled, node){
node.opacity = .2
}
})
x.opacity;
-> .2; Questions to consider
Marking for developer meeting as part of the current inputEnabledProperty work being done in #1116. |
Steps for this issue:
Index: sun/js/SunConstants.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/sun/js/SunConstants.js b/sun/js/SunConstants.js
--- a/sun/js/SunConstants.js (revision ea1383d9af036c9c652f3fb78e788134ad5b1520)
+++ b/sun/js/SunConstants.js (date 1616094339704)
@@ -40,7 +40,6 @@
disabledOpacity: SunConstants.DISABLED_OPACITY
}, options );
- node.inputEnabled = enabled;
node.opacity = enabled ? 1.0 : options.disabledOpacity;
}
};
Index: sun/js/buttons/ButtonNode.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/sun/js/buttons/ButtonNode.js b/sun/js/buttons/ButtonNode.js
--- a/sun/js/buttons/ButtonNode.js (revision ea1383d9af036c9c652f3fb78e788134ad5b1520)
+++ b/sun/js/buttons/ButtonNode.js (date 1616094339778)
@@ -85,8 +85,6 @@
enabledAppearanceStrategy: ( enabled, button, background, content ) => {
background.filters = enabled ? [] : [ CONTRAST_FILTER, BRIGHTNESS_FILTER ];
- button.inputEnabled = enabled;
-
if ( content ) {
content.filters = enabled ? [] : [ Grayscale.FULL ];
content.opacity = enabled ? 1 : SunConstants.DISABLED_OPACITY;
Index: scenery/js/nodes/Node.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/scenery/js/nodes/Node.js b/scenery/js/nodes/Node.js
--- a/scenery/js/nodes/Node.js (revision 4ac1519ff438ace8e94b358a99ecf750219a190a)
+++ b/scenery/js/nodes/Node.js (date 1616094339769)
@@ -4269,6 +4269,7 @@
*/
onEnabledPropertyChange( enabled ) {
!enabled && this.interruptSubtreeInput();
+ this.inputEnabled = enabled;
}
There was also talk about only applying this to "components" (which generally control their children. There was also talk of creating a default enabled appearance strategy baked into Node. These two ideas are at odds. We decided to move this on to a sub group. I would like to be part of it. I think @jonathanolson will be part of it too. Not sure who else. @jbphet will also be a part of it. @jonathanolson will write down his recommendations. |
I feel like we should avoid conflicts for node attributes that would be overridden by handling enabled/disabled appearance. Any opacity or filter or other thing that the appearance would set should stack nicely with what the user sets on the component's Node. The simplest way to do that would be by creating a single child (e.g. for opacity), or by applying things to each child. Having a filter would also be possible (and perhaps more convenient), but may potentially hurt performance. So, each component would be responsible for handling its own appearance strategy. The common "opacity" method should be factored out so code isn't duplicated. Buttons would be adding filters in the background like they do now. Some components might set opacity of a child, OR create a child to set opacity on in one place. Notably, this also brought up what I consider to be a "component" - generally this to me means that the component (node) is responsible for all of its children, and you interact with it through defined APIs. Removing or messing with children of a component will likely mess with it. This does not include layout containers (e.g. LayoutBox), where it gives control of its children explicitly to its clients. If we implement the conflict-avoidance by adding in a child, it would not be possible to do that for layout containers. |
I created #1185 to do this. |
I'll add disabledOpacity as a field, that gets multiplied with the normal opacity when disabled. |
Pushed to a branch (not master), since the current SunConstants strategy uses the same name, and we'd be doubling up disabled opacities due to it, e.g.: (new phet.scenery.HBox( { disabledOpacity: 0.5, enabled: false } )).effectiveOpacity
// 0.25 @zepumph can you review the implementation? I'm emitting on |
…ledAppearanceStrategy options, phetsims/scenery#1173
…ledAppearanceStrategy options, phetsims/scenery#1173
…ledAppearanceStrategy options, phetsims/scenery#1173
…ledAppearanceStrategy options, #1173
…ledAppearanceStrategy options, phetsims/scenery#1173
I reviewed this change by adding in my work for testing. This involved removing Review of scenery change:
Does that mean we need a I think I will commit fixes for the small mistakes myself. I have to merge the branch in with the change to prevent regressions, so let's go forward on master. |
It's an error because of #1108
Agreed with the fix.
Agreed with the fix.
Maybe going over it together would be good? It had separate filter/opacity handling, and those were coalesced given the changes needed. |
That sentence was very helpful thanks
Could you please create an issue if you feel like this is the right direction, otherwise feel free to close. I don't think this should block publication anymore. |
If this comes up multiple times in the future, I'd propose it then. Status quo sounds great for right now. Thanks! |
…ledAppearanceStrategy options, phetsims/scenery#1173
@jonathanolson and I ran into this in #1116 where we were surprised that this code happened:
This is because of this line of code:
scenery/js/nodes/LayoutBox.js
Lines 113 to 115 in 2285549
This
link
blows away our options mutation. I think this is expected, but it sure seems like a bummer.The text was updated successfully, but these errors were encountered: