Skip to content

Commit

Permalink
dynamic layout support, see #399
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Mar 8, 2023
1 parent 0beab87 commit b0d4209
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 8 additions & 4 deletions js/quadrilateral/view/QuadrilateralScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,14 @@ export default class QuadrilateralScreenView extends ScreenView {

shapeNameDisplay.centerBottom = gridNode.centerTop.minusXY( 0, QuadrilateralConstants.VIEW_SPACING );
shapeSoundsCheckbox.rightCenter = new Vector2( gridNode.right, shapeNameDisplay.centerY );
resetShapeButton.rightCenter = shapeSoundsCheckbox.leftCenter.minusXY(
// effectively centers this button between the other name display controls
( shapeSoundsCheckbox.left - shapeNameDisplay.right - resetShapeButton.width ) / 2, 0
);

// dynamic string layout
resetShapeButton.boundsProperty.link( () => {
resetShapeButton.rightCenter = shapeSoundsCheckbox.leftCenter.minusXY(
// effectively centers this button between the other name display controls
( shapeSoundsCheckbox.left - shapeNameDisplay.right - resetShapeButton.width ) / 2, 0
);
} );

deviceConnectionParentNode.leftBottom = visibilityControls.leftTop.minusXY( 0, QuadrilateralConstants.VIEW_GROUP_SPACING );

Expand Down
6 changes: 5 additions & 1 deletion js/quadrilateral/view/QuadrilateralVertexNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export default class QuadrilateralVertexNode extends QuadrilateralMovableNode {
this.quadrilateralModel = quadrilateralModel;

const vertexLabelText = new Text( vertexLabel, {
center: this.center,
font: LABEL_TEXT_FONT,

// i18n
Expand Down Expand Up @@ -88,6 +87,11 @@ export default class QuadrilateralVertexNode extends QuadrilateralMovableNode {
vertexLabelText.visible = vertexLabelsVisible;
} );

// dynamic string layout
vertexLabelText.boundsProperty.link( () => {
vertexLabelText.center = circle.center;
} );

const keyboardDragListener = new KeyboardDragListener( {
dragDelta: this.largeViewDragDelta,
shiftDragDelta: this.smallViewDragDelta,
Expand Down

0 comments on commit b0d4209

Please sign in to comment.