void renderwidget(skin_t *skin, image *dest, widget *item, int state) { image *img = NULL; int height; int y; if(!dest) return; if((item->type == tyButton) || (item->type == tyHpotmeter) || (item->type == tyPotmeter)) img = item->bitmap[0]; if(!img) return; y = item->y; if(item->type == tyPotmeter) { height = img->height / item->phases; y = height * (int)(item->value * item->phases / 100); if(y > img->height-height) y = img->height - height; } else { height = img->height / 3; y = state * height; } /* redraw background */ if(item->type == tyButton) render(skin->desktopbpp, dest, find_background(skin,item), item->x, item->y, item->x, item->y, img->width, height, 1); if((item->type == tyHpotmeter) || (item->type == tyPotmeter)) { /* repaint the area behind the slider */ render(skin->desktopbpp, dest, find_background(skin, item), item->wx, item->wy, item->wx, item->wy, item->wwidth, item->height, 1); item->x = item->value * (item->wwidth-item->width) / 100 + item->wx; if((item->x + item->width) > (item->wx + item->wwidth)) item->x = item->wx + item->wwidth - item->width; if(item->x < item->wx) item->x = item->wx; /* workaround for blue */ if(item->type == tyHpotmeter) height = (item->height < img->height / 3) ? item->height : img->height / 3; } render(skin->desktopbpp, dest, img, item->x, item->y, 0, y, img->width, height, 1); }
void renderwidget(skin_t *skin, image *dest, widget *item, int state) { image *img = NULL; int height; int y; if(!dest) return; if((item->type == tyButton) || (item->type == tyHpotmeter) || (item->type == tyVpotmeter) || (item->type == tyPimage)) img = item->bitmap[0]; if(item->type == tyRpotmeter) img = item->bitmap[1]; if(!img) return; y = item->y; if(item->type == tyPimage || /* legacy (potmeter) */ (item->type == tyHpotmeter && item->width == item->wwidth) || item->type == tyRpotmeter) { height = img->height / item->phases; y = height * (int)(item->value * item->phases / 100); if(y > img->height-height) y = img->height - height; } else { height = img->height / 3; y = state * height; } /* redraw background */ if(item->type == tyButton) render(skin->desktopbpp, dest, find_background(skin,item), item->x, item->y, item->x, item->y, img->width, height, 1); if((item->type == tyHpotmeter) || (item->type == tyVpotmeter) || (item->type == tyRpotmeter) || (item->type == tyPimage)) { if(item->type == tyVpotmeter) { /* repaint the area behind the slider */ render(skin->desktopbpp, dest, find_background(skin, item), item->wx, item->wy, item->wx, item->wy, item->width, item->wheight, 1); item->y = (100 - item->value) * (item->wheight-item->height) / 100 + item->wy; } else if(item->type == tyRpotmeter) { /* repaint the area behind the rpotmeter */ render(skin->desktopbpp, dest, find_background(skin, item), item->wx, item->wy, item->wx, item->wy, item->wwidth, item->wheight, 1); item->x = item->wx; item->y = item->wy; } else { /* repaint the area behind the slider */ render(skin->desktopbpp, dest, find_background(skin, item), item->wx, item->wy, item->wx, item->wy, item->wwidth, item->height, 1); item->x = item->value * (item->wwidth-item->width) / 100 + item->wx; } } render(skin->desktopbpp, dest, img, item->x, item->y, 0, y, img->width, height, 1); /* rpotmeter button */ if(item->type == tyRpotmeter && item->bitmap[0] != item->bitmap[1]) { img = item->bitmap[0]; if(img) { double radius, radian; int ix, iy; // keep the button inside the potmeter outline radius = (FFMIN(item->wwidth, item->wheight) - item->maxwh) / 2.0; radian = item->value / 100.0 * item->arclength + item->zeropoint; // coordinates plus a correction for a non-square item // (remember: both axes are mirrored, we have a clockwise radian) ix = item->wx + radius * (1 + cos(radian)) + FFMAX(0, (item->wwidth - item->wheight) / 2.0) + 0.5; iy = item->wy + radius * (1 + sin(radian)) + FFMAX(0, (item->wheight - item->wwidth) / 2.0) + 0.5; height = img->height / 3; y = state * height; render(skin->desktopbpp, dest, img, ix, iy, 0, y, img->width, height, 1); } } }
/* updates all dlabels and slabels */ void renderinfobox(skin_t *skin, window_priv_t *priv) { unsigned int i; if (!priv) return; /* repaint the area behind the text*/ /* we have to do this for all labels here, because they may overlap in buggy skins ;( */ for (i=0; i<skin->widgetcount; i++) if((skin->widgets[i]->type == tyDlabel) || (skin->widgets[i]->type == tySlabel)) { if(skin->widgets[i]->window == priv->type) render(skin->desktopbpp, &priv->img, find_background(skin, skin->widgets[i]), skin->widgets[i]->x, skin->widgets[i]->y, skin->widgets[i]->x, skin->widgets[i]->y, skin->widgets[i]->length, skin->widgets[i]->font->chars[0]->height, 1); } /* load all slabels and dlabels */ for (i=0; i<skin->widgetcount; i++) { widget *item = skin->widgets[i]; if(item->window != priv->type) continue; if((i == skin->widgetcount) || (item->type == tyDlabel) || (item->type == tySlabel)) { char *text = generatetextfromlabel(item); unsigned int current, c; int offset = 0; unsigned int textlen; if(!text) continue; textlen = strlen(text); /* render(win, win->background, gui->skin->widgets[i]->x, gui->skin->widgets[i]->y, gui->skin->widgets[i]->x, gui->skin->widgets[i]->y, gui->skin->widgets[i]->length, gui->skin->widgets[i]->font->chars[0]->height,1); */ /* calculate text size */ for (current=0; current<textlen; current++) { for (c=0; c<item->font->charcount; c++) if(item->font->chars[c]->c == text[current]) { offset += item->font->chars[c]->width; break; } } /* labels can be scrolled if they are to big */ if((item->type == tyDlabel) && (item->length < offset)) { int tomuch = (offset - item->length) / (offset /textlen); scrolltext(text, textlen - tomuch - 1, &skin->widgets[i]->value); textlen = strlen(text); } /* align the text */ if(item->align == 1) offset = (item->length-offset) / 2; else if(item->align == 2) offset = item->length-offset; else offset = 0; if(offset < 0) offset = 0; /* render the text */ for (current=0; current<textlen; current++) { for (c=0; c<item->font->charcount; c++) { char_t *cchar = item->font->chars[c]; if(cchar->c == *(text + current)) { render(skin->desktopbpp, &priv->img, item->font->image, item->x + offset, item->y, cchar->x, cchar->y, (cchar->width + offset > item->length) ? item->length - offset : cchar->width, cchar->height, 1); offset += cchar->width; break; } } } free(text); } } }