pcadmin/src/bar/draw.c

26 lines
824 B
C
Raw Normal View History

2021-04-16 11:08:47 +02:00
#include "bar.h"
2021-05-24 11:07:56 +02:00
#include <gint/display.h>
2021-04-16 11:08:47 +02:00
void
bar_draw(struct Bar bar)
{
2021-05-24 11:07:56 +02:00
const int height = bar.fill * (float)bar.height;
const int low_y = bar.y + bar.height;
const int high_y = bar.y - bar.limit_height + bar.height - height;
int i;
2021-05-24 11:07:56 +02:00
/* borders */
drect(bar.x, bar.y - bar.limit_height, bar.x + BAR_WIDTH - 1,
low_y + bar.limit_height - 1, C_BLACK);
/* draw lower limit */
dsubimage(bar.x, low_y, &bimg_bar3, 0, bar.limit_height + 1,
bimg_bar3.width, bar.limit_height, DIMAGE_NOCLIP);
/* draw higher limit */
dsubimage(bar.x, high_y, &bimg_bar3, 0, 0, bimg_bar3.width,
bar.limit_height, DIMAGE_NOCLIP);
/* draw fill */
for (i = high_y + bar.limit_height; i < low_y; i += 1)
dsubimage(bar.x, i, &bimg_bar3, 0, bar.limit_height,
bimg_bar3.width, 1, DIMAGE_NOCLIP);
2021-04-16 11:08:47 +02:00
}