Merge pull request #66 from informatik-ag-ngl/f/ThemeCustomizationAlignment

Settings UI Allignment
This commit is contained in:
DieGurke 2019-12-21 12:32:51 +01:00 committed by GitHub
commit e2dc19fbef

View File

@ -25,6 +25,7 @@ import envoy.client.util.EnvoyLog;
* Created: <strong>20 Dec 2019</strong><br> * Created: <strong>20 Dec 2019</strong><br>
* *
* @author Kai S. K. Engelbart * @author Kai S. K. Engelbart
* @author Maximilian K&auml;fer
* @since Envoy v0.2-alpha * @since Envoy v0.2-alpha
*/ */
public class ThemeCustomizationPanel extends SettingsPanel { public class ThemeCustomizationPanel extends SettingsPanel {
@ -82,8 +83,15 @@ public class ThemeCustomizationPanel extends SettingsPanel {
add(themes, gbc_themes); add(themes, gbc_themes);
colorsPanel.setLayout(new BoxLayout(colorsPanel, BoxLayout.Y_AXIS)); GridBagLayout gbl_colorCustomizations = new GridBagLayout();
colorsPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
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()); Theme theme = Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme());
buildCustomizeElements(theme); buildCustomizeElements(theme);
@ -170,6 +178,7 @@ public class ThemeCustomizationPanel extends SettingsPanel {
colorsPanel.removeAll(); colorsPanel.removeAll();
buildCustomizeElements(theme); buildCustomizeElements(theme);
colorsPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
GridBagConstraints gbc_createNewTheme = new GridBagConstraints(); GridBagConstraints gbc_createNewTheme = new GridBagConstraints();
gbc_createNewTheme.gridx = 0; gbc_createNewTheme.gridx = 0;
@ -179,19 +188,18 @@ public class ThemeCustomizationPanel extends SettingsPanel {
} }
private void buildCustomizeElements(Theme theme) { private void buildCustomizeElements(Theme theme) {
buildCustomizeElement(theme, theme.getBackgroundColor(), "Background", "backgroundColor"); buildCustomizeElement(theme, theme.getBackgroundColor(), "Background", "backgroundColor", 1);
buildCustomizeElement(theme, theme.getCellColor(), "Cells", "cellColor"); buildCustomizeElement(theme, theme.getCellColor(), "Cells", "cellColor", 2);
buildCustomizeElement(theme, theme.getInteractableForegroundColor(), "Interactable Foreground", "interactableForegroundColor"); buildCustomizeElement(theme, theme.getInteractableForegroundColor(), "Interactable Foreground", "interactableForegroundColor", 3);
buildCustomizeElement(theme, theme.getInteractableBackgroundColor(), "Interactable Background", "interactableBackgroundColor"); buildCustomizeElement(theme, theme.getInteractableBackgroundColor(), "Interactable Background", "interactableBackgroundColor", 4);
buildCustomizeElement(theme, theme.getMessageColorChat(), "Messages Chat", "messageColorChat"); buildCustomizeElement(theme, theme.getMessageColorChat(), "Messages Chat", "messageColorChat", 5);
buildCustomizeElement(theme, theme.getDateColorChat(), "Date Chat", "dateColorCat"); buildCustomizeElement(theme, theme.getDateColorChat(), "Date Chat", "dateColorCat", 6);
buildCustomizeElement(theme, theme.getSelectionColor(), "Selection", "selectionColor"); buildCustomizeElement(theme, theme.getSelectionColor(), "Selection", "selectionColor", 7);
buildCustomizeElement(theme, theme.getTypingMessageColor(), "Typing Message", "typingMessageColor"); buildCustomizeElement(theme, theme.getTypingMessageColor(), "Typing Message", "typingMessageColor", 8);
buildCustomizeElement(theme, theme.getUserNameColor(), "User Names", "userNameColor"); buildCustomizeElement(theme, theme.getUserNameColor(), "User Names", "userNameColor", 9);
} }
private void buildCustomizeElement(Theme theme, Color color, String name, String colorName) { private void buildCustomizeElement(Theme theme, Color color, String name, String colorName, int gridy) {
JPanel panel = new JPanel();
JButton button = new JButton(); JButton button = new JButton();
JTextPane textPane = new JTextPane(); JTextPane textPane = new JTextPane();
@ -222,12 +230,24 @@ public class ThemeCustomizationPanel extends SettingsPanel {
} }
}); });
panel.add(textPane); GridBagConstraints gbc_textPane = new GridBagConstraints();
panel.add(button); gbc_textPane.fill = GridBagConstraints.BOTH;
panel.setBackground(theme.getCellColor()); gbc_textPane.gridx = 0;
panel.setAlignmentX(Component.LEFT_ALIGNMENT); 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()); } private Color getInvertedColor(Color color) { return new Color(255 - color.getRed(), 255 - color.getGreen(), 255 - color.getBlue()); }