decentralized setTheme to MyView

This commit is contained in:
Meruemon
2022-03-23 18:53:24 +01:00
parent 73c3255d09
commit c30e59203d
8 changed files with 39 additions and 13 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -49,6 +49,8 @@ public class GUIMainFrame extends JFrame {
JPanel oPanel2 = new JPanel();
JPanel oPanel3 = new JPanel();
MyView oMyView = new MyView(this, oGUIMCMenu, oGUIMenuBar, oGUIPorts, oGUIRamTable, oGUIRegister, oGUIRegistersDetailed, oGUIStack, oGUITestFileTable, oGUITime, oMainPanel);
ArrayList<JPanel> oPanels = new ArrayList<JPanel>();
/**
* Constructor
@@ -137,7 +139,7 @@ public class GUIMainFrame extends JFrame {
this.setIconImage(guiLogo.getImage()); // change icon of frame
//Set menubar
oGUIMenuBar = new GUIMenuBar(env, this, oGUITestFileTable, oGUIRegister, oGUIRegistersDetailed);
oGUIMenuBar = new GUIMenuBar(oMyView, env, this, oGUITestFileTable, oGUIRegister, oGUIRegistersDetailed);
this.setJMenuBar(oGUIMenuBar);
//Build this frame

View File

@@ -25,6 +25,8 @@ public class GUIMenuBar extends JMenuBar implements ActionListener {
GUIRegister oGUIRegister;
GUIRegistersDetailed oGUIRegistersDetailed;
MyView oMyView;
ArrayList<JCheckBox> oBreakpoints;
ReadEepromFile oRef;
boolean[] bBreakpointSet;
@@ -96,7 +98,7 @@ public class GUIMenuBar extends JMenuBar implements ActionListener {
* Constructor initializes menubar.
* @param frame
*/
public GUIMenuBar(Environment env, GUIMainFrame mainframe, GUITestFileTable guitft, GUIRegister guiregs, GUIRegistersDetailed guiregsdet) { //TODO maybe single components, with methods, of frame to set theme
public GUIMenuBar(MyView view, Environment env, GUIMainFrame mainframe, GUITestFileTable guitft, GUIRegister guiregs, GUIRegistersDetailed guiregsdet) { //TODO maybe single components, with methods, of frame to set theme
//Custom Separators since default is not able to change background.
oSeparator0 = new JMenuItem();
@@ -113,6 +115,7 @@ public class GUIMenuBar extends JMenuBar implements ActionListener {
oSeparator3.setPreferredSize(new Dimension(0,1));
//Referrence to change different parts of gui for theme.
oMyView = view;
oEnv = env;
oGUIMainFrame = mainframe;
oGUITestFileTable = guitft;
@@ -368,19 +371,13 @@ public class GUIMenuBar extends JMenuBar implements ActionListener {
if (e.getSource() == oDarkTheme) {
System.out.println("It's gettin dark brooo"); //TODO
setTheme(aoDarkTheme[0], aoDarkTheme[1]);
oGUITestFileTable.setTheme(1);
oGUIRegister.setTheme(1);
oGUIMainFrame.setTheme(1);
oGUIRegistersDetailed.setTheme(1);
oMyView.setTheme(1);
}
//Change to light theme
if (e.getSource() == oLightTheme) {
System.out.println("Death to all vampires!"); //TODO
setTheme(aoLightTheme[0], aoLightTheme[1]);
oGUITestFileTable.setTheme(0);
oGUIRegister.setTheme(0);
oGUIMainFrame.setTheme(0);
oGUIRegistersDetailed.setTheme(0);
oMyView.setTheme(0);
}
//Microcontroller

View File

@@ -2,4 +2,5 @@ package View;
public interface IMyView {
public void setTheme(int iThemeNr);
}

View File

@@ -2,18 +2,44 @@ package View;
import javax.swing.JPanel;
public class MyView {
public class MyView implements IMyView {
GUIMainFrame oGUIMainFrame;
GUIMCMenu oGUIMCMenu;
GUIMenuBar oGUIMenuBar;
GUIPorts oGUIPorts;
GUIRamTable oGUIRamTable;
GUIRegister oGUIRegister;
GUIRegistersDetailed oGUIRegistersDetailed;
GUIStack oGUIStack;
GUITestFileTable oGUITestFileTable;
GUITime oGUITime;
JPanel oGUIMainPanel;
public MyView() {
public MyView(GUIMainFrame oGUIMainFrame, GUIMCMenu oGUIMCMenu, GUIMenuBar oGUIMenuBar, GUIPorts oGUIPorts, GUIRamTable oGUIRamTable, GUIRegister oGUIRegister, GUIRegistersDetailed oGUIRegistersDetailed, GUIStack oGUIStack, GUITestFileTable oGUITestFileTable, GUITime oGUITime, JPanel oGUIMainPanel) {
this.oGUIMainFrame = oGUIMainFrame;
this.oGUIMCMenu = oGUIMCMenu;
this.oGUIMenuBar = oGUIMenuBar;
this.oGUIPorts = oGUIPorts;
this.oGUIRamTable = oGUIRamTable;
this.oGUIRegister = oGUIRegister;
this.oGUIRegistersDetailed = oGUIRegistersDetailed;
this.oGUIStack = oGUIStack;
this.oGUITestFileTable = oGUITestFileTable;
this.oGUITime = oGUITime;
this.oGUIMainPanel = oGUIMainPanel;
}
public void setTheme(int iThemeNr) {
oGUIMainFrame.setTheme(iThemeNr);
oGUIMCMenu.setTheme(iThemeNr);
oGUIPorts.setTheme(iThemeNr);
oGUIRamTable.setTheme(iThemeNr);
oGUIRegister.setTheme(iThemeNr);
oGUIRegistersDetailed.setTheme(iThemeNr);
oGUIStack.setTheme(iThemeNr);
oGUITestFileTable.setTheme(iThemeNr);
oGUITime.setTheme(iThemeNr);
}
}