Add split pane so user can adjust number of text columns

This commit is contained in:
Nathan McRae 2025-02-20 22:57:47 -08:00
parent 307620a930
commit e4ad5d16d6
2 changed files with 30 additions and 5 deletions

View File

@ -26,6 +26,7 @@ import javafx.scene.input.KeyEvent;
import javafx.scene.input.KeyCode;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.SplitPane;
import javafx.stage.Modality;
import javafx.stage.Stage;
@ -48,6 +49,9 @@ public class MainController implements Initializable {
@FXML
private TextField stationNameField;
@FXML
private SplitPane splitPane;
@FXML
private void handleStationSettingsButtonPress() {
if (settingsStage == null || !settingsStage.isShowing()) {
@ -218,6 +222,17 @@ public class MainController implements Initializable {
}
}
});
// The SplitPane allows the user to set the number of columns of
// numbers, which can help align with their pads.
//
// The splitpane doesn't seem to stick at 1.0 when resizing though,
// so we snap it to the right when it's close.
splitPane.widthProperty().addListener((obs, oldVal, newVal) -> {
if (splitPane.getDividerPositions()[0] > 0.95) {
splitPane.setDividerPositions(1.0);
}
});
}
private void updateStationSettings(StationSettings newStationSettings) {

View File

@ -36,6 +36,7 @@
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Separator?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
@ -76,16 +77,25 @@
<Button layoutX="534.0" layoutY="13.0" mnemonicParsing="false" onMouseClicked="#handleStationSettingsButtonPress" text="Station Settings" AnchorPane.rightAnchor="6.5" AnchorPane.topAnchor="13.0" />
</children>
</AnchorPane>
<SplitPane fx:id="splitPane" dividerPositions="1.0" prefHeight="272.0" prefWidth="640.0">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<TextArea fx:id="messageTextArea" prefHeight="270.0" text="0239 0480 2938 0928&#10;3093 2298 3923 8933" wrapText="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<font>
<Font name="Liberation Mono" size="30.0" />
</font>
</TextArea>
</children>
</AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0" />
</items>
</SplitPane>
</children>
<padding>
<Insets bottom="10.0" />
</padding>
</VBox>
<TextArea fx:id="messageTextArea" layoutY="110.0" prefHeight="270.0" prefWidth="640.0" text="0239 0480 2938 0928&#10;3093 2298 3923 8933" wrapText="true" AnchorPane.bottomAnchor="40.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="90.0">
<font>
<Font name="Liberation Mono" size="30.0" />
</font>
</TextArea>
<FlowPane alignment="CENTER_RIGHT" prefHeight="34.0" prefWidth="620.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<children>
<Button mnemonicParsing="false" onMousePressed="#handleSetAsNextMessageButtonPress" text="Set as next message" />