acme: fix rounding in rows computation

R=rsc
CC=codebot
http://codereview.appspot.com/2007045
This commit is contained in:
Rob Pike 2010-08-24 10:16:32 -04:00 committed by Russ Cox
parent a06877afa9
commit a208917e7a
2 changed files with 8 additions and 4 deletions

View file

@ -21,8 +21,9 @@ Mathieu Lonjaret <mathieu.lonjaret@gmail.com>
Michael Teichgräber <mt4swm@googlemail.com> Michael Teichgräber <mt4swm@googlemail.com>
Michael Teichgräber <mt@ib.wmipf.de> Michael Teichgräber <mt@ib.wmipf.de>
Nikolai Saoukh <nikolai.saoukh@gmail.com> Nikolai Saoukh <nikolai.saoukh@gmail.com>
Rob Pike <robpike@gmail.com>
Russ Cox <rsc@swtch.com> Russ Cox <rsc@swtch.com>
Tim Newsham <tim.newsham@gmail.com> Tim Newsham <tim.newsham@gmail.com>
Tony Lainson <t.lainson@gmail.com> Tony Lainson <t.lainson@gmail.com>
Venkatesh Srinivas <extrudedaluminiu@gmail.com> Venkatesh Srinivas <extrudedaluminiu@gmail.com>
grai <t.lainson@gmail.com>

View file

@ -102,12 +102,14 @@ rowadd(Row *row, Column *c, int x)
void void
rowresize(Row *row, Rectangle r) rowresize(Row *row, Rectangle r)
{ {
int i, dx, odx; int i, dx, odx, deltax;
Rectangle r1, r2; Rectangle or, r1, r2;
Column *c; Column *c;
dx = Dx(r); dx = Dx(r);
odx = Dx(row->r); odx = Dx(row->r);
or = row->r;
deltax = r.min.x - or.min.x;
row->r = r; row->r = r;
r1 = r; r1 = r;
r1.max.y = r1.min.y + font->height; r1.max.y = r1.min.y + font->height;
@ -121,10 +123,11 @@ rowresize(Row *row, Rectangle r)
for(i=0; i<row->ncol; i++){ for(i=0; i<row->ncol; i++){
c = row->col[i]; c = row->col[i];
r1.min.x = r1.max.x; r1.min.x = r1.max.x;
/* the test should not be necessary, but guarantee we don't lose a pixel */
if(i == row->ncol-1) if(i == row->ncol-1)
r1.max.x = r.max.x; r1.max.x = r.max.x;
else else
r1.max.x = r1.min.x+Dx(c->r)*dx/odx; r1.max.x = (c->r.max.x-or.min.x)*Dx(r)/Dx(or) + deltax;
if(i > 0){ if(i > 0){
r2 = r1; r2 = r1;
r2.max.x = r2.min.x+Border; r2.max.x = r2.min.x+Border;