Skip to content

Commit

Permalink
Converted Batch GUI form into a resizable form.
Browse files Browse the repository at this point in the history
  • Loading branch information
EasyG0ing1 committed Aug 5, 2023
1 parent 817efaf commit f9876f2
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 34 deletions.
49 changes: 30 additions & 19 deletions src/main/java/GUI/Forms/Batch.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import javafx.beans.property.SimpleBooleanProperty;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
Expand Down Expand Up @@ -56,6 +57,8 @@
import java.util.concurrent.TimeUnit;

import static GUI.Forms.Constants.*;
import static javafx.scene.layout.AnchorPane.*;
import static javafx.scene.layout.AnchorPane.setRightAnchor;

/**
* This is the second main GUI form, and it manages batch jobs for the user.
Expand All @@ -66,8 +69,8 @@
public class Batch {

private final double scale = .6;
private double width;
private double height;
private final double width;
private final double height;
private Stage stage;
private Folders folders;
private ConcurrentLinkedDeque<Job> jobList;
Expand Down Expand Up @@ -116,9 +119,7 @@ public Batch(ConsoleOut consoleOut) {
this.consoleOut = consoleOut;
height = (int) screenSize.getHeight() * scale;
width = (int) screenSize.getWidth() * scale;
System.out.println("Batch W: " + screenSize.getWidth());
System.out.println("Batch H: " + screenSize.getHeight());
folders = AppSettings.get.getFolders();
folders = AppSettings.get.getFolders();
if (AppSettings.get.getJobs() != null) {
jobList = AppSettings.get.getJobs().jobList();
}
Expand All @@ -127,8 +128,8 @@ public Batch(ConsoleOut consoleOut) {
}
Platform.runLater(() -> {
createControls();
//setControlProperties();
//setControlActions();
setControlProperties();
setControlActions();
makeScene();
tfDir.setText(folders.getDownloadFolder());
});
Expand Down Expand Up @@ -177,6 +178,8 @@ private ImageView imageToggle(double scale) {
double width = Constants.imgUpUp.getWidth();
imageView.setPreserveRatio(true);
imageView.setFitWidth(width * scale);
anchorPane.getChildren().add(imageView);
placeControl(imageView,-1,20,-1,20);
return imageView;
}

Expand All @@ -200,6 +203,13 @@ private ImageView imageView(Image image, double ratio) {
return iv;
}

private void placeControl(Node node, double left, double right, double top, double bottom) {
if (top != -1) setTopAnchor(node, top);
if (bottom != -1) setBottomAnchor(node, bottom);
if (left != -1) setLeftAnchor(node, left);
if (right != -1) setRightAnchor(node, right);
}

private void createControls() {
anchorPane = new AnchorPane();
anchorPane.setPrefWidth(width);
Expand Down Expand Up @@ -245,6 +255,7 @@ private void createControls() {
vbox.setAlignment(Pos.CENTER);
vbox.setPrefWidth(width);
vbox.setPrefHeight(height);
ivBtnConsole = imageToggle(.5);
anchorPane.getChildren().add(vbox);
}

Expand Down Expand Up @@ -333,7 +344,7 @@ private void setControlActions() {
AppSettings.set.setIsBatchAutoPasteEnabled(newValue);
}
}));
ivBtnConsole.setOnMouseClicked(e -> toggleConsole());
ivBtnConsole.setOnMouseClicked(e -> toggleConsole(false));
}

private void triageInbound(String newLink) {
Expand Down Expand Up @@ -397,17 +408,17 @@ public void makeScene() {
consoleOut.rePosition(stage.getX(), (double) newValue);
}
}));
stage.fullScreenProperty().addListener(((observable, oldValue, newValue) -> ivBtnConsole.setVisible(!newValue)));
//stage.fullScreenProperty().addListener(((observable, oldValue, newValue) -> ivBtnConsole.setVisible(!newValue)));
stage.setScene(scene);
stage.setWidth(width);
stage.setMinHeight(height);
}

public void show() {
System.out.println("Batch Show Scene");
stage.show();
commitJobListToListView();
consoleOut.rePosition(width, height, stage.getX(), stage.getY());
ivBtnConsole.toFront();
}

private void close() {
Expand Down Expand Up @@ -495,21 +506,21 @@ private void getDirectory() {
}
}

private void toggleConsole() {
if (!consoleOpen) {
ivBtnConsole.setImage(Constants.imgDownUp);
ivBtnConsole.setOnMousePressed(e -> ivBtnConsole.setImage(Constants.imgDownDown));
ivBtnConsole.setOnMouseReleased(e -> ivBtnConsole.setImage(Constants.imgDownUp));
consoleOut.show();
consoleOpen = true;
}
else {
private void toggleConsole(boolean close) {
if (consoleOpen || close) {
ivBtnConsole.setImage(Constants.imgUpUp);
ivBtnConsole.setOnMousePressed(e -> ivBtnConsole.setImage(Constants.imgUpDown));
ivBtnConsole.setOnMouseReleased(e -> ivBtnConsole.setImage(Constants.imgUpUp));
consoleOut.hide();
consoleOpen = false;
}
else {
ivBtnConsole.setImage(Constants.imgDownUp);
ivBtnConsole.setOnMousePressed(e -> ivBtnConsole.setImage(Constants.imgDownDown));
ivBtnConsole.setOnMouseReleased(e -> ivBtnConsole.setImage(Constants.imgDownUp));
consoleOut.show();
consoleOpen = true;
}
}

/**
Expand Down
31 changes: 18 additions & 13 deletions src/main/java/GUI/Forms/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,39 +206,39 @@ private void createControls() {
anchorPane.setPrefHeight(height);
Image imgBanner = new Image(Constants.mainGUIBanner.toExternalForm());
ImageView ivBanner = imageView(imgBanner, .5);
VBox boxBanner = new VBox(30, ivBanner, getSpacer(), getSpacer());
pBar = pbar();
VBox boxBanner = new VBox(15, ivBanner, pBar, getSpacer());
boxBanner.setAlignment(Pos.CENTER);
pBar = new ProgressBar();
ivLinkLabel = imageView(imgLink, .8);
ivAutoLabel = imageView(imgAutoPaste, .8);
ivLinkLabel = imageView(imgLink, scale);
ivAutoLabel = imageView(imgAutoPaste, scale);
cbAutoPaste = new CheckBox();
HBox boxLinkLabel = new HBox(10, ivLinkLabel, getSpacer(), ivAutoLabel, cbAutoPaste);
tfLink = newTextField();
lblLinkOut = label();
lblLinkOut = label("lblLinkOut");
HBox boxLinkOut = new HBox(lblLinkOut);
boxLinkOut.setAlignment(Pos.CENTER_LEFT);

ivDirLabel = imageView(imgDirectory, .8);
ivDirLabel = imageView(imgDirectory, scale);
HBox boxDirLabel = new HBox(ivDirLabel);
boxDirLabel.setAlignment(Pos.CENTER_LEFT);

tfDir = newTextField();
lblDirOut = label();
lblDirOut = label("lblDirOut");
HBox boxLblDirOut = new HBox(lblDirOut);
boxLblDirOut.setAlignment(Pos.CENTER_LEFT);

ivFilenameLabel = imageView(imgFilename, .8);
ivFilenameLabel = imageView(imgFilename, scale);
HBox boxFilenameLabel = new HBox(ivFilenameLabel);
boxFilenameLabel.setAlignment(Pos.CENTER_LEFT);
tfFilename = newTextField();

lblFilenameOut = label();
lblFilenameOut = label("lblFilenameOut");
HBox boxLblFilenameOut = new HBox(lblFilenameOut);
boxLblFilenameOut.setAlignment(Pos.CENTER_LEFT);
lblDownloadInfo = label();
lblDownloadInfo = label("lblDownloadInfo");
HBox boxLblDownloadInfo = new HBox(lblDownloadInfo);
boxLblDownloadInfo.setAlignment(Pos.CENTER_LEFT);
vbox = new VBox(10, boxBanner, boxLinkLabel, tfLink, boxLinkOut, boxDirLabel, tfDir, boxLblDirOut, boxFilenameLabel, tfFilename, boxLblFilenameOut, boxLblDownloadInfo, makeButtonBox());
vbox = new VBox(0, boxBanner, boxLinkLabel, tfLink, boxLinkOut, boxDirLabel, tfDir, boxLblDirOut, boxFilenameLabel, tfFilename, boxLblFilenameOut, boxLblDownloadInfo, makeButtonBox());
vbox.setPadding(new Insets(50, 50, 0, 50));
vbox.setAlignment(Pos.CENTER);
vbox.setPrefWidth(width);
Expand All @@ -247,6 +247,11 @@ private void createControls() {
menuBar(getMenuItemsOfMenu(), getWindowMenu(), getHelpMenuItems());
}

private ProgressBar pbar() {
ProgressBar pbar = new ProgressBar();
pbar.setPrefWidth(screenSize.getWidth());
return pbar;
}
private TextField newTextField() {
TextField tf = new TextField();
tf.setFont(new Font(monacoFont.toExternalForm(), 19));
Expand All @@ -273,8 +278,8 @@ private Label getSpacer() {
return label;
}

private Label label() {
Label label = new Label();
private Label label(String text) {
Label label = new Label(text);
label.setFont(new Font(monacoFont.toExternalForm(), 20));
return label;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/GUI/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public static void main(String[] args) {
System.setProperty("apple.awt.UIElement", "false");
Toolkit.getDefaultToolkit();
for (String arg : args) {
if (arg.toLowerCase().contains("enablemaxstart")) {
if (arg.toLowerCase().contains("--enablemaxstart")) {
AppSettings.set.startMax(true);
}
if (arg.toLowerCase().contains("disablemaxstart")) {
if (arg.toLowerCase().contains("--disablemaxstart")) {
AppSettings.set.startMax(false);
}
}
Expand Down

0 comments on commit f9876f2

Please sign in to comment.