better scrolling in panel

This commit is contained in:
Radek Davidek 2026-02-10 19:16:38 +01:00
parent d00d5222c5
commit abd2ba15b8

View File

@ -695,6 +695,12 @@ public class FilePanelTab extends JPanel {
JScrollPane scrollPane = new JScrollPane(fileTable);
// Enable horizontal scrollbar when needed so BRIEF mode can scroll left-right
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
// Increase scroll speed
scrollPane.getVerticalScrollBar().setUnitIncrement(30);
scrollPane.getHorizontalScrollBar().setUnitIncrement(30);
scrollPane.getVerticalScrollBar().setBlockIncrement(200);
scrollPane.getHorizontalScrollBar().setBlockIncrement(200);
// Info panel for Quick View (Ctrl+Q)
infoTextArea = new JTextArea();
@ -708,29 +714,26 @@ public class FilePanelTab extends JPanel {
cardPanel.add(scrollPane, "TABLE");
cardPanel.add(infoScrollPane, "INFO");
// Implement mouse wheel navigation in BRIEF and FULL mode to match arrow key behavior
// Implement mouse wheel scrolling without changing selection
fileTable.addMouseWheelListener(new java.awt.event.MouseWheelListener() {
@Override
public void mouseWheelMoved(java.awt.event.MouseWheelEvent e) {
int rotation = e.getWheelRotation();
if (rotation == 0) return;
if (viewMode == ViewMode.BRIEF) {
// Navigate by one full column per wheel step
handleBriefNavigation(rotation > 0, tableModel.briefRowsPerColumn);
e.consume();
} else if (viewMode == ViewMode.FULL) {
// Navigate by one item at a time in FULL mode
int currentRow = fileTable.getSelectedRow();
int newRow = currentRow + (rotation > 0 ? 1 : -1);
if (newRow >= 0 && newRow < fileTable.getRowCount()) {
fileTable.setRowSelectionInterval(newRow, newRow);
fileTable.scrollRectToVisible(fileTable.getCellRect(newRow, 0, true));
updateStatus();
// In BRIEF mode (horizontal layout), vertical wheel scrolls horizontally
JScrollPane sp = (JScrollPane) SwingUtilities.getAncestorOfClass(JScrollPane.class, fileTable);
if (sp != null) {
JScrollBar hBar = sp.getHorizontalScrollBar();
if (hBar != null && hBar.isVisible()) {
int rotation = e.getWheelRotation();
// Scroll by a larger amount for significantly faster movement
int amount = rotation * hBar.getUnitIncrement() * 10;
hBar.setValue(hBar.getValue() + amount);
}
}
e.consume();
}
// In FULL mode, we don't consume the event, allowing the JScrollPane
// to perform standard vertical scrolling without changing the selection.
}
});