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

This commit is contained in:
Nishi 2026-05-01 22:25:13 +09:00
commit 3542d7524a
Signed by: nishi
GPG key ID: 27EF69B208EB9343
2 changed files with 97 additions and 30 deletions

View file

@ -3,7 +3,73 @@
#define TitleHeight 20 #define TitleHeight 20
#define ButtonSize 14 #define ButtonSize 14
static void resize(MwWidget handle){ static void close_draw(MwWidget handle) {
int w = MwGetInteger(handle, MwNwidth);
int h = MwGetInteger(handle, MwNheight);
MwPoint p[2];
MwLLColor c = MwParseColor(handle, MwGetText(handle, MwNforeground));
int bw = MwDefaultBorderWidth(handle);
p[0].x = bw * 2;
p[0].y = bw * 2;
p[1].x = w - bw * 2 - 1;
p[1].y = h - bw * 2 - 1;
MwLLLine(handle->lowlevel, p, c);
p[0].x = w - bw * 2 - 1;
p[0].y = bw * 2;
p[1].x = bw * 2;
p[1].y = h - bw * 2 - 1;
MwLLLine(handle->lowlevel, p, c);
MwLLFreeColor(c);
}
static void maximize_draw(MwWidget handle) {
int w = MwGetInteger(handle, MwNwidth);
int h = MwGetInteger(handle, MwNheight);
MwPoint p[2];
MwLLColor c = MwParseColor(handle, MwGetText(handle, MwNforeground));
int bw = MwDefaultBorderWidth(handle);
p[0].x = bw * 2;
p[0].y = bw * 2;
p[1].x = w - bw * 2 - 1;
p[1].y = bw * 2;
MwLLLine(handle->lowlevel, p, c);
p[0].y = p[1].y = h - bw * 2 - 1;
MwLLLine(handle->lowlevel, p, c);
p[0].x = bw * 2;
p[0].y = bw * 2;
p[1].x = bw * 2;
p[1].y = h - bw * 2 - 1;
MwLLLine(handle->lowlevel, p, c);
p[0].x = p[1].x = w - bw * 2 - 1;
MwLLLine(handle->lowlevel, p, c);
MwLLFreeColor(c);
}
static void minimize_draw(MwWidget handle) {
int w = MwGetInteger(handle, MwNwidth);
int h = MwGetInteger(handle, MwNheight);
MwPoint p[2];
MwLLColor c = MwParseColor(handle, MwGetText(handle, MwNforeground));
int bw = MwDefaultBorderWidth(handle);
p[0].x = bw * 2;
p[0].y = h - bw * 2 - 1;
p[1].x = w - bw * 2 - 1;
p[1].y = h - bw * 2 - 1;
MwLLLine(handle->lowlevel, p, c);
MwLLFreeColor(c);
}
static void resize(MwWidget handle) {
MwSubWindow sw = handle->internal; MwSubWindow sw = handle->internal;
int x, y, w, h; int x, y, w, h;
int ww = MwGetInteger(handle, MwNwidth); int ww = MwGetInteger(handle, MwNwidth);
@ -15,9 +81,9 @@ static void resize(MwWidget handle){
y = bw * 2 + TitleHeight; y = bw * 2 + TitleHeight;
w = ww - bw * 4; w = ww - bw * 4;
h = wh - bw * 4 - TitleHeight; h = wh - bw * 4 - TitleHeight;
if(sw->frame == NULL){ if(sw->frame == NULL) {
sw->frame = MwCreateWidget(MwFrameClass, "frame", handle, x, y, w, h); sw->frame = MwCreateWidget(MwFrameClass, "frame", handle, x, y, w, h);
}else{ } else {
MwVaApply(sw->frame, MwVaApply(sw->frame,
MwNx, x, MwNx, x,
MwNy, y, MwNy, y,
@ -34,9 +100,10 @@ static void resize(MwWidget handle){
#define BUTTON(name) \ #define BUTTON(name) \
x -= ButtonSize; \ x -= ButtonSize; \
if(sw->name == NULL){ \ if(sw->name == NULL) { \
sw->name = MwCreateWidget(MwButtonClass, #name, handle, x, y, w, h); \ sw->name = MwCreateWidget(MwButtonClass, #name, handle, x, y, w, h); \
}else{ \ sw->name->draw_inject = name##_draw; \
} else { \
MwVaApply(sw->name, \ MwVaApply(sw->name, \
MwNx, x, \ MwNx, x, \
MwNy, y, \ MwNy, y, \
@ -90,7 +157,7 @@ static void draw(MwWidget handle) {
r2.height = TitleHeight; r2.height = TitleHeight;
MwDrawRect(handle, &r2, tb); MwDrawRect(handle, &r2, tb);
if(title != NULL){ if(title != NULL) {
MwPoint p; MwPoint p;
p.x = r2.x + (TitleHeight - ButtonSize); p.x = r2.x + (TitleHeight - ButtonSize);
p.y = r2.y + TitleHeight / 2; p.y = r2.y + TitleHeight / 2;

View file

@ -2,7 +2,7 @@
#include "../../external/stb_ds.h" #include "../../external/stb_ds.h"
#define OpenerSize 10 #define OpenerSize 11
#define LineSpace 16 #define LineSpace 16
#define LinePadding 4 #define LinePadding 4
@ -68,7 +68,7 @@ static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwTreeViewEntry**
MwDrawRect(handle, &r, col); MwDrawRect(handle, &r, col);
MwDrawFrame(handle, &r, base, tree->opened); MwDrawFrame(handle, &r, base, tree->opened);
if(tree->opened) { if(tree->opened) {
l[0].x = r.x + (r.width - len) / 2; l[0].x = r.x + (r.width - 1 - len) / 2;
l[0].y = r.y + r.height / 2; l[0].y = r.y + r.height / 2;
l[1].x = l[0].x + len; l[1].x = l[0].x + len;