Skip to content

Commit

Permalink
Improve dynamic layout, see #90
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Dec 20, 2024
1 parent 4ce0e52 commit f5b58f3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import EraserButton from '../../../../scenery-phet/js/buttons/EraserButton.js';
import InfoButton from '../../../../scenery-phet/js/buttons/InfoButton.js';
import ResetAllButton from '../../../../scenery-phet/js/buttons/ResetAllButton.js';
import GridCheckbox from '../../../../scenery-phet/js/GridCheckbox.js';
import { Node } from '../../../../scenery/js/imports.js';
import { ManualConstraint, Node } from '../../../../scenery/js/imports.js';
import { AccordionBoxOptions } from '../../../../sun/js/AccordionBox.js';
import leastSquaresRegression from '../../leastSquaresRegression.js';
import LeastSquaresRegressionConstants from '../LeastSquaresRegressionConstants.js';
Expand Down Expand Up @@ -105,7 +105,7 @@ export default class LeastSquaresRegressionScreenView extends ScreenView {

// Create the dataSet combo box that appears on top of the graph
// Width of contents limited by width of graphNode for i18n
const dataSetLabelMaxWidth = this.graphNode.width / 2;
const dataSetLabelMaxWidth = 320;
const dataSetListParent = new Node();
const dataSetComboBox = new DataSetComboBox( model.selectedDataSetProperty, model.dataSets, dataSetListParent, dataSetLabelMaxWidth );

Expand Down Expand Up @@ -332,15 +332,21 @@ export default class LeastSquaresRegressionScreenView extends ScreenView {
myLineControlPanel.top = 20;
bestFitLineAccordionBox.left = 15;
bestFitLineAccordionBox.top = myLineControlPanel.top;
dataSetComboBox.centerX = viewGraphBounds.centerX;
dataSetComboBox.top = myLineControlPanel.top;
gridCheckbox.left = myLineControlPanel.left + 10;
gridCheckbox.top = myLineControlPanel.bottom + 10;
correlationCoefficientAccordionBox.centerX = bestFitLineAccordionBox.centerX;
correlationCoefficientAccordionBox.top = bestFitLineAccordionBox.bottom + 10;
infoButton.centerY = dataSetComboBox.centerY;
infoButton.left = dataSetComboBox.right + 10;
}

ManualConstraint.create( this, [ dataSetComboBox, this.graphNode, myLineControlPanel, infoButton ], ( dataSetComboBoxProxy, graphNodeProxy, myLineControlPanelProxy, infoButtonProxy ) => {

// Compensate for the graph labels.
dataSetComboBoxProxy.centerX = graphNodeProxy.centerX + 20;
dataSetComboBoxProxy.top = myLineControlPanelProxy.top;

infoButtonProxy.centerY = dataSetComboBox.centerY;
infoButtonProxy.left = dataSetComboBox.right + 10;
} );
}

public override step( dt: number ): void {
Expand Down
2 changes: 1 addition & 1 deletion js/least-squares-regression/view/MyLineControlPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const SLIDER_OPTIONS = {
thumbTouchAreaXDilation: 8,
majorTickLength: 18
};
const MAX_WIDTH = 150;
const MAX_WIDTH = 120;

export default class MyLineControlPanel extends Panel {
public readonly sumOfSquaredResiduals: SumOfSquaredResidualsChart;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default class SumOfSquaredResidualsChart extends Node {
font: FONT,
centerX: horizontalArrow.centerX,
top: horizontalArrow.bottom + 5,
maxWidth: 150
maxWidth: 100
} );
const zeroLabel = new Text( '0', { font: FONT, centerX: horizontalArrow.left, top: horizontalArrow.bottom + 5 } );

Expand Down

0 comments on commit f5b58f3

Please sign in to comment.