diff -r 412790168d30 -r 35779840ebfd ui/common/context.c --- a/ui/common/context.c Mon Jun 15 21:16:47 2026 +0200 +++ b/ui/common/context.c Tue Jun 16 17:29:14 2026 +0200 @@ -67,6 +67,8 @@ ctx->state_widgets = cxLinkedListCreate(mp->allocator, sizeof(UiStateWidget)); ctx->states = cxArrayListCreate(mp->allocator, sizeof(int), 32); cxSetCompareFunc(ctx->states, cx_cmp_int); + ctx->suppressed_states = cxArrayListCreate(mp->allocator, sizeof(int), 16); + cxSetCompareFunc(ctx->suppressed_states, cx_cmp_int); ctx->actions = cxHashMapCreate(ctx->allocator, sizeof(UiAction), 8); ctx->action_bindings = cxArrayListCreate(ctx->allocator, sizeof(UiActionBinding), 0); @@ -682,15 +684,39 @@ uic_check_state_widgets(ui_context_toplevel_parent(ctx)); } +void ui_suppress_state(UiContext *ctx, int state) { + if(!cxListIndexValid(ctx->suppressed_states, cxListFind(ctx->suppressed_states, &state))) { + cxListAdd(ctx->suppressed_states, &state); + } + + // enable/disable group widgets + uic_check_state_widgets(ui_context_toplevel_parent(ctx)); +} + +void ui_unsuppress_state(UiContext *ctx, int state) { + int i = cxListFind(ctx->suppressed_states, &state); + if(i != -1) { + cxListRemove(ctx->suppressed_states, i); + } + + // enable/disable group widgets + uic_check_state_widgets(ui_context_toplevel_parent(ctx)); +} + typedef struct StatesList { CX_ARRAY(int, states); + CX_ARRAY(int, suppressed); } StatesList; static void add_ctx_states(UiContext *ctx, StatesList *states) { size_t nstates = cxListSize(ctx->states); - int *ctx_states = cxListAt(ctx->states, 0);; + int *ctx_states = cxListAt(ctx->states, 0); + + size_t nsuppressed = cxListSize(ctx->suppressed_states); + int *ctx_suppressed_states = cxListAt(ctx->suppressed_states, 0); cx_array_add_array(states->states, ctx_states, nstates); + cx_array_add_array(states->suppressed, ctx_suppressed_states, nsuppressed); CxIterator i = cxListIterator(ctx->documents); cx_foreach(void *, doc, i) { @@ -702,7 +728,28 @@ int* ui_active_states(UiContext *ctx, int *nstates) { StatesList states; cx_array_init(states.states, 32); + cx_array_init(states.suppressed, 8); add_ctx_states(ctx, &states); + + // remove suppressed states + for(size_t i=0;istate_widgets); cx_foreach(UiStateWidget *, gw, i) { char *check = calloc(1, gw->numstates); - for(int i=0;inumstates;k++) { - if(groups[i] == gw->states[k]) { + if(states[i] == gw->states[k]) { check[k] = 1; } } @@ -738,7 +785,7 @@ gw->enable(gw->widget, enable); } - free(groups); + free(states); } void ui_widget_set_states(UiContext *ctx, UIWIDGET widget, ui_enablefunc enable, ...) {