use view ordering to improve transaction pane perf

This commit is contained in:
Craig Raw 2020-06-16 12:11:06 +02:00
parent 7f03778ec7
commit 7cc330fde9
13 changed files with 48 additions and 26 deletions

View file

@ -14,6 +14,7 @@ public class HeadersForm extends TransactionForm {
public Node getContents() throws IOException { public Node getContents() throws IOException {
FXMLLoader loader = new FXMLLoader(getClass().getResource("headers.fxml")); FXMLLoader loader = new FXMLLoader(getClass().getResource("headers.fxml"));
Node node = loader.load(); Node node = loader.load();
node.setUserData(this);
HeadersController controller = loader.getController(); HeadersController controller = loader.getController();
controller.setModel(this); controller.setModel(this);
return node; return node;

View file

@ -48,6 +48,7 @@ public class InputForm extends IndexedTransactionForm {
public Node getContents() throws IOException { public Node getContents() throws IOException {
FXMLLoader loader = new FXMLLoader(getClass().getResource("input.fxml")); FXMLLoader loader = new FXMLLoader(getClass().getResource("input.fxml"));
Node node = loader.load(); Node node = loader.load();
node.setUserData(this);
InputController controller = loader.getController(); InputController controller = loader.getController();
controller.setModel(this); controller.setModel(this);
return node; return node;

View file

@ -14,6 +14,7 @@ public class InputsForm extends TransactionForm {
public Node getContents() throws IOException { public Node getContents() throws IOException {
FXMLLoader loader = new FXMLLoader(getClass().getResource("inputs.fxml")); FXMLLoader loader = new FXMLLoader(getClass().getResource("inputs.fxml"));
Node node = loader.load(); Node node = loader.load();
node.setUserData(this);
InputsController controller = loader.getController(); InputsController controller = loader.getController();
controller.setModel(this); controller.setModel(this);
return node; return node;

View file

@ -38,6 +38,7 @@ public class OutputForm extends IndexedTransactionForm {
public Node getContents() throws IOException { public Node getContents() throws IOException {
FXMLLoader loader = new FXMLLoader(getClass().getResource("output.fxml")); FXMLLoader loader = new FXMLLoader(getClass().getResource("output.fxml"));
Node node = loader.load(); Node node = loader.load();
node.setUserData(this);
OutputController controller = loader.getController(); OutputController controller = loader.getController();
controller.setModel(this); controller.setModel(this);
return node; return node;

View file

@ -17,6 +17,7 @@ public class OutputsForm extends TransactionForm {
public Node getContents() throws IOException { public Node getContents() throws IOException {
FXMLLoader loader = new FXMLLoader(getClass().getResource("outputs.fxml")); FXMLLoader loader = new FXMLLoader(getClass().getResource("outputs.fxml"));
Node node = loader.load(); Node node = loader.load();
node.setUserData(this);
OutputsController controller = loader.getController(); OutputsController controller = loader.getController();
controller.setModel(this); controller.setModel(this);
return node; return node;

View file

@ -197,13 +197,29 @@ public class TransactionController implements Initializable {
Platform.runLater(this::refreshTxHex); Platform.runLater(this::refreshTxHex);
} }
} else { } else {
try { Node detailPane = null;
Node node = transactionForm.getContents(); for(Node txdetail : txpane.getChildren()) {
txpane.getChildren().clear(); TransactionForm childForm = (TransactionForm)txdetail.getUserData();
txpane.getChildren().add(node); if(transactionForm == childForm) {
detailPane = txdetail;
txdetail.setViewOrder(0);
} else {
txdetail.setViewOrder(1);
}
}
if (node instanceof Parent) { try {
Parent parent = (Parent) node; if(detailPane == null) {
detailPane = transactionForm.getContents();
detailPane.setViewOrder(0);
txpane.getChildren().add(detailPane);
}
} catch (IOException e) {
throw new IllegalStateException("Can't find pane", e);
}
if(detailPane instanceof Parent) {
Parent parent = (Parent)detailPane;
txhex.getStylesheets().clear(); txhex.getStylesheets().clear();
txhex.getStylesheets().addAll(parent.getStylesheets()); txhex.getStylesheets().addAll(parent.getStylesheets());
@ -219,9 +235,6 @@ public class TransactionController implements Initializable {
Platform.runLater(this::refreshTxHex); Platform.runLater(this::refreshTxHex);
} }
} catch (IOException e) {
throw new IllegalStateException("Can't find pane", e);
}
} }
}); });

View file

@ -15,7 +15,7 @@
<?import com.sparrowwallet.sparrow.control.IdLabel?> <?import com.sparrowwallet.sparrow.control.IdLabel?>
<?import com.sparrowwallet.sparrow.control.CoinLabel?> <?import com.sparrowwallet.sparrow.control.CoinLabel?>
<GridPane hgap="10.0" vgap="10.0" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.sparrowwallet.sparrow.transaction.HeadersController" stylesheets="@headers.css, @../general.css"> <GridPane hgap="10.0" vgap="10.0" styleClass="tx-pane" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.sparrowwallet.sparrow.transaction.HeadersController" stylesheets="@headers.css, @transaction.css, @../general.css">
<padding> <padding>
<Insets left="25.0" right="25.0" top="25.0" /> <Insets left="25.0" right="25.0" top="25.0" />
</padding> </padding>

View file

@ -17,7 +17,7 @@
<?import com.sparrowwallet.sparrow.control.AddressLabel?> <?import com.sparrowwallet.sparrow.control.AddressLabel?>
<?import com.sparrowwallet.sparrow.control.UnlabeledToggleSwitch?> <?import com.sparrowwallet.sparrow.control.UnlabeledToggleSwitch?>
<GridPane hgap="10.0" vgap="10.0" stylesheets="@input.css, @../script.css, @../general.css" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.sparrowwallet.sparrow.transaction.InputController"> <GridPane hgap="10.0" vgap="10.0" styleClass="tx-pane" stylesheets="@input.css, @transaction.css, @../script.css, @../general.css" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.sparrowwallet.sparrow.transaction.InputController">
<padding> <padding>
<Insets left="25.0" right="25.0" top="25.0" /> <Insets left="25.0" right="25.0" top="25.0" />
</padding> </padding>

View file

@ -8,7 +8,7 @@
<?import com.sparrowwallet.sparrow.control.CopyableLabel?> <?import com.sparrowwallet.sparrow.control.CopyableLabel?>
<?import com.sparrowwallet.sparrow.control.CoinLabel?> <?import com.sparrowwallet.sparrow.control.CoinLabel?>
<GridPane hgap="10.0" vgap="10.0" stylesheets="@inputs.css, @../general.css" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.sparrowwallet.sparrow.transaction.InputsController"> <GridPane hgap="10.0" vgap="10.0" styleClass="tx-pane" stylesheets="@inputs.css, @transaction.css, @../general.css" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.sparrowwallet.sparrow.transaction.InputsController">
<padding> <padding>
<Insets left="25.0" right="25.0" top="25.0" /> <Insets left="25.0" right="25.0" top="25.0" />
</padding> </padding>

View file

@ -15,7 +15,7 @@
<?import com.sparrowwallet.sparrow.control.CoinLabel?> <?import com.sparrowwallet.sparrow.control.CoinLabel?>
<?import com.sparrowwallet.sparrow.control.AddressLabel?> <?import com.sparrowwallet.sparrow.control.AddressLabel?>
<GridPane hgap="10.0" vgap="10.0" stylesheets="@output.css, @../script.css, @../general.css" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.sparrowwallet.sparrow.transaction.OutputController"> <GridPane hgap="10.0" vgap="10.0" styleClass="tx-pane" stylesheets="@output.css, @transaction.css, @../script.css, @../general.css" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.sparrowwallet.sparrow.transaction.OutputController">
<padding> <padding>
<Insets left="25.0" right="25.0" top="25.0" /> <Insets left="25.0" right="25.0" top="25.0" />
</padding> </padding>

View file

@ -8,7 +8,7 @@
<?import com.sparrowwallet.sparrow.control.CopyableLabel?> <?import com.sparrowwallet.sparrow.control.CopyableLabel?>
<?import com.sparrowwallet.sparrow.control.CoinLabel?> <?import com.sparrowwallet.sparrow.control.CoinLabel?>
<GridPane hgap="10.0" vgap="10.0" stylesheets="@outputs.css, @../general.css" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.sparrowwallet.sparrow.transaction.OutputsController"> <GridPane hgap="10.0" vgap="10.0" styleClass="tx-pane" stylesheets="@outputs.css, @transaction.css, @../general.css" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.sparrowwallet.sparrow.transaction.OutputsController">
<padding> <padding>
<Insets left="25.0" right="25.0" top="25.0" /> <Insets left="25.0" right="25.0" top="25.0" />
</padding> </padding>

View file

@ -4,6 +4,10 @@
-fx-padding: 2; -fx-padding: 2;
} }
.tx-pane {
-fx-background-color: -fx-background;
}
.color-0 { -fx-fill: #ca1243 } .color-0 { -fx-fill: #ca1243 }
.color-1 { -fx-fill: #d75f00 } .color-1 { -fx-fill: #d75f00 }
.color-2 { -fx-fill: #c18401 } .color-2 { -fx-fill: #c18401 }

View file

@ -15,7 +15,7 @@
<TreeView fx:id="txtree" minWidth="120"> <TreeView fx:id="txtree" minWidth="120">
<SplitPane.resizableWithParent>false</SplitPane.resizableWithParent> <SplitPane.resizableWithParent>false</SplitPane.resizableWithParent>
</TreeView> </TreeView>
<StackPane fx:id="txpane" /> <StackPane fx:id="txpane" styleClass="tx-pane"/>
</items> </items>
</SplitPane> </SplitPane>
</masterNode> </masterNode>