From b55f9320bc40a465cd33ddbf6e8c9b7223ae538d Mon Sep 17 00:00:00 2001 From: Christoph Budziszewski Date: Fri, 12 Jun 2020 23:53:05 +0200 Subject: [PATCH] fixed x/y coordinate mixup --- CPUMeter.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CPUMeter.c b/CPUMeter.c index 9c63f41e..99be44f8 100644 --- a/CPUMeter.c +++ b/CPUMeter.c @@ -221,10 +221,11 @@ static void MultiColCPUsMeter_draw(Meter* this, int x, int y, int w){ int ncol = MapClassnameToColumncount(this); int colwidth = (w-ncol)/ncol + 1; int diff = (w - (colwidth * ncol)); + int nrows = (count + ncol - 1) / ncol; for (int i = 0; i < count; i++){ - int d = (i%ncol) > diff ? diff : (i % ncol) ; // dynamic spacer - int xpos = x + ((i % ncol) * colwidth) + d; - int ypos = y + ((i / ncol) * meters[0]->h); + int d = (i/nrows) > diff ? diff : (i / nrows) ; // dynamic spacer + int xpos = x + ((i / nrows) * colwidth) + d; + int ypos = y + ((i % nrows) * meters[0]->h); meters[i]->draw(meters[i], xpos, ypos, colwidth); } }