Immediate-Mode-UI / Nuklear

A single-header ANSI C immediate mode cross-platform GUI library
https://immediate-mode-ui.github.io/Nuklear/doc/index.html
Other
9.17k stars 553 forks source link

Added feature to disable widgets #580

Closed yukyduky closed 10 months ago

yukyduky commented 12 months ago

I've added functions to disable widgets and gray them out. You use it like this:

nk_widget_disable_begin(ctx); nk_widget(...); nk_widget(...); nk_widget(...); nk_widget_disable_end(ctx);

There's a variable in each style struct in case you want to change the gray out factor per widget type. So far I've only tested it on the widgets in overview.c. Let me know if you have any issues :)

RobLoach commented 11 months ago

Looks great! Thanks so much. Will let others review :+1:

kotvkvante commented 11 months ago

That's great.

I think it would be cool to add another option to disable all widgets on window. For example add flag like NK_WINDOW_DISABLED. We already have NK_WINDOW_NO_INPUT, but it's useless (i think). I understand that this flag handles different purpose. But I think no one need just disable input without any visual effect of this.

yukyduky commented 11 months ago

Neat idea! I personally don't need that atm, but I already have an idea of how to add it so I'll look into it.

kotvkvante commented 11 months ago

By the way, is it good to change style parameters for every widget and restore them back every time? If I'm using only buttons in my GUI, can I change only button style? I don't know lot about how compilers works (does he enough clever to remove unnecessary assignments??), but.. I go crazy when I think about the speed of programs... If there is no other options to do this or this just how such things works, then ok.. I'm just beginner programmer.

yukyduky commented 11 months ago

Is setting the style only for the ones you want faster? Yes. Is it a significant amount? No. I know it looks bad, but it's really not. The alternatives may be slightly faster, but are more cumbersome to deal with for very little gain.

riri commented 11 months ago

I'll check this asap

yukyduky commented 10 months ago

I will try and fix this ASAP :)

yukyduky commented 10 months ago

Should be fixed now. I made the widget disabling example be one level further out so that it can also be applied to charts etc.

riri commented 10 months ago

@yukyduky Thanks for the functionality and efforts after the review ;-)