Closed bolt-blue closed 1 month ago
Possible solution is to make a function for the "template", and call it after defining each window
void mytemplate(ctx) {
/* fixed widget pixel width */
nk_layout_row_static(ctx, 30, 80, 1);
if (nk_button_label(ctx, "button")) {
/* event handling */
}
}
// ....
struct nk_context ctx;
if (nk_begin(&ctx, "Window 1", nk_rect(50, 50, 220, 220),
NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_CLOSABLE)) {
mytemplate(ctx);
}
nk_end(&ctx);
if (nk_begin(&ctx, "Window 2", nk_rect(50, 50, 220, 220),
NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_CLOSABLE)) {
mytemplate(ctx);
}
nk_end(&ctx);
Thank you. That could be a workable solution.
I suppose I've had in my head that the string id's would have to be compile-time defined. But I guess there's no reason they couldn't be generated at run time. Unless I'm mistaken.
If that's reasonable, then this approach is definitely fine.
Is it possible to have multiple windows, each with the same "template" so-to-speak, but with varying content?
With what I know of the code base so far, I don't think this can be done.
Each window has a hard-coded string identifier, which I believe is used predominantly to store and reference it's scroll position(s). I don't see a way around this.
Is there perhaps an alternative to help effectively achieve the same ends?