mirror of
https://github.com/1j01/textual-paint.git
synced 2024-09-11 15:56:03 +03:00
Fix crash with Polygon tool(s), dragging from outside to inside canvas
When clicking outside the canvas and dragging and releasing over it, several tools exhibited issues, which this commit fixes. - Free-Form Select, Polygon: crash with IndexError - Select: useless selection created - Magnifier, Pick Color: returned to last tool before use
This commit is contained in:
parent
9897266a14
commit
1f5457d992
@ -126,7 +126,6 @@ cat file.ans
|
||||
|
||||
## Known Issues
|
||||
|
||||
- Dragging from outside the canvas to inside with Free-Form Select crashes the program, and with Select makes a stupid selection (using the starting mouse position from the last time you clicked on the canvas).
|
||||
- The Text tool doesn't collapse a text selection when typing. Undo/Redo doesn't work with text. Ctrl+Z will delete the textbox.
|
||||
- Selection box border is inside instead of outside (and lacks dashes). For the text box, I hid the border because it was too visually confusing, but it should also have an outer border.
|
||||
- Pick Color can't be cancelled, since it samples the color continuously.
|
||||
@ -140,6 +139,7 @@ cat file.ans
|
||||
- The program sometimes crashes or freezes randomly, and there's no auto-save feature.
|
||||
- Saved ANSI files are unnecessarily large, because they include escape sequences for every cell, even if the colors match the previous cell.
|
||||
- Loading and saving a file without making any edits can change color values slightly, e.g. 128 → 127. The Color Eraser feature compensates for this with a slight tolerance, but the fill tool does not.
|
||||
- Free-Form Select stamping/finalizing is incorrect when the selection is off-screen to the left or top.
|
||||
|
||||
The program has only been tested on Linux. Issues on other platforms are as-yet _unknown_ :)
|
||||
|
||||
|
18
paint.py
18
paint.py
@ -1151,10 +1151,11 @@ class Canvas(Widget):
|
||||
self.fix_mouse_event(event)
|
||||
event.x //= self.magnification
|
||||
event.y //= self.magnification
|
||||
|
||||
|
||||
if self.pointer_active:
|
||||
self.post_message(self.ToolStop(event))
|
||||
self.pointer_active = False
|
||||
self.capture_mouse(False)
|
||||
self.post_message(self.ToolStop(event))
|
||||
|
||||
def on_leave(self, event: events.Leave) -> None:
|
||||
"""Called when the mouse leaves the canvas. Stop preview if applicable."""
|
||||
@ -2899,13 +2900,12 @@ class PaintApp(App[None]):
|
||||
# Done selecting text
|
||||
self.selecting_text = False
|
||||
return
|
||||
# TODO: FIXME: dragging from outside the canvas shouldn't make a selection
|
||||
# and for Free-Form Select it gets ValueError: min() arg is an empty sequence
|
||||
# - self.mouse_at_start is never unset so it can't be used to check if the mouse is down
|
||||
# - self.canvas.pointer_active is always False during ToolStop currently so I can't use that
|
||||
# I could make it be set to False after ToolStop, but I could also
|
||||
# just make ToolStop not fire if ToolStart didn't fire, right?
|
||||
if self.selected_tool in [Tool.select, Tool.free_form_select, Tool.text] and self.mouse_at_start:
|
||||
|
||||
assert self.mouse_at_start is not None, "mouse_at_start should be set on mouse down"
|
||||
# Note that self.mouse_at_start is not set to None on mouse up,
|
||||
# so it can't be used to check if the mouse is down.
|
||||
# But ToolStop should only happen if the mouse is down.
|
||||
if self.selected_tool in [Tool.select, Tool.free_form_select, Tool.text]:
|
||||
# Finish making a selection
|
||||
if self.selected_tool == Tool.free_form_select:
|
||||
# Find bounds of the polygon
|
||||
|
Loading…
Reference in New Issue
Block a user