Skip to content

Commit

Permalink
Texture Viewer: Show "face" instead of "slice" for cubemaps
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadelessFox committed Nov 23, 2023
1 parent 8f11e44 commit 21bf8ea
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public class TextureViewerPanel extends JComponent implements PropertyChangeList
public static final float ZOOM_MAX_LEVEL = (float) Math.pow(2, 7);
public static final float RANGE_PRECISION = 1e3f;

private static final String[] CUBEMAP_FACE_NAMES = {"X+", "X-", "Y+", "Y-", "Z+", "Z-"};

protected final ImagePanelViewport imageViewport;
protected final ImagePanel imagePanel;
protected final JLabel statusLabel;
Expand Down Expand Up @@ -70,7 +72,7 @@ protected void customizeCellRenderer(@NotNull JList<? extends Integer> list, @No
if (provider != null) {
final int width = Math.max(provider.getMaxWidth() >> value, 1);
final int height = Math.max(provider.getMaxHeight() >> value, 1);
append("%dx%d".formatted(width, height), TextAttributes.REGULAR_ATTRIBUTES);
append("%d - %dx%d".formatted(value, width, height), TextAttributes.REGULAR_ATTRIBUTES);
} else {
append("?", TextAttributes.REGULAR_ATTRIBUTES);
}
Expand All @@ -82,12 +84,14 @@ protected void customizeCellRenderer(@NotNull JList<? extends Integer> list, @No
sliceCombo.setRenderer(new ColoredListCellRenderer<>() {
@Override
protected void customizeCellRenderer(@NotNull JList<? extends Integer> list, @NotNull Integer value, int index, boolean selected, boolean focused) {
append("Slice: ", TextAttributes.GRAYED_SMALL_ATTRIBUTES);

if (imagePanel.getProvider() != null) {
append(String.valueOf(value), TextAttributes.REGULAR_ATTRIBUTES);
if (imagePanel.getProvider() == null) {
append("Slice: ?", TextAttributes.REGULAR_ATTRIBUTES);
} else if (imagePanel.getProvider().getType() == ImageProvider.Type.CUBEMAP) {
append("Face: ", TextAttributes.GRAYED_SMALL_ATTRIBUTES);
append(CUBEMAP_FACE_NAMES[value], TextAttributes.REGULAR_ATTRIBUTES);
} else {
append("?", TextAttributes.REGULAR_ATTRIBUTES);
append("Slice: ", TextAttributes.GRAYED_SMALL_ATTRIBUTES);
append(String.valueOf(value), TextAttributes.REGULAR_ATTRIBUTES);
}
}
});
Expand Down

0 comments on commit 21bf8ea

Please sign in to comment.