Change scroll "center" to rightmost bar on screen

bar_select
Tyler Goodlet 2020-10-19 21:32:50 -04:00
parent c57f678295
commit 1902507703
1 changed files with 16 additions and 9 deletions

View File

@ -49,10 +49,10 @@ class ChartView(pg.ViewBox):
vl = r - l vl = r - l
if ev.delta() > 0 and vl <= _min_points_to_show: if ev.delta() > 0 and vl <= _min_points_to_show:
log.trace("Max zoom bruh...") log.debug("Max zoom bruh...")
return return
if ev.delta() < 0 and vl >= len(self.linked_charts._array): if ev.delta() < 0 and vl >= len(self.linked_charts._array):
log.trace("Min zoom bruh...") log.debug("Min zoom bruh...")
return return
# actual scaling factor # actual scaling factor
@ -64,14 +64,21 @@ class ChartView(pg.ViewBox):
# ) # )
# XXX: scroll "around" the right most element in the view # XXX: scroll "around" the right most element in the view
furthest_right_coord = self.boundingRect().topRight() # which stays "pinned" in place.
center = pg.Point(
fn.invertQTransform( # furthest_right_coord = self.boundingRect().topRight()
self.childGroup.transform()
).map(furthest_right_coord) # yaxis = pg.Point(
) # fn.invertQTransform(
# self.childGroup.transform()
# ).map(furthest_right_coord)
# )
# This seems like the most "intuitive option, a hybrdid of
# tws and tv styles
last_bar = pg.Point(rbar)
self._resetTarget() self._resetTarget()
self.scaleBy(s, center) self.scaleBy(s, last_bar)
ev.accept() ev.accept()
self.sigRangeChangedManually.emit(mask) self.sigRangeChangedManually.emit(mask)