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
Update ImGui and use event-based io #688
Conversation
Oops I just saw the other PR implementing this (#685). Leaving this one open in case it is more complete. |
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 great, thanks! I didn't get to the event-based API changes in the other PR, so this one is much further along
There's a couple of tweaks to merge this, mainly just running rustfmt and the commented out line. Updating the remaining platform-support code to use the event based API would be nice but feel free to leave it for now, and can be done after the PR is merged
Hmm the |
Ahh I think this is Gilnaa/memoffset#49 - the issue is the Io struct is now quite large because of the keymap etc Edit: As a workaround, it seems just splitting the |
Yes it seems like offset_of! allocates a new |
That should be solved by rust-lang/rfcs#3308, and was some part of the motivation for it, for what it's worth (not |
What should be done about the changes in |
In the mean time you should just run that test on a thread with a lot of stack, perhaps. |
I see, until then, splitting the checks is probably fine |
that would work too |
I think I fixed everything now. winit-support now uses the full event system, the tests work by using a thread with a 4MB stack and I ran cargo fmt... |
Oh, not mysterious, I just forgot how stack variables work,
So makes perfect sense the test function tries to allocate enough space for every
Ah excellent, good to know! Moving the test to a thread is a good idea, bit neater than splitting it over multiple functions
I think there is two options (well, three if we count "just break the API" 😛 )
For this case However for future I'm increasingly thinking keeping the deprecated function bindings around is a good idea - as it would make it easier to avoid breaking changes, avoiding redundant reimplementation. That said:
|
Hmm the freetype failure seems to be caused by a change in cimgui,
to |
When we stick to |
If/when you're willing to bump the MSRV to 1.65 and memoffset to v0.8, you can use EDIT: ofc it's better to use |
Ohhh, I see - yeh the builder backwards-compat with the With a bulk of these changes in #537 I just resigned to breaking things, as it would involve duplicating a large portion of the code However with this and the few builders I initially though we keep Instead I realized we can probably just:
That way we:
So basically the change would not be "semver compatible", but "probably source compatible" (i.e will work in common cases without library user changing code; and where code changes are needed the old code will error clearly importantly never keep working and cause unexpected runtime behaviour) - which for a GUI library (large API surface) binding to a third-party library (some changes outside our control) is possibly a good target to aim for Sorry for the long reply! A bit excessive answer for this particular case, mostly thinking of how best to handle these changes in general |
That would probably work quite well in every "normal" API usage case 👍. I had the idea of making a similar thing work with generics. However, I will probably not have time for this until after christmas... |
:c waiting |
The changes to ImageButton should now be backwards compatible, as long as the type |
In this case we are intentionally returning different struct for backwards-compat
Hope you had a good Christmas! The backwards-compat changes look good, thanks. I pushed a few minor changes to fix the obvious CI failures, the remaining ones need a bit more looking into 🤔
|
May help with macOS builds
The ubuntu build failure seems to be caused by a missing flag to generator.lua. When changing update-cimgui-output.sh to include "internal,freetype" as flags instead of "internal" and regenerating bindings, everything seems to work. |
There are now a few freetype-specific functions in the API so we need seperate bindgen output for it Duplicates the imgui code somewhat unnecessarily, but shouldn't impact repo size much due to git's compression
Ahh quite right - short of moving the cimgui generator to build-time (which increases the build requirements for imgui-rs to include luajit etc, which I think is unreasonable), I think the solution is just to add a freetype variant to the various generated Pushed commit with this, and it adds a bit of clutter but nothing too drastic. |
Was missing required flag to cimgui generator
Glob pattern no longer matched anything, including the intermediate cimgui files unnecessarily
This all looks good to me - @Rob2309 are you aware of any outstanding issues, or is it good to merge? |
I see no major problems. The only thing we might want to revert is the name change to It might be good to add a test that uses all public variables of the major imgui structs, so that breaking changes would be caught easily. |
I think this is okay - it was a typo (in imgui-rs), and I think it's worth changing given:
This is a very good point, it's pretty hard to keep track of exactly what is breaking I suspect a bit of code using everything would be hard to maintain - something like one of the semver-checking tools might be more practical:
The latter outputs the following for the current state of this PR: Output
It raises a good point we should add |
The changelog should probably be updated. |
finally its merged yay |
This PR updates ImGui to v1.89.1 and exposes the new event-based io functions.
Possibly breaking changes:
ImageButton
now takes an explicit ID,ImageButton::new()
changed, addedui.image_button()
andui.image_button_config()