use MwPolygon/MwLine instead of lowlevel ones
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good

This commit is contained in:
Nishi 2026-09-27 06:09:21 +09:00
commit e591577801
9 changed files with 102 additions and 77 deletions

View file

@ -83,6 +83,23 @@ MWDECL void MWAPI MwDrawRectLine(MwWidget handle, MwRect* rect, MwColor color);
*/
MWDECL void MWAPI MwDrawRectFading(MwWidget handle, MwRect* rect, MwColor color);
/*!
* @brief Draws a polygon
* @param handle Widget
* @param points Points (counter-clockwise)
* @param points_count Amount of points
* @param color Color
*/
MWDECL void MWAPI MwPolygon(MwWidget handle, MwPoint* points, int points_count, MwColor color);
/*!
* @brief Draws a Line
* @param handle Widget
* @param points Points
* @param color Color
*/
MWDECL void MWAPI MwLine(MwWidget handle, MwPoint* points, MwColor color);
/*!
* @brief Draws a frame
* @param handle Widget

View file

@ -131,7 +131,7 @@ void MwDrawRect(MwWidget handle, MwRect* rect, MwColor color) {
p[3].x = r.x;
p[3].y = r.y + r.height;
MwLLPolygon(handle->lowlevel, p, 4, color->lowlevel);
MwPolygon(handle, p, 4, color);
}
void MwDrawRectLine(MwWidget handle, MwRect* rect, MwColor color) {
@ -154,10 +154,10 @@ void MwDrawRectLine(MwWidget handle, MwRect* rect, MwColor color) {
p[4] = p[0];
MwLLLine(handle->lowlevel, &p[0], color->lowlevel);
MwLLLine(handle->lowlevel, &p[1], color->lowlevel);
MwLLLine(handle->lowlevel, &p[2], color->lowlevel);
MwLLLine(handle->lowlevel, &p[3], color->lowlevel);
MwLine(handle, &p[0], color);
MwLine(handle, &p[1], color);
MwLine(handle, &p[2], color);
MwLine(handle, &p[3], color);
}
void MwDrawRectFading(MwWidget handle, MwRect* rect, MwColor color) {
@ -202,6 +202,14 @@ void MwDrawRectFading(MwWidget handle, MwRect* rect, MwColor color) {
free(data);
}
void MwPolygon(MwWidget handle, MwPoint* points, int points_count, MwColor color) {
MwLLPolygon(handle->lowlevel, points, points_count, color->lowlevel);
}
void MwLine(MwWidget handle, MwPoint* points, MwColor color) {
MwLLLine(handle->lowlevel, points, color->lowlevel);
}
void MwDrawFrame(MwWidget handle, MwRect* rect, MwColor color, int invert) {
MwDrawFrameWithBorder(handle, rect, color, invert, MwDefaultBorderWidth(handle));
}
@ -305,7 +313,7 @@ void MwDrawDiamond(MwWidget handle, MwRect* rect, MwColor color, int invert) {
p[5].x = rect->x + border;
p[5].y = rect->y + rect->height / 2;
MwLLPolygon(handle->lowlevel, p, 6, (invert ? darker : lighter)->lowlevel);
MwPolygon(handle, p, 6, (invert ? darker : lighter));
p[0].x = rect->x;
p[0].y = rect->y + rect->height / 2;
@ -325,7 +333,7 @@ void MwDrawDiamond(MwWidget handle, MwRect* rect, MwColor color, int invert) {
p[5].x = rect->x + border;
p[5].y = rect->y + rect->height / 2;
MwLLPolygon(handle->lowlevel, p, 6, (invert ? lighter : darker)->lowlevel);
MwPolygon(handle, p, 6, (invert ? lighter : darker));
p[0].x = rect->x + rect->width / 2;
p[0].y = rect->y + border;
@ -339,7 +347,7 @@ void MwDrawDiamond(MwWidget handle, MwRect* rect, MwColor color, int invert) {
p[3].x = rect->x + border;
p[3].y = rect->y + rect->height / 2;
MwLLPolygon(handle->lowlevel, p, 4, col->lowlevel);
MwPolygon(handle, p, 4, col);
MwFreeColor(col);
MwFreeColor(lighter);
@ -469,7 +477,7 @@ static void MwDrawFrameEx_simple(MwWidget handle, MwRect* rect, MwColor color, i
p[5].x = rect->x;
p[5].y = rect->y + rect->height;
MwLLPolygon(handle->lowlevel, p, 6, (invert ? darker : lighter)->lowlevel);
MwPolygon(handle, p, 6, (invert ? darker : lighter));
p[0].x = rect->x + rect->width;
p[0].y = rect->y;
@ -488,7 +496,7 @@ static void MwDrawFrameEx_simple(MwWidget handle, MwRect* rect, MwColor color, i
p[5].x = rect->x + rect->width;
p[5].y = rect->y + rect->height;
MwLLPolygon(handle->lowlevel, p, 6, (invert ? lighter : darker)->lowlevel);
MwPolygon(handle, p, 6, (invert ? lighter : darker));
MwFreeColor(lighter);
MwFreeColor(darker);
@ -521,7 +529,7 @@ static void frame_border_complex(MwWidget handle, MwRect* rect, MwColor lighter,
p[5].x = rect->x;
p[5].y = rect->y + rect->height;
MwLLPolygon(handle->lowlevel, p, 6, (invert ? lighter : darker)->lowlevel);
MwPolygon(handle, p, 6, (invert ? lighter : darker));
p[0].x = rect->x + rect->width;
p[0].y = rect->y;
@ -540,7 +548,7 @@ static void frame_border_complex(MwWidget handle, MwRect* rect, MwColor lighter,
p[5].x = rect->x + rect->width;
p[5].y = rect->y + rect->height;
MwLLPolygon(handle->lowlevel, p, 6, (invert ? lighter : darker)->lowlevel);
MwPolygon(handle, p, 6, (invert ? lighter : darker));
}
static void MwDrawFrameEx_complex(MwWidget handle, MwRect* rect, MwColor color, int invert, int border, int diff, int same) {
@ -633,9 +641,9 @@ void MwDrawTriangle(MwWidget handle, MwRect* rect, MwColor color, int invert, in
p3[3].x = (int)(rect->x + rect->width - c * border);
p3[3].y = (int)(rect->y + rect->height - s * border);
MwLLPolygon(handle->lowlevel, p1, 4, (invert ? darker : lighter)->lowlevel);
MwLLPolygon(handle->lowlevel, p2, 4, (invert ? lighter : darker)->lowlevel);
MwLLPolygon(handle->lowlevel, p3, 4, (invert ? lighter : darker)->lowlevel);
MwPolygon(handle, p1, 4, (invert ? darker : lighter));
MwPolygon(handle, p2, 4, (invert ? lighter : darker));
MwPolygon(handle, p3, 4, (invert ? lighter : darker));
p4[0].x = (int)(rect->x + c * border);
p4[0].y = (int)(rect->y + rect->height - s * border);
@ -682,9 +690,9 @@ void MwDrawTriangle(MwWidget handle, MwRect* rect, MwColor color, int invert, in
p3[3].x = (int)(rect->x + rect->width - c * border);
p3[3].y = (int)(rect->y + s * border);
MwLLPolygon(handle->lowlevel, p1, 4, (invert ? darker : lighter)->lowlevel);
MwLLPolygon(handle->lowlevel, p2, 4, (invert ? darker : lighter)->lowlevel);
MwLLPolygon(handle->lowlevel, p3, 4, (invert ? lighter : darker)->lowlevel);
MwPolygon(handle, p1, 4, (invert ? darker : lighter));
MwPolygon(handle, p2, 4, (invert ? darker : lighter));
MwPolygon(handle, p3, 4, (invert ? lighter : darker));
p4[0].x = (int)(rect->x + c * border);
p4[0].y = (int)(rect->y + s * border);
@ -731,9 +739,9 @@ void MwDrawTriangle(MwWidget handle, MwRect* rect, MwColor color, int invert, in
p3[3].x = (int)(rect->x + rect->width - border);
p3[3].y = rect->y + rect->height / 2;
MwLLPolygon(handle->lowlevel, p1, 4, (invert ? darker : lighter)->lowlevel);
MwLLPolygon(handle->lowlevel, p2, 4, (invert ? darker : lighter)->lowlevel);
MwLLPolygon(handle->lowlevel, p3, 4, (invert ? lighter : darker)->lowlevel);
MwPolygon(handle, p1, 4, (invert ? darker : lighter));
MwPolygon(handle, p2, 4, (invert ? darker : lighter));
MwPolygon(handle, p3, 4, (invert ? lighter : darker));
p4[0].x = (int)(rect->x + rect->width - border);
p4[0].y = rect->y + rect->height / 2;
@ -780,9 +788,9 @@ void MwDrawTriangle(MwWidget handle, MwRect* rect, MwColor color, int invert, in
p3[3].x = rect->x + rect->width;
p3[3].y = rect->y + rect->height;
MwLLPolygon(handle->lowlevel, p1, 4, (invert ? darker : lighter)->lowlevel);
MwLLPolygon(handle->lowlevel, p2, 4, (invert ? lighter : darker)->lowlevel);
MwLLPolygon(handle->lowlevel, p3, 4, (invert ? lighter : darker)->lowlevel);
MwPolygon(handle, p1, 4, (invert ? darker : lighter));
MwPolygon(handle, p2, 4, (invert ? lighter : darker));
MwPolygon(handle, p3, 4, (invert ? lighter : darker));
p4[0].x = (int)(rect->x + border);
p4[0].y = rect->y + rect->height / 2;
@ -793,7 +801,7 @@ void MwDrawTriangle(MwWidget handle, MwRect* rect, MwColor color, int invert, in
p4[2].x = (int)(rect->x + rect->width - c * border);
p4[2].y = (int)(rect->y + s * border);
}
MwLLPolygon(handle->lowlevel, p4, 3, col->lowlevel);
MwPolygon(handle, p4, 3, col);
MwFreeColor(col);
MwFreeColor(lighter);

View file

@ -135,7 +135,7 @@ static void draw(MwWidget handle) {
p[4].y = p[0].y + gh * 7;
p[5].x = p[0].x + h;
p[5].y = p[0].y;
MwLLPolygon(handle->lowlevel, p, 6, cb_g->lowlevel);
MwPolygon(handle, p, 6, cb_g);
p[0].x = (r.width - h) / 2;
p[0].y = (r.height - h - sh) / 2;
@ -149,7 +149,7 @@ static void draw(MwWidget handle) {
p[4].y = p[0].y + gh * 3;
p[5].x = p[0].x + h;
p[5].y = p[0].y;
MwLLPolygon(handle->lowlevel, p, 6, ct->lowlevel);
MwPolygon(handle, p, 6, ct);
r2.width = h;
r2.height = h - ph - gh;
@ -175,7 +175,7 @@ static void draw(MwWidget handle) {
p[2].y = r2.y + r2.height + ph;
p[3].x = r2.x + r2.width;
p[3].y = r2.y + r2.height;
MwLLPolygon(handle->lowlevel, p, 4, cb->lowlevel);
MwPolygon(handle, p, 4, cb);
p[0].x = r.width / 2;
p[0].y = (r.height - sh) / 2;

View file

@ -53,13 +53,13 @@ static void draw_line(MwWidget handle, const char* text, double x, double y, dou
p2[1].x += height;
p2[1].y -= height;
MwLLLine(handle->lowlevel, &p2[0], color->lowlevel);
MwLine(handle, &p2[0], color);
p[0].x += height;
p[0].y -= height;
p[1].y -= height;
}
MwLLLine(handle->lowlevel, &p[0], color->lowlevel);
MwLine(handle, &p[0], color);
}
#define CALC_VMIN_VMAX \
@ -126,14 +126,14 @@ static void bar_chart(MwWidget handle, MwRect* _r, double vmin, double vmax, int
p[1].x = node.x;
p[1].y = r.height - space;
MwLLLine(handle->lowlevel, &p[0], border->lowlevel);
MwLine(handle, &p[0], border);
p[0].x = node.x;
p[0].y = r.height - space;
p[1].x = node.x + twidth;
p[1].y = p[0].y;
MwLLLine(handle->lowlevel, &p[0], border->lowlevel);
MwLine(handle, &p[0], border);
node.width = width;
for(i = 0; i < arrlen(c->entries); i++) {
@ -170,7 +170,7 @@ static void bar_chart(MwWidget handle, MwRect* _r, double vmin, double vmax, int
persp_top[4] = persp_top[0];
MwLLPolygon(handle->lowlevel, persp_top, 4, colorl->lowlevel);
MwPolygon(handle, persp_top, 4, colorl);
persp_right[0] = *(MwPoint*)&node2;
persp_right[1] = *(MwPoint*)&node2;
@ -189,22 +189,22 @@ static void bar_chart(MwWidget handle, MwRect* _r, double vmin, double vmax, int
persp_right[4] = persp_right[0];
MwLLPolygon(handle->lowlevel, persp_right, 4, colord->lowlevel);
MwPolygon(handle, persp_right, 4, colord);
}
if(!modern) {
MwDrawRectLine(handle, &node, border);
if(type == MwCHART_BAR_3D) {
MwLLLine(handle->lowlevel, &persp_top[0], border->lowlevel);
MwLLLine(handle->lowlevel, &persp_top[1], border->lowlevel);
MwLLLine(handle->lowlevel, &persp_top[2], border->lowlevel);
MwLLLine(handle->lowlevel, &persp_top[3], border->lowlevel);
MwLine(handle, &persp_top[0], border);
MwLine(handle, &persp_top[1], border);
MwLine(handle, &persp_top[2], border);
MwLine(handle, &persp_top[3], border);
MwLLLine(handle->lowlevel, &persp_right[0], border->lowlevel);
MwLLLine(handle->lowlevel, &persp_right[1], border->lowlevel);
MwLLLine(handle->lowlevel, &persp_right[2], border->lowlevel);
MwLLLine(handle->lowlevel, &persp_right[3], border->lowlevel);
MwLine(handle, &persp_right[0], border);
MwLine(handle, &persp_right[1], border);
MwLine(handle, &persp_right[2], border);
MwLine(handle, &persp_right[3], border);
}
}
@ -282,27 +282,27 @@ static void pie_chart(MwWidget handle, MwRect* _r, const char** colors, int n, M
p3[2] = p2[1];
if(k == 0) {
MwLLPolygon(handle->lowlevel, p3, count + 2, color->lowlevel);
MwPolygon(handle, p3, count + 2, color);
} else if(d == 1 && k == 1) {
for(j = 3; j < count + 1; j++) {
if(!modern) MwLLLine(handle->lowlevel, &p3[j], border->lowlevel);
if(!modern) MwLine(handle, &p3[j], border);
}
p2[0] = p2[1];
p2[0].y += radius / 8;
if(!modern) MwLLLine(handle->lowlevel, p2, border->lowlevel);
if(!modern) MwLine(handle, p2, border);
}
}
}
if(k == 2) {
MwLLPolygon(handle->lowlevel, p2, count, (type == MwCHART_PIE_3D ? colorl : color)->lowlevel);
MwPolygon(handle, p2, count, (type == MwCHART_PIE_3D ? colorl : color));
} else if(k == 3) {
int j;
p2[count] = p2[0];
for(j = 0; j < count; j++) {
if(!modern) MwLLLine(handle->lowlevel, &p2[j], border->lowlevel);
if(!modern) MwLine(handle, &p2[j], border);
}
p2[0].x += cos((cangle + angle / 2 - 90) / 180 * M_PI) * radius / 4;
@ -325,10 +325,10 @@ static void pie_chart(MwWidget handle, MwRect* _r, const char** colors, int n, M
p[0].y = r.height / 2;
p[1] = p[0];
p[1].y += radius / 8;
MwLLLine(handle->lowlevel, p, border->lowlevel);
MwLine(handle, p, border);
p[0].x = p[1].x = r.width / 2 + radius / 2;
MwLLLine(handle->lowlevel, p, border->lowlevel);
MwLine(handle, p, border);
}
}
@ -376,7 +376,7 @@ static void line_chart(MwWidget handle, MwRect* _r, double vmin, double vmax, in
p[1] = p[0];
p[1].y = r.height - space;
MwLLLine(handle->lowlevel, p, border->lowlevel);
MwLine(handle, p, border);
for(j = 0; j < 2; j++) {
for(i = j == 0 ? 1 : 0; i < arrlen(c->entries); i++) {
@ -386,7 +386,7 @@ static void line_chart(MwWidget handle, MwRect* _r, double vmin, double vmax, in
p[1].y = (r.height - space) - (c->entries[i].value - vmin) / (vmax - vmin) * (r.height - space);
if(j == 0) {
MwLLLine(handle->lowlevel, p, border->lowlevel);
MwLine(handle, p, border);
} else {
MwDrawText(handle, NULL, &p[1], c->entries[i].name, MwALIGNMENT_CENTER, border);
}

View file

@ -60,7 +60,7 @@ static void draw(MwWidget handle) {
p[5] = p[0];
p[5].y -= r.height / 3;
MwLLPolygon(handle->lowlevel, p, 6, text2->lowlevel);
MwPolygon(handle, p, 6, text2);
}
MwFreeColor(text2);

View file

@ -43,12 +43,12 @@ static void hand(MwWidget handle, double x, double y, double width, double lengt
p[4] = p[0];
MwLLPolygon(handle->lowlevel, p, 4, inside->lowlevel);
MwPolygon(handle, p, 4, inside);
MwLLLine(handle->lowlevel, &p[0], border->lowlevel);
MwLLLine(handle->lowlevel, &p[1], border->lowlevel);
MwLLLine(handle->lowlevel, &p[2], border->lowlevel);
MwLLLine(handle->lowlevel, &p[3], border->lowlevel);
MwLine(handle, &p[0], border);
MwLine(handle, &p[1], border);
MwLine(handle, &p[2], border);
MwLine(handle, &p[3], border);
}
static void draw(MwWidget handle) {
@ -96,7 +96,7 @@ static void draw(MwWidget handle) {
p[1].x = x;
p[1].y = y;
MwLLLine(handle->lowlevel, p, border->lowlevel);
MwLine(handle, p, border);
}
hand(handle, ShadowDist, ShadowDist, BaseWidth, w / 2 * 2 / 3, h, shadow, shadow);

View file

@ -138,7 +138,7 @@ static void draw(MwWidget handle) {
if(j == 0 || j == 1) {
line[0].y += MwTextHeight(handle, font, l->text) / 2 * (2 - j);
line[1].y += MwTextHeight(handle, font, l->text) / 2 * (2 - j);
MwLLLine(handle->lowlevel, line, (c ? base : text)->lowlevel);
MwLine(handle, line, (c ? base : text));
}
}
}

View file

@ -18,21 +18,21 @@ static void close_draw(MwWidget handle) {
p[0].y = bw * 2;
p[1].x = w - bw * 2 - 1;
p[1].y = h - bw * 2 - 1;
MwLLLine(handle->lowlevel, p, c->lowlevel);
MwLine(handle, p, c);
p[0].x++;
p[1].x--;
MwLLLine(handle->lowlevel, p, c->lowlevel);
MwLine(handle, p, c);
p[0].x = w - bw * 2 - 1;
p[0].y = bw * 2;
p[1].x = bw * 2;
p[1].y = h - bw * 2 - 1;
MwLLLine(handle->lowlevel, p, c->lowlevel);
MwLine(handle, p, c);
p[0].x--;
p[1].x++;
MwLLLine(handle->lowlevel, p, c->lowlevel);
MwLine(handle, p, c);
MwFreeColor(c);
}
@ -59,22 +59,22 @@ static void maximize_draw(MwWidget handle) {
p[0].y = bw * 2;
p[1].x = w - bw * 2 - 1;
p[1].y = bw * 2;
MwLLLine(handle->lowlevel, p, c->lowlevel);
MwLine(handle, p, c);
p[0].y = p[1].y = h - bw * 2 - 1;
MwLLLine(handle->lowlevel, p, c->lowlevel);
MwLine(handle, p, c);
p[0].y = p[1].y = bw * 2 + 1;
MwLLLine(handle->lowlevel, p, c->lowlevel);
MwLine(handle, p, c);
p[0].x = bw * 2;
p[0].y = bw * 2;
p[1].x = bw * 2;
p[1].y = h - bw * 2 - 1;
MwLLLine(handle->lowlevel, p, c->lowlevel);
MwLine(handle, p, c);
p[0].x = p[1].x = w - bw * 2 - 1;
MwLLLine(handle->lowlevel, p, c->lowlevel);
MwLine(handle, p, c);
MwFreeColor(c);
}
@ -124,11 +124,11 @@ static void minimize_draw(MwWidget handle) {
p[0].y = h - bw * 2 - 1;
p[1].x = w - bw * 2 - 1;
p[1].y = h - bw * 2 - 1;
MwLLLine(handle->lowlevel, p, c->lowlevel);
MwLine(handle, p, c);
p[0].y--;
p[1].y--;
MwLLLine(handle->lowlevel, p, c->lowlevel);
MwLine(handle, p, c);
MwFreeColor(c);
}

View file

@ -42,7 +42,7 @@ static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwTreeViewEntry**
l[0] = *p;
l[0].x -= LineSpace / 2;
l[1] = *p;
if(draw) MwLLLine(handle->lowlevel, &l[0], text2->lowlevel);
if(draw) MwLine(handle, &l[0], text2);
}
if(shift > LineSpace) {
@ -53,7 +53,7 @@ static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwTreeViewEntry**
if(next) {
l[1].y += MwTextHeight(handle, Font, "M") / 2;
}
if(draw) MwLLLine(handle->lowlevel, &l[0], text2->lowlevel);
if(draw) MwLine(handle, &l[0], text2);
}
if(tree->tree != NULL) {
r.width = OpenerSize;
@ -74,7 +74,7 @@ static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwTreeViewEntry**
l[1].x = l[0].x + len;
l[1].y = l[0].y;
MwLLLine(handle->lowlevel, &l[0], text->lowlevel);
MwLine(handle, &l[0], text);
} else {
l[0].x = r.x + (r.width - len) / 2;
l[0].y = r.y + r.height / 2;
@ -82,7 +82,7 @@ static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwTreeViewEntry**
l[1].x = l[0].x + len;
l[1].y = l[0].y;
MwLLLine(handle->lowlevel, &l[0], text->lowlevel);
MwLine(handle, &l[0], text);
l[0].x = r.x + r.width / 2;
l[0].y = r.y + (r.height - len) / 2;
@ -90,7 +90,7 @@ static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwTreeViewEntry**
l[1].x = l[0].x;
l[1].y = l[0].y + len;
MwLLLine(handle->lowlevel, &l[0], text->lowlevel);
MwLine(handle, &l[0], text);
}
r = r2;
MwDrawFrame(handle, &r, base, tree->opened);
@ -160,7 +160,7 @@ static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwTreeViewEntry**
if(skipped && p->y > l[0].y) {
skipped = 0;
}
if(draw && !skipped && i != (arrlen(tree->tree) - 1)) MwLLLine(handle->lowlevel, &l[0], text->lowlevel);
if(draw && !skipped && i != (arrlen(tree->tree) - 1)) MwLine(handle, &l[0], text);
}
}