introduce MwNflat

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@723 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-11-14 18:42:31 +00:00
parent b5180b2081
commit d5890ee67e
5 changed files with 25 additions and 16 deletions

View File

@@ -85,9 +85,10 @@ MWDECL void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int i
* @param color Color
* @param invert Invert the 3D border color or not
* @param border Border width
* @param diff Difference
* @warning `rect` gets changed to the area of rectangle inside
*/
MWDECL void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border);
MWDECL void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff);
/*!
* @brief Creates a pixmap from image

View File

@@ -28,6 +28,7 @@
#define MwNwaitMS "IwaitMS"
#define MwNhideInput "IhideInput"
#define MwNsingleClickSelectable "IsingleClickSelectable"
#define MwNflat "Iflat"
#define MwNtitle "Stitle"
#define MwNtext "Stext"

View File

@@ -64,6 +64,7 @@
<integer name="waitMS" />
<integer name="hideInput" />
<integer name="singleClickSelectable" />
<integer name="flat" />
<string name="title" />
<string name="text" />
@@ -438,6 +439,7 @@
<properties>
<property name="pixmap" />
<property name="text" />
<property name="flat" />
</properties>
</widget>
<widget name="CheckBox">

View File

@@ -15,7 +15,7 @@ static int get_color_diff(MwWidget handle) {
if(MwGetInteger(handle, MwNmodernLook)) {
return 46;
} else {
return 96;
return 80;
}
}
@@ -128,20 +128,17 @@ void MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor color) {
void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
if(MwGetInteger(handle, MwNmodernLook)) {
MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth(handle));
MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth(handle), 0);
} else {
int diff = get_color_diff(handle) / 2;
MwLLColor col = MwLightenColor(handle, color, diff, diff, diff);
int diff = get_color_diff(handle) / 3 * 2;
if(invert) {
MwDrawFrameEx(handle, rect, col, invert, MwDefaultBorderWidth(handle) / 2);
MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth(handle) / 2);
MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth(handle) / 2, -diff);
MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth(handle) / 2, diff);
} else {
MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth(handle) / 2);
MwDrawFrameEx(handle, rect, col, invert, MwDefaultBorderWidth(handle) / 2);
MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth(handle) / 2, -diff);
MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth(handle) / 2, diff);
}
MwLLFreeColor(col);
}
}
@@ -227,11 +224,11 @@ void MwDrawDiamond(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
MwLLFreeColor(darker);
}
void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border) {
void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff) {
MwPoint p[6];
int ColorDiff = get_color_diff(handle);
MwLLColor darker = MwLightenColor(handle, color, -ColorDiff * 3 / 2, -ColorDiff * 3 / 2, -ColorDiff * 3 / 2);
MwLLColor lighter = MwLightenColor(handle, color, ColorDiff, ColorDiff, ColorDiff);
MwLLColor darker = MwLightenColor(handle, color, -ColorDiff * 3 / 2 + diff, -ColorDiff * 3 / 2 + diff, -ColorDiff * 3 / 2 + diff);
MwLLColor lighter = MwLightenColor(handle, color, ColorDiff - diff, ColorDiff - diff, ColorDiff - diff);
p[0].x = rect->x;
p[0].y = rect->y;

View File

@@ -4,6 +4,8 @@
static int create(MwWidget handle) {
MwSetDefault(handle);
MwSetInteger(handle, MwNflat, 0);
return 0;
}
@@ -22,7 +24,13 @@ static void draw(MwWidget handle) {
r.width = MwGetInteger(handle, MwNwidth);
r.height = MwGetInteger(handle, MwNheight);
MwDrawWidgetBack(handle, &r, base, handle->pressed, MwTRUE);
MwDrawWidgetBack(handle, &r, base, handle->pressed, MwGetInteger(handle, MwNflat) ? handle->pressed : 1);
if(MwGetInteger(handle, MwNflat) && !handle->pressed) {
r.x += MwDefaultBorderWidth(handle);
r.y += MwDefaultBorderWidth(handle);
r.width -= MwDefaultBorderWidth(handle) * 2;
r.height -= MwDefaultBorderWidth(handle) * 2;
}
if(px != NULL) {
int ow = r.width;
@@ -61,7 +69,7 @@ static void click(MwWidget handle) {
}
static void prop_change(MwWidget handle, const char* key) {
if(strcmp(key, MwNtext) == 0 || strcmp(key, MwNpixmap) == 0) MwForceRender(handle);
if(strcmp(key, MwNtext) == 0 || strcmp(key, MwNpixmap) == 0 || strcmp(key, MwNflat) == 0) MwForceRender(handle);
}
MwClassRec MwButtonClassRec = {