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

<?import atlantafx.base.controls.Spacer?>
<?import cn.octopusyan.dmt.view.filemanager.DirectoryTree?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import org.kordamp.ikonli.javafx.*?>
<StackPane xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1"
           fx:id="root" prefHeight="800.0" prefWidth="1000.0"
           fx:controller="cn.octopusyan.dmt.controller.MainController">

    <VBox alignment="TOP_CENTER" prefWidth="${root.width}" prefHeight="Infinity">
        <MenuBar prefWidth="Infinity">
            <Menu mnemonicParsing="false" text="文件">
                <MenuItem text="打开" onAction="#selectFile">
                    <graphic>
                        <FontIcon iconLiteral="fth-folder"/>
                    </graphic>
                </MenuItem>
                <SeparatorMenuItem/>
                <MenuItem text="退出" onAction="#exit"/>
            </Menu>
            <Menu mnemonicParsing="false" text="设置">
                <Menu fx:id="viewStyle" text="界面">
                    <graphic>
                        <FontIcon iconLiteral="fth-grid"/>
                    </graphic>
                </Menu>
                <MenuItem text="翻译" onAction="#openSetupTranslate"/>
                <MenuItem text="代理" onAction="#openSetupProxy">
                    <graphic>
                        <FontIcon iconLiteral="fth-globe"/>
                    </graphic>
                </MenuItem>
            </Menu>
            <Menu mnemonicParsing="false" text="帮助">
                <MenuItem text="帮助" onAction="#openHelp">
                    <graphic>
                        <FontIcon iconLiteral="fth-help-circle"/>
                    </graphic>
                </MenuItem>
                <MenuItem text="关于" onAction="#openAbout">
                    <graphic>
                        <FontIcon iconLiteral="fth-info"/>
                    </graphic>
                </MenuItem>
            </Menu>
        </MenuBar>
        <StackPane fx:id="mainView" prefWidth="Infinity">
            <VBox fx:id="translateView" visible="false">
                <ToolBar>
                    <Button fx:id="fileNameLabel" disable="true" text="fileName.pbo"/>
                    <Spacer/>
                    <!-- 翻译按钮 -->
                    <Button fx:id="translate" text="翻译" onAction="#startTranslate">
                        <graphic>
                            <FontIcon iconLiteral="fth-play"/>
                        </graphic>
                    </Button>
                    <!-- 打包按钮 -->
                    <Button text="打包" onAction="#startPack"/>
                </ToolBar>
                <VBox prefHeight="${root.height}">
                    <ProgressBar fx:id="translateProgress" prefWidth="Infinity" progress="0" visible="false"/>
                    <SplitPane dividerPositions="0.25" prefWidth="Infinity" VBox.vgrow="ALWAYS">
                        <DirectoryTree fx:id="treeFileBox" maxWidth="420" minWidth="40"/>
                        <StackPane GridPane.columnIndex="1" minWidth="40">
                            <VBox fx:id="loadWordBox" alignment="CENTER" spacing="20">
                                <Label text="正在查找待翻译文本"/>
                                <ProgressBar fx:id="loadWordProgressBar" prefWidth="150"/>
                            </VBox>
                            <VBox fx:id="wordBox">
                            </VBox>
                        </StackPane>
                    </SplitPane>
                </VBox>
            </VBox>
            <StackPane fx:id="selectFileBox">
                <VBox fx:id="openFileView" alignment="CENTER">
                    <Button text="打开文件" onAction="#selectFile"/>
                    <Label text="或将 pbo文件 拖到此处">
                        <VBox.margin>
                            <Insets top="10.0"/>
                        </VBox.margin>
                    </Label>
                </VBox>
                <VBox fx:id="dragFileView" alignment="CENTER" visible="false"
                      style="-fx-background-color: -color-bg-default">
                    <Label alignment="CENTER" prefHeight="-Infinity" text="将文件拖放到此处"
                           textAlignment="CENTER"/>
                </VBox>
                <VBox fx:id="loadFileView" alignment="CENTER" spacing="20" visible="false"
                      style="-fx-background-color: -color-bg-default">
                    <Label text="正在读取文件"/>
                    <ProgressBar prefWidth="200"/>
                </VBox>
            </StackPane>
        </StackPane>
        <TitledPane fx:id="titledPane" text="信息" expanded="false">
            <TextArea fx:id="logArea" editable="false" minHeight="150">
                <contextMenu>
                    <ContextMenu>
                        <items>
                            <MenuItem text="全选" onAction="#selectAllLog"/>
                            <MenuItem text="复制" onAction="#copyLog"/>
                            <MenuItem text="清空" onAction="#clearLog"/>
                        </items>
                    </ContextMenu>
                </contextMenu>
            </TextArea>
        </TitledPane>
    </VBox>
</StackPane>
