mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-07 18:09:44 +00:00
introduce MwNflat
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@723 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#define MwNwaitMS "IwaitMS"
|
||||
#define MwNhideInput "IhideInput"
|
||||
#define MwNsingleClickSelectable "IsingleClickSelectable"
|
||||
#define MwNflat "Iflat"
|
||||
|
||||
#define MwNtitle "Stitle"
|
||||
#define MwNtext "Stext"
|
||||
|
||||
@@ -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">
|
||||
|
||||
23
src/draw.c
23
src/draw.c
@@ -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;
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user