add disabled widgets

This commit is contained in:
IoIxD 2026-05-22 11:41:08 -07:00
commit 149f99622a
7 changed files with 91 additions and 20 deletions

View file

@ -76,10 +76,22 @@ static MwFLFont assume_ttf(MwWidget handle, MwFLFont ttf) {
#endif
void MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, int align, MwLLColor color) {
MwPoint p = *point;
char* input = (char*)text;
char* last = input;
int cp;
MwPoint p = *point;
char* input = (char*)text;
char* last = input;
int cp;
MwLLColor fadedColor = NULL;
if(MwGetInteger(handle, MwNdisabled) == 1) {
MwLLColor c = handle->parent == NULL ? NULL : MwParseColor(handle->parent, MwGetText(handle->parent, MwNbackground));
if(c != NULL) {
fadedColor = MwLLAllocColor(handle->lowlevel, color->common.red, color->common.blue, color->common.green);
fadedColor->common.red = fadedColor->common.red + (c->common.red - fadedColor->common.red) * 0.5;
fadedColor->common.green = fadedColor->common.green + (c->common.green - fadedColor->common.green) * 0.5;
fadedColor->common.blue = fadedColor->common.blue + (c->common.blue - fadedColor->common.blue) * 0.5;
}
}
#ifdef TTF
if(ttf <= MwFLBuildFont(0xff) && !is_bitmap(handle, ttf)) ttf = assume_ttf(handle, ttf);
@ -122,9 +134,9 @@ void MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text,
#ifdef TTF
if(MwFLDrawText)
if(is_bitmap(handle, ttf) || ttf == NULL || MwFLDrawText(handle, ttf, &p, line, color))
if(is_bitmap(handle, ttf) || ttf == NULL || MwFLDrawText(handle, ttf, &p, line, fadedColor ? fadedColor : color))
#endif
bitmap_MwDrawText(handle, &p, line, is_bold(handle, ttf), color);
bitmap_MwDrawText(handle, &p, line, is_bold(handle, ttf), fadedColor ? fadedColor : color);
p.y += MwTextHeight(handle, ttf, line);
@ -133,6 +145,10 @@ void MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text,
last = input;
}
}
if(fadedColor) {
MwLLFreeColor(fadedColor);
}
}
int MwTextWidth(MwWidget handle, MwFLFont ttf, const char* text) {