Skip to content

fix move to pointer for linear and linear region selector #855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions fastplotlib/graphics/selectors/_base_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def _move(self, ev):
# if it was disabled, keep it disabled
self._plot_area.controller.enabled = self._initial_controller_state

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

def _move_end(self, ev):
Expand Down Expand Up @@ -384,8 +384,9 @@ def _move_to_pointer(self, ev):
# else use an edge, such as for linear selector
else:
move_info = MoveInfo(
start_position=current_pos_world,
last_position=current_pos_world,
start_position=None,
start_selection=None,
delta=delta,
source=self._edges[0],
)

Expand Down
6 changes: 3 additions & 3 deletions fastplotlib/graphics/selectors/_linear_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def _move_graphic(self, move_info: MoveInfo):
cur_min, cur_max = move_info.start_selection

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

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

elif self._move_info.source == self.edges[1]:
elif move_info.source == self.edges[1]:
# change only right or top bound
new_max = max(cur_max + delta, cur_min)
self._selection.set_value(self, (cur_min, new_max))
18 changes: 9 additions & 9 deletions fastplotlib/graphics/selectors/_rectangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ def _move_graphic(self, move_info: MoveInfo):
xmin, xmax, ymin, ymax = move_info.start_selection

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

if self._move_info.source == self.vertices[0]: # bottom left
if move_info.source == self.vertices[0]: # bottom left
self._selection.set_value(self, (xmin_new, xmax, ymin_new, ymax))
if self._move_info.source == self.vertices[1]: # bottom right
if move_info.source == self.vertices[1]: # bottom right
self._selection.set_value(self, (xmin, xmax_new, ymin_new, ymax))
if self._move_info.source == self.vertices[2]: # top left
if move_info.source == self.vertices[2]: # top left
self._selection.set_value(self, (xmin_new, xmax, ymin, ymax_new))
if self._move_info.source == self.vertices[3]: # top right
if move_info.source == self.vertices[3]: # top right
self._selection.set_value(self, (xmin, xmax_new, ymin, ymax_new))
# if event source was an edge and selector is resizable, move the edge that caused the event
if self._move_info.source == self.edges[0]:
if move_info.source == self.edges[0]:
self._selection.set_value(self, (xmin_new, xmax, ymin, ymax))
if self._move_info.source == self.edges[1]:
if move_info.source == self.edges[1]:
self._selection.set_value(self, (xmin, xmax_new, ymin, ymax))
if self._move_info.source == self.edges[2]:
if move_info.source == self.edges[2]:
self._selection.set_value(self, (xmin, xmax, ymin_new, ymax))
if self._move_info.source == self.edges[3]:
if move_info.source == self.edges[3]:
self._selection.set_value(self, (xmin, xmax, ymin, ymax_new))

def _move_to_pointer(self, ev):
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy