<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import org.controlsfx.glyphfont.*?>
<?import tornadofx.control.*?>
<?import org.fxmisc.richtext.CodeArea?>
<?import org.fxmisc.flowless.VirtualizedScrollPane?>
<?import org.controlsfx.control.SegmentedButton?>
<?import javafx.collections.FXCollections?>
<?import java.lang.String?>
<?import com.sparrowwallet.sparrow.control.RelativeTimelockSpinner?>
<?import com.sparrowwallet.sparrow.control.CopyableLabel?>
<?import com.sparrowwallet.sparrow.control.IdLabel?>
<?import com.sparrowwallet.sparrow.control.CoinLabel?>
<?import com.sparrowwallet.sparrow.control.AddressLabel?>
<?import com.sparrowwallet.sparrow.control.UnlabeledToggleSwitch?>
<?import com.sparrowwallet.sparrow.control.ScriptArea?>

<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>
        <Insets left="25.0" right="25.0" top="25.0" />
    </padding>
    <columnConstraints>
        <ColumnConstraints percentWidth="50" />
        <ColumnConstraints percentWidth="50" />
    </columnConstraints>
    <rowConstraints>
        <RowConstraints />
        <RowConstraints />
    </rowConstraints>
    <Form GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.rowIndex="0">
        <Fieldset fx:id="inputFieldset" inputGrow="SOMETIMES" text="Input" wrapWidth="680">
            <Field text="Outpoint:" styleClass="label-button">
                <IdLabel fx:id="outpoint" />
                <Hyperlink fx:id="linkedOutpoint" styleClass="id" visible="false" />
                <Button fx:id="outpointSelect" maxWidth="25" minWidth="-Infinity" prefWidth="30" text="Ed">
                    <graphic>
                        <Glyph fontFamily="FontAwesome" icon="EDIT" prefWidth="15" />
                    </graphic>
                </Button>
            </Field>
            <Field text="Spends:">
                <CoinLabel fx:id="spends" />
                <CopyableLabel fx:id="from" text="from" />
                <AddressLabel fx:id="address" />
            </Field>
        </Fieldset>
    </Form>

    <Separator styleClass="form-separator" GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.rowIndex="1" />

    <Form GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.rowIndex="2">
        <Fieldset inputGrow="SOMETIMES" text="Script">
            <Field text="ScriptSig:">
                <VirtualizedScrollPane>
                    <content>
                        <ScriptArea fx:id="scriptSigArea" editable="false" wrapText="true" prefHeight="42" maxHeight="42" styleClass="uneditable-codearea" />
                    </content>
                </VirtualizedScrollPane>
            </Field>
            <Field text="RedeemScript:">
                <VirtualizedScrollPane fx:id="redeemScriptScroll">
                    <content>
                        <ScriptArea fx:id="redeemScriptArea" editable="false" wrapText="true" prefHeight="42" maxHeight="42" styleClass="uneditable-codearea" />
                    </content>
                </VirtualizedScrollPane>
            </Field>
            <Field text="Witnesses:">
                <VirtualizedScrollPane fx:id="witnessesScroll">
                    <content>
                        <ScriptArea fx:id="witnessesArea" editable="false" wrapText="true" prefHeight="42" maxHeight="42" styleClass="uneditable-codearea" />
                    </content>
                </VirtualizedScrollPane>
            </Field>
            <Field text="WitnessScript:">
                <VirtualizedScrollPane fx:id="witnessScriptScroll">
                    <content>
                        <ScriptArea fx:id="witnessScriptArea" editable="false" wrapText="true" prefHeight="42" maxHeight="42" styleClass="uneditable-codearea" />
                    </content>
                </VirtualizedScrollPane>
            </Field>
        </Fieldset>
    </Form>

    <Separator styleClass="form-separator" GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.rowIndex="3" />

    <Form GridPane.columnIndex="0" GridPane.rowIndex="4">
        <Fieldset text="Status" inputGrow="SOMETIMES">
            <Field text="Signatures:">
                <CopyableLabel fx:id="signatures" />
            </Field>
            <Field text="RBF:">
                <UnlabeledToggleSwitch fx:id="rbf"/>
            </Field>
        </Fieldset>
    </Form>

    <Form GridPane.columnIndex="1" GridPane.rowIndex="4">
        <Fieldset fx:id="locktimeFieldset" text="Locktime" inputGrow="SOMETIMES">
            <Field text="Type:">
                <SegmentedButton>
                    <toggleGroup>
                        <ToggleGroup fx:id="locktimeToggleGroup" />
                    </toggleGroup>
                    <buttons>
                        <ToggleButton fx:id="locktimeNoneType" text="Disabled" userData="none" toggleGroup="$locktimeToggleGroup">
                            <tooltip>
                                <Tooltip text="Disable time locks"/>
                            </tooltip>
                        </ToggleButton>
                        <ToggleButton fx:id="locktimeAbsoluteType" text="Absolute" userData="absolute" toggleGroup="$locktimeToggleGroup">
                            <tooltip>
                                <Tooltip text="Enable absolute (transaction level) time lock only"/>
                            </tooltip>
                        </ToggleButton>
                        <ToggleButton fx:id="locktimeRelativeType" text="Relative" userData="relative" toggleGroup="$locktimeToggleGroup">
                            <tooltip>
                                <Tooltip text="Enable both absolute and relative time locks"/>
                            </tooltip>
                        </ToggleButton>
                    </buttons>
                </SegmentedButton>
            </Field>
            <Field fx:id="locktimeAbsoluteField" text="Block:">
                <CopyableLabel fx:id="locktimeAbsolute" />
            </Field>
            <Field fx:id="locktimeRelativeField" text="Value:">
                <Spinner fx:id="locktimeRelativeBlocks" editable="true" prefWidth="110"/>
                <RelativeTimelockSpinner fx:id="locktimeRelativeSeconds" editable="true" prefWidth="110"/>
                <ComboBox fx:id="locktimeRelativeCombo">
                    <items>
                        <FXCollections fx:factory="observableArrayList">
                            <String fx:value="blocks" />
                            <String fx:value="time" />
                        </FXCollections>
                    </items>
                </ComboBox>
            </Field>
        </Fieldset>
    </Form>

</GridPane>
