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