diff --git a/chunky/src/java/se/llbit/chunky/renderer/postprocessing/PostProcessingFilters.java b/chunky/src/java/se/llbit/chunky/renderer/postprocessing/PostProcessingFilters.java index 4c54162d91..640de9bb09 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/postprocessing/PostProcessingFilters.java +++ b/chunky/src/java/se/llbit/chunky/renderer/postprocessing/PostProcessingFilters.java @@ -24,13 +24,6 @@ public static Optional getPostProcessingFilterFromId(Strin return Optional.ofNullable(filters.get(id)); } - // TODO Create a ChoiceBox that can use different string as ID and as visual representation - // so this isn't needed - @Deprecated - public static Optional getPostProcessingFilterFromName(String name) { - return Optional.ofNullable(filtersByName.get(name)); - } - public static Collection getFilters() { return filtersByName.values(); } diff --git a/chunky/src/java/se/llbit/chunky/ui/render/tabs/PostprocessingTab.java b/chunky/src/java/se/llbit/chunky/ui/render/tabs/PostprocessingTab.java index b83f900e77..d4a7e2bc9e 100644 --- a/chunky/src/java/se/llbit/chunky/ui/render/tabs/PostprocessingTab.java +++ b/chunky/src/java/se/llbit/chunky/ui/render/tabs/PostprocessingTab.java @@ -20,10 +20,11 @@ import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; import javafx.scene.Node; -import javafx.scene.control.ChoiceBox; +import javafx.scene.control.ComboBox; import javafx.scene.control.ScrollPane; import javafx.scene.control.Separator; import javafx.scene.control.Tooltip; +import javafx.scene.control.SingleSelectionModel; import javafx.util.StringConverter; import se.llbit.chunky.renderer.postprocessing.PostProcessingFilter; import se.llbit.chunky.renderer.postprocessing.PostProcessingFilters; @@ -32,20 +33,22 @@ import se.llbit.chunky.ui.DoubleAdjuster; import se.llbit.chunky.ui.controller.RenderControlsFxController; import se.llbit.chunky.ui.render.RenderControlsTab; +import se.llbit.chunky.ui.RegisterableCellAdapter; +import se.llbit.fxutil.CustomizedListCellFactory; import se.llbit.util.ProgressListener; import se.llbit.util.TaskTracker; +import se.llbit.util.TaskTracker.Task; import java.io.IOException; import java.net.URL; import java.util.ResourceBundle; -import se.llbit.util.TaskTracker.Task; public class PostprocessingTab extends ScrollPane implements RenderControlsTab, Initializable { private Scene scene; private RenderControlsFxController controller; @FXML private DoubleAdjuster exposure; - @FXML private ChoiceBox postprocessingFilter; + @FXML private ComboBox postprocessingFilter; public PostprocessingTab() throws IOException { FXMLLoader loader = new FXMLLoader(getClass().getResource("PostprocessingTab.fxml")); @@ -84,21 +87,13 @@ public PostprocessingTab() throws IOException { postprocessingFilter.getSelectionModel().select(Scene.DEFAULT_POSTPROCESSING_FILTER); postprocessingFilter.getSelectionModel().selectedItemProperty().addListener( (observable, oldValue, newValue) -> { - scene.setPostprocess(newValue); - scene.postProcessFrame(new TaskTracker(ProgressListener.NONE)); - controller.getCanvas().forceRepaint(); + if (!(newValue instanceof Separator)) { + scene.setPostprocess(newValue); + scene.postProcessFrame(new TaskTracker(ProgressListener.NONE)); + controller.getCanvas().forceRepaint(); + } }); - postprocessingFilter.setConverter(new StringConverter() { - @Override - public String toString(PostProcessingFilter object) { - return object == null ? null : object.getName(); - } - - @Override - public PostProcessingFilter fromString(String string) { - return PostProcessingFilters.getPostProcessingFilterFromName(string).orElse(Scene.DEFAULT_POSTPROCESSING_FILTER); - } - }); + CustomizedListCellFactory.install(postprocessingFilter, RegisterableCellAdapter.INSTANCE); exposure.setName("Exposure"); exposure.setTooltip("Linear exposure of the image."); exposure.setRange(Scene.MIN_EXPOSURE, Scene.MAX_EXPOSURE); diff --git a/chunky/src/res/se/llbit/chunky/ui/render/tabs/PostprocessingTab.fxml b/chunky/src/res/se/llbit/chunky/ui/render/tabs/PostprocessingTab.fxml index af17ccfcad..6a71132f65 100644 --- a/chunky/src/res/se/llbit/chunky/ui/render/tabs/PostprocessingTab.fxml +++ b/chunky/src/res/se/llbit/chunky/ui/render/tabs/PostprocessingTab.fxml @@ -1,7 +1,7 @@ - + @@ -14,7 +14,7 @@ diff --git a/lib/src/se/llbit/fxutil/CustomizedListCellFactory.java b/lib/src/se/llbit/fxutil/CustomizedListCellFactory.java index 54b87cfdc0..53218b49c8 100644 --- a/lib/src/se/llbit/fxutil/CustomizedListCellFactory.java +++ b/lib/src/se/llbit/fxutil/CustomizedListCellFactory.java @@ -16,11 +16,11 @@ */ package se.llbit.fxutil; -import javafx.scene.control.ComboBox; -import javafx.scene.control.ListCell; -import javafx.scene.control.ListView; -import javafx.scene.control.Tooltip; +import javafx.geometry.Insets; +import javafx.scene.Node; +import javafx.scene.control.*; import javafx.util.Callback; +import javafx.util.StringConverter; /** * A list cell factory that shows labels and tooltips. @@ -66,7 +66,13 @@ protected void updateItem(T item, boolean empty) { super.updateItem(item, empty); if (item == null || empty || adapter == null) { setGraphic(null); + } else if (item instanceof Separator) { + setDisabled(true); + setMouseTransparent(true); + setGraphic((Node) item); + setPadding(Insets.EMPTY); } else { + setGraphic(null); setText(adapter.getLabel(item)); setTooltip(adapter.getTooltip(item)); }