From 3e40b9ab16194e20b9d8f6866895932dbb609827 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Sun, 16 Nov 2025 08:59:09 +0000 Subject: [PATCH] fancier git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@744 b9cfdab3-6d41-4d17-bbe4-086880011989 --- include/Mw/Draw.h | 5 +++-- milsko.xml | 3 +++ src/core.c | 2 +- src/draw.c | 10 +++++----- src/widget/combobox.c | 18 +++++++++++++++--- src/widget/listbox.c | 9 +++++++++ src/widget/separator.c | 2 +- 7 files changed, 37 insertions(+), 12 deletions(-) diff --git a/include/Mw/Draw.h b/include/Mw/Draw.h index 0bc267e..09ad305 100644 --- a/include/Mw/Draw.h +++ b/include/Mw/Draw.h @@ -85,10 +85,11 @@ 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 + * @param diff Difference (set this to 0 if you don't know what this does) + * @param same Same as dark color * @warning `rect` gets changed to the area of rectangle inside */ -MWDECL void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff); +MWDECL void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same); /*! * @brief Creates a pixmap from image diff --git a/milsko.xml b/milsko.xml index 01467d3..bc2373e 100644 --- a/milsko.xml +++ b/milsko.xml @@ -607,6 +607,9 @@ + + + diff --git a/src/core.c b/src/core.c index e7f63c1..cc5b6f5 100644 --- a/src/core.c +++ b/src/core.c @@ -164,7 +164,7 @@ MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent, MwDestroyWidget(h); return NULL; } - if(h->widget_class == NULL){ + if(h->widget_class == NULL) { MwSetDefault(h); } h->prop_event = 1; diff --git a/src/draw.c b/src/draw.c index 01d4985..ec19e91 100644 --- a/src/draw.c +++ b/src/draw.c @@ -128,12 +128,12 @@ 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), 0); + MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth(handle), 0, 0); } else { int diff = get_color_diff(handle) / 3 * 2; - MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth(handle) / 2, -diff); - MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth(handle) / 2, diff); + MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth(handle) / 2, -diff, handle->widget_class == MwWindowClass ? 1 : 0); + MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth(handle) / 2, diff, 0); } } @@ -219,11 +219,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, int diff) { +void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same) { MwPoint p[6]; int ColorDiff = get_color_diff(handle); 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); + MwLLColor lighter = same ? MwLightenColor(handle, darker, 0, 0, 0) : MwLightenColor(handle, color, ColorDiff - diff, ColorDiff - diff, ColorDiff - diff); p[0].x = rect->x; p[0].y = rect->y; diff --git a/src/widget/combobox.c b/src/widget/combobox.c index 50cf598..0dd7ce7 100644 --- a/src/widget/combobox.c +++ b/src/widget/combobox.c @@ -14,6 +14,8 @@ static int create(MwWidget handle) { MwSetDefault(handle); + MwSetInteger(handle, MwNareaShown, 6); + return 0; } @@ -102,6 +104,14 @@ static void click(MwWidget handle) { int i; void* packet; int width = MwGetInteger(handle, MwNwidth); + int ent = MwGetInteger(handle, MwNareaShown); + + if(arrlen(cb->list) == 0) { + cb->opened = 0; + return; + } + + if(ent > arrlen(cb->list)) ent = arrlen(cb->list); MwLLSetCursor(handle->lowlevel, &MwCursorArrow, &MwCursorArrowMask); @@ -110,10 +120,11 @@ static void click(MwWidget handle) { if(l > width) width = l; } - cb->listbox = MwVaCreateWidget(MwListBoxClass, "listbox", handle, 0, MwGetInteger(handle, MwNheight), width, MwTextHeight(handle, "M") * 6 + MwDefaultBorderWidth(handle) * 2 + MwTextHeight(handle, "M") / 4, + cb->listbox = MwVaCreateWidget(MwListBoxClass, "listbox", handle, 0, MwGetInteger(handle, MwNheight), width, MwTextHeight(handle, "M") * ent + MwDefaultBorderWidth(handle) * 2 + MwTextHeight(handle, "M") / 4, MwNsingleClickSelectable, 1, NULL); - MwLLShow(cb->listbox->lowlevel, 0); + + MwLLSetCursor(((MwListBox)cb->listbox->internal)->frame->lowlevel, &MwCursorArrow, &MwCursorArrowMask); packet = MwListBoxCreatePacket(); for(i = 0; i < arrlen(cb->list); i++) { @@ -127,9 +138,10 @@ static void click(MwWidget handle) { p.x = 0; p.y = MwGetInteger(handle, MwNheight); + MwLLBeginStateChange(cb->listbox->lowlevel); MwLLDetach(cb->listbox->lowlevel, &p); MwLLMakeToolWindow(cb->listbox->lowlevel); - MwLLShow(cb->listbox->lowlevel, 1); + MwLLEndStateChange(cb->listbox->lowlevel); } else { MwLLSetCursor(handle->lowlevel, &MwCursorDefault, &MwCursorDefaultMask); diff --git a/src/widget/listbox.c b/src/widget/listbox.c index f0058eb..6c6bef6 100644 --- a/src/widget/listbox.c +++ b/src/widget/listbox.c @@ -259,6 +259,7 @@ static void resize(MwWidget handle) { int w = MwGetInteger(handle, MwNwidth); int h = MwGetInteger(handle, MwNheight); int ih, y; + int aw; y = MwGetInteger(handle, MwNhasHeading) ? (MwTextHeight(handle, "M") + MwDefaultBorderWidth(handle) * 2) : 0; @@ -289,6 +290,7 @@ static void resize(MwWidget handle) { MwNheight, h, NULL); } + aw = w; h -= MwDefaultBorderWidth(handle) * 2; ih = arrlen(lb->list); @@ -298,6 +300,13 @@ static void resize(MwWidget handle) { MwNareaShown, h / MwTextHeight(handle, "M"), MwNmaxValue, ih, NULL); + + if(ih <= (h / MwTextHeight(handle, "M"))) { + MwLLShow(lb->vscroll->lowlevel, 0); + MwSetInteger(lb->frame, MwNwidth, aw); + } else { + MwLLShow(lb->vscroll->lowlevel, 1); + } } static int create(MwWidget handle) { diff --git a/src/widget/separator.c b/src/widget/separator.c index 4b13509..a34495f 100644 --- a/src/widget/separator.c +++ b/src/widget/separator.c @@ -26,7 +26,7 @@ static void draw(MwWidget handle) { r.y = (r.height - 2) / 2; r.height = 2; } - MwDrawFrameEx(handle, &r, base, 1, 1, 0); + MwDrawFrameEx(handle, &r, base, 1, 1, 0, 0); MwLLFreeColor(base); }