pcadmin/src/bar/draw.c

31 lines
1007 B
C

#include "bar.h"
#include <gint/display.h>
extern bopti_image_t *vimg_bar3;
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, vimg_bar3, 0, bar.limit_height + 1,
vimg_bar3->width, bar.limit_height, DIMAGE_NOCLIP);
/* draw higher limit */
dsubimage(bar.x, high_y, vimg_bar3, 0, 0, vimg_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, vimg_bar3, 0, bar.limit_height,
vimg_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);
}