Scroll cursor into view when moving cursor

This commit is contained in:
Isaiah Odhner 2024-11-08 18:51:51 -05:00
parent e8cc107f55
commit 62db73e328
2 changed files with 10 additions and 0 deletions

View File

@ -42,6 +42,7 @@ Header.-tall HeaderIcon {
#canvas {
width: auto;
height: auto;
/* Note: styles.margin is used in cursor position calculations (could be changed to use difference between absolute regions of parent and child or something...) */
margin: 1 2;
}

View File

@ -3199,6 +3199,15 @@ Columns: {len(self.palette) // 2}
self.image.selection.copy_from_document(self.image)
self.canvas.refresh_scaled_region(select_region)
# Scroll the canvas area if needed.
# TODO: prevent animation for small movements, maybe ideally preserving it for page up/down and home/end.
self.editing_area.scroll_to_region(Region(
x * self.magnification + self.canvas.styles.margin.left,
y * self.magnification + self.canvas.styles.margin.top,
self.magnification,
self.magnification,
))
self.canvas.refresh_scaled_region(textbox.region)
def on_paste(self, event: events.Paste) -> None: