Skip to content

Commit

Permalink
New UI for opening players to external ui
Browse files Browse the repository at this point in the history
  • Loading branch information
goxr3plus committed Oct 28, 2018
1 parent 3425f36 commit 8b28600
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import org.kordamp.ikonli.javafx.StackedFontIcon;

import com.jfoenix.controls.JFXButton;

import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.input.KeyCombination;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import main.java.com.goxr3plus.fxborderlessscene.borderless.BorderlessScene;
import main.java.com.goxr3plus.xr3player.application.tools.general.InfoTool;
import main.java.com.goxr3plus.xr3player.xplayer.presenter.XPlayerController;

Expand All @@ -24,11 +31,30 @@ public class XPlayerWindow extends BorderPane {

// -----------------------------------------------------------------------------

@FXML
private BorderPane topBar;

@FXML
private Label topLabel;

@FXML
private JFXButton maxOrNormalize;

@FXML
private StackedFontIcon sizeStackedFontIcon;

@FXML
private JFXButton closeWindow;

// -----------------------------------------------------------------------------

/**
* The Window
*/
private Stage window;

private BorderlessScene borderlessScene;

/**
* The XPlayer that the window is holding :)
*/
Expand Down Expand Up @@ -69,17 +95,20 @@ public XPlayerWindow(XPlayerController xPlayerController) {
@FXML
private void initialize() {

// BorderlessScene scene = new BorderlessScene(window, StageStyle.TRANSPARENT, this, 150, 150)
// scene.setMoveControl(topBar)

// -- Scene
Scene scene = new Scene(this, InfoTool.getScreenWidth() / 3, InfoTool.getScreenHeight() / 3);
scene.getStylesheets().add(getClass().getResource(InfoTool.STYLES + InfoTool.APPLICATIONCSS).toExternalForm());
getWindow().setScene(scene);
borderlessScene = new BorderlessScene(window, StageStyle.TRANSPARENT, this, InfoTool.getScreenWidth() / 3, InfoTool.getScreenHeight() / 3);
borderlessScene.setMoveControl(topBar);
borderlessScene.getStylesheets().add(getClass().getResource(InfoTool.STYLES + InfoTool.APPLICATIONCSS).toExternalForm());
getWindow().setScene(borderlessScene);

// -- Label
topLabel.setText("Player " + ( xPlayerController.getKey() + 1 ));

// -- Window
//getWindow().centerOnScreen()
// -- closeWindow
closeWindow.setOnAction(a -> close());

// -- maxOrNormalize
maxOrNormalize.setOnAction(a -> borderlessScene.maximizeStage());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public class VisualizerWindowController extends StackPane {

// ------------------------------------

private BorderlessScene scene;
private BorderlessScene borderlessScene;

/** The window. */
private Stage window;
Expand Down Expand Up @@ -177,10 +177,10 @@ public VisualizerWindowController(XPlayerController xPlayerController) {
private void initialize() {

// -- Scene
scene = new BorderlessScene(window, StageStyle.TRANSPARENT, this, 150, 150);
scene.setMoveControl(topBar);
scene.setFill(Color.rgb(0, 0, 0, transparencySlider.getValue()));
scene.getStylesheets().add(getClass().getResource(InfoTool.STYLES + InfoTool.APPLICATIONCSS).toExternalForm());
borderlessScene = new BorderlessScene(window, StageStyle.TRANSPARENT, this, 150, 150);
borderlessScene.setMoveControl(topBar);
borderlessScene.setFill(Color.rgb(0, 0, 0, transparencySlider.getValue()));
borderlessScene.getStylesheets().add(getClass().getResource(InfoTool.STYLES + InfoTool.APPLICATIONCSS).toExternalForm());

// width listener
window.widthProperty().addListener((observable , oldValue , newValue) -> {
Expand All @@ -197,7 +197,7 @@ private void initialize() {
addEventHandler(MouseEvent.MOUSE_MOVED, m -> restartPauseTransition());

// -- KeyListeners
scene.setOnKeyReleased(key -> {
borderlessScene.setOnKeyReleased(key -> {
if (key.getCode() == KeyCode.ESCAPE) {
if (!window.isFullScreen())
removeVisualizer();
Expand All @@ -208,9 +208,9 @@ private void initialize() {
});

// ----------Drag && Drop Listeners
scene.setOnDragOver(dragOver -> dragOver.acceptTransferModes(TransferMode.LINK));
scene.setOnDragDropped(xPlayerController.audioDropEvent);
window.setScene(scene);
borderlessScene.setOnDragOver(dragOver -> dragOver.acceptTransferModes(TransferMode.LINK));
borderlessScene.setOnDragDropped(xPlayerController.audioDropEvent);
window.setScene(borderlessScene);

// -------------Top Bar Elements---------------

Expand All @@ -229,11 +229,11 @@ private void initialize() {
});

// ----------------------------- Minimize
maxOrNormalize.setOnAction(a -> scene.maximizeStage());
maxOrNormalize.setOnAction(a -> borderlessScene.maximizeStage());
close.setOnAction(action -> removeVisualizer());

//stage
scene.maximizedProperty().addListener((observable , oldValue , newValue) -> {
borderlessScene.maximizedProperty().addListener((observable , oldValue , newValue) -> {
if (newValue) {
sizeStackedFontIcon.getChildren().get(0).setVisible(true);
sizeStackedFontIcon.getChildren().get(1).setVisible(false);
Expand All @@ -245,7 +245,7 @@ private void initialize() {

// transparencySlider
//transparencySlider.disableProperty().bind(window.showingProperty().not());
transparencySlider.valueProperty().addListener(list -> scene.setFill(Color.rgb(0, 0, 0, transparencySlider.getValue())));
transparencySlider.valueProperty().addListener(list -> borderlessScene.setFill(Color.rgb(0, 0, 0, transparencySlider.getValue())));

// PauseTransition
pauseTransition.setOnFinished(f -> {
Expand Down
56 changes: 56 additions & 0 deletions src/main/resources/fxml/players/XPlayerWindow.fxml
Original file line number Diff line number Diff line change
@@ -1,10 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import com.jfoenix.controls.JFXButton?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.Cursor?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.effect.DropShadow?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.text.Font?>
<?import org.kordamp.ikonli.javafx.FontIcon?>
<?import org.kordamp.ikonli.javafx.StackedFontIcon?>

<fx:root prefHeight="304.0" prefWidth="546.0" style="-fx-background-color: rgb(0,0,0,0.9);" stylesheets="@../../style/application.css" type="BorderPane" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1">
<padding>
<Insets bottom="2.0" left="2.0" right="2.0" top="2.0" />
</padding>
<top>
<BorderPane fx:id="topBar" maxHeight="-Infinity" minHeight="16.0" prefHeight="36.0" prefWidth="533.0" style="-fx-background-color: #202020; -fx-border-color: #202020; -fx-border-width: 3;" BorderPane.alignment="CENTER">
<center>
<Label fx:id="topLabel" alignment="CENTER" contentDisplay="RIGHT" graphicTextGap="5.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="0.0" style="-fx-text-fill: white; -fx-font-weight: bold; -fx-background-color: #202020; -fx-border-color: transparent firebrick; -fx-border-width: 2;" text="Player" BorderPane.alignment="CENTER">
<effect>
<DropShadow />
</effect>
<cursor>
<Cursor fx:constant="MOVE" />
</cursor>
<BorderPane.margin>
<Insets right="5.0" />
</BorderPane.margin>
</Label>
</center>
<right>
<HBox alignment="TOP_CENTER" spacing="5.0" BorderPane.alignment="CENTER">
<children>
<JFXButton fx:id="maxOrNormalize" contentDisplay="GRAPHIC_ONLY" focusTraversable="false" maxHeight="-Infinity" minHeight="-Infinity" prefHeight="32.0" prefWidth="32.0" style="-fx-font-size: 10;" styleClass="jfx-button-green" text="+">
<font>
<Font size="8.0" />
</font>
<graphic>
<StackedFontIcon fx:id="sizeStackedFontIcon">
<children>
<FontIcon iconColor="WHITE" iconLiteral="fa-plus" iconSize="20" selectionEnd="0" selectionStart="0" visible="false" />
<FontIcon iconColor="WHITE" iconLiteral="fa-plus" iconSize="20" layoutX="10.0" layoutY="29.0" selectionEnd="0" selectionStart="0" />
</children>
</StackedFontIcon>
</graphic>
</JFXButton>
<JFXButton fx:id="closeWindow" contentDisplay="GRAPHIC_ONLY" focusTraversable="false" maxHeight="-Infinity" minHeight="-Infinity" prefHeight="32.0" prefWidth="32.0" style="-fx-font-size: 10;" styleClass="jfx-button-red" text="X">
<font>
<Font size="8.0" />
</font>
<graphic>
<FontIcon iconColor="WHITE" iconLiteral="fa-close" iconSize="20">
<effect>
<DropShadow />
</effect>
</FontIcon>
</graphic>
</JFXButton>
</children>
</HBox>
</right>
</BorderPane>
</top>
</fx:root>

0 comments on commit 8b28600

Please sign in to comment.