Skip to content

Commit 72a3f02

Browse files
authored
fix move to pointer for linear and linear region selector (#855)
* fix move to pointer for liner and linear region selctor * Update fastplotlib/graphics/selectors/_base_selector.py
1 parent 09db45d commit 72a3f02

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

fastplotlib/graphics/selectors/_base_selector.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def _move(self, ev):
323323
# if it was disabled, keep it disabled
324324
self._plot_area.controller.enabled = self._initial_controller_state
325325

326-
def _move_graphic(self, delta: np.ndarray):
326+
def _move_graphic(self, move_info: MoveInfo):
327327
raise NotImplementedError("Must be implemented in subclass")
328328

329329
def _move_end(self, ev):
@@ -384,8 +384,9 @@ def _move_to_pointer(self, ev):
384384
# else use an edge, such as for linear selector
385385
else:
386386
move_info = MoveInfo(
387-
start_position=current_pos_world,
388-
last_position=current_pos_world,
387+
start_position=None,
388+
start_selection=None,
389+
delta=delta,
389390
source=self._edges[0],
390391
)
391392

fastplotlib/graphics/selectors/_linear_region.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ def _move_graphic(self, move_info: MoveInfo):
381381
cur_min, cur_max = move_info.start_selection
382382

383383
# move entire selector if event source was fill
384-
if self._move_info.source == self.fill:
384+
if move_info.source == self.fill:
385385
# Limit the delta to avoid weird resizine behavior
386386
min_delta = self.limits[0] - cur_min
387387
max_delta = self.limits[1] - cur_max
@@ -396,12 +396,12 @@ def _move_graphic(self, move_info: MoveInfo):
396396

397397
# if event source was an edge and selector is resizable,
398398
# move the edge that caused the event
399-
if self._move_info.source == self.edges[0]:
399+
if move_info.source == self.edges[0]:
400400
# change only left or bottom bound
401401
new_min = min(cur_min + delta, cur_max)
402402
self._selection.set_value(self, (new_min, cur_max))
403403

404-
elif self._move_info.source == self.edges[1]:
404+
elif move_info.source == self.edges[1]:
405405
# change only right or top bound
406406
new_max = max(cur_max + delta, cur_min)
407407
self._selection.set_value(self, (cur_min, new_max))

fastplotlib/graphics/selectors/_rectangle.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ def _move_graphic(self, move_info: MoveInfo):
491491
xmin, xmax, ymin, ymax = move_info.start_selection
492492

493493
# move entire selector if source is fill
494-
if self._move_info.source == self.fill:
494+
if move_info.source == self.fill:
495495
# Limit the delta to avoid weird resizine behavior
496496
min_deltax = self.limits[0] - xmin
497497
max_deltax = self.limits[1] - xmax
@@ -514,22 +514,22 @@ def _move_graphic(self, move_info: MoveInfo):
514514
ymin_new = min(ymin + deltay, ymax)
515515
ymax_new = max(ymax + deltay, ymin)
516516

517-
if self._move_info.source == self.vertices[0]: # bottom left
517+
if move_info.source == self.vertices[0]: # bottom left
518518
self._selection.set_value(self, (xmin_new, xmax, ymin_new, ymax))
519-
if self._move_info.source == self.vertices[1]: # bottom right
519+
if move_info.source == self.vertices[1]: # bottom right
520520
self._selection.set_value(self, (xmin, xmax_new, ymin_new, ymax))
521-
if self._move_info.source == self.vertices[2]: # top left
521+
if move_info.source == self.vertices[2]: # top left
522522
self._selection.set_value(self, (xmin_new, xmax, ymin, ymax_new))
523-
if self._move_info.source == self.vertices[3]: # top right
523+
if move_info.source == self.vertices[3]: # top right
524524
self._selection.set_value(self, (xmin, xmax_new, ymin, ymax_new))
525525
# if event source was an edge and selector is resizable, move the edge that caused the event
526-
if self._move_info.source == self.edges[0]:
526+
if move_info.source == self.edges[0]:
527527
self._selection.set_value(self, (xmin_new, xmax, ymin, ymax))
528-
if self._move_info.source == self.edges[1]:
528+
if move_info.source == self.edges[1]:
529529
self._selection.set_value(self, (xmin, xmax_new, ymin, ymax))
530-
if self._move_info.source == self.edges[2]:
530+
if move_info.source == self.edges[2]:
531531
self._selection.set_value(self, (xmin, xmax, ymin_new, ymax))
532-
if self._move_info.source == self.edges[3]:
532+
if move_info.source == self.edges[3]:
533533
self._selection.set_value(self, (xmin, xmax, ymin, ymax_new))
534534

535535
def _move_to_pointer(self, ev):

0 commit comments

Comments
 (0)