mirror of
https://github.com/1j01/textual-paint.git
synced 2024-09-11 15:56:03 +03:00
Re-color in-progress polygon/curve immediately
This commit is contained in:
parent
ad39f34084
commit
91b2c285fe
@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
- Fixed behavior of Free-Form Select tool when melding with the canvas, when the selection was off-screen to the left or top (i.e. with negative coordinates).
|
||||
- Fixed Polygon tool closing the polygon when clicking quickly but moving between clicks, detected as a double-click.
|
||||
- In-progress curves/polygons are now re-colored immediately when a color is selected, instead of only when mousing over the canvas.
|
||||
|
||||
## [0.2.0] - 2023-09-05
|
||||
|
||||
|
@ -295,6 +295,9 @@ class PaintApp(App[None]):
|
||||
self.image.selection.contained_image.bg[y][x] = self.selected_bg_color
|
||||
self.canvas.refresh_scaled_region(self.image.selection.region)
|
||||
|
||||
# update Polygon/Curve tool preview immediately
|
||||
self.on_canvas_tool_preview_update(Canvas.ToolPreviewUpdate(events.MouseMove(-100, -100, 0, 0, 0, False, False, False)))
|
||||
|
||||
def watch_selected_fg_color(self, selected_fg_color: str) -> None:
|
||||
"""Called when selected_fg_color changes."""
|
||||
# self.query_one("#selected_color_char_input", CharInput).styles.color = selected_fg_color
|
||||
@ -309,6 +312,9 @@ class PaintApp(App[None]):
|
||||
self.image.selection.contained_image.fg[y][x] = self.selected_fg_color
|
||||
self.canvas.refresh_scaled_region(self.image.selection.region)
|
||||
|
||||
# update Polygon/Curve tool preview immediately
|
||||
self.on_canvas_tool_preview_update(Canvas.ToolPreviewUpdate(events.MouseMove(-100, -100, 0, 0, 0, False, False, False)))
|
||||
|
||||
def watch_selected_char(self, selected_char: str) -> None:
|
||||
"""Called when selected_char changes."""
|
||||
self.query_one("#selected_color_char_input", CharInput).value = selected_char
|
||||
|
@ -142,7 +142,6 @@ def test_paint_about_paint_dialog(snap_compare: SnapCompareType, each_theme: Non
|
||||
|
||||
assert snap_compare(PAINT, run_before=show_about_paint)
|
||||
|
||||
# TODO: test changing color of in-progress polygon when selecting a color from the palette
|
||||
|
||||
def test_paint_polygon_tool(snap_compare: SnapCompareType):
|
||||
async def draw_polygon(pilot: Pilot[None]):
|
||||
@ -163,13 +162,14 @@ def test_paint_polygon_tool(snap_compare: SnapCompareType):
|
||||
await pilot.click('#canvas', offset=Offset(35, 10))
|
||||
# second shape (defined above) should be closed by double clicking
|
||||
|
||||
await click_by_index(pilot, '#available_colors Button', 17) # yellow
|
||||
await pilot.click('#canvas', offset=Offset(33, 2))
|
||||
await pilot.click('#canvas', offset=Offset(58, 16))
|
||||
await pilot.click('#canvas', offset=Offset(58, 2))
|
||||
await pilot.click('#canvas', offset=Offset(44, 2))
|
||||
await pilot.click('#canvas', offset=Offset(52, 7))
|
||||
# third shape (defined above) should be left open as a polyline
|
||||
# Selecting a color should immediately update the in-progress shape:
|
||||
await click_by_index(pilot, '#available_colors Button', 17) # yellow
|
||||
|
||||
assert snap_compare(PAINT, run_before=draw_polygon, terminal_size=LARGER)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user