mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-22 15:58:52 -05:00
Refactor hard-coded colours into ThemeSupport
This commit is contained in:
parent
6bb142bb8e
commit
3604b504a4
BIN
lib/jars/darcula.jar
Normal file
BIN
lib/jars/darcula.jar
Normal file
Binary file not shown.
@ -8,6 +8,7 @@ import static net.filebot.Logging.*;
|
||||
import static net.filebot.MediaTypes.*;
|
||||
import static net.filebot.Settings.*;
|
||||
import static net.filebot.ui.GettingStartedUtil.*;
|
||||
import static net.filebot.ui.ThemeSupport.*;
|
||||
import static net.filebot.util.FileUtilities.*;
|
||||
import static net.filebot.util.FileUtilities.getChildren;
|
||||
import static net.filebot.util.XPathUtilities.*;
|
||||
@ -216,7 +217,7 @@ public class Main {
|
||||
|
||||
private static void startUserInterface(ArgumentBean args) {
|
||||
// use native LaF an all platforms
|
||||
setSystemLookAndFeel();
|
||||
setTheme(Theme.System);
|
||||
|
||||
// start standard frame or single panel frame
|
||||
PanelBuilder[] panels = args.getPanelBuilders();
|
||||
|
@ -1,9 +1,18 @@
|
||||
package net.filebot.ui;
|
||||
|
||||
import static com.bulenkov.iconloader.util.ColorUtil.*;
|
||||
import static net.filebot.Logging.*;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.LinearGradientPaint;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.metal.MetalLookAndFeel;
|
||||
import javax.swing.plaf.metal.OceanTheme;
|
||||
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
|
||||
|
||||
import com.bulenkov.darcula.DarculaLaf;
|
||||
|
||||
import net.filebot.util.ui.GradientStyle;
|
||||
import net.filebot.util.ui.notification.SeparatorBorder;
|
||||
@ -27,16 +36,78 @@ public class ThemeSupport {
|
||||
}
|
||||
|
||||
public static Color getColor(int rgba) {
|
||||
if (dark) {
|
||||
return getDarkColor(new Color(rgba));
|
||||
return theme.getColor(rgba);
|
||||
}
|
||||
|
||||
private static Theme theme = Theme.System;
|
||||
|
||||
public static void setTheme(Theme t) {
|
||||
theme = t;
|
||||
|
||||
try {
|
||||
theme.setLookAndFeel();
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, e, message("Failed to set LaF", t));
|
||||
}
|
||||
return new Color(rgba);
|
||||
}
|
||||
|
||||
public static Color getDarkColor(Color c) {
|
||||
return isDark(c) ? c : shift(c, 0.2);
|
||||
}
|
||||
public enum Theme {
|
||||
|
||||
private static boolean dark = false;
|
||||
System {
|
||||
|
||||
@Override
|
||||
public void setLookAndFeel() throws Exception {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
}
|
||||
},
|
||||
|
||||
CrossPlatform {
|
||||
|
||||
@Override
|
||||
public void setLookAndFeel() throws Exception {
|
||||
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
|
||||
}
|
||||
},
|
||||
|
||||
Darcula {
|
||||
|
||||
@Override
|
||||
public void setLookAndFeel() throws Exception {
|
||||
UIManager.setLookAndFeel(new DarculaLaf());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getColor(int rgba) {
|
||||
return getDarkColor(new Color(rgba));
|
||||
}
|
||||
|
||||
public Color getDarkColor(Color c) {
|
||||
return isDark(c) ? c : shift(c, 0.2);
|
||||
}
|
||||
},
|
||||
|
||||
Nimbus {
|
||||
|
||||
@Override
|
||||
public void setLookAndFeel() throws Exception {
|
||||
UIManager.setLookAndFeel(new NimbusLookAndFeel());
|
||||
}
|
||||
},
|
||||
|
||||
Metal {
|
||||
|
||||
@Override
|
||||
public void setLookAndFeel() throws Exception {
|
||||
MetalLookAndFeel.setCurrentTheme(new OceanTheme());
|
||||
UIManager.setLookAndFeel(new MetalLookAndFeel());
|
||||
}
|
||||
};
|
||||
|
||||
public Color getColor(int rgba) {
|
||||
return new Color(rgba);
|
||||
}
|
||||
|
||||
public abstract void setLookAndFeel() throws Exception;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -53,7 +53,6 @@ import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.SwingWorker;
|
||||
import javax.swing.Timer;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.event.MenuEvent;
|
||||
import javax.swing.event.MenuListener;
|
||||
import javax.swing.event.MouseInputListener;
|
||||
@ -67,30 +66,6 @@ import net.filebot.Settings;
|
||||
|
||||
public final class SwingUI {
|
||||
|
||||
public static void setNimbusLookAndFeel() {
|
||||
try {
|
||||
UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "Failed to set Nimbus LaF", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setDarculaLookAndFeel() {
|
||||
try {
|
||||
UIManager.setLookAndFeel("com.bulenkov.darcula.DarculaLaf");
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "Failed to set Nimbus LaF", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setSystemLookAndFeel() {
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "Failed to set System LaF", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void openURI(String uri) {
|
||||
try {
|
||||
if (Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
|
||||
|
Loading…
Reference in New Issue
Block a user