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
|
|
|
|
2021-05-26 10:42:24 +02:00
|
|
|
extern bopti_image_t *vimg_bar3;
|
|
|
|
|
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;
|
2021-05-26 00:07:55 +02:00
|
|
|
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 */
|
2021-05-26 00:07:55 +02:00
|
|
|
drect(bar.x, bar.y - bar.limit_height, bar.x + BAR_WIDTH - 1,
|
|
|
|
low_y + bar.limit_height - 1, C_BLACK);
|
|
|
|
/* draw lower limit */
|
2021-05-26 10:42:24 +02:00
|
|
|
dsubimage(bar.x, low_y, vimg_bar3, 0, bar.limit_height + 1,
|
|
|
|
vimg_bar3->width, bar.limit_height, DIMAGE_NOCLIP);
|
2021-05-26 00:07:55 +02:00
|
|
|
/* draw higher limit */
|
2021-05-26 10:42:24 +02:00
|
|
|
dsubimage(bar.x, high_y, vimg_bar3, 0, 0, vimg_bar3->width,
|
2021-05-26 00:07:55 +02:00
|
|
|
bar.limit_height, DIMAGE_NOCLIP);
|
|
|
|
/* draw fill */
|
|
|
|
for (i = high_y + bar.limit_height; i < low_y; i += 1)
|
2021-05-26 10:42:24 +02:00
|
|
|
dsubimage(bar.x, i, vimg_bar3, 0, bar.limit_height,
|
|
|
|
vimg_bar3->width, 1, DIMAGE_NOCLIP);
|
2021-05-26 00:29:23 +02:00
|
|
|
/* draw icons */
|
|
|
|
dsubimage(bar.x, BAR_ICON_Y, &bimg_icons, BAR_ICON_WIDTH * bar.id, 0,
|
|
|
|
BAR_ICON_WIDTH, BAR_ICON_HEIGHT, DIMAGE_NOCLIP);
|
2021-04-16 11:08:47 +02:00
|
|
|
}
|