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,5 +1,7 @@
|
||||
package com.ts3client.ui;
|
||||
|
||||
import com.formdev.flatlaf.util.ScaledEmptyBorder;
|
||||
import com.formdev.flatlaf.util.UIScale;
|
||||
import com.ts3client.net.ChannelNode;
|
||||
import com.ts3client.net.TeamspeakConnection;
|
||||
import com.ts3client.net.filetransfer.FileTransfer;
|
||||
@@ -65,15 +67,15 @@ public final class FileBrowserDialog extends JDialog {
|
||||
this.channelId = channel.id;
|
||||
this.channelPassword = "";
|
||||
|
||||
JPanel content = new JPanel(new BorderLayout(0, 8));
|
||||
JPanel content = new JPanel(new BorderLayout(0, UIScale.scale(8)));
|
||||
content.setBackground(Theme.windowBg());
|
||||
content.setBorder(BorderFactory.createEmptyBorder(10, 12, 10, 12));
|
||||
content.setBorder(new ScaledEmptyBorder(10, 12, 10, 12));
|
||||
content.add(buildToolbar(), BorderLayout.NORTH);
|
||||
content.add(buildTable(), BorderLayout.CENTER);
|
||||
content.add(buildTransfers(), BorderLayout.SOUTH);
|
||||
setContentPane(content);
|
||||
|
||||
setPreferredSize(new Dimension(640, 480));
|
||||
setPreferredSize(UIScale.scale(new Dimension(640, 480)));
|
||||
pack();
|
||||
setLocationRelativeTo(owner);
|
||||
|
||||
@@ -98,17 +100,17 @@ public final class FileBrowserDialog extends JDialog {
|
||||
deleteButton.addActionListener(e -> deleteSelected());
|
||||
|
||||
bar.add(upButton);
|
||||
bar.add(Box.createHorizontalStrut(6));
|
||||
bar.add(Box.createHorizontalStrut(UIScale.scale(6)));
|
||||
bar.add(refresh);
|
||||
bar.add(Box.createHorizontalStrut(16));
|
||||
bar.add(Box.createHorizontalStrut(UIScale.scale(16)));
|
||||
bar.add(pathLabel);
|
||||
bar.add(Box.createHorizontalGlue());
|
||||
bar.add(mkdir);
|
||||
bar.add(Box.createHorizontalStrut(6));
|
||||
bar.add(Box.createHorizontalStrut(UIScale.scale(6)));
|
||||
bar.add(upload);
|
||||
bar.add(Box.createHorizontalStrut(6));
|
||||
bar.add(Box.createHorizontalStrut(UIScale.scale(6)));
|
||||
bar.add(downloadButton);
|
||||
bar.add(Box.createHorizontalStrut(6));
|
||||
bar.add(Box.createHorizontalStrut(UIScale.scale(6)));
|
||||
bar.add(deleteButton);
|
||||
|
||||
pathLabel.setFont(Theme.uiFont());
|
||||
@@ -118,14 +120,14 @@ public final class FileBrowserDialog extends JDialog {
|
||||
|
||||
private JScrollPane buildTable() {
|
||||
table.setFont(Theme.uiFont());
|
||||
table.setRowHeight(20);
|
||||
table.setRowHeight(UIScale.scale(20));
|
||||
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||
table.setFillsViewportHeight(true);
|
||||
table.getColumnModel().getColumn(0).setPreferredWidth(300);
|
||||
table.getColumnModel().getColumn(0).setPreferredWidth(UIScale.scale(300));
|
||||
table.getColumnModel().getColumn(0).setCellRenderer(new NameRenderer());
|
||||
table.getColumnModel().getColumn(1).setPreferredWidth(90);
|
||||
table.getColumnModel().getColumn(2).setPreferredWidth(70);
|
||||
table.getColumnModel().getColumn(3).setPreferredWidth(150);
|
||||
table.getColumnModel().getColumn(1).setPreferredWidth(UIScale.scale(90));
|
||||
table.getColumnModel().getColumn(2).setPreferredWidth(UIScale.scale(70));
|
||||
table.getColumnModel().getColumn(3).setPreferredWidth(UIScale.scale(150));
|
||||
table.getSelectionModel().addListSelectionListener(e -> updateButtons());
|
||||
table.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
@@ -146,7 +148,7 @@ public final class FileBrowserDialog extends JDialog {
|
||||
transfersPanel.setBackground(Theme.windowBg());
|
||||
JScrollPane scroll = new JScrollPane(transfersPanel);
|
||||
scroll.setBorder(BorderFactory.createTitledBorder("Transfers"));
|
||||
scroll.setPreferredSize(new Dimension(10, 120));
|
||||
scroll.setPreferredSize(UIScale.scale(new Dimension(10, 120)));
|
||||
scroll.getViewport().setBackground(Theme.windowBg());
|
||||
return scroll;
|
||||
}
|
||||
@@ -325,10 +327,10 @@ public final class FileBrowserDialog extends JDialog {
|
||||
private FileTransfer transfer;
|
||||
|
||||
TransferRow() {
|
||||
setLayout(new BorderLayout(8, 0));
|
||||
setLayout(new BorderLayout(UIScale.scale(8), 0));
|
||||
setBackground(Theme.windowBg());
|
||||
setBorder(BorderFactory.createEmptyBorder(3, 2, 3, 2));
|
||||
setMaximumSize(new Dimension(Integer.MAX_VALUE, 44));
|
||||
setBorder(new ScaledEmptyBorder(3, 2, 3, 2));
|
||||
setMaximumSize(new Dimension(Integer.MAX_VALUE, UIScale.scale(44)));
|
||||
label.setFont(Theme.uiFont());
|
||||
bar.setStringPainted(true);
|
||||
add(label, BorderLayout.NORTH);
|
||||
|
||||
Reference in New Issue
Block a user