Drop old marker drawing code from `LevelLine.paint()`

We haven't been using it for a while and the supposed (remembered)
latency issue on interaction doesn't seem existing after applying the
cache mode. This allows dropping some internal state-logic and generally
simplifying the show-on-hover checks.

Further add `.show_markers()` and `.hide_markers()` as explicit methods
that can be called externally by UI business logic.
history_view
Tyler Goodlet 2022-09-23 17:12:57 -04:00
parent 4818af1445
commit cc67d23eee
1 changed files with 20 additions and 30 deletions

View File

@ -92,7 +92,6 @@ class LevelLine(pg.InfiniteLine):
self._marker = None self._marker = None
self.only_show_markers_on_hover = only_show_markers_on_hover self.only_show_markers_on_hover = only_show_markers_on_hover
self.show_markers: bool = True # presuming the line is hovered at init
self.track_marker_pos: bool = False self.track_marker_pos: bool = False
# should line go all the way to far end or leave a "margin" # should line go all the way to far end or leave a "margin"
@ -358,24 +357,12 @@ class LevelLine(pg.InfiniteLine):
line_end, marker_right, r_axis_x = self._chart.marker_right_points() line_end, marker_right, r_axis_x = self._chart.marker_right_points()
if self.show_markers and self.markers: # (legacy) NOTE: at one point this seemed slower when moving around
# order lines.. not sure if that's still true or why but we've
p.setPen(self.pen) # dropped the original hacky `.pain()` transform stuff for inf
qgo_draw_markers( # line markers now - check the git history if it needs to be
self.markers, # reverted.
self.pen.color(), if self._marker:
p,
vb_left,
vb_right,
marker_right,
)
# marker_size = self.markers[0][2]
self._maxMarkerSize = max([m[2] / 2. for m in self.markers])
# this seems slower when moving around
# order lines.. not sure wtf is up with that.
# for now we're just using it on the position line.
elif self._marker:
if self.track_marker_pos: if self.track_marker_pos:
# make the line end at the marker's x pos # make the line end at the marker's x pos
line_end = marker_right = self._marker.pos().x() line_end = marker_right = self._marker.pos().x()
@ -468,10 +455,7 @@ class LevelLine(pg.InfiniteLine):
return return
if self.only_show_markers_on_hover: if self.only_show_markers_on_hover:
self.show_markers = True self.show_markers()
if self._marker:
self._marker.show()
# highlight if so configured # highlight if so configured
if self.highlight_on_hover: if self.highlight_on_hover:
@ -514,11 +498,7 @@ class LevelLine(pg.InfiniteLine):
cur._hovered.remove(self) cur._hovered.remove(self)
if self.only_show_markers_on_hover: if self.only_show_markers_on_hover:
self.show_markers = False self.hide_markers()
if self._marker:
self._marker.hide()
self._marker.label.hide()
if self not in cur._trackers: if self not in cur._trackers:
cur.show_xhair(y_label_level=self.value()) cur.show_xhair(y_label_level=self.value())
@ -530,6 +510,15 @@ class LevelLine(pg.InfiniteLine):
self.update() self.update()
def hide_markers(self) -> None:
if self._marker:
self._marker.hide()
self._marker.label.hide()
def show_markers(self) -> None:
if self._marker:
self._marker.show()
def level_line( def level_line(
@ -735,7 +724,7 @@ def order_line(
marker = LevelMarker( marker = LevelMarker(
chart=chart, chart=chart,
style=marker_style, style=marker_style,
get_level=line.value, get_level=line.value, # callback
size=marker_size, size=marker_size,
keep_in_view=False, keep_in_view=False,
) )
@ -744,7 +733,8 @@ def order_line(
marker = line.add_marker(marker) marker = line.add_marker(marker)
# XXX: DON'T COMMENT THIS! # XXX: DON'T COMMENT THIS!
# this fixes it the artifact issue! .. of course, bounding rect stuff # this fixes it the artifact issue!
# .. of course, bounding rect stuff
line._maxMarkerSize = marker_size line._maxMarkerSize = marker_size
assert line._marker is marker assert line._marker is marker