smoother tab

This commit is contained in:
Nishi 2026-05-07 22:59:54 +09:00
commit d1143a68ac
Signed by: nishi
GPG key ID: 27EF69B208EB9343

View file

@ -152,14 +152,8 @@ static void show_frame(MwWidget handle) {
int n = MwGetInteger(handle, MwNvalue);
int i;
for(i = 0; i < arrlen(t->frames); i++) {
if(i != n) MwLLShow(t->frames[i]->lowlevel, 0);
}
resize(handle);
MwLLShow(t->frames[n]->lowlevel, 1);
MwForceRender(handle);
MwDispatchUserHandler(handle, MwNchangedHandler, NULL);
@ -185,14 +179,12 @@ static void click(MwWidget handle) {
static MwWidget mwTabAddImpl(MwWidget handle, const char* name) {
MwTab t = handle->internal;
MwWidget f = MwCreateWidget(MwFrameClass, "tabframe", handle, 0, MwGetInteger(handle, MwNheight), 0, 0);
MwWidget f = MwCreateWidget(MwFrameClass, "tabframe", handle, 0, MwGetInteger(handle, MwNheight), MwGetInteger(handle, MwNwidth) - MwDefaultBorderWidth(handle) * 2, MwGetInteger(handle, MwNheight) - tab_height(handle) - MwDefaultBorderWidth(handle) * 2);
char* n = MwStringDuplicate(name);
arrput(t->frames, f);
arrput(t->names, n);
MwLLShow(f->lowlevel, 0);
MwForceRender(handle);
if(MwGetInteger(handle, MwNvalue) == -1) {
@ -229,15 +221,20 @@ static void func_handler(MwWidget handle, const char* name, void* out, va_list v
static void resize(MwWidget handle) {
MwTab t = handle->internal;
int v = MwGetInteger(handle, MwNvalue);
int i;
if(v == -1) return;
for(i = 0; i < arrlen(t->frames); i++) {
int y = MwGetInteger(handle, MwNheight);
MwVaApply(t->frames[v],
MwNx, MwDefaultBorderWidth(handle),
MwNy, tab_height(handle) + MwDefaultBorderWidth(handle),
MwNwidth, MwGetInteger(handle, MwNwidth) - MwDefaultBorderWidth(handle) * 2,
MwNheight, MwGetInteger(handle, MwNheight) - tab_height(handle) - MwDefaultBorderWidth(handle) * 2,
NULL);
if(i == v) tab_height(handle) + MwDefaultBorderWidth(handle);
MwVaApply(t->frames[i],
MwNx, MwDefaultBorderWidth(handle),
MwNy, y,
MwNwidth, MwGetInteger(handle, MwNwidth) - MwDefaultBorderWidth(handle) * 2,
MwNheight, MwGetInteger(handle, MwNheight) - tab_height(handle) - MwDefaultBorderWidth(handle) * 2,
NULL);
}
}
MwClassRec MwTabClassRec = {