From 2c7d8cdbb0e084017c9ce6bb8f9f8f3e6e817213 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 18 Mar 2021 13:27:49 -0400 Subject: [PATCH] Support hiding only "half" the xhair --- piker/ui/_graphics/_cursor.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/piker/ui/_graphics/_cursor.py b/piker/ui/_graphics/_cursor.py index 3afc2723..4144e3fd 100644 --- a/piker/ui/_graphics/_cursor.py +++ b/piker/ui/_graphics/_cursor.py @@ -380,17 +380,19 @@ class Cursor(pg.GraphicsObject): # px perfect... line_offset = self._lw / 2 + # update y-range items if iy != last_iy: - # update y-range items - self.graphics[plot]['hl'].setY(iy + line_offset) - if self._y_label_update: self.graphics[self.active_plot]['yl'].update_label( abs_pos=plot.mapFromView(QPointF(ix, iy + line_offset)), value=iy ) + # only update horizontal xhair line if label is enabled + self.graphics[plot]['hl'].setY(iy + line_offset) + + # update all trackers for item in self._trackers: # print(f'setting {item} with {(ix, y)}') @@ -451,11 +453,16 @@ class Cursor(pg.GraphicsObject): self, hide_label: bool = False, y_label_level: float = None, + just_vertical: bool = False, fg_color: str = None, # bg_color: str = 'papas_special', ) -> None: g = self.graphics[self.active_plot] - g['hl'].hide() + + hl = g['hl'] + if not just_vertical: + hl.hide() + g['vl'].hide() # only disable cursor y-label updates @@ -467,6 +474,7 @@ class Cursor(pg.GraphicsObject): elif y_label_level: yl.update_from_data(0, y_label_level, _save_last=False) + hl.setY(y_label_level) if fg_color is not None: yl.fg_color = pg.mkColor(hcolor(fg_color))