From b402e808ac83176923167095d1dfb65f16f392a6 Mon Sep 17 00:00:00 2001 From: pixelzoom Date: Wed, 1 May 2024 12:24:37 -0600 Subject: [PATCH] adjust tandem hierarchy and naming for container and its children, https://github.com/phetsims/gas-properties/issues/30 --- js/common/view/IdealGasLawContainerNode.ts | 10 +++++----- js/common/view/LidNode.ts | 6 ++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/js/common/view/IdealGasLawContainerNode.ts b/js/common/view/IdealGasLawContainerNode.ts index 47b5e602..edc4ba1d 100644 --- a/js/common/view/IdealGasLawContainerNode.ts +++ b/js/common/view/IdealGasLawContainerNode.ts @@ -94,7 +94,7 @@ export default class IdealGasLawContainerNode extends Node { baseWidth: modelViewTransform.modelToViewDeltaX( container.lidWidthProperty.value ), baseHeight: modelViewTransform.modelToViewDeltaX( container.lidThickness ), gripColor: options.lidGripColor, - tandem: options.tandem.createTandem( 'lidNode' ) + lidHandleNodeTandem: options.tandem.createTandem( 'lidHandleNode' ) } ); const lidHandleNode = lidNode.handleNode; @@ -167,10 +167,10 @@ export default class IdealGasLawContainerNode extends Node { // Dragging the resize handle horizontally changes the container's width const resizeHandleDragListener = new ResizeHandleDragListener( container, modelViewTransform, this, - resizeHandleNode.tandem.createTandem( 'resizeHandleDragListener' ) ); + resizeHandleNode.tandem.createTandem( 'dragListener' ) ); resizeHandleNode.addInputListener( resizeHandleDragListener ); const resizeHandleKeyboardDragListener = new ResizeHandleKeyboardDragListener( container, modelViewTransform, - resizeHandleNode.tandem.createTandem( 'resizeHandleKeyboardDragListener' ) ); + resizeHandleNode.tandem.createTandem( 'keyboardDragListener' ) ); resizeHandleNode.addInputListener( resizeHandleKeyboardDragListener ); // While interacting with the resize handle... @@ -197,10 +197,10 @@ export default class IdealGasLawContainerNode extends Node { // Dragging the lid's handle horizontally changes the size of the opening in the top of the container. const lidHandleDragListener = new LidHandleDragListener( container, modelViewTransform, this, - lidHandleNode.tandem.createTandem( 'lidHandleDragListener' ) ); + lidHandleNode.tandem.createTandem( 'dragListener' ) ); lidHandleNode.addInputListener( lidHandleDragListener ); const lidHandleKeyboardDragListener = new LidHandleKeyboardDragListener( container, modelViewTransform, - lidHandleNode.tandem.createTandem( 'lidHandleKeyboardDragListener' ) ); + lidHandleNode.tandem.createTandem( 'keyboardDragListener' ) ); lidHandleNode.addInputListener( lidHandleKeyboardDragListener ); // This implementation assumes that the lid is not interactive while the container is being resized. This is diff --git a/js/common/view/LidNode.ts b/js/common/view/LidNode.ts index 46b042c8..ff25afba 100644 --- a/js/common/view/LidNode.ts +++ b/js/common/view/LidNode.ts @@ -13,6 +13,7 @@ import { InteractiveHighlighting, Node, NodeOptions, NodeTranslationOptions, Rec import gasProperties from '../../gasProperties.js'; import GasPropertiesColors from '../GasPropertiesColors.js'; import PickRequired from '../../../../phet-core/js/types/PickRequired.js'; +import Tandem from '../../../../tandem/js/Tandem.js'; // constants const HANDLE_ATTACHMENT_LINE_WIDTH = 1; @@ -22,9 +23,10 @@ type SelfOptions = { baseWidth: number; baseHeight: number; gripColor?: TColor; + lidHandleNodeTandem: Tandem; }; -type LidNodeOptions = SelfOptions & PickRequired; +type LidNodeOptions = SelfOptions; export default class LidNode extends Node { @@ -52,7 +54,7 @@ export default class LidNode extends Node { const lidHandleNode = new LidHandleNode( options.gripColor, { right: baseNode.right - HANDLE_RIGHT_INSET, bottom: baseNode.top + 1, - tandem: options.tandem.createTandem( 'lidHandleNode' ) + tandem: options.lidHandleNodeTandem } ); assert && assert( lidHandleNode.width <= baseNode.width, `handleNode.width ${lidHandleNode.width} is wider than baseNode.width ${baseNode.width}` );