add props_change, closes #20
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good

This commit is contained in:
Nishi 2026-04-20 16:22:06 +09:00
commit 1fd86732f5
24 changed files with 114 additions and 52 deletions

View file

@ -78,7 +78,6 @@ static void layout(MwWidget handle) {
static void draw(MwWidget handle) {
MwRect r;
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
MwBox b = handle->internal;
r.x = 0;
r.y = 0;
@ -92,12 +91,6 @@ static void draw(MwWidget handle) {
MwDrawRect(handle, &r, base);
MwLLFreeColor(base);
if(b->layout) {
layout(handle);
b->layout = 0;
}
}
static void prop_change(MwWidget handle, const char* key) {
@ -120,6 +113,16 @@ static void children_prop_change(MwWidget handle, MwWidget child, const char* ke
}
}
static void tick(MwWidget handle) {
MwBox b = handle->internal;
if(b->layout) {
layout(handle);
b->layout = 0;
}
}
static void resize(MwWidget handle) {
MwBox b = handle->internal;
b->layout = 1;
@ -146,12 +149,12 @@ MwClassRec MwBoxClassRec = {
NULL, /* mouse_down */
NULL, /* key */
NULL, /* execute */
NULL, /* tick */
tick, /* tick */
resize, /* resize */
children_update, /* children_update */
children_prop_change, /* children_prop_change */
NULL, /* clipboard */
NULL,
NULL, /* props_change */
NULL,
NULL,
NULL};

View file

@ -109,7 +109,7 @@ MwClassRec MwButtonClassRec = {
NULL, /* children_update */
NULL, /* children_prop_change */
NULL, /* clipboard */
NULL,
NULL, /* props_change */
NULL,
NULL,
NULL};

View file

@ -54,7 +54,7 @@ MwClassRec MwCheckBoxClassRec = {
NULL, /* children_update */
NULL, /* children_prop_change */
NULL, /* clipboard */
NULL,
NULL, /* props_change */
NULL,
NULL,
NULL};

View file

@ -200,7 +200,7 @@ MwClassRec MwComboBoxClassRec = {
NULL, /* children_update */
NULL, /* children_prop_change */
NULL, /* clipboard */
NULL,
NULL, /* props_change */
NULL,
NULL,
NULL};

View file

@ -204,7 +204,7 @@ MwClassRec MwEntryClassRec = {
NULL, /* children_update */
NULL, /* children_prop_change */
clipboard, /* clipboard */
NULL,
NULL, /* props_change */
NULL,
NULL,
NULL};

View file

@ -62,7 +62,7 @@ MwClassRec MwFrameClassRec = {
NULL, /* children_update */
NULL, /* children_prop_change */
NULL, /* clipboard */
NULL,
NULL, /* props_change */
NULL,
NULL,
NULL};

View file

@ -58,7 +58,7 @@ MwClassRec MwImageClassRec = {
NULL, /* children_update */
NULL, /* children_prop_change */
NULL, /* clipboard */
NULL,
NULL, /* props_change */
NULL,
NULL,
NULL};

View file

@ -376,7 +376,7 @@ MwClassRec MwLabelClassRec = {
NULL, /* children_update */
NULL, /* children_prop_change */
NULL, /* clipboard */
NULL,
NULL, /* props_change */
NULL,
NULL,
NULL};

View file

@ -377,7 +377,6 @@ static void draw(MwWidget handle) {
}
static void prop_change(MwWidget handle, const char* prop) {
if(strcmp(prop, MwNwidth) == 0 || strcmp(prop, MwNheight) == 0 || strcmp(prop, MwNhasHeading) == 0) resize(handle);
if(strcmp(prop, MwNleftPadding) == 0) {
MwListBox lb = handle->internal;
MwForceRender(lb->frame);
@ -564,6 +563,17 @@ static void tick(MwWidget handle) {
}
}
static void props_change(MwWidget handle, char** props) {
int i;
int rsz = 0;
for(i = 0; props[i] != NULL; i++) {
if(strcmp(props[i], MwNwidth) == 0 || strcmp(props[i], MwNheight) == 0 || strcmp(props[i], MwNhasHeading) == 0) rsz = 1;
}
if(rsz) resize(handle);
}
MwClassRec MwListBoxClassRec = {
wcreate, /* create */
destroy, /* destroy */
@ -581,7 +591,7 @@ MwClassRec MwListBoxClassRec = {
NULL, /* children_update */
NULL, /* children_prop_change */
NULL, /* clipboard */
NULL,
props_change, /* props_change */
NULL,
NULL,
NULL};

View file

@ -205,7 +205,7 @@ MwClassRec MwMenuClassRec = {
NULL, /* children_update */
NULL, /* children_prop_change */
NULL, /* clipboard */
NULL,
NULL, /* props_change */
NULL,
NULL,
NULL};

View file

@ -146,7 +146,7 @@ MwClassRec MwNumberEntryClassRec = {
NULL, /* children_update */
NULL, /* children_prop_change */
NULL, /* clipboard */
NULL,
NULL, /* props_change */
NULL,
NULL,
NULL};

View file

@ -521,7 +521,8 @@ MwClassRec MwOpenGLClassRec = {wcreate, /* create */
NULL, /* children_update */
NULL, /* children_prop_change */
NULL, /* clipboard */
NULL, NULL, NULL, NULL};
NULL, /* props_change */
NULL, NULL, NULL};
MwClass MwOpenGLClass = &MwOpenGLClassRec;
#else
MWDECL MwClass MwOpenGLClass;

View file

@ -62,7 +62,7 @@ MwClassRec MwProgressBarClassRec = {
NULL, /* children_update */
NULL, /* children_prop_change */
NULL, /* clipboard */
NULL,
NULL, /* props_change */
NULL,
NULL,
NULL};

View file

@ -63,7 +63,7 @@ MwClassRec MwRadioBoxClassRec = {
NULL, /* children_update */
NULL, /* children_prop_change */
NULL, /* clipboard */
NULL,
NULL, /* props_change */
NULL,
NULL,
NULL};

View file

@ -273,7 +273,7 @@ MwClassRec MwScrollBarClassRec = {
NULL, /* children_update */
NULL, /* children_prop_change */
NULL, /* clipboard */
NULL,
NULL, /* props_change */
NULL,
NULL,
NULL};

View file

@ -51,7 +51,7 @@ MwClassRec MwSeparatorClassRec = {
NULL, /* children_update */
NULL, /* children_prop_change */
NULL, /* clipboard */
NULL,
NULL, /* props_change */
NULL,
NULL,
NULL};

View file

@ -101,7 +101,7 @@ static void draw(MwWidget handle) {
}
static void click(MwWidget handle) {
MwWidget w = handle;
MwWidget w = handle;
MwMenu menu = handle->internal;
if(arrlen(menu->sub) > 0) {
@ -257,7 +257,7 @@ MwClassRec MwSubMenuClassRec = {
NULL, /* children_update */
NULL, /* children_prop_change */
NULL, /* clipboard */
NULL,
NULL, /* props_change */
NULL,
NULL,
NULL};

View file

@ -331,10 +331,6 @@ static void draw(MwWidget handle) {
MwLLFreeColor(c);
}
static void prop_change(MwWidget handle, const char* prop) {
if(strcmp(prop, MwNwidth) == 0 || strcmp(prop, MwNheight) == 0) resize(handle);
}
static void* mwTreeViewAddImpl(MwWidget handle, void* parent, MwLLPixmap pixmap, const char* item) {
MwTreeView tv = handle->internal;
MwTreeViewEntry* t = malloc(sizeof(*t));
@ -480,13 +476,24 @@ static void tick(MwWidget handle) {
}
}
static void props_change(MwWidget handle, char** props) {
int i;
int rsz = 0;
for(i = 0; props[i] != NULL; i++) {
if(strcmp(props[i], MwNwidth) == 0 || strcmp(props[i], MwNheight) == 0) rsz = 1;
}
if(rsz) resize(handle);
}
MwClassRec MwTreeViewClassRec = {
wcreate, /* create */
destroy, /* destroy */
draw, /* draw */
NULL, /* click */
NULL, /* parent_resize */
prop_change, /* prop_change */
NULL, /* prop_change */
NULL, /* mouse_move */
NULL, /* mouse_up */
NULL, /* mouse_down */
@ -497,7 +504,7 @@ MwClassRec MwTreeViewClassRec = {
NULL, /* children_update */
NULL, /* children_prop_change */
NULL, /* clipboard */
NULL,
props_change, /* props_change */
NULL,
NULL,
NULL};

View file

@ -192,7 +192,7 @@ MwClassRec MwViewportClassRec = {
NULL, /* children_update */
NULL, /* children_prop_change */
NULL, /* clipboard */
NULL,
NULL, /* props_change */
NULL,
NULL,
NULL};

View file

@ -594,7 +594,7 @@ MwClassRec MwVulkanClassRec = {
NULL, /* children_update */
NULL, /* children_prop_change */
NULL, /* clipboard */
NULL,
NULL, /* props_change */
NULL,
NULL,
NULL};

View file

@ -60,7 +60,7 @@ MwClassRec MwWindowClassRec = {
NULL, /* children_update */
NULL, /* children_prop_change */
NULL, /* clipboard */
NULL,
NULL, /* props_change */
NULL,
NULL,
NULL};