Skip to content

Commit

Permalink
Finalized DarkMode
Browse files Browse the repository at this point in the history
  • Loading branch information
klassenserver7b committed Mar 16, 2024
1 parent ec0137a commit 4a1d627
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 37 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<groupId>de.klassenserver7b</groupId>
<artifactId>danceinterpreter</artifactId>
<version>3.9.6</version>
<version>3.10.0</version>

<name>DanceInterpreter</name>
<organization>
Expand Down
23 changes: 4 additions & 19 deletions src/main/java/de/klassenserver7b/danceinterpreter/Main.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.klassenserver7b.danceinterpreter;

import java.awt.AWTException;
import java.awt.Color;
import java.awt.Image;
import java.awt.SystemTray;
import java.awt.Toolkit;
Expand All @@ -16,7 +15,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.formdev.flatlaf.FlatLightLaf;
import com.formdev.flatlaf.FlatDarculaLaf;

import de.klassenserver7b.danceinterpreter.connections.SpotifyInteractions;
import de.klassenserver7b.danceinterpreter.graphics.ConfigWindow;
Expand All @@ -43,8 +42,8 @@ public class Main {
private Thread shutdownT;
private final Logger log;
private TrayIcon trayIcon;
private final Color backgroundColor = Color.decode("#353535");
private final Color textColor = Color.decode("#EAE5D6");
// private final Color backgroundColor = Color.decode("#1E1F22");
// private final Color textColor = Color.decode("#EAE5D6");

/**
*
Expand Down Expand Up @@ -142,7 +141,7 @@ protected AppModes askForAppMode() {
* @return
*/
protected boolean initalizeUILayout() {
return FlatLightLaf.setup();
return FlatDarculaLaf.setup();
}

protected void initSystemTray() {
Expand Down Expand Up @@ -284,18 +283,4 @@ public TrayIcon getTrayIcon() {
return this.trayIcon;
}

/**
* @return the backgroundColor
*/
public Color getBackgroundColor() {
return this.backgroundColor;
}

/**
* @return the textColor
*/
public Color getTextColor() {
return this.textColor;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JSeparator;
import javax.swing.SwingConstants;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -72,7 +74,7 @@ public ConfigWindow() {
} catch (IOException e) {
this.log.error("No Icon Found!");
}

this.mainFrame.setTitle("DI - Config");
this.mainFrame.setBounds(10, 10, 1280, 720);

Expand All @@ -84,10 +86,7 @@ public ConfigWindow() {
img = new JLabel(new ImageIcon(this.gifPath));

this.mainPanel.add(img);

this.mainPanel.setBackground(Main.Instance.getBackgroundColor());
this.mainFrame.setBackground(Main.Instance.getBackgroundColor());


this.mainFrame.addComponentListener(new ComponentAdapter() {

@Override
Expand Down Expand Up @@ -127,6 +126,12 @@ public void updateWindow() {
this.mainPanel.add(label);
}

this.mainPanel.add(new JSeparator(SwingConstants.HORIZONTAL));

for (JLabel label : this.playlistViewGen.loadStaticActionsView()) {
this.mainPanel.add(label);
}

} else {

JLabel img = new JLabel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.SwingUtilities;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.formdev.flatlaf.FlatDarculaLaf;
import com.formdev.flatlaf.FlatLightLaf;

import de.klassenserver7b.danceinterpreter.AppModes;
import de.klassenserver7b.danceinterpreter.Main;
import de.klassenserver7b.danceinterpreter.connections.SpotifyInteractions;
Expand Down Expand Up @@ -51,9 +55,6 @@ public JMenuBar getMenuBar() {

bar.setOpaque(true);

bar.setForeground(Main.Instance.getTextColor());
bar.setBackground(Main.Instance.getBackgroundColor());

bar.add(getFileMenu());

bar.add(getEditMenu());
Expand All @@ -69,7 +70,6 @@ public JMenuBar getMenuBar() {
protected JMenu getFileMenu() {

JMenu filem = new JMenu("File");
filem.setBackground(Main.Instance.getBackgroundColor());

filem.add(getExit());

Expand All @@ -79,10 +79,13 @@ protected JMenu getFileMenu() {
protected JMenu getEditMenu() {

JMenu editm = new JMenu("Edit");
editm.setBackground(Main.Instance.getBackgroundColor());

editm.add(getConfigAnimationCheck());

editm.addSeparator();

editm.add(getDarkModeCheck());

if (Main.Instance.getAppMode() == AppModes.Playlist) {
editm.addSeparator();
editm.add(getPlaylistViewCheck());
Expand All @@ -103,7 +106,6 @@ protected JMenu getEditMenu() {
protected JMenu getSongWindowMenu() {

JMenu songwindowm = new JMenu("SongWindow");
songwindowm.setBackground(Main.Instance.getBackgroundColor());

songwindowm.add(getPictureCheck());
songwindowm.add(getNextCheck());
Expand All @@ -113,9 +115,8 @@ protected JMenu getSongWindowMenu() {
}

protected JMenu getHelpMenu() {

JMenu helpm = new JMenu("Help");
helpm.setBackground(Main.Instance.getBackgroundColor());

helpm.add(getHelp());

Expand Down Expand Up @@ -208,6 +209,27 @@ protected JCheckBoxMenuItem getConfigAnimationCheck() {

return cacI;
}

protected JCheckBoxMenuItem getDarkModeCheck() {

JCheckBoxMenuItem dmcI = new JCheckBoxMenuItem();
dmcI.setText("Enable DarkMode");
dmcI.setSelected(true);
dmcI.addActionListener(e -> {

if (dmcI.isSelected()) {
FlatDarculaLaf.setup();
} else {
FlatLightLaf.setup();
}

SwingUtilities.updateComponentTreeUI(Main.Instance.getConfigWindow().getMainframe());

});

return dmcI;

}

protected JMenuItem getPlaylistViewExport() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import javax.swing.BorderFactory;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import javax.swing.filechooser.FileNameExtensionFilter;

import org.slf4j.Logger;
Expand Down Expand Up @@ -226,12 +229,22 @@ public List<JLabel> loadPlaylistView() {
List<JLabel> labels = new LinkedList<>();
labels.addAll(loadSongs());
labels.addAll(loadStaticSongs());
labels.addAll(loadStaticLabels());

return labels;

}

public List<JLabel> loadStaticActionsView() {
if (!playlistViewEnabled) {
return null;
}

List<JLabel> labels = new LinkedList<>();
labels.addAll(loadStaticLabels());

return labels;
}

protected List<JLabel> loadSongs() {

List<JLabel> songLabels = new LinkedList<>();
Expand Down Expand Up @@ -317,9 +330,10 @@ protected JLabel generateGenericLabel() {

JLabel songp = new JLabel();
songp.setSize(200, 200);
songp.setBorder(BorderFactory.createLineBorder(Main.Instance.getTextColor(), 3, true));
songp.setForeground(Main.Instance.getTextColor());
songp.setBackground(Main.Instance.getBackgroundColor());

LineBorder lBorder = new LineBorder(UIManager.getColor("Label.foreground"), 3, true);
EmptyBorder eBorder = new EmptyBorder(2, 5, 2, 5);
songp.setBorder(BorderFactory.createCompoundBorder(lBorder, eBorder));

return songp;
}
Expand Down

0 comments on commit 4a1d627

Please sign in to comment.