1
0
Fork 0

CoverItem yay

master
Ambrose Chua 2015-10-12 18:41:22 +08:00
parent cc6c65cab1
commit 8c6c904632
7 changed files with 187 additions and 12 deletions

View File

@ -38,7 +38,7 @@ public class Main extends Application {
Parent root = null;
try {
root = FXMLLoader.load(getClass().getResource("view/interface-test.fxml"));
root = FXMLLoader.load(getClass().getResource("view/interface.fxml"));
} catch (IOException e) {
e.printStackTrace();
System.exit(284);

View File

@ -0,0 +1,93 @@
package io.makerforce.undefined.view;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import java.io.IOException;
public class CoverItemController extends AnchorPane {
@FXML
private Label titleLabel;
@FXML
private Label subtitleLabel;
@FXML
private Parent subtitleContainer;
@FXML
private Label secondaryLabel;
@FXML
private ImageView imageView;
private StringProperty title = new SimpleStringProperty();
private StringProperty subtitle = new SimpleStringProperty();
private StringProperty secondary = new SimpleStringProperty();
private StringProperty image = new SimpleStringProperty();
public CoverItemController() {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("coveritem.fxml"));
fxmlLoader.setRoot(this);
fxmlLoader.setController(this);
try {
fxmlLoader.load();
} catch (IOException exception) {
throw new RuntimeException(exception);
}
initializeBindings();
}
public CoverItemController(String image, String title, String subtitle, String secondary) {
this();
this.image.set(image);
this.title.set(title);
this.subtitle.set(subtitle);
this.secondary.set(secondary);
}
public CoverItemController(String image, String title, String subtitle) {
this(image, title, subtitle, "");
}
public CoverItemController(String image, String title) {
this(image, title, "", "");
}
public void initializeBindings() {
titleLabel.textProperty().bind(title);
subtitleLabel.textProperty().bind(subtitle);
secondaryLabel.textProperty().bind(secondary);
image.addListener((observable) -> {
String url = ((StringProperty) observable).getValue();
if (url.equals("")) {
imageView.setImage(null);
} else {
imageView.setImage(new Image(url));
}
});
subtitleContainer.managedProperty().bind(secondary.isEqualTo(""));
}
public StringProperty titleProperty() {
return title;
}
public StringProperty subtitleProperty() {
return subtitle;
}
public StringProperty secondaryProperty() {
return subtitle;
}
public StringProperty imageProperty() {
return image;
}
}

View File

@ -11,6 +11,7 @@ import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.VBox;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
@ -40,6 +41,8 @@ public class InterfaceController {
@FXML
private ScrollPane scrollPane;
@FXML
private FlowPane flowPane;
private Image playIcon = new Image("/icons/play3.48.png");
private Image pauseIcon = new Image("/icons/pause2.48.png");
@ -104,6 +107,11 @@ public class InterfaceController {
// Temporary stuff
currentImage.setImage(new Image("http://ambrose.makerforce.io:8080/art/Alan%20Walker/Fade/1"));
currentArtist.setText("Alan Walker");
currentTitle.setText("Fade");
flowPane.getChildren().add(new CoverItemController("http://ambrose.makerforce.io:8080/art/Alan%20Walker/Spectre/1", "Spectre", "Alan Walker"));
flowPane.getChildren().add(new CoverItemController("http://ambrose.makerforce.io:8080/art/Alan%20Walker/Fade/1", "Fade", "Alan Walker"));
// Player events

View File

@ -0,0 +1,20 @@
package io.makerforce.undefined.view;
import javafx.fxml.FXMLLoader;
import java.io.IOException;
public class TrackListController {
public TrackListController() {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("tracklist.fxml"));
fxmlLoader.setRoot(this);
fxmlLoader.setController(this);
try {
fxmlLoader.load();
} catch (IOException exception) {
throw new RuntimeException(exception);
}
}
}

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.Font?>
<fx:root xmlns:fx="http://javafx.com/fxml/1" prefHeight="180.0" prefWidth="180.0" type="javafx.scene.layout.AnchorPane"
xmlns="http://javafx.com/javafx/8.0.40">
<children>
<ImageView fx:id="imageView" fitHeight="180.0" fitWidth="180.0" pickOnBounds="true"
preserveRatio="true"></ImageView>
<VBox style="-fx-background-color: #0002, linear-gradient(#0000 0%, #0006 100%);" AnchorPane.bottomAnchor="0.0"
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<children>
<Label fx:id="titleLabel" textFill="WHITE">
<font>
<Font name="System Bold" size="13.0"/>
</font>
</Label>
<HBox fx:id="subtitleContainer" alignment="CENTER_LEFT">
<children>
<Pane HBox.hgrow="ALWAYS">
<children>
<Label fx:id="subtitleLabel" textFill="WHITE"/>
</children>
</Pane>
<Label fx:id="secondaryLabel" textAlignment="RIGHT" textFill="WHITE">
<font>
<Font size="10.0"/>
</font>
<HBox.margin>
<Insets left="7.0"/>
</HBox.margin>
</Label>
</children>
</HBox>
</children>
<padding>
<Insets bottom="7.0" left="10.0" right="10.0" top="7.0"/>
</padding>
</VBox>
</children>
</fx:root>

View File

@ -6,7 +6,7 @@
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<BorderPane xmlns:fx="http://javafx.com/fxml/1" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="400.0"
minWidth="600.0" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.40"
minWidth="600.0" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/null"
fx:controller="io.makerforce.undefined.view.InterfaceController">
<bottom>
<HBox alignment="CENTER_LEFT" spacing="7.0" BorderPane.alignment="CENTER_LEFT">
@ -72,11 +72,11 @@
<Separator orientation="VERTICAL"/>
<HBox alignment="CENTER" spacing="7.0" HBox.hgrow="ALWAYS">
<children>
<Label fx:id="playbackTimeLabel" minWidth="42.0" prefHeight="24.0" text="01:00"/>
<Label fx:id="playbackTimeLabel" minWidth="42.0" prefHeight="24.0" text="--:--"/>
<Slider fx:id="playbackSlider" max="1.0" min="0.0" prefHeight="16.0" prefWidth="156.0"
HBox.hgrow="ALWAYS"/>
<Label fx:id="playbackLeftLabel" alignment="CENTER_RIGHT" minWidth="42.0" prefHeight="24.0"
text="-01:00"/>
text="--:--"/>
</children>
<HBox.margin>
<Insets/>
@ -127,19 +127,15 @@
<VBox fx:id="currentDetails" alignment="BOTTOM_LEFT">
<children>
<ImageView fx:id="currentImage" fitHeight="120.0" fitWidth="120.0" pickOnBounds="true"
preserveRatio="true">
<image>
<Image url="@/images/srw.png"/>
</image>
</ImageView>
preserveRatio="true"/>
<VBox>
<children>
<Label fx:id="currentTitle" text="Fade">
<Label fx:id="currentTitle">
<font>
<Font name="System Bold" size="13.0"/>
</font>
</Label>
<Label fx:id="currentArtist" text="Alan Walker"/>
<Label fx:id="currentArtist"/>
</children>
<padding>
<Insets bottom="7.0" left="10.0" right="10.0" top="7.0"/>
@ -151,7 +147,14 @@
</VBox>
<ScrollPane fx:id="scrollPane" fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER">
<content>
<FlowPane/>
<FlowPane fx:id="flowPane" columnHalignment="CENTER" hgap="7.0" vgap="7.0">
<children>
</children>
<padding>
<Insets bottom="7.0" left="7.0" right="7.0" top="7.0"/>
</padding>
</FlowPane>
</content>
</ScrollPane>
</items>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.AnchorPane?>
<fx:root xmlns:fx="http://javafx.com/fxml/1" prefHeight="180.0" prefWidth="180.0" type="javafx.scene.layout.AnchorPane"
xmlns="http://javafx.com/javafx/8.0.40">
</fx:root>