From f31f25261387ce3db51fef185b1f1e19feee5472 Mon Sep 17 00:00:00 2001
From: DieGurke <55625494+DieGurke@users.noreply.github.com>
Date: Sat, 21 Dec 2019 11:17:23 +0100
Subject: [PATCH 1/2] Fixed UI Alignment of theme customization components
Fixes #39
---
.../ui/settings/ThemeCustomizationPanel.java | 58 +++++++++++++------
1 file changed, 40 insertions(+), 18 deletions(-)
diff --git a/src/main/java/envoy/client/ui/settings/ThemeCustomizationPanel.java b/src/main/java/envoy/client/ui/settings/ThemeCustomizationPanel.java
index 6a1aa66..755b5b1 100644
--- a/src/main/java/envoy/client/ui/settings/ThemeCustomizationPanel.java
+++ b/src/main/java/envoy/client/ui/settings/ThemeCustomizationPanel.java
@@ -82,9 +82,19 @@ public class ThemeCustomizationPanel extends SettingsPanel {
add(themes, gbc_themes);
- colorsPanel.setLayout(new BoxLayout(colorsPanel, BoxLayout.Y_AXIS));
- colorsPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
+// colorsPanel.setLayout(new BoxLayout(colorsPanel, BoxLayout.Y_AXIS));
+// colorsPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
+
+ GridBagLayout gbl_colorCustomizations = new GridBagLayout();
+ gbl_colorCustomizations.columnWidths = new int[] { 1, 1 };
+ gbl_colorCustomizations.rowHeights = new int[] { 1, 1, 1, 1, 1, 1, 1, 1, 1};
+ gbl_colorCustomizations.columnWeights = new double[] { 1.0, 1.0 };
+ gbl_colorCustomizations.rowWeights = new double[] { 1, 1, 1, 1, 1, 1, 1, 1};
+
+ colorsPanel.setLayout(gbl_colorCustomizations);
+
+
Theme theme = Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme());
buildCustomizeElements(theme);
@@ -170,6 +180,7 @@ public class ThemeCustomizationPanel extends SettingsPanel {
colorsPanel.removeAll();
buildCustomizeElements(theme);
+ colorsPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
GridBagConstraints gbc_createNewTheme = new GridBagConstraints();
gbc_createNewTheme.gridx = 0;
@@ -179,19 +190,18 @@ public class ThemeCustomizationPanel extends SettingsPanel {
}
private void buildCustomizeElements(Theme theme) {
- buildCustomizeElement(theme, theme.getBackgroundColor(), "Background", "backgroundColor");
- buildCustomizeElement(theme, theme.getCellColor(), "Cells", "cellColor");
- buildCustomizeElement(theme, theme.getInteractableForegroundColor(), "Interactable Foreground", "interactableForegroundColor");
- buildCustomizeElement(theme, theme.getInteractableBackgroundColor(), "Interactable Background", "interactableBackgroundColor");
- buildCustomizeElement(theme, theme.getMessageColorChat(), "Messages Chat", "messageColorChat");
- buildCustomizeElement(theme, theme.getDateColorChat(), "Date Chat", "dateColorCat");
- buildCustomizeElement(theme, theme.getSelectionColor(), "Selection", "selectionColor");
- buildCustomizeElement(theme, theme.getTypingMessageColor(), "Typing Message", "typingMessageColor");
- buildCustomizeElement(theme, theme.getUserNameColor(), "User Names", "userNameColor");
+ buildCustomizeElement(theme, theme.getBackgroundColor(), "Background", "backgroundColor", 1);
+ buildCustomizeElement(theme, theme.getCellColor(), "Cells", "cellColor", 2);
+ buildCustomizeElement(theme, theme.getInteractableForegroundColor(), "Interactable Foreground", "interactableForegroundColor", 3);
+ buildCustomizeElement(theme, theme.getInteractableBackgroundColor(), "Interactable Background", "interactableBackgroundColor", 4);
+ buildCustomizeElement(theme, theme.getMessageColorChat(), "Messages Chat", "messageColorChat", 5);
+ buildCustomizeElement(theme, theme.getDateColorChat(), "Date Chat", "dateColorCat", 6);
+ buildCustomizeElement(theme, theme.getSelectionColor(), "Selection", "selectionColor", 7);
+ buildCustomizeElement(theme, theme.getTypingMessageColor(), "Typing Message", "typingMessageColor", 8);
+ buildCustomizeElement(theme, theme.getUserNameColor(), "User Names", "userNameColor", 9);
}
- private void buildCustomizeElement(Theme theme, Color color, String name, String colorName) {
- JPanel panel = new JPanel();
+ private void buildCustomizeElement(Theme theme, Color color, String name, String colorName, int gridy) {
JButton button = new JButton();
JTextPane textPane = new JTextPane();
@@ -222,12 +232,24 @@ public class ThemeCustomizationPanel extends SettingsPanel {
}
});
- panel.add(textPane);
- panel.add(button);
- panel.setBackground(theme.getCellColor());
- panel.setAlignmentX(Component.LEFT_ALIGNMENT);
+ GridBagConstraints gbc_textPane = new GridBagConstraints();
+ gbc_textPane.fill = GridBagConstraints.BOTH;
+ gbc_textPane.gridx = 0;
+ gbc_textPane.gridy = gridy;
+ gbc_textPane.anchor = GridBagConstraints.CENTER;
+ gbc_textPane.insets = insets;
- colorsPanel.add(panel);
+ colorsPanel.add(textPane, gbc_textPane);
+
+
+ GridBagConstraints gbc_button = new GridBagConstraints();
+ gbc_button.fill = GridBagConstraints.BOTH;
+ gbc_button.gridx = 1;
+ gbc_button.gridy = gridy;
+ gbc_button.anchor = GridBagConstraints.CENTER;
+ gbc_button.insets = insets;
+
+ colorsPanel.add(button, gbc_button);
}
private Color getInvertedColor(Color color) { return new Color(255 - color.getRed(), 255 - color.getGreen(), 255 - color.getBlue()); }
From f22f0a766bd7aec2e65a3d8e446b88b4840fe18e Mon Sep 17 00:00:00 2001
From: DieGurke <55625494+DieGurke@users.noreply.github.com>
Date: Sat, 21 Dec 2019 12:31:32 +0100
Subject: [PATCH 2/2] Revising
Added Author
Removed Comments
---
.../envoy/client/ui/settings/ThemeCustomizationPanel.java | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/main/java/envoy/client/ui/settings/ThemeCustomizationPanel.java b/src/main/java/envoy/client/ui/settings/ThemeCustomizationPanel.java
index 755b5b1..abd70a8 100644
--- a/src/main/java/envoy/client/ui/settings/ThemeCustomizationPanel.java
+++ b/src/main/java/envoy/client/ui/settings/ThemeCustomizationPanel.java
@@ -25,6 +25,7 @@ import envoy.client.util.EnvoyLog;
* Created: 20 Dec 2019
*
* @author Kai S. K. Engelbart
+ * @author Maximilian Käfer
* @since Envoy v0.2-alpha
*/
public class ThemeCustomizationPanel extends SettingsPanel {
@@ -81,9 +82,6 @@ public class ThemeCustomizationPanel extends SettingsPanel {
gbc_themes.insets = insets;
add(themes, gbc_themes);
-
-// colorsPanel.setLayout(new BoxLayout(colorsPanel, BoxLayout.Y_AXIS));
-// colorsPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
GridBagLayout gbl_colorCustomizations = new GridBagLayout();