Scale the interface fractionally on Linux
Java2D on X11 (and so under XWayland) truncates its scale to a whole number, drawing 150 % at 100 %. On Linux, pin Java2D to 1 and hand the full factor to FlatLaf, taken from XSETTINGS Xft/DPI, KWin's Xwayland scale or GDK_SCALE, or chosen in Options → Design. The client's own sizes now go through UIScale: borders, gaps, dialog and row sizes, icons (rendered at the scaled size, so they stay crisp), custom-painted components and font sizes in the HTML views. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
package com.ts3client.ui;
|
||||
|
||||
import com.formdev.flatlaf.util.ScaledEmptyBorder;
|
||||
import com.formdev.flatlaf.util.UIScale;
|
||||
import com.ts3client.config.AwayMessages;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
@@ -39,13 +40,13 @@ public final class AwayMessagesDialog extends JDialog {
|
||||
table.setTableHeader(null);
|
||||
table.setShowGrid(false);
|
||||
table.setFillsViewportHeight(true);
|
||||
table.setRowHeight(Math.max(20, table.getRowHeight()));
|
||||
table.setRowHeight(Math.max(UIScale.scale(20), table.getRowHeight()));
|
||||
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
// Single click selects, double click starts editing — like a renameable list.
|
||||
table.putClientProperty("JTable.autoStartsEdit", Boolean.FALSE);
|
||||
|
||||
JScrollPane scroll = new JScrollPane(table);
|
||||
scroll.setBorder(BorderFactory.createEmptyBorder(8, 8, 4, 8));
|
||||
scroll.setBorder(new ScaledEmptyBorder(8, 8, 4, 8));
|
||||
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
getContentPane().add(scroll, BorderLayout.CENTER);
|
||||
@@ -53,14 +54,14 @@ public final class AwayMessagesDialog extends JDialog {
|
||||
|
||||
Dialogs.closeOnEscape(this, this::closeDialog);
|
||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
setSize(new Dimension(360, 300));
|
||||
setSize(UIScale.scale(new Dimension(360, 300)));
|
||||
setLocationRelativeTo(owner);
|
||||
}
|
||||
|
||||
private JPanel buildButtons() {
|
||||
JPanel buttons = new JPanel();
|
||||
buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
|
||||
buttons.setBorder(BorderFactory.createEmptyBorder(0, 8, 8, 8));
|
||||
buttons.setBorder(new ScaledEmptyBorder(0, 8, 8, 8));
|
||||
addButton(buttons, "Add", this::addEntry);
|
||||
addButton(buttons, "Remove", this::removeSelected);
|
||||
buttons.add(Box.createHorizontalGlue());
|
||||
@@ -72,7 +73,7 @@ public final class AwayMessagesDialog extends JDialog {
|
||||
JButton b = new JButton(text);
|
||||
b.addActionListener(e -> action.run());
|
||||
panel.add(b);
|
||||
panel.add(Box.createHorizontalStrut(4));
|
||||
panel.add(Box.createHorizontalStrut(UIScale.scale(4)));
|
||||
}
|
||||
|
||||
private void addEntry() {
|
||||
|
||||
Reference in New Issue
Block a user