Skip to content
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

Change the Fluid Displaced from Checkbox to Accordion Box #150

Closed
DianaTavares opened this issue May 7, 2024 · 10 comments
Closed

Change the Fluid Displaced from Checkbox to Accordion Box #150

DianaTavares opened this issue May 7, 2024 · 10 comments

Comments

@DianaTavares
Copy link

Hi team! I talked with Taliesin about the focus order. It was super useful!! And she makes a super good observation on the lab screen. The Fluid displaced is important, it is not good to have it hidden in the Forces + checkboxes. Then I had an idea;
@AgustinVallejo and @zepumph, can a header have 2 lines?

image

image

I think that it needs to have 2 lines also in the actual design to have room for longer translations.

@samreid
Copy link
Member

samreid commented May 7, 2024

Yes, an AccordionBox title can be any scenery Node, including a VBox of Text. It looks like the Fluid Displaced is only on the Lab Screen in Buoyancy, is that correct? Want us to change it from checkbox to 2-line accordion box?

@samreid samreid assigned samreid and DianaTavares and unassigned samreid May 7, 2024
@DianaTavares
Copy link
Author

Yes, it is only in the lab screen of Buoyancy and yes, please make the change!

That also means taking out “Fluid Displaced” from this menu:
Screenshot 2024-05-07 at 3 43 32 p m

samreid added a commit to phetsims/density-buoyancy-common that referenced this issue May 7, 2024
@samreid samreid changed the title Can a header have two lines? Change the Fluid Displaced from Checkbox to Accordion Box May 7, 2024
@samreid
Copy link
Member

samreid commented May 7, 2024

I implemented it in the commits. It looks like this:

image

This also fixes a bug that was in main where resizing the window crashed it out:

Uncaught Error: Assertion failed: left control panels on lab screen are too big to fit under the ground
    at window.assertions.assertFunction (assert.js:28:13)
    at BuoyancyLabScreenView.ts:105:19
    at listener (Multilink.ts:111:11)
    at TinyProperty.notifyLoop (TinyEmitter.ts:213:7)
    at TinyProperty.emit (TinyEmitter.ts:185:18)
    at Property._notifyListeners (ReadOnlyProperty.ts:352:23)
    at Property.unguardedSet (ReadOnlyProperty.ts:296:14)
    at Property.set (ReadOnlyProperty.ts:276:12)
    at set value (Property.ts:54:11)
    at BuoyancyLabScreenView.layout (ScreenView.ts:210:37)

When hidden in studio, the layout flows correctly:

image

Here is a picture expanded, with double strings

image

I left a TODO in the commits for a reviewer consultation. One more commit coming to address max width better.

samreid added a commit to phetsims/density-buoyancy-common that referenced this issue May 7, 2024
@samreid
Copy link
Member

samreid commented May 7, 2024

OK ready for review. I reverted some code from #144 so I feel @zepumph would be a good reviewer.

@samreid samreid assigned zepumph and unassigned samreid May 7, 2024
samreid added a commit to phetsims/density-buoyancy-common that referenced this issue May 7, 2024
zepumph added a commit to phetsims/density-buoyancy-common that referenced this issue May 9, 2024
@zepumph
Copy link
Member

zepumph commented May 9, 2024

  • It is sad that you need to create the entire exandedProperty just to change the default. Perhaps we could add an option call defaultExpanded, which only applies when creating our own expanded. Seems simple enough, what do you think? I believe I have done this before which is why I'm mentioning it.

  • I also removed the TODO. What do you think?

  • The title font seems off to me.

  • Can we remove showFluidDisplacedProperty now?

@zepumph zepumph assigned samreid and unassigned zepumph May 9, 2024
@samreid
Copy link
Member

samreid commented May 14, 2024

Something like this?

Subject: [PATCH] Make bottle and boat tab order before their control panels, see https://github.com/phetsims/density-buoyancy-common/issues/121
---
Index: density-buoyancy-common/js/common/view/DensityBuoyancyScreenView.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/density-buoyancy-common/js/common/view/DensityBuoyancyScreenView.ts b/density-buoyancy-common/js/common/view/DensityBuoyancyScreenView.ts
--- a/density-buoyancy-common/js/common/view/DensityBuoyancyScreenView.ts	(revision 0c4e3571e0d573676b2dc7a8a5701e5e64cd353f)
+++ b/density-buoyancy-common/js/common/view/DensityBuoyancyScreenView.ts	(date 1715652425748)
@@ -65,6 +65,7 @@
 import NumberIO from '../../../../tandem/js/types/NumberIO.js';
 import Utils from '../../../../dot/js/Utils.js';
 import createObservableArray, { ObservableArray } from '../../../../axon/js/createObservableArray.js';
+import Emitter from '../../../../axon/js/Emitter.js';
 
 // constants
 const MARGIN = DensityBuoyancyCommonConstants.MARGIN;
@@ -114,6 +115,8 @@
   // TODO: PhET-iO instrument for https://github.com/phetsims/density-buoyancy-common/issues/82
   protected waterLevelVolumeProperty: TReadOnlyProperty<number>;
 
+  protected readonly resetEmitter = new Emitter();
+
   public constructor( model: Model, providedOptions: SelfOptions ) {
 
     const scaleIncrease = 3.5;
@@ -574,6 +577,7 @@
       listener: () => {
         this.interruptSubtreeInput();
         model.reset();
+        this.resetEmitter.emit();
       },
       tandem: tandem.createTandem( 'resetAllButton' )
     } );
Index: density-buoyancy-common/js/buoyancy/view/BuoyancyLabScreenView.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/density-buoyancy-common/js/buoyancy/view/BuoyancyLabScreenView.ts b/density-buoyancy-common/js/buoyancy/view/BuoyancyLabScreenView.ts
--- a/density-buoyancy-common/js/buoyancy/view/BuoyancyLabScreenView.ts	(revision 0c4e3571e0d573676b2dc7a8a5701e5e64cd353f)
+++ b/density-buoyancy-common/js/buoyancy/view/BuoyancyLabScreenView.ts	(date 1715652546261)
@@ -34,7 +34,6 @@
 import ScaleHeightControl from '../../common/view/ScaleHeightControl.js';
 import fluid_displaced_scale_icon_png from '../../../images/fluid_displaced_scale_icon_png.js';
 import AccordionBox from '../../../../sun/js/AccordionBox.js';
-import BooleanProperty from '../../../../axon/js/BooleanProperty.js';
 import PhetFont from '../../../../scenery-phet/js/PhetFont.js';
 import CuboidView from '../../common/view/CuboidView.js';
 
@@ -60,10 +59,6 @@
 
     const fluidDisplacedAccordionBoxTandem = tandem.createTandem( 'fluidDisplacedAccordionBox' );
 
-    const accordionBoxIsExpandedProperty = new BooleanProperty( false, {
-      tandem: fluidDisplacedAccordionBoxTandem.createTandem( 'expandedProperty' )
-    } );
-
     const fluidDisplacedAccordionBox = new AccordionBox( new FluidDisplacedPanel( this.waterLevelVolumeProperty,
       maxBlockVolume,
       model.liquidMaterialProperty,
@@ -72,7 +67,7 @@
         font: new PhetFont( 14 ), // Matches the checkbox label font size
         maxWidth: 100
       } ),
-      expandedProperty: accordionBoxIsExpandedProperty,
+      expandedDefaultValue: false,
 
       titleAlignX: 'left',
       titleAlignY: 'center',
@@ -86,6 +81,8 @@
       tandem: fluidDisplacedAccordionBoxTandem
     } );
 
+    this.resetEmitter.addListener( () => fluidDisplacedAccordionBox.expandedProperty.reset() );
+
     const leftSideVBox = new VBox( {
       align: 'left',
       spacing: 5,
Index: sun/js/AccordionBox.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/sun/js/AccordionBox.ts b/sun/js/AccordionBox.ts
--- a/sun/js/AccordionBox.ts	(revision 70a7bed0587ca9b9d79306aa5c6a816a3efc2718)
+++ b/sun/js/AccordionBox.ts	(date 1715651891769)
@@ -29,8 +29,9 @@
   // If not provided, a Text node will be supplied. Should have and maintain well-defined bounds if passed in
   titleNode?: Node;
 
-  // If not provided, a BooleanProperty will be created, defaulting to true.
+  // If not provided, a BooleanProperty will be created, defaulting to the value of expandedDefaultValue.
   expandedProperty?: Property<boolean>;
+  expandedDefaultValue?: boolean;
 
   // If true (the default), we'll adjust the title so that it isn't pickable at all
   overrideTitleNodePickable?: boolean;
@@ -142,10 +143,16 @@
    */
   public constructor( contentNode: Node, providedOptions?: AccordionBoxOptions ) {
 
+    assert && providedOptions && assert(
+      !( providedOptions.hasOwnProperty( 'expandedProperty' ) && providedOptions.hasOwnProperty( 'expandedDefaultValue' ) ),
+      'cannot specify expandedProperty and expandedDefaultValue in providedOptions'
+    );
+
     const options = optionize<AccordionBoxOptions, StrictOmit<SelfOptions, 'expandCollapseButtonOptions'>, NodeOptions>()( {
 
       titleNode: null as unknown as Node,
       expandedProperty: null as unknown as BooleanProperty,
+      expandedDefaultValue: true,
       resize: true,
 
       overrideTitleNodePickable: true,
@@ -249,7 +256,7 @@
 
     this.expandedProperty = options.expandedProperty;
     if ( !this.expandedProperty ) {
-      this.expandedProperty = new BooleanProperty( true, {
+      this.expandedProperty = new BooleanProperty( options.expandedDefaultValue, {
         tandem: options.tandem.createTandem( 'expandedProperty' ),
         phetioFeatured: true
       } );

Also the title font does look off. I hypothesized the maxWidth was shrinking it a bit, but couldn't prove it. Do you think it could look a little different since it is RichText instead of Text?

Can we remove showFluidDisplacedProperty now?

Yes, let's do that. I forgot to do that in the patch above but can do it after review.

I also removed the TODO. What do you think?

That is certainly better! Maybe one day do you think we can ManualConstraint.create(parent, Node | TReadOnlyProperty<Bounds2>)?

@samreid samreid assigned zepumph and unassigned samreid May 14, 2024
@zepumph
Copy link
Member

zepumph commented May 14, 2024

Excellent. Anything else here?

zepumph added a commit to phetsims/sun that referenced this issue May 14, 2024
zepumph added a commit to phetsims/density-buoyancy-common that referenced this issue May 14, 2024
zepumph added a commit to phetsims/density-buoyancy-common that referenced this issue May 14, 2024
zepumph added a commit to phetsims/density-buoyancy-common that referenced this issue May 14, 2024
@zepumph zepumph assigned samreid and unassigned zepumph May 14, 2024
@samreid
Copy link
Member

samreid commented May 15, 2024

The commits look great, thanks! Closing.

@samreid samreid closed this as completed May 15, 2024
@zepumph
Copy link
Member

zepumph commented May 15, 2024

I'm seeing a few more things here while working on dynamic locale. One second on the close.

@zepumph zepumph reopened this May 15, 2024
@zepumph zepumph assigned zepumph and unassigned samreid May 15, 2024
zepumph added a commit that referenced this issue May 15, 2024
Signed-off-by: Michael Kauzmann <[email protected]>
zepumph added a commit to phetsims/density-buoyancy-common that referenced this issue May 15, 2024
zepumph added a commit to phetsims/density-buoyancy-common that referenced this issue May 15, 2024
Signed-off-by: Michael Kauzmann <[email protected]>
zepumph added a commit to phetsims/density-buoyancy-common that referenced this issue May 15, 2024
zepumph added a commit to phetsims/density-buoyancy-common that referenced this issue May 15, 2024
Signed-off-by: Michael Kauzmann <[email protected]>
zepumph added a commit to phetsims/density-buoyancy-common that referenced this issue May 15, 2024
zepumph added a commit to phetsims/density-buoyancy-common that referenced this issue May 15, 2024
@zepumph
Copy link
Member

zepumph commented May 15, 2024

I moved the accordionBox into the fluid displaced class, which felt nicer to me, since there were so many options associated with it. I also fixed a couple of i18n layout things, and a tiny color change (238 gray vs 240 gray background colors).

@zepumph zepumph closed this as completed May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants