Skip to content

Commit

Permalink
Merge pull request #4734 from bubblobill/chat_bg
Browse files Browse the repository at this point in the history
Chat background colour fix
  • Loading branch information
cwisniew authored Mar 30, 2024
2 parents d6ffeea + 1ba1c15 commit ba0d384
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import net.rptools.maptool.client.ui.htmlframe.HTMLFrameFactory;
import net.rptools.maptool.client.ui.theme.Icons;
import net.rptools.maptool.client.ui.theme.RessourceManager;
import net.rptools.maptool.client.ui.theme.ThemeSupport;
import net.rptools.maptool.events.MapToolEventBus;
import net.rptools.maptool.language.I18N;
import net.rptools.maptool.model.*;
Expand Down Expand Up @@ -82,7 +83,6 @@ public class CommandPanel extends JPanel {
public CommandPanel() {
setLayout(new BorderLayout());
setBorder(BorderFactory.createLineBorder(Color.gray));

add(BorderLayout.SOUTH, createSouthPanel());
add(BorderLayout.CENTER, getMessagePanel());
initializeSmilies();
Expand Down Expand Up @@ -607,6 +607,10 @@ protected void paintComponent(Graphics g) {
commandTextArea.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
commandTextArea.setPreferredSize(new Dimension(50, 40)); // XXX should be resizable
commandTextArea.setFont(new Font("sans-serif", 0, AppPreferences.getFontSize()));
if (!ThemeSupport.shouldUseThemeColorsForChat()) {
commandTextArea.setBackground(Color.WHITE);
commandTextArea.setForeground(Color.BLACK);
}
commandTextArea.addKeyListener(new ChatTypingListener());
SwingUtil.useAntiAliasing(commandTextArea);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public MessagePanel() {
textPane.setEditorKit(new MessagePanelEditorKit());
if (ThemeSupport.shouldUseThemeColorsForChat()) {
textPane.setUI(new javax.swing.plaf.basic.BasicEditorPaneUI());
} else {
textPane.setBackground(new Color(253, 253, 254));
textPane.setForeground(Color.BLACK);
}
textPane.addComponentListener(
new ComponentListener() {
Expand Down Expand Up @@ -149,13 +152,19 @@ public void refreshRenderer() {
new MapToolEventBus().getMainEventBus().register(this);
// Create the style
StyleSheet style = document.getStyleSheet();
var defColor =
var fgColour =
ThemeSupport.shouldUseThemeColorsForChat()
? MessageUtil.getDefaultForegroundHex()
: "black";
var bgColour =
ThemeSupport.shouldUseThemeColorsForChat()
? MessageUtil.getDefaultBackgroundHex()
: "#fdfdfe";
var mainCss =
"body {color: "
+ defColor
"body {background-color: "
+ bgColour
+ "; color: "
+ fgColour
+ " ; font-family: sans-serif; font-size: "
+ AppPreferences.getFontSize()
+ "pt}";
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/net/rptools/maptool/util/MessageUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ public static String getChatColorHex() {
return String.format("#%06X", color.getRGB() & 0x00FFFFFF);
}

public static String getDefaultBackgroundHex() {
var color = UIManager.getColor("Panel.background");
return String.format("#%06X", color.getRGB() & 0x00FFFFFF);
}

public static String getDefaultForegroundHex() {
var color = UIManager.getColor("Panel.foreground");
return String.format("#%06X", color.getRGB() & 0x00FFFFFF);
Expand Down

0 comments on commit ba0d384

Please sign in to comment.