ok
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good

This commit is contained in:
Nishi 2026-09-21 12:41:56 +09:00
commit f8c678ac53
5 changed files with 78 additions and 12 deletions

View file

@ -390,6 +390,13 @@ MWDECL void MWAPI MwFreeWidget(MwWidget handle);
*/
MWDECL void MWAPI MwGetFrame(MwWidget handle, MwRect* rect);
/*!
* @brief Gets the clipping frame of the widget
* @param handle Widget
* @param rect Frame
*/
MWDECL void MWAPI MwGetClipFrame(MwWidget handle, MwRect* rect);
#ifdef _MILSKO
MWDECL void MwForceRender_Internal(MwWidget handle);
MWDECL void MwForceRender2_Internal(MwWidget handle, void* ptr);

View file

@ -220,6 +220,13 @@ MWDECL void MWAPI MwDrawDiamond(MwWidget handle, MwRect* rect, MwLLColor color,
*/
MWDECL void MWAPI MwDrawCircle(MwWidget handle, MwRect* rect, MwLLColor color, MwLLColor background, int filled);
/*!
* @brief Calculate intersect of 2 rectangles
* @param a 1st rectangle
* @param a 2nd rectangle
*/
MWDECL void MwIntersectRect(MwRect* a, const MwRect* b);
/* text.c */
/*!

View file

@ -1241,4 +1241,31 @@ void MwGetFrame(MwWidget handle, MwRect* rect) {
rect->height = MwGetInteger(handle, MwNheight);
}
void MwGetClipFrame(MwWidget handle, MwRect* rect) {
MwWidget child = handle;
MwWidget p = handle->parent;
int o_x = 0, o_y = 0;
rect->x = 0;
rect->y = 0;
rect->width = MwGetInteger(handle, MwNwidth);
rect->height = MwGetInteger(handle, MwNheight);
while(p != NULL && p->widget_class != MwWindowClass) {
MwRect pclip;
o_x += MwGetInteger(child, MwNx);
o_y += MwGetInteger(child, MwNy);
pclip.x = -o_x;
pclip.y = -o_y;
pclip.width = MwGetInteger(p, MwNwidth);
pclip.height = MwGetInteger(p, MwNheight);
MwIntersectRect(rect, &pclip);
if(rect->width == 0 || rect->height == 0) break;
child = p;
p = p->parent;
}
}
const char* MwVersionString = MwVERSION;

View file

@ -1125,3 +1125,35 @@ MwLLPixmap MwLoadXPM(MwWidget handle, char** data) {
return px;
}
static int _min(int a, int b) {
return a < b ? a : b;
}
static int _max(int a, int b) {
return a > b ? a : b;
}
void MwIntersectRect(MwRect* a, const MwRect* b) {
int x;
int y;
int right;
int bottom;
x = _max(a->x, b->x);
y = _max(a->y, b->y);
right = _min(a->x + a->width, b->x + b->width);
bottom = _min(a->y + a->height, b->y + b->height);
a->x = x;
a->y = y;
if(right <= x || bottom <= x) {
a->width = 0;
a->height = 0;
return;
}
a->width = right - x;
a->height = bottom - y;
}

View file

@ -59,17 +59,9 @@ static void draw(MwWidget handle) {
MwFLFont font = NULL;
MwPoint u_p, s_p, c_p;
int u = 0, s = 0, c = 0;
int s_y = 0;
int s_h = MwGetInteger(handle, MwNheight);
MwWidget p = handle->parent;
MwRect clip;
s_y = MwGetInteger(handle, MwNy);
while(p != NULL && p->widget_class != MwWindowClass) {
s_y += MwGetInteger(p, MwNy);
p = p->parent;
}
s_y *= -1;
MwGetClipFrame(handle, &clip);
u_p.x = s_p.x = c_p.x = 0;
u_p.y = s_p.y = c_p.y = 0;
@ -87,11 +79,12 @@ static void draw(MwWidget handle) {
case MwDOCUMENT_TEXT:
{
MwPoint p;
int th2;
p.x = l->x;
p.y = l->y + MwTextHeight(handle, font, l->text) / 2;
p.y = l->y + (th2 = MwTextHeight(handle, font, l->text) / 2);
if(p.y <= s_y || p.y >= s_y + s_h) break;
if((p.y + th2) <= clip.y || (p.y - th2) >= clip.y + clip.height) break;
if(u || s || c) {
MwPoint line[2];