forked from pyrite-dev/milsko
DrawWidgetBack fix
This commit is contained in:
parent
fe9b08ef55
commit
19416d7451
17 changed files with 88 additions and 34 deletions
|
|
@ -83,6 +83,12 @@ MWDECL const int MwDefaultShadow;
|
||||||
*/
|
*/
|
||||||
MWDECL int MWAPI MwDefaultBorderWidth(MwWidget handle);
|
MWDECL int MWAPI MwDefaultBorderWidth(MwWidget handle);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Gets default thin border width
|
||||||
|
* @param handle Widget
|
||||||
|
*/
|
||||||
|
MWAPI int MwDefaultThinBorderWidth(MwWidget handle);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,17 @@ MWDECL void MWAPI MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor colo
|
||||||
*/
|
*/
|
||||||
MWDECL void MWAPI MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert);
|
MWDECL void MWAPI MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Draws a frame
|
||||||
|
* @param handle Widget
|
||||||
|
* @param rect Rectangle area
|
||||||
|
* @param color Color
|
||||||
|
* @param invert Invert the 3D border color or not
|
||||||
|
* @param border Border
|
||||||
|
* @warning `rect` gets changed to the area of rectangle inside
|
||||||
|
*/
|
||||||
|
MWDECL void MWAPI MwDrawFrameWithBorder(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Does the DrawFrame/DrawRect combo used for drawing widget.
|
* @brief Does the DrawFrame/DrawRect combo used for drawing widget.
|
||||||
* @param handle Widget
|
* @param handle Widget
|
||||||
|
|
|
||||||
|
|
@ -27,3 +27,15 @@ int MwDefaultBorderWidth(MwWidget handle) {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MwDefaultThinBorderWidth(MwWidget handle) {
|
||||||
|
int bw = MwGetInteger(handle, MwNborderWidth);
|
||||||
|
|
||||||
|
if(bw != MwDEFAULT) return bw;
|
||||||
|
|
||||||
|
if(MwGetInteger(handle, MwNmodernLook)) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
45
src/draw.c
45
src/draw.c
|
|
@ -141,23 +141,35 @@ void MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor color) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
|
void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
|
||||||
|
MwDrawFrameWithBorder(handle, rect, color, invert, MwDefaultBorderWidth(handle));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int translate_border(MwWidget handle, int border) {
|
||||||
|
if(border == MwDEFAULT) return MwDefaultBorderWidth(handle);
|
||||||
|
|
||||||
|
return border;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MwDrawFrameWithBorder(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border) {
|
||||||
int inv;
|
int inv;
|
||||||
|
|
||||||
|
border = translate_border(handle, border);
|
||||||
|
|
||||||
if((inv = MwGetInteger(handle, MwNforceInverted)) != MwDEFAULT && inv) invert = 1;
|
if((inv = MwGetInteger(handle, MwNforceInverted)) != MwDEFAULT && inv) invert = 1;
|
||||||
if(MwGetInteger(handle, MwNmodernLook)) {
|
if(MwGetInteger(handle, MwNmodernLook)) {
|
||||||
MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth(handle), 0, 0);
|
MwDrawFrameEx(handle, rect, color, invert, border, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
int diff = get_color_diff(handle) / 3 * 2;
|
int diff = get_color_diff(handle) / 3 * 2;
|
||||||
|
|
||||||
if(MwDefaultBorderWidth(handle) >= 2) {
|
if(border >= 2) {
|
||||||
int i;
|
int i;
|
||||||
int st = invert ? 1 : 0;
|
int st = invert ? 1 : 0;
|
||||||
for(i = st; i < st + 2; i++) {
|
for(i = st; i < st + 2; i++) {
|
||||||
if((i % 2) == 0) MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth(handle) - 1, -diff, (handle->parent == NULL || handle->parent->lowlevel == NULL) ? 1 : 0);
|
if((i % 2) == 0) MwDrawFrameEx(handle, rect, color, invert, border - 1, -diff, (handle->parent == NULL || handle->parent->lowlevel == NULL) ? 1 : 0);
|
||||||
if((i % 2) == 1) MwDrawFrameEx(handle, rect, color, invert, 1, diff, 0);
|
if((i % 2) == 1) MwDrawFrameEx(handle, rect, color, invert, 1, diff, 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MwDrawFrameEx(handle, rect, color, invert, 1, 0, 0);
|
MwDrawFrameEx(handle, rect, color, invert, border, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -177,7 +189,16 @@ void MwDrawWidgetBack(MwWidget handle, MwRect* rect, MwLLColor color, int invert
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MwDrawFrame(handle, rect, color, invert);
|
MwDrawFrameWithBorder(handle, rect, color, invert, border);
|
||||||
|
|
||||||
|
if(border == MwDEFAULT) {
|
||||||
|
int d = MwDefaultBorderWidth(handle) - MwDefaultThinBorderWidth(handle);
|
||||||
|
|
||||||
|
rect->x -= d;
|
||||||
|
rect->y -= d;
|
||||||
|
rect->width += d * 2;
|
||||||
|
rect->height += d * 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rect->width <= 0 || rect->height <= 0) return;
|
if(rect->width <= 0 || rect->height <= 0) return;
|
||||||
|
|
@ -359,13 +380,15 @@ static void MwDrawFrameEx_complex(MwWidget handle, MwRect* rect, MwLLColor color
|
||||||
MwLLColor lighter = same ? MwLightenColor(handle, darker, 0, 0, 0) : MwLightenColor(handle, color, (ColorDiff / 2) - diff, (ColorDiff / 2) - diff, (ColorDiff / 2) - diff);
|
MwLLColor lighter = same ? MwLightenColor(handle, darker, 0, 0, 0) : MwLightenColor(handle, color, (ColorDiff / 2) - diff, (ColorDiff / 2) - diff, (ColorDiff / 2) - diff);
|
||||||
MwRect r = *rect;
|
MwRect r = *rect;
|
||||||
|
|
||||||
frame_border_complex(handle, rect, lighter, darker, invert, border / 2, diff, same);
|
frame_border_complex(handle, rect, lighter, darker, invert, border == 1 ? 1 : (border / 2), diff, same);
|
||||||
|
|
||||||
r.x += 1;
|
if(border > 1) {
|
||||||
r.y += 1;
|
r.x += border / 2;
|
||||||
r.width -= 2;
|
r.y += border / 2;
|
||||||
r.height -= 2;
|
r.width -= border;
|
||||||
|
r.height -= border;
|
||||||
frame_border_complex(handle, &r, lighter, darker, !invert, border / 2, diff, same);
|
frame_border_complex(handle, &r, lighter, darker, !invert, border / 2, diff, same);
|
||||||
|
}
|
||||||
|
|
||||||
MwLLFreeColor(lighter);
|
MwLLFreeColor(lighter);
|
||||||
MwLLFreeColor(darker);
|
MwLLFreeColor(darker);
|
||||||
|
|
@ -377,6 +400,8 @@ static void MwDrawFrameEx_complex(MwWidget handle, MwRect* rect, MwLLColor color
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same) {
|
void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same) {
|
||||||
|
border = translate_border(handle, border);
|
||||||
|
|
||||||
if(MwGetInteger(handle, MwNmodernLook)) {
|
if(MwGetInteger(handle, MwNmodernLook)) {
|
||||||
MwDrawFrameEx_complex(handle, rect, color, invert, border, diff, same);
|
MwDrawFrameEx_complex(handle, rect, color, invert, border, diff, same);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,12 @@ static void draw(MwWidget handle) {
|
||||||
|
|
||||||
if(MwGetInteger(handle, MwNflat)) {
|
if(MwGetInteger(handle, MwNflat)) {
|
||||||
if(handle->pressed || ((inv = MwGetInteger(handle, MwNforceInverted)) != MwDEFAULT && inv)) {
|
if(handle->pressed || ((inv = MwGetInteger(handle, MwNforceInverted)) != MwDEFAULT && inv)) {
|
||||||
MwDrawWidgetBack(handle, &r, base, handle->pressed, 1);
|
MwDrawWidgetBack(handle, &r, base, handle->pressed, MwDEFAULT);
|
||||||
} else {
|
} else {
|
||||||
MwDrawRect(handle, &r, base);
|
MwDrawRect(handle, &r, base);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MwDrawWidgetBack(handle, &r, base, handle->pressed, 1);
|
MwDrawWidgetBack(handle, &r, base, handle->pressed, MwDEFAULT);
|
||||||
}
|
}
|
||||||
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
||||||
if(MwGetInteger(handle, MwNflat) && !(handle->pressed || ((inv = MwGetInteger(handle, MwNforceInverted)) != MwDEFAULT && inv))) {
|
if(MwGetInteger(handle, MwNflat) && !(handle->pressed || ((inv = MwGetInteger(handle, MwNforceInverted)) != MwDEFAULT && inv))) {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ static void draw(MwWidget handle) {
|
||||||
r.x = (MwGetInteger(handle, MwNwidth) - r.width) / 2;
|
r.x = (MwGetInteger(handle, MwNwidth) - r.width) / 2;
|
||||||
r.y = (MwGetInteger(handle, MwNheight) - r.height) / 2;
|
r.y = (MwGetInteger(handle, MwNheight) - r.height) / 2;
|
||||||
|
|
||||||
MwDrawWidgetBack(handle, &r, base, (handle->pressed || MwGetInteger(handle, MwNchecked)) ? 1 : 0, MwTRUE);
|
MwDrawWidgetBack(handle, &r, base, (handle->pressed || MwGetInteger(handle, MwNchecked)) ? 1 : 0, MwDEFAULT);
|
||||||
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
||||||
if(handle->pressed || MwGetInteger(handle, MwNchecked)) {
|
if(handle->pressed || MwGetInteger(handle, MwNchecked)) {
|
||||||
/* TODO: write check mark */
|
/* TODO: write check mark */
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ static void draw(MwWidget handle) {
|
||||||
r.width = MwGetInteger(handle, MwNwidth);
|
r.width = MwGetInteger(handle, MwNwidth);
|
||||||
r.height = MwGetInteger(handle, MwNheight);
|
r.height = MwGetInteger(handle, MwNheight);
|
||||||
|
|
||||||
MwDrawWidgetBack(handle, &r, base, 0, 1);
|
MwDrawWidgetBack(handle, &r, base, 0, MwDEFAULT);
|
||||||
|
|
||||||
rc = r;
|
rc = r;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ static void draw(MwWidget handle) {
|
||||||
r.width = MwGetInteger(handle, MwNwidth) - t->right;
|
r.width = MwGetInteger(handle, MwNwidth) - t->right;
|
||||||
r.height = MwGetInteger(handle, MwNheight);
|
r.height = MwGetInteger(handle, MwNheight);
|
||||||
|
|
||||||
MwDrawWidgetBack(handle, &r, base, 1, 1);
|
MwDrawWidgetBack(handle, &r, base, 1, MwDEFAULT);
|
||||||
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
||||||
if(str != NULL) {
|
if(str != NULL) {
|
||||||
int w = MwTextWidth(handle, font, "M");
|
int w = MwTextWidth(handle, font, "M");
|
||||||
|
|
|
||||||
|
|
@ -107,12 +107,12 @@ static void draw(MwWidget handle) {
|
||||||
|
|
||||||
MENU_LOOP_INIT;
|
MENU_LOOP_INIT;
|
||||||
|
|
||||||
MwDrawWidgetBack(handle, &r, base, 0, MwTRUE);
|
MwDrawWidgetBack(handle, &r, base, 0, MwDEFAULT);
|
||||||
|
|
||||||
BEGIN_MENU_LOOP;
|
BEGIN_MENU_LOOP;
|
||||||
if(m->sub[i]->wsub != NULL || (in_area && handle->pressed)) {
|
if(m->sub[i]->wsub != NULL || (in_area && handle->pressed)) {
|
||||||
MwDrawFrame(handle, &r, base, MwFALSE);
|
MwDrawFrame(handle, &r, base, MwFALSE);
|
||||||
MwDrawWidgetBack(handle, &r, base, 0, MwFALSE);
|
MwDrawWidgetBack(handle, &r, base, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MwDrawText(handle, MwFLBuildFont((m->sub[i]->wsub != NULL || (in_area && handle->pressed)) ? MwFLFlagBold : 0), &p, m->sub[i]->name + incr, MwALIGNMENT_CENTER, text);
|
MwDrawText(handle, MwFLBuildFont((m->sub[i]->wsub != NULL || (in_area && handle->pressed)) ? MwFLFlagBold : 0), &p, m->sub[i]->name + incr, MwALIGNMENT_CENTER, text);
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ static void draw(MwWidget handle) {
|
||||||
r.y = 0;
|
r.y = 0;
|
||||||
r.width = e->right;
|
r.width = e->right;
|
||||||
r.height = h / 2;
|
r.height = h / 2;
|
||||||
MwDrawWidgetBack(handle, &r, base, pr, MwTRUE);
|
MwDrawWidgetBack(handle, &r, base, pr, MwDEFAULT);
|
||||||
|
|
||||||
if(r.width > r.height) {
|
if(r.width > r.height) {
|
||||||
r.width = r.height;
|
r.width = r.height;
|
||||||
|
|
@ -49,7 +49,7 @@ static void draw(MwWidget handle) {
|
||||||
r.y = h / 2;
|
r.y = h / 2;
|
||||||
r.width = e->right;
|
r.width = e->right;
|
||||||
r.height = h / 2;
|
r.height = h / 2;
|
||||||
MwDrawWidgetBack(handle, &r, base, pr, MwTRUE);
|
MwDrawWidgetBack(handle, &r, base, pr, MwDEFAULT);
|
||||||
|
|
||||||
if(r.width > r.height) {
|
if(r.width > r.height) {
|
||||||
r.width = r.height;
|
r.width = r.height;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ static void draw(MwWidget handle) {
|
||||||
w = MwGetInteger(handle, MwNvalue) - MwGetInteger(handle, MwNminValue);
|
w = MwGetInteger(handle, MwNvalue) - MwGetInteger(handle, MwNminValue);
|
||||||
w = w / (MwGetInteger(handle, MwNmaxValue) - MwGetInteger(handle, MwNminValue));
|
w = w / (MwGetInteger(handle, MwNmaxValue) - MwGetInteger(handle, MwNminValue));
|
||||||
|
|
||||||
MwDrawWidgetBack(handle, &r, base, 1, MwTRUE);
|
MwDrawWidgetBack(handle, &r, base, 1, MwDEFAULT);
|
||||||
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
||||||
|
|
||||||
r.x += MwDefaultBorderWidth(handle);
|
r.x += MwDefaultBorderWidth(handle);
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ static void draw(MwWidget handle) {
|
||||||
ux = r.height;
|
ux = r.height;
|
||||||
dx = r.width - r.height;
|
dx = r.width - r.height;
|
||||||
|
|
||||||
MwDrawWidgetBack(handle, &r, dark, 1, MwTRUE);
|
MwDrawWidgetBack(handle, &r, dark, 1, MwDEFAULT);
|
||||||
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
||||||
|
|
||||||
rt = r;
|
rt = r;
|
||||||
|
|
@ -131,7 +131,7 @@ static void draw(MwWidget handle) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rbar.height >= 0) MwDrawWidgetBack(handle, &rbar, base, 0, MwTRUE);
|
if(rbar.height >= 0) MwDrawWidgetBack(handle, &rbar, base, 0, MwDEFAULT);
|
||||||
|
|
||||||
MwLLFreeColor(dark);
|
MwLLFreeColor(dark);
|
||||||
MwLLFreeColor(base);
|
MwLLFreeColor(base);
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ static void draw(MwWidget handle) {
|
||||||
r.y = (r.height - 2) / 2;
|
r.y = (r.height - 2) / 2;
|
||||||
r.height = 2;
|
r.height = 2;
|
||||||
}
|
}
|
||||||
MwDrawFrameEx(handle, &r, base, 1, 1, 0, 0);
|
MwDrawFrameEx(handle, &r, base, 1, MwDEFAULT, 0, 0);
|
||||||
|
|
||||||
MwLLFreeColor(base);
|
MwLLFreeColor(base);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ static void draw(MwWidget handle) {
|
||||||
r.width = MwGetInteger(handle, MwNwidth);
|
r.width = MwGetInteger(handle, MwNwidth);
|
||||||
r.height = MwGetInteger(handle, MwNheight);
|
r.height = MwGetInteger(handle, MwNheight);
|
||||||
|
|
||||||
MwDrawWidgetBack(handle, &r, base, 0, MwTRUE);
|
MwDrawWidgetBack(handle, &r, base, 0, MwDEFAULT);
|
||||||
|
|
||||||
if(menu != NULL) {
|
if(menu != NULL) {
|
||||||
MwPoint p;
|
MwPoint p;
|
||||||
|
|
@ -73,7 +73,7 @@ static void draw(MwWidget handle) {
|
||||||
r.y = p.y - 3;
|
r.y = p.y - 3;
|
||||||
r.width = MwGetInteger(handle, MwNwidth) - MwGetInteger(handle, MwNleftPadding);
|
r.width = MwGetInteger(handle, MwNwidth) - MwGetInteger(handle, MwNleftPadding);
|
||||||
r.height = th + 3 * 2;
|
r.height = th + 3 * 2;
|
||||||
MwDrawWidgetBack(handle, &r, base, 0, MwTRUE);
|
MwDrawWidgetBack(handle, &r, base, 0, MwDEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
p.x = 5 + tw / 2 + MwGetInteger(handle, MwNleftPadding);
|
p.x = 5 + tw / 2 + MwGetInteger(handle, MwNleftPadding);
|
||||||
|
|
|
||||||
|
|
@ -156,10 +156,10 @@ static void show_frame(MwWidget handle) {
|
||||||
if(i != n) MwLLShow(t->frames[i]->lowlevel, 0);
|
if(i != n) MwLLShow(t->frames[i]->lowlevel, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MwLLShow(t->frames[n]->lowlevel, 1);
|
|
||||||
|
|
||||||
resize(handle);
|
resize(handle);
|
||||||
|
|
||||||
|
MwLLShow(t->frames[n]->lowlevel, 1);
|
||||||
|
|
||||||
MwForceRender(handle);
|
MwForceRender(handle);
|
||||||
|
|
||||||
MwDispatchUserHandler(handle, MwNchangedHandler, NULL);
|
MwDispatchUserHandler(handle, MwNchangedHandler, NULL);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue