From e07667726e68d2dea65f1cc5a659a807dbd6f130 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Sat, 26 Sep 2026 22:20:18 +0200 Subject: [PATCH] Viewer: Shift + wheel on macOS, Mac keys in the mouse-shortcut help macOS turns Shift + a vertical mouse wheel into horizontal scrolling, so the notch arrives in angleDelta().x() and y() is 0; the contrast step read only y and did nothing. The wheel handler now takes whichever axis carries the notch, for zoom, foreground and background alike. Help > Mouse Shortcuts names Cmd for Ctrl on macOS (Qt maps Command to Ctrl), Ctrl-click for right click and Fn + arrows for Home/End/Page Up/Down, and lists B held + wheel, which was missing. The magnifier's tooltip says how to drive it. Co-Authored-By: Claude Opus 5.5 --- docs/CHANGELOG.md | 1 + docs/JFJOCH_VIEWER.md | 5 ++++ viewer/image_viewer/JFJochImage.cpp | 14 +++++++---- viewer/widgets/JFJochViewerMagnifier.cpp | 2 +- viewer/windows/JFJochMouseShortcutsWindow.cpp | 23 +++++++++++++++---- 5 files changed, 35 insertions(+), 10 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 6699b98c0..691e78a43 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -26,6 +26,7 @@ * Rugnux also reports `R_MEAS_WEIGHTED`, the R_meas with each observation weighted as the merge weights it, so weak frames kept in the merge at low weight can be told from real disagreement; `R_MEAS` is unchanged. * Rugnux no longer stops per-frame scaling as unsettled because of a single frame that is about to be dropped as blank. * The viewer's magnifier is a panel below the inspector (or, popped out, a window of its own) with three fixed zoom levels (×64, ×32, ×10), follows the cursor only while Shift is held, and a frame on the image shows the area it covers; the inspector's image statistics can now be folded. +* The viewer's Shift + wheel changes the contrast on macOS again, and Help ▸ Mouse Shortcuts names the Mac keys (⌘ for Ctrl). * Rugnux writes its files in the standard setting, as XDS and POINTLESS do (e.g. P 21 21 2 with the pure two-fold on c rather than P 2 21 21), or in the setting of a reference MTZ, of a model that fits, of the cell given with `-C` or of a non-standard `-S` symbol; `SETTING_OPERATOR=` and `SETTING_SOURCE=` report it. * Rugnux puts the merge onto a reference MTZ's axes before inheriting its free-R flags, and does not inherit them where the merge does not match the reference (`REFERENCE_MISMATCH`); `REFERENCE_OPERATOR=`, `REFERENCE_CC=` and `REFERENCE_MATCHED_FRACTION=` report the match. * Rugnux places a space group given with `-S` on the axes its systematic absences name, so `-S 18` on a cell whose pure two-fold is not its longest axis no longer merges with the screw absences on the wrong rows. diff --git a/docs/JFJOCH_VIEWER.md b/docs/JFJOCH_VIEWER.md index abf3663b3..f2dfe0913 100644 --- a/docs/JFJOCH_VIEWER.md +++ b/docs/JFJOCH_VIEWER.md @@ -110,6 +110,10 @@ X11 forwarding. The same list is available in the application under **Help ▸ Mouse Shortcuts**. +On macOS, `Ctrl` below means the Command key (`⌘`); right click is also `Ctrl`-click, and on a +keyboard without them `Home` / `End` are `Fn`+`←` / `Fn`+`→` and `Page Up` / `Page Down` are +`Fn`+`↑` / `Fn`+`↓`. The Mouse Shortcuts window shows the Mac keys directly. + ### Diffraction image | Action | Effect | @@ -118,6 +122,7 @@ The same list is available in the application under **Help ▸ Mouse Shortcuts** | `Shift` + wheel | Move the foreground (upper contrast limit) in linear steps | | `Ctrl` + wheel | Move the foreground in multiplicative steps (×1.15 per notch) | | `F` held + wheel | Same as `Shift` + wheel, for as long as `F` is held | +| `B` held + wheel | Move the background (lower contrast limit) in linear steps, for as long as `B` is held | | `A` | Apply auto-contrast once; press it again to switch on continuous Auto | | `Home` / `End` | Jump to the first / last image in the dataset | | `Page Up` / `Page Down` | Step one image forward / back | diff --git a/viewer/image_viewer/JFJochImage.cpp b/viewer/image_viewer/JFJochImage.cpp index 0026afd84..e43d4f960 100644 --- a/viewer/image_viewer/JFJochImage.cpp +++ b/viewer/image_viewer/JFJochImage.cpp @@ -168,12 +168,18 @@ void JFJochImage::wheelEvent(QWheelEvent *event) { // Get the position of the mouse in scene coordinates QPointF targetScenePos = mapToScene(event->position().toPoint()); + // macOS turns Shift + a vertical mouse wheel into horizontal scrolling, so with Shift held the + // notch arrives in x, not y. Take whichever axis carries it. + const int delta = (event->angleDelta().y() != 0) ? event->angleDelta().y() : event->angleDelta().x(); + if (delta == 0) + return; + const bool exp_fg_adjust = (event->modifiers() & Qt::ControlModifier); const bool lin_fg_adjust = (event->modifiers() & Qt::ShiftModifier) || m_adjustForegroundWithWheel; if (m_adjustBackgroundWithWheel) { // Held B: the wheel moves the black point, clamped so a positive display range remains. - float new_background = background + event->angleDelta().y() / 120.0f; + float new_background = background + delta / 120.0f; new_background = std::clamp(new_background, 0.0f, std::max(0.0f, foreground - 1.0f)); changeBackground(new_background); emit backgroundChanged(background); @@ -181,10 +187,10 @@ void JFJochImage::wheelEvent(QWheelEvent *event) { float new_foreground = foreground; if (exp_fg_adjust) { - const float step = (event->angleDelta().y() > 0) ? zoomFactor : (1.0 / zoomFactor); + const float step = (delta > 0) ? zoomFactor : (1.0 / zoomFactor); new_foreground = foreground * step; } else { - new_foreground = foreground + event->angleDelta().y() / 120.0f; + new_foreground = foreground + delta / 120.0f; } // Keep the white point above the black point (1.0 when the background sits at zero). @@ -194,7 +200,7 @@ void JFJochImage::wheelEvent(QWheelEvent *event) { changeForeground(new_foreground); emit foregroundChanged(foreground); } else { - pending_zoom_steps_ += (event->angleDelta().y() > 0) ? 1 : -1; + pending_zoom_steps_ += (delta > 0) ? 1 : -1; zoom_anchor_vp_ = event->position().toPoint(); if (RemoteDisplayMode() && zoom_rate_.isValid() && zoom_rate_.elapsed() < kHoverIntervalMs) { zoom_tail_timer_->start(kHoverIntervalMs); diff --git a/viewer/widgets/JFJochViewerMagnifier.cpp b/viewer/widgets/JFJochViewerMagnifier.cpp index f072c1520..9bb4cc24a 100644 --- a/viewer/widgets/JFJochViewerMagnifier.cpp +++ b/viewer/widgets/JFJochViewerMagnifier.cpp @@ -44,7 +44,7 @@ JFJochViewerMagnifier::JFJochViewerMagnifier(QWidget *parent) : QWidget(parent) image_ = new JFJochFollowerImage(this); image_->setMinimumHeight(200); - image_->setToolTip("Move the cursor over the diffraction image with Shift held to move the magnifier"); + image_->setToolTip("Hold Shift and move the cursor over the diffraction image to update"); image_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); layout->addWidget(image_, 1); connect(image_, &JFJochFollowerImage::fieldChanged, this, &JFJochViewerMagnifier::fieldChanged); diff --git a/viewer/windows/JFJochMouseShortcutsWindow.cpp b/viewer/windows/JFJochMouseShortcutsWindow.cpp index 448a7d7cd..68b1a058d 100644 --- a/viewer/windows/JFJochMouseShortcutsWindow.cpp +++ b/viewer/windows/JFJochMouseShortcutsWindow.cpp @@ -11,23 +11,36 @@ namespace { struct Section { QString title; QVector rows; }; QString BuildHtml() { + // Qt reads the Command key as Ctrl on macOS, and a Mac keyboard often has no Home/End/Page keys +#ifdef Q_OS_MACOS + const QString ctrl = "Cmd (\u2318)"; + const QString home_end = "Home / End (Fn + \u2190 / \u2192)"; + const QString page_up_down = "Page Up / Page Down (Fn + \u2191 / \u2193)"; + const QString right_click = "Right click (Ctrl + click)"; +#else + const QString ctrl = "Ctrl"; + const QString home_end = "Home / End"; + const QString page_up_down = "Page Up / Page Down"; + const QString right_click = "Right click"; +#endif const QVector
sections = { // JFJochImage / JFJochDiffractionImage mouse handling {"Diffraction image", { {"Wheel", "Zoom in / out, centred on the cursor"}, {"Shift + wheel", "Move the foreground (upper contrast limit) in linear steps"}, - {"Ctrl + wheel", "Move the foreground in multiplicative steps (×1.15 per notch)"}, + {ctrl + " + wheel", "Move the foreground in multiplicative steps (×1.15 per notch)"}, {"F held + wheel", "Same as Shift + wheel, for as long as F is held"}, + {"B held + wheel", "Move the background (lower contrast limit) in linear steps, for as long as B is held"}, {"A", "Apply auto-contrast once; press again to switch on continuous Auto"}, - {"Home / End", "Jump to the first / last image in the dataset"}, - {"Page Up / Page Down", "Step one image forward / back"}, + {home_end, "Jump to the first / last image in the dataset"}, + {page_up_down, "Step one image forward / back"}, {"Hover", "Status bar shows the pixel position, its value and the resolution"}, {"Drag", "Pan the image"}, {"Shift + move", "Move the magnifier panel to the cursor; a frame shows the area it covers"}, {"Shift + drag", "Draw a rectangular ROI"}, - {"Shift + Ctrl + drag", "Draw a circular ROI"}, + {"Shift + " + ctrl + " + drag", "Draw a circular ROI"}, {"Drag an ROI or its handle", "Move or resize the selected ROI"}, - {"Right click", "Copy / save the image, fit to view, clear the ROI"}, + {right_click, "Copy / save the image, fit to view, clear the ROI"}, }}, // JFJochGridScanImage {"Grid scan", {