Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/main/java/com/parafield/storming/Icons.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.parafield.storming;

import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.extras.FlatSVGIcon;
import javax.swing.ImageIcon;
import java.awt.*;
Expand All @@ -9,6 +10,7 @@
/**
* Provides access to SVG and PNG icon resources used throughout the Storming Engine Editor.
* Automatically handles SVG loading (using FlatLaf) and PNG fallbacks.
* SVGs are automatically tinted to match the current theme (light/dark).
*/
public class Icons {
/** The main window icon for the application. */
Expand All @@ -17,6 +19,7 @@ public class Icons {
/**
* Loads an icon from resources by name.
* Attempts to find a .svg file in icons/svg first, falling back to .png in icons/png if not found.
* SVGs are configured with a theme-aware color filter.
*
* @param name The base name of the icon file.
* @param width The target width to scale to (set to 0 for default).
Expand All @@ -29,6 +32,19 @@ private static ImageIcon loadIcon(String name, int width, int height) {

if (svgUrl != null) {
FlatSVGIcon svgIcon = new FlatSVGIcon(svgUrl);

// Apply dynamic theme-aware color filter for all icons except brand icons
if (!name.equalsIgnoreCase("icon") && !name.equalsIgnoreCase("exe-icon")) {
svgIcon.setColorFilter(new FlatSVGIcon.ColorFilter(color -> {
// If the current theme is light, map white icons to dark gray
if (!FlatLaf.isLafDark()) {
return new Color(60, 60, 60);
}
// Otherwise keep original (white)
return color;
}));
}

if (width > 0 && height > 0) {
return svgIcon.derive(width, height);
}
Expand All @@ -39,7 +55,12 @@ private static ImageIcon loadIcon(String name, int width, int height) {
if (pngUrl == null) {
return null;
}

ImageIcon icon = new ImageIcon(pngUrl);

// Note: PNG inversion/tinting is more complex and usually handled via separate assets
// or specific ImageFilters if needed. For now, we prioritize SVG scaling and tinting.

if (width > 0 && height > 0) {
icon = new ImageIcon(icon.getImage().getScaledInstance(width, height, Image.SCALE_SMOOTH));
}
Expand Down Expand Up @@ -84,6 +105,6 @@ private static ImageIcon loadIcon(String name, int width, int height) {
public static final ImageIcon PLUS = loadIcon("plus", 16, 16);
public static final ImageIcon BRUSH = loadIcon("brush", 16, 16);
public static final ImageIcon CLIPBOARD = loadIcon("clipboard", 16, 16);
public static final ImageIcon RESTART = loadIcon("restart", 18, 18);
public static final ImageIcon PAUSE = loadIcon("pause", 18, 18);
public static final ImageIcon RESTART = loadIcon("restart", 23, 23);
public static final ImageIcon PAUSE = loadIcon("pause", 23, 23);
}
15 changes: 12 additions & 3 deletions src/main/java/com/parafield/storming/ui/panels/SceneViewPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public interface LibC extends Library {
// 2D Overlays
private boolean showGrid = true;
private boolean showCollisions = false;
private final JPanel overlayToolbar;

/**
* Constructs a SceneViewPanel, initializing the image buffer and floating toolbar.
Expand All @@ -56,7 +57,7 @@ public SceneViewPanel() {
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);

// --- Floating Scene Toolbar ---
JPanel overlayToolbar = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 2));
overlayToolbar = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 2));
overlayToolbar.setOpaque(true);
overlayToolbar.setBackground(new Color(40, 40, 45, 180));
overlayToolbar.setBorder(BorderFactory.createLineBorder(new Color(100, 100, 100, 50)));
Expand Down Expand Up @@ -89,6 +90,14 @@ public SceneViewPanel() {
timer.start();
}

/**
* Toggles the visibility of the floating scene toolbar.
* @param visible true to show the toolbar, false to hide it.
*/
public void setToolbarVisible(boolean visible) {
overlayToolbar.setVisible(visible);
}

/**
* Utility method to create a stylized toggle button for scene overlays.
* @param tip The tooltip text.
Expand Down Expand Up @@ -155,8 +164,8 @@ protected void paintComponent(Graphics g) {
// Draw image centered and scaled
g.drawImage(image, 0, 0, getWidth(), getHeight(), null);

// Draw custom grid if enabled
if (showGrid) {
// Draw custom grid if enabled (only if toolbar/overlays would be visible)
if (showGrid && overlayToolbar.isVisible()) {
drawGrid(g);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.formdev.flatlaf.FlatClientProperties;
import com.parafield.storming.Icons;
import com.parafield.storming.ui.utils.UIUtils;
import com.parafield.storming.ui.windows.SettingsWindow;
import javax.swing.*;
import java.awt.*;
import java.awt.event.AWTEventListener;
Expand Down Expand Up @@ -184,6 +185,12 @@ public void paintIcon(Component c, Graphics g, int x, int y) {
JButton settingsBtn = new JButton(Icons.SETTINGS);
settingsBtn.setToolTipText("Settings");
settingsBtn.putClientProperty(FlatClientProperties.BUTTON_TYPE, FlatClientProperties.BUTTON_TYPE_TOOLBAR_BUTTON);
settingsBtn.addActionListener(e -> {
Window parent = SwingUtilities.getWindowAncestor(this);
if (parent instanceof Frame) {
new SettingsWindow((Frame) parent).setVisible(true);
}
});
add(settingsBtn);
}

Expand All @@ -198,7 +205,16 @@ private JMenu createFileMenu() {
menu.addSeparator();
menu.add(new JMenuItem("Save Scene", Icons.CLIPBOARD));
menu.addSeparator();
menu.add(new JMenuItem("Settings...", Icons.SETTINGS));

JMenuItem settingsItem = new JMenuItem("Settings...", Icons.SETTINGS);
settingsItem.addActionListener(e -> {
Window parent = SwingUtilities.getWindowAncestor(this);
if (parent instanceof Frame) {
new SettingsWindow((Frame) parent).setVisible(true);
}
});
menu.add(settingsItem);

menu.add(new JMenuItem("Exit"));
return menu;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void mouseExited(java.awt.event.MouseEvent e) {

JButton settingsBtn = new JButton(" Settings", Icons.SETTINGS);
settingsBtn.putClientProperty(FlatClientProperties.BUTTON_TYPE, FlatClientProperties.BUTTON_TYPE_TOOLBAR_BUTTON);
settingsBtn.addActionListener(e -> JOptionPane.showMessageDialog(this, "Settings coming soon!"));
settingsBtn.addActionListener(e -> new SettingsWindow(this).setVisible(true));
sidebarFooter.add(settingsBtn, BorderLayout.WEST);

sidebar.add(sidebarFooter, BorderLayout.SOUTH);
Expand Down
Loading
Loading