From ebe0860ed4446d76005b00493ebf2c05aec5d93e Mon Sep 17 00:00:00 2001 From: Dawn Date: Thu, 13 Aug 2026 11:00:20 +0200 Subject: [PATCH] feat: add More link in sample camera help overlay opening F1 dialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Underlined 'More… (F1)' line at the bottom of the painted help box emits open_full_help, wired to the existing Mouse / Keyboard Controls dialog. Co-Authored-By: Claude Fable 5 --- src/aare/gui/main_window.py | 1 + src/aare/gui/widgets/camera_image.py | 39 +++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/aare/gui/main_window.py b/src/aare/gui/main_window.py index ad3a4a79..118427fd 100644 --- a/src/aare/gui/main_window.py +++ b/src/aare/gui/main_window.py @@ -913,6 +913,7 @@ class MainWindow(QMainWindow): self.sample_camera.smargon.connect(self.daq.move_smargon) self.beamline.smargon_panel.smargon.connect(self.daq.move_smargon) self.sample_camera.samcam_updated.connect(self.daq.samcam_settings) + self.sample_camera.open_full_help.connect(self.show_controls_help) self.raster.omega.connect(self.daq.set_omega) self.raster.smargon.connect(self.daq.move_smargon) diff --git a/src/aare/gui/widgets/camera_image.py b/src/aare/gui/widgets/camera_image.py index 14b8a0dd..7895aa88 100644 --- a/src/aare/gui/widgets/camera_image.py +++ b/src/aare/gui/widgets/camera_image.py @@ -98,6 +98,8 @@ class SampleCameraImageLabel(QGraphicsView): samcam_updated = Signal(SampleCameraSettings) switch_raster_grid = Signal() + # "More…" link in the help overlay; main window opens the full F1 dialog. + open_full_help = Signal() def __init__( self, @@ -147,6 +149,7 @@ class SampleCameraImageLabel(QGraphicsView): # legend visibility is already handled by the panel checkboxes. self._help_expanded = False self._help_hit_rect: QRectF | None = None # viewport coords, set on paint + self._help_more_rect: QRectF | None = None # "More…" link inside the overlay self._target_point = None self._target_shape = None self._target_color_name = "Cyan" @@ -471,6 +474,19 @@ class SampleCameraImageLabel(QGraphicsView): self._scaling() def mousePressEvent(self, event): + # "More…" link before the box toggle: its rect lies inside the help box, + # so the toggle below would swallow the click otherwise. + if ( + event.button() == Qt.MouseButton.LeftButton + and self._help_more_rect is not None + and self._help_more_rect.contains(QPointF(self.viewport().mapFrom(self, event.pos()))) + ): + self._help_expanded = False + self.update() + self.open_full_help.emit() + event.accept() + return + # Help badge first: pure UI affordance, must work even when camera # interaction is disabled (session overlay etc.). if ( @@ -1087,6 +1103,7 @@ class SampleCameraImageLabel(QGraphicsView): def _draw_help_overlay(self, painter: QPainter): self._help_hit_rect = None + self._help_more_rect = None if not self._help_expanded: self._draw_help_badge(painter) return @@ -1114,8 +1131,15 @@ class SampleCameraImageLabel(QGraphicsView): for entry in entries: max_width = max(max_width, fm.horizontalAdvance(entry)) + more_text = "More… (F1)" + max_width = max(max_width, fm.horizontalAdvance(more_text)) + width = max_width + padding * 2 - height = len(self._HELP_SECTIONS) * header_height + n_lines * line_height + padding * 2 + height = ( + len(self._HELP_SECTIONS) * header_height + + (n_lines + 1) * line_height # +1: trailing "More…" link line + + padding * 2 + ) bg_rect = QRectF(18, max(18, self.viewport().height() - height - 18), width, height) self._help_hit_rect = bg_rect # click anywhere on the box to close @@ -1135,6 +1159,19 @@ class SampleCameraImageLabel(QGraphicsView): painter.drawText(QPointF(bg_rect.left() + padding, y + fm.ascent()), entry) y += line_height + # Trailing link to the full F1 dialog; underlined so it reads as clickable. + link_font = QFont(font) + link_font.setUnderline(True) + painter.setFont(link_font) + painter.setPen(QPen(qcolor(LEGEND_TEXT), 1)) + painter.drawText(QPointF(bg_rect.left() + padding, y + fm.ascent()), more_text) + self._help_more_rect = QRectF( + bg_rect.left() + padding, + y, + fm.horizontalAdvance(more_text), + line_height, + ) + painter.restore() def _draw_overlay_legend(self, painter: QPainter):