pcadmin/src/bar/draw.c

29 lines
973 B
C

#include "bar.h"
#include <gint/display.h>
void
bar_draw(struct Bar bar)
{
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;
/* 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);
/* draw icons */
dsubimage(bar.x, BAR_ICON_Y, &bimg_icons, BAR_ICON_WIDTH * bar.id, 0,
BAR_ICON_WIDTH, BAR_ICON_HEIGHT, DIMAGE_NOCLIP);
}