shithub: vcrop

Download patch

ref: b3d399a6aad96527b79dfe254ee11eb54df9ee4a
parent: b404464b2e4bf770168fd670ea9fb662d9dbca32
author: phil9 <telephil9@gmail.com>
date: Sat Jan 23 00:47:08 EST 2021

restore previous image position on undo

	we now keep track of the panning before cropping image so that it can be
	restored in case of undo

--- a/vcrop.c	Sat Jan 23 00:41:48 2021
+++ b/vcrop.c	Sat Jan 23 00:47:08 2021
@@ -12,7 +12,7 @@
 Image *bg;
 Image *p;
 Image *n;
-Point pos;
+Point pos, oldpos;
 enum { Mcrop, Mundo, Msave, Mexit };
 char  *menustr[] = { "crop", "undo", "save", "exit", 0 };
 Menu   menu = { menustr };
@@ -57,6 +57,7 @@
 		freeimage(p);
 	p = n;
 	n = i;
+	oldpos = pos;
 	pos = subpt(ZP, n->r.min);
 	eresized(0);
 }
@@ -87,6 +88,7 @@
 	freeimage(n);
 	n = p;
 	p = nil;
+	pos = oldpos;
 	eresized(0);
 }
 
@@ -145,6 +147,7 @@
 	close(fd);
 	p = nil;
 	pos = subpt(ZP, n->r.min);
+	oldpos = pos;
 	eresized(0);
 	for(;;){
 		e = event(&ev);