Add combobox to select a font

... no actual functionality behinfd it, yet
This commit is contained in:
0xb00bface 2021-08-22 11:16:46 +02:00
parent ac135b3e0b
commit 0b762eba0d
1 changed files with 31 additions and 0 deletions

View File

@ -50,11 +50,14 @@ import javafx.beans.property.SimpleLongProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.control.Tab;
import javafx.scene.control.TextInputDialog;
import javafx.scene.layout.Background;
@ -68,6 +71,7 @@ import javafx.scene.layout.GridPane;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.util.Duration;
public class SettingsTab extends Tab implements TabSelectionListener {
@ -229,6 +233,8 @@ public class SettingsTab extends Tab implements TabSelectionListener {
Setting.of("Total model count in title", totalModelCountInTitle, "Show the total number of models in the title bar"),
Setting.of("Start Tab", startTab),
Setting.of("Colors (Base / Accent)", new ColorSettingsPane(Config.getInstance())).needsRestart()
//,
//Setting.of("Font", buildFontFaceCombo()).needsRestart()
),
Group.of("Player",
Setting.of("Player", mediaPlayer),
@ -611,4 +617,29 @@ public class SettingsTab extends Tab implements TabSelectionListener {
};
}
}
private ComboBox<String> buildFontFaceCombo() {
ObservableList<String> lst = FXCollections.observableList(javafx.scene.text.Font.getFamilies());
ComboBox<String> cb = new ComboBox<>(lst);
cb.getSelectionModel().select(0);
cb.setCellFactory((listview -> new ListCell<String>() {
@Override
protected void updateItem(String family, boolean empty) {
super.updateItem(family, empty);
if (empty) {
setText(null);
} else {
setFont(Font.font(family));
setText(family);
}
}
}));
cb.setOnAction(evt -> {
// TODO write a css file with the font setting
// System.out.println(evt);
// Font font = Font.font(cb.getSelectionModel().getSelectedItem());
// SettingsTab.this.getTabPane().getScene().getStylesheets().add(".root {-fx-font: 24 '" + font.getFamily() + "';}");
});
return cb;
}
}