Fixes bugs with the incorrect applying of the changed colors.

Fixes #50
This commit is contained in:
DieGurke 2019-12-14 11:22:37 +01:00
parent ecf2566431
commit 89b75b00c8
3 changed files with 28 additions and 57 deletions

View File

@ -116,7 +116,7 @@ public class Settings {
*/
public void addNewThemeToMap(Theme theme) {
settings.getThemes().put(theme.getThemeName(), theme);
currentTheme = theme.getThemeName();
// currentTheme = theme.getThemeName();
}
/**

View File

@ -206,63 +206,63 @@ public class SettingsScreen extends JDialog {
theme,
theme.getBackgroundColor(),
"Background",
1);
0);
buildCustomizeElement(new JPanel(),
new JButton(),
new JTextPane(),
theme,
theme.getCellColor(),
"Cells",
2);
1);
buildCustomizeElement(new JPanel(),
new JButton(),
new JTextPane(),
theme,
theme.getInteractableForegroundColor(),
"Interactable Foreground",
3);
2);
buildCustomizeElement(new JPanel(),
new JButton(),
new JTextPane(),
theme,
theme.getInteractableBackgroundColor(),
"Interactable Background",
4);
3);
buildCustomizeElement(new JPanel(),
new JButton(),
new JTextPane(),
theme,
theme.getMessageColorChat(),
"Messages Chat",
5);
4);
buildCustomizeElement(new JPanel(),
new JButton(),
new JTextPane(),
theme,
theme.getDateColorChat(),
"Date Chat",
6);
5);
buildCustomizeElement(new JPanel(),
new JButton(),
new JTextPane(),
theme,
theme.getSelectionColor(),
"Selection",
7);
6);
buildCustomizeElement(new JPanel(),
new JButton(),
new JTextPane(),
theme,
theme.getTypingMessageColor(),
"Typing Message",
8);
7);
buildCustomizeElement(new JPanel(),
new JButton(),
new JTextPane(),
theme,
theme.getUserNameColor(),
"User Names",
9);
8);
GridBagConstraints gbc_colorsPanel = new GridBagConstraints();
gbc_colorsPanel.fill = GridBagConstraints.HORIZONTAL;
@ -438,7 +438,7 @@ public class SettingsScreen extends JDialog {
theme,
theme.getBackgroundColor(),
"Background",
1);
0);
buildCustomizeElement(new JPanel(),
new JButton(),
@ -446,7 +446,7 @@ public class SettingsScreen extends JDialog {
theme,
theme.getCellColor(),
"Cells",
2);
1);
buildCustomizeElement(new JPanel(),
new JButton(),
@ -454,7 +454,7 @@ public class SettingsScreen extends JDialog {
theme,
theme.getInteractableForegroundColor(),
"Interactable Foreground",
3);
2);
buildCustomizeElement(new JPanel(),
new JButton(),
@ -462,7 +462,7 @@ public class SettingsScreen extends JDialog {
theme,
theme.getInteractableBackgroundColor(),
"Interactable Background",
4);
3);
buildCustomizeElement(new JPanel(),
new JButton(),
@ -470,7 +470,7 @@ public class SettingsScreen extends JDialog {
theme,
theme.getMessageColorChat(),
"Messages Chat",
5);
4);
buildCustomizeElement(new JPanel(),
new JButton(),
@ -478,7 +478,7 @@ public class SettingsScreen extends JDialog {
theme,
theme.getDateColorChat(),
"Date Chat",
6);
5);
buildCustomizeElement(new JPanel(),
new JButton(),
@ -486,7 +486,7 @@ public class SettingsScreen extends JDialog {
theme,
theme.getSelectionColor(),
"Selection",
7);
6);
buildCustomizeElement(new JPanel(),
new JButton(),
@ -494,7 +494,7 @@ public class SettingsScreen extends JDialog {
theme,
theme.getTypingMessageColor(),
"Typing Message",
8);
7);
buildCustomizeElement(new JPanel(),
new JButton(),
@ -502,7 +502,7 @@ public class SettingsScreen extends JDialog {
theme,
theme.getUserNameColor(),
"User Names",
9);
8);
GridBagConstraints gbc_createNewTheme = new GridBagConstraints();
gbc_createNewTheme.gridx = 0;
@ -532,18 +532,11 @@ public class SettingsScreen extends JDialog {
System.out.println(color.getRGB());
// TODO: When Theme changed in same settings screen, color variable doesnt
// update.
Color[] colorsArray = temporaryTheme.getAllColors();
for (int i = 0; i < colorsArray.length; i++) {
if (color.getRGB() == colorsArray[i].getRGB()) {
temporaryTheme.setColor(i, newColor);
colorChanged = true;
createNewThemeButton.setEnabled(true);
break;
}
}
temporaryTheme.setColor(yIndex, newColor);
colorChanged = true;
createNewThemeButton.setEnabled(true);
}
button.setBackground(newColor);
}
} catch (Exception e) {
logger.info("An error occured while opening Color Chooser: " + e);
@ -551,12 +544,9 @@ public class SettingsScreen extends JDialog {
}
});
panel.add(textPane);
panel.add(button);
panel.setBackground(theme.getCellColor());
panel.setAlignmentX(Component.LEFT_ALIGNMENT);
panel.add(textPane);panel.add(button);panel.setBackground(theme.getCellColor());panel.setAlignmentX(Component.LEFT_ALIGNMENT);
colorsPanel.add(panel);
}
colorsPanel.add(panel);
}
}

View File

@ -44,8 +44,8 @@ public class Theme implements Serializable {
}
public Theme(String name, Theme other) {
this(name, other.backgroundColor, other.cellColor, other.interactableBackgroundColor,
other.interactableForegroundColor, other.messageColorChat, other.dateColorChat, other.selectionColor,
this(name, other.backgroundColor, other.cellColor, other.interactableForegroundColor,
other.interactableBackgroundColor, other.messageColorChat, other.dateColorChat, other.selectionColor,
other.typingMessageColor, other.userNameColor);
}
@ -109,25 +109,6 @@ public class Theme implements Serializable {
*/
public Color getUserNameColor() { return userNameColor; }
/**
* @return a color array containing all colors of this theme
* @since Envoy v0.2-alpha
*/
public Color[] getAllColors() {
Color[] c = new Color[9];
c[0] = backgroundColor;
c[1] = cellColor;
c[2] = interactableForegroundColor;
c[3] = interactableBackgroundColor;
c[4] = messageColorChat;
c[5] = dateColorChat;
c[6] = selectionColor;
c[7] = typingMessageColor;
c[8] = userNameColor;
return c;
}
/**
* Sets the a specific {@link Color} in this theme to a new {@link Color}
*