mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-31 01:11:12 +02:00
progressbar: make sure colormodes stay inside the box
This commit is contained in:
@@ -192,7 +192,6 @@ void CProgressBar::realpaint(const int pos_x, const int pos_y,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
int itemw = ITEMW, itemh = ITEMW, pointx = POINT, pointy = POINT;
|
int itemw = ITEMW, itemh = ITEMW, pointx = POINT, pointy = POINT;
|
||||||
int hcnt = height / itemh; /* how many POINTs is the bar high */
|
|
||||||
switch ((pb_color_t)g_settings.progressbar_color)
|
switch ((pb_color_t)g_settings.progressbar_color)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
@@ -201,7 +200,6 @@ void CProgressBar::realpaint(const int pos_x, const int pos_y,
|
|||||||
case PB_LINES_V: /* vert. lines */
|
case PB_LINES_V: /* vert. lines */
|
||||||
itemh = height;
|
itemh = height;
|
||||||
pointy = height;
|
pointy = height;
|
||||||
hcnt = 0;
|
|
||||||
break;
|
break;
|
||||||
case PB_LINES_H: /* horiz. lines */
|
case PB_LINES_H: /* horiz. lines */
|
||||||
itemw = POINT;
|
itemw = POINT;
|
||||||
@@ -210,9 +208,12 @@ void CProgressBar::realpaint(const int pos_x, const int pos_y,
|
|||||||
itemw = POINT;
|
itemw = POINT;
|
||||||
itemh = height;
|
itemh = height;
|
||||||
pointy = height;
|
pointy = height;
|
||||||
hcnt = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
const int spc = itemh - pointy; /* space between horizontal lines / points */
|
||||||
|
int hcnt = (height + spc) / itemh; /* how many POINTs is the bar high */
|
||||||
|
int yoff = (height + spc - itemh * hcnt) / 2;
|
||||||
|
//printf("height: %d itemh: %d hcnt: %d yoff: %d spc: %d\n", height, itemh, hcnt, yoff, spc);
|
||||||
/* red, yellow, green are given in percent */
|
/* red, yellow, green are given in percent */
|
||||||
int rd = red * width / (100 * itemw); /* how many POINTs red */
|
int rd = red * width / (100 * itemw); /* how many POINTs red */
|
||||||
int yw = yellow * width / (100 * itemw); /* how many POINTs yellow */
|
int yw = yellow * width / (100 * itemw); /* how many POINTs yellow */
|
||||||
@@ -234,6 +235,7 @@ void CProgressBar::realpaint(const int pos_x, const int pos_y,
|
|||||||
|
|
||||||
if (active_pb_width != last_width) {
|
if (active_pb_width != last_width) {
|
||||||
int i, j;
|
int i, j;
|
||||||
|
const int py = pos_y + yoff;
|
||||||
if (active_pb_width > last_width) {
|
if (active_pb_width > last_width) {
|
||||||
int step, off;
|
int step, off;
|
||||||
int b = 0;
|
int b = 0;
|
||||||
@@ -245,8 +247,8 @@ void CProgressBar::realpaint(const int pos_x, const int pos_y,
|
|||||||
else
|
else
|
||||||
rgb = RED + (diff << 8); // adding green
|
rgb = RED + (diff << 8); // adding green
|
||||||
color = make16color(rgb);
|
color = make16color(rgb);
|
||||||
for(j = 0; j <= hcnt; j++)
|
for (j = 0; j < hcnt; j++)
|
||||||
frameBuffer->paintBoxRel(pos_x + i * itemw, pos_y + j * itemh,
|
frameBuffer->paintBoxRel(pos_x + i * itemw, py + j * itemh,
|
||||||
pointx, pointy, color);
|
pointx, pointy, color);
|
||||||
}
|
}
|
||||||
step = yw - rd - 1;
|
step = yw - rd - 1;
|
||||||
@@ -259,8 +261,8 @@ void CProgressBar::realpaint(const int pos_x, const int pos_y,
|
|||||||
else
|
else
|
||||||
rgb = YELLOW - (diff << 16); // removing red
|
rgb = YELLOW - (diff << 16); // removing red
|
||||||
color = make16color(rgb);
|
color = make16color(rgb);
|
||||||
for(j = 0; j <= hcnt; j++)
|
for (j = 0; j < hcnt; j++)
|
||||||
frameBuffer->paintBoxRel(pos_x + i * itemw, pos_y + j * itemh,
|
frameBuffer->paintBoxRel(pos_x + i * itemw, py + j * itemh,
|
||||||
pointx, pointy, color);
|
pointx, pointy, color);
|
||||||
}
|
}
|
||||||
off = diff;
|
off = diff;
|
||||||
@@ -275,14 +277,14 @@ void CProgressBar::realpaint(const int pos_x, const int pos_y,
|
|||||||
else
|
else
|
||||||
rgb = YELLOW - (diff << 16); // removing red
|
rgb = YELLOW - (diff << 16); // removing red
|
||||||
color = make16color(rgb);
|
color = make16color(rgb);
|
||||||
for(j = 0; j <= hcnt; j++)
|
for (j = 0; j < hcnt; j++)
|
||||||
frameBuffer->paintBoxRel(pos_x + i * itemw, pos_y + j * itemh,
|
frameBuffer->paintBoxRel(pos_x + i * itemw, py + j * itemh,
|
||||||
pointx, pointy, color);
|
pointx, pointy, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(i = maxi; i < total; i++) {
|
for(i = maxi; i < total; i++) {
|
||||||
for(j = 0; j <= hcnt; j++)
|
for (j = 0; j < hcnt; j++)
|
||||||
frameBuffer->paintBoxRel(pos_x + i * itemw, pos_y + j * itemh,
|
frameBuffer->paintBoxRel(pos_x + i * itemw, py + j * itemh,
|
||||||
pointx, pointy, COL_INFOBAR_PLUS_3);//fill passive
|
pointx, pointy, COL_INFOBAR_PLUS_3);//fill passive
|
||||||
}
|
}
|
||||||
last_width = active_pb_width;
|
last_width = active_pb_width;
|
||||||
|
Reference in New Issue
Block a user