New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Window improvements: callbacks, ids #35
Window improvements: callbacks, ids #35
Conversation
… for vertices (they check correctly now). Paq.sh now automatically outputs to nuklear.h.
keharriso's Prevent clicking more than one (overlapping) button per frame. However, this has a couple of other changes that should fix dropdowns from intefering as well.
- Sets click to 0 every start of frame - Input was still down for that frame, so it triggered the next event Now it waits for your button to go back up before resetting the clicked variable, so as long as your mouse is down, only one item is clicked.
…checkbox! With README changes that show off more features and the updated style. Slightly modified.
…nto fix_radio_buttons
…nto fix_radio_buttons
…nto fix_radio_buttons
…mension of the window (if it is resizable). All old functionality will remain the same (it used to return 1 instead of a pointer, but if(nk_begin) will remain the same, since it checks for 0).
This is also useful if you want to have a max or minimum size for the window: if(nk_window *wnd = nk_begin(...)){
if(wnd->bounds.w < minW)
wnd->bounds.w = minW;
if(wnd->bounds.h < minH)
wnd->bounds.h = minH;
//...
nk_end();
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nitpick. It would be nice if your PR's would not depend on other PR's when not required. This would make them easier to review and merge independent of each other :)
*/ | ||
NK_API int nk_begin(struct nk_context *ctx, const char *title, struct nk_rect bounds, nk_flags flags); | ||
NK_API struct nk_window* nk_begin(struct nk_context *ctx, const char *title, struct nk_rect bounds, nk_flags flags); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, this return type change is also a breaking change :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(nk_begin(...)) is generally used and that will still behave the exact same way. Only if the user stores int it will break. Otherwise it will now provide functionality to immediately get the window you opened
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, this is not a problem for most users, but it is a breaking change for some. I'm only really pointing this out because the patch version was bumped, and not at least the minor version (maybe I could have been a little clearer, mb).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, will get on bumping the minor versions and merging asap
@@ -8,6 +8,12 @@ | |||
/// - [yy]: Minor version with non-breaking API and library changes | |||
/// - [zz]: Bug fix version with no direct changes to API | |||
/// | |||
/// - 2019/12/23 (4.01.9) - Changed nk_begin to return a nk_window so you can get the position and other useful info. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a change that needs a minor bump :)
nk_add_window has been added to support adding a window that isn't necessarily drawn and returning it. You then have to check via
nk_window_has_contents
to see if you can actually fill the window. This is very useful as this provides you with a callback whenever your window is closed or minimized.It also takes in an id and a title instead of a name of the window. Meaning you don't need a name and title for a window anymore to keep them apart (so no nk_begin and nk_begin_titled equiv).
nk_begin now returns an nk_window, so you can get the location and dimension of the window (handy if it is resizable). All old functionality will remain the same (it used to return 1 instead of a pointer, but if(nk_begin) will remain the same, since it checks for 0).
An example for when this is used in pratice; abstraction for UI where you'd like to know physical location of the window and keep that up-to-date.
This branch depends on fix_radio_buttons.