From b04e1a76a649a790df3228a5ec9391e70342a81d Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Thu, 16 Oct 2025 05:58:04 +0000 Subject: [PATCH] cleanup git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@349 b9cfdab3-6d41-4d17-bbe4-086880011989 --- include/Mw/Draw.h | 21 ------------------- src/draw.c | 48 +++++++++----------------------------------- src/widget/listbox.c | 2 +- 3 files changed, 10 insertions(+), 61 deletions(-) diff --git a/include/Mw/Draw.h b/include/Mw/Draw.h index 31216f0..7a993d1 100644 --- a/include/Mw/Draw.h +++ b/include/Mw/Draw.h @@ -82,18 +82,6 @@ MWDECL void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int in */ MWDECL void MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color); -/*! - * %brief Draws a text - * %param handle Widget - * %param point Center point of the text - * %param text Text - * %param bold Bold - * %param align Align - * %param color Color - * %param bgcolor Background color - */ -MWDECL void MwDrawTextEx(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color, MwLLColor bgcolor); - /*! * %brief Creates a pixmap from image * %param handle Widget @@ -145,15 +133,6 @@ MWDECL MwLLPixmap MwLoadRaw(MwWidget handle, unsigned char* rgb, int width, int */ MWDECL MwLLPixmap MwLoadXPM(MwWidget handle, char** data); -/*! - * %brief Creates a pixmap from XPM data with background - * %param handle Widget - * %param data Data - * %param bgcolor RGBA data for background - * %return Pixmap - */ -MWDECL MwLLPixmap MwLoadXPMEx(MwWidget handle, char** data, unsigned char* bgcolor); - /* color.c */ /*! diff --git a/src/draw.c b/src/draw.c index 86a3d6b..daca390 100644 --- a/src/draw.c +++ b/src/draw.c @@ -363,12 +363,6 @@ void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, } void MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color) { - MwLLColor bg = MwParseColor(handle, MwGetText(handle, MwNbackground)); - MwDrawTextEx(handle, point, text, bold, align, color, bg); - MwLLFreeColor(bg); -} - -void MwDrawTextEx(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color, MwLLColor bgcolor) { int i = 0, x, y, sx, sy; int tw = MwTextWidth(handle, text); int th = MwTextHeight(handle, text); @@ -400,10 +394,10 @@ void MwDrawTextEx(MwWidget handle, MwPoint* point, const char* text, int bold, i ppx[2] = color->blue; ppx[3] = 255; } else { - ppx[0] = bgcolor->red; - ppx[1] = bgcolor->green; - ppx[2] = bgcolor->blue; - ppx[3] = 255; + ppx[0] = 0; + ppx[1] = 0; + ppx[2] = 0; + ppx[3] = 0; } } } @@ -604,26 +598,9 @@ MwLLPixmap MwLoadImage(MwWidget handle, const char* path) { MwLLPixmap MwLoadRaw(MwWidget handle, unsigned char* rgb, int width, int height) { MwLLPixmap px; - MwLLColor bg = MwParseColor(handle, MwGetText(handle, MwNbackground)); - unsigned char* out = malloc(width * height * 4); - int y, x; - for(y = 0; y < height; y++) { - for(x = 0; x < width; x++) { - unsigned char* pin = &rgb[(y * width + x) * 4]; - unsigned char* pout = &out[(y * width + x) * 4]; - pout[0] = pin[0] * (pin[3] / 255.0) + bg->red * (1.0 - pin[3] / 255.0); - pout[1] = pin[1] * (pin[3] / 255.0) + bg->green * (1.0 - pin[3] / 255.0); - pout[2] = pin[2] * (pin[3] / 255.0) + bg->blue * (1.0 - pin[3] / 255.0); - pout[3] = 255; - } - } - - MwLLFreeColor(bg); px = MwLLCreatePixmap(handle->lowlevel, rgb, width, height); - free(out); - return px; } @@ -642,7 +619,7 @@ typedef struct color { int a; } color_t; -MwLLPixmap MwLoadXPMEx(MwWidget handle, char** data, unsigned char* bgcolor) { +MwLLPixmap MwLoadXPM(MwWidget handle, char** data) { int col, row, colors, cpp; unsigned char* rgb; MwLLPixmap px; @@ -665,10 +642,10 @@ MwLLPixmap MwLoadXPMEx(MwWidget handle, char** data, unsigned char* bgcolor) { shput(c, k, v); ind = shgeti(c, k); - c[ind].r = bgcolor[0]; - c[ind].g = bgcolor[1]; - c[ind].b = bgcolor[2]; - c[ind].a = bgcolor[3]; + c[ind].r = 0; + c[ind].g = 0; + c[ind].b = 0; + c[ind].a = 0; } else { MwLLColor color = MwParseColor(handle, v); @@ -714,10 +691,3 @@ MwLLPixmap MwLoadXPMEx(MwWidget handle, char** data, unsigned char* bgcolor) { return px; } - -MwLLPixmap MwLoadXPM(MwWidget handle, char** data) { - unsigned char rgba[4]; - memset(rgba, 0, 4); - - return MwLoadXPMEx(handle, data, rgba); -} diff --git a/src/widget/listbox.c b/src/widget/listbox.c index a51f995..d29609c 100644 --- a/src/widget/listbox.c +++ b/src/widget/listbox.c @@ -104,7 +104,7 @@ static void frame_draw(MwWidget handle) { MwDrawRect(handle, &r2, text); } p.y += MwTextHeight(handle, lb->list[i]) / 2; - MwDrawTextEx(handle, &p, lb->list[i], 0, MwALIGNMENT_BEGINNING, selected ? base : text, selected ? text : base); + MwDrawText(handle, &p, lb->list[i], 0, MwALIGNMENT_BEGINNING, selected ? base : text); p.y += MwTextHeight(handle, lb->list[i]) / 2; }