add props_change, closes #20
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
This commit is contained in:
parent
4423c318e8
commit
1fd86732f5
24 changed files with 114 additions and 52 deletions
|
|
@ -35,7 +35,7 @@ typedef void* MwWidget;
|
|||
#endif
|
||||
typedef void (*MwHandler)(MwWidget handle);
|
||||
typedef int (*MwHandlerWithStatus)(MwWidget handle);
|
||||
typedef void (*MwHandlerProps)(MwWidget handle, const char** key);
|
||||
typedef void (*MwHandlerProps)(MwWidget handle, char** key);
|
||||
typedef void (*MwHandlerProp)(MwWidget handle, const char* key);
|
||||
typedef void (*MwHandlerChildrenProp)(MwWidget handle, MwWidget child, const char* key);
|
||||
typedef void (*MwHandlerKey)(MwWidget handle, int key);
|
||||
|
|
|
|||
|
|
@ -1994,7 +1994,7 @@ static void MwLLSetXYImpl(MwLL handle, int x, int y) {
|
|||
}
|
||||
region_setup(handle);
|
||||
|
||||
recursive_render(handle);
|
||||
if(handle->wayland.type == MwLL_WAYLAND_SUBLEVEL) recursive_render(handle);
|
||||
|
||||
MwLLDispatch(handle, draw, NULL);
|
||||
}
|
||||
|
|
@ -2028,7 +2028,7 @@ static void MwLLSetWHImpl(MwLL handle, int w, int h) {
|
|||
}
|
||||
|
||||
region_setup(handle);
|
||||
recursive_render(handle);
|
||||
if(handle->wayland.type == MwLL_WAYLAND_SUBLEVEL) recursive_render(handle);
|
||||
|
||||
framebuffer_destroy(&handle->wayland);
|
||||
framebuffer_setup(&handle->wayland);
|
||||
|
|
|
|||
41
src/core.c
41
src/core.c
|
|
@ -550,6 +550,13 @@ void MwSetInteger(MwWidget handle, const char* key, int n) {
|
|||
shput(handle->integer, key, n);
|
||||
}
|
||||
if(handle->prop_event) {
|
||||
char** keys = NULL;
|
||||
|
||||
arrput(keys, (char*)key);
|
||||
arrput(keys, NULL);
|
||||
MwDispatch3(handle, props_change, keys);
|
||||
arrfree(keys);
|
||||
|
||||
MwDispatch3(handle, prop_change, key);
|
||||
if(handle->parent != NULL) MwDispatch4(handle->parent, children_prop_change, handle, key);
|
||||
}
|
||||
|
|
@ -584,6 +591,13 @@ void MwSetText(MwWidget handle, const char* key, const char* value) {
|
|||
}
|
||||
}
|
||||
if(handle->prop_event) {
|
||||
char** keys = NULL;
|
||||
|
||||
arrput(keys, (char*)key);
|
||||
arrput(keys, NULL);
|
||||
MwDispatch3(handle, props_change, keys);
|
||||
arrfree(keys);
|
||||
|
||||
MwDispatch3(handle, prop_change, key);
|
||||
if(handle->parent != NULL) MwDispatch4(handle->parent, children_prop_change, handle, key);
|
||||
}
|
||||
|
|
@ -605,6 +619,13 @@ void MwSetVoid(MwWidget handle, const char* key, void* value) {
|
|||
shput(handle->data, key, value);
|
||||
}
|
||||
if(handle->prop_event) {
|
||||
char** keys = NULL;
|
||||
|
||||
arrput(keys, (char*)key);
|
||||
arrput(keys, NULL);
|
||||
MwDispatch3(handle, props_change, keys);
|
||||
arrfree(keys);
|
||||
|
||||
MwDispatch3(handle, prop_change, key);
|
||||
if(handle->parent != NULL) MwDispatch4(handle->parent, children_prop_change, handle, key);
|
||||
}
|
||||
|
|
@ -731,8 +752,16 @@ void MwVaApply(MwWidget handle, ...) {
|
|||
static void MwVaListApply_Internal(MwWidget handle, va_list va, int only_early) {
|
||||
char* key;
|
||||
int x = MwDEFAULT, y = MwDEFAULT, w = MwDEFAULT, h = MwDEFAULT;
|
||||
char** keys = NULL;
|
||||
int old = handle->prop_event;
|
||||
int i;
|
||||
|
||||
handle->prop_event = 0;
|
||||
while((key = va_arg(va, char*)) != NULL) {
|
||||
if(!only_early || key[1] == 'E') {
|
||||
arrput(keys, key);
|
||||
}
|
||||
|
||||
if(key[0] == 'I') {
|
||||
int n = va_arg(va, int);
|
||||
if(only_early && key[1] != 'E') continue;
|
||||
|
|
@ -790,6 +819,18 @@ static void MwVaListApply_Internal(MwWidget handle, va_list va, int only_early)
|
|||
MwSetInteger(handle, MwNheight, h);
|
||||
}
|
||||
}
|
||||
handle->prop_event = old;
|
||||
|
||||
arrput(keys, NULL);
|
||||
|
||||
if(handle->prop_event) {
|
||||
for(i = 0; keys[i] != NULL; i++) {
|
||||
MwDispatch3(handle, prop_change, keys[i]);
|
||||
}
|
||||
MwDispatch3(handle, props_change, keys);
|
||||
}
|
||||
|
||||
arrfree(keys);
|
||||
}
|
||||
|
||||
void MwVaListApply(MwWidget handle, va_list va) {
|
||||
|
|
|
|||
|
|
@ -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};
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ MwClassRec MwButtonClassRec = {
|
|||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL, /* props_change */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ MwClassRec MwCheckBoxClassRec = {
|
|||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL, /* props_change */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ MwClassRec MwComboBoxClassRec = {
|
|||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL, /* props_change */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ MwClassRec MwEntryClassRec = {
|
|||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
clipboard, /* clipboard */
|
||||
NULL,
|
||||
NULL, /* props_change */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ MwClassRec MwFrameClassRec = {
|
|||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL, /* props_change */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ MwClassRec MwImageClassRec = {
|
|||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL, /* props_change */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
|
|
|||
|
|
@ -376,7 +376,7 @@ MwClassRec MwLabelClassRec = {
|
|||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL, /* props_change */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
|
|
|||
|
|
@ -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};
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ MwClassRec MwMenuClassRec = {
|
|||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL, /* props_change */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ MwClassRec MwNumberEntryClassRec = {
|
|||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL, /* props_change */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ MwClassRec MwProgressBarClassRec = {
|
|||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL, /* props_change */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ MwClassRec MwRadioBoxClassRec = {
|
|||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL, /* props_change */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ MwClassRec MwScrollBarClassRec = {
|
|||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL, /* props_change */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ MwClassRec MwSeparatorClassRec = {
|
|||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL, /* props_change */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ MwClassRec MwSubMenuClassRec = {
|
|||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL, /* props_change */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
|
|
|||
|
|
@ -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};
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ MwClassRec MwViewportClassRec = {
|
|||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL, /* props_change */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
|
|
|||
|
|
@ -594,7 +594,7 @@ MwClassRec MwVulkanClassRec = {
|
|||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL, /* props_change */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ MwClassRec MwWindowClassRec = {
|
|||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL, /* props_change */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue