Skip to content

Commit

Permalink
Add dynamic binder creation
Browse files Browse the repository at this point in the history
  • Loading branch information
IzN432 committed Oct 21, 2024
1 parent 530ac38 commit 0d9dea4
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 141 deletions.
43 changes: 40 additions & 3 deletions src/main/java/keycontacts/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import java.util.logging.Logger;

import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.MenuItem;
Expand All @@ -13,6 +11,8 @@
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Arc;
import javafx.stage.Stage;
import keycontacts.commons.core.GuiSettings;
import keycontacts.commons.core.LogsCenter;
Expand Down Expand Up @@ -48,6 +48,9 @@ public class MainWindow extends UiPart<Stage> {
@FXML
private StackPane binder;

@FXML
private VBox loopParent;

@FXML
private StackPane commandBoxPlaceholder;

Expand All @@ -63,6 +66,11 @@ public class MainWindow extends UiPart<Stage> {
@FXML
private StackPane statusbarPlaceholder;

private static final double ARC_RADIUS_X = 8.0;
private static final double ARC_RADIUS_Y = 6.0;
private static final double ARC_LENGTH = 260.0;
private static final double ARC_START_ANGLE = -40.0;

/**
* Creates a {@code MainWindow} with the given {@code Stage} and {@code Logic}.
*/
Expand All @@ -80,11 +88,40 @@ public MainWindow(Stage primaryStage, Logic logic) {

helpWindow = new HelpWindow();

rightPage.getParent().getScene().widthProperty().addListener((observable, oldValue, newValue) -> {
primaryStage.getScene().widthProperty().addListener((observable, oldValue, newValue) -> {
double newWidth = newValue.doubleValue();
leftPage.setPrefWidth((newWidth - binder.getWidth()) / 2);
rightPage.setPrefWidth((newWidth - binder.getWidth()) / 2);
});

primaryStage.getScene().heightProperty().addListener((observable, oldValue, newValue) -> {
updateArcs((Double) newValue);
});
}

private void updateArcs(double height) {
// Clear previous arcs
loopParent.getChildren().clear();

// Dynamically decide how many arcs to add based on the height (as an example)
int numArcs = (int) (height / (ARC_RADIUS_Y * 2 + loopParent.getSpacing())) - 5; // You can change this logic

// Add the arcs dynamically
addArcs(numArcs);
}

private void addArcs(int numArcs) {
for (int i = 0; i < numArcs; i++) {
Arc arc = new Arc();
arc.setRadiusX(ARC_RADIUS_X);
arc.setRadiusY(ARC_RADIUS_Y);
arc.setLength(ARC_LENGTH);
arc.setStartAngle(ARC_START_ANGLE);
arc.setFill(Color.TRANSPARENT);
arc.setStroke(Color.BLACK);

loopParent.getChildren().add(arc);
}
}

public Stage getPrimaryStage() {
Expand Down
89 changes: 0 additions & 89 deletions src/main/resources/view/DarkTheme.css
Original file line number Diff line number Diff line change
@@ -1,92 +1,3 @@
.background {
-fx-background-color: derive(#1d1d1d, 20%);
background-color: #383838; /* Used in the default.html file */
}

.label {
-fx-font-size: 11pt;
-fx-font-family: "Segoe UI Semibold";
-fx-text-fill: #555555;
-fx-opacity: 0.9;
}

.label-bright {
-fx-font-size: 11pt;
-fx-font-family: "Segoe UI Semibold";
-fx-text-fill: white;
-fx-opacity: 1;
}

.label-header {
-fx-font-size: 32pt;
-fx-font-family: "Segoe UI Light";
-fx-text-fill: white;
-fx-opacity: 1;
}

.text-field {
-fx-font-size: 12pt;
-fx-font-family: "Segoe UI Semibold";
}

.tab-pane {
-fx-padding: 0 0 0 1;
}

.tab-pane .tab-header-area {
-fx-padding: 0 0 0 0;
-fx-min-height: 0;
-fx-max-height: 0;
}

.table-view {
-fx-base: #1d1d1d;
-fx-control-inner-background: #1d1d1d;
-fx-background-color: #1d1d1d;
-fx-table-cell-border-color: transparent;
-fx-table-header-border-color: transparent;
-fx-padding: 5;
}

.table-view .column-header-background {
-fx-background-color: transparent;
}

.table-view .column-header, .table-view .filler {
-fx-size: 35;
-fx-border-width: 0 0 1 0;
-fx-background-color: transparent;
-fx-border-color:
transparent
transparent
derive(-fx-base, 80%)
transparent;
-fx-border-insets: 0 10 1 0;
}

.table-view .column-header .label {
-fx-font-size: 20pt;
-fx-font-family: "Segoe UI Light";
-fx-text-fill: white;
-fx-alignment: center-left;
-fx-opacity: 1;
}

.table-view:focused .table-row-cell:filled:focused:selected {
-fx-background-color: -fx-focus-color;
}

.split-pane:horizontal .split-pane-divider {
-fx-background-color: derive(#1d1d1d, 20%);
-fx-border-color: transparent transparent transparent #4d4d4d;
}

.split-pane {
-fx-border-radius: 1;
-fx-border-width: 1;
-fx-background-color: derive(#1d1d1d, 20%);
}

.list-view {
-fx-background-insets: 0;
-fx-padding: 0;
Expand Down
63 changes: 14 additions & 49 deletions src/main/resources/view/Notebook.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@
<?import javafx.scene.shape.Arc?>
<?import javafx.stage.Stage?>

<fx:root minHeight="600" minWidth="450" onCloseRequest="#handleExit" title="KeyContacts" type="javafx.stage.Stage" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<fx:root minHeight="400" minWidth="600" onCloseRequest="#handleExit" title="KeyContacts" type="javafx.stage.Stage" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<scene>
<Scene>
<VBox prefHeight="200.0" prefWidth="100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<VBox AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<MenuBar fx:id="menuBar" stylesheets="@DarkTheme.css" VBox.vgrow="NEVER">
<MenuBar fx:id="menuBar" VBox.vgrow="NEVER">
<Menu mnemonicParsing="false" text="File">
<MenuItem mnemonicParsing="false" onAction="#handleExit" text="Exit" />
</Menu>
<Menu mnemonicParsing="false" text="Help">
<MenuItem fx:id="helpMenuItem" mnemonicParsing="false" onAction="#handleHelp" text="Help" />
</Menu>
</MenuBar>
<AnchorPane style="-fx-background-color: brown;" VBox.vgrow="ALWAYS">
<AnchorPane style="-fx-background-color: dimgrey;" VBox.vgrow="ALWAYS">
<children>
<HBox layoutX="10.0" layoutY="10.0" style="-fx-background-color: whitesmoke;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<AnchorPane fx:id="leftPage" HBox.hgrow="ALWAYS">
<children>
<VBox style="-fx-border-color: brown; -fx-border-width: 2;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<VBox style="-fx-border-color: dimgrey; -fx-border-width: 2;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<StackPane fx:id="commandBoxPlaceholder" styleClass="pane-with-border" VBox.vgrow="NEVER">
<padding>
<Insets bottom="5" left="10" right="10" top="5" />
Expand Down Expand Up @@ -62,62 +62,27 @@
</padding></AnchorPane>
<StackPane fx:id="binder" prefWidth="20.0">
<children>
<Pane prefHeight="200.0" prefWidth="10.0" style="-fx-border-color: black; -fx-border-width: 0 1 0 1; -fx-background-color: whitesmoke;">
<Pane prefWidth="10.0" style="-fx-border-color: black; -fx-border-width: 0 1 0 1; -fx-background-color: whitesmoke;">
<StackPane.margin>
<Insets left="5.0" right="5.0" />
</StackPane.margin>
<effect>
<DropShadow radius="6.335" spread="0.16" width="6.34" />
</effect>
</Pane>
<VBox alignment="TOP_CENTER" prefHeight="200.0" prefWidth="100.0" spacing="5.0">
<children>
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="586.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" VBox.vgrow="ALWAYS" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="16.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" VBox.vgrow="ALWAYS" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="31.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" VBox.vgrow="ALWAYS" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="46.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="61.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="76.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="91.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="106.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="121.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="136.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="151.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="166.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="181.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="196.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="211.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="226.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="241.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="256.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="271.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="286.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="301.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="316.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="331.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="346.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="361.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="376.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="391.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="406.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="421.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="436.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="451.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="466.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="481.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="496.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="511.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="526.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="541.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="556.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="571.0" length="260.0" radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE" />
</children>
<VBox fx:id="loopParent" alignment="TOP_CENTER" spacing="5.0">
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="586.0" length="260.0"
radiusX="8.0" radiusY="6.0" startAngle="-40.0" stroke="BLACK"
strokeType="INSIDE" VBox.vgrow="ALWAYS"/>
<Arc fill="TRANSPARENT" layoutX="20.0" layoutY="16.0" length="260.0" radiusX="8.0"
radiusY="6.0" startAngle="-40.0" stroke="BLACK" strokeType="INSIDE"
VBox.vgrow="ALWAYS"/>
</VBox>
</children>
</StackPane>
<AnchorPane fx:id="rightPage" HBox.hgrow="ALWAYS">
<children>
<VBox style="-fx-border-color: brown; -fx-border-width: 2;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
<VBox style="-fx-border-color: dimgrey; -fx-border-width: 2;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
Expand Down

0 comments on commit 0d9dea4

Please sign in to comment.