-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
ImGuiMod_Shortcut is not "portable" #5923
Comments
1+ |
{
"name": "ImGuiMod_Shortcut",
"value": "ImGuiMod_Super",
"conditionals": [
{
"condition": "if",
"expression": "defined(__APPLE__)"
}
]
},
{
"name": "ImGuiMod_Shortcut",
"value": "ImGuiMod_Ctrl",
"conditionals": [
{
"condition": "ifnot",
"expression": "defined(__APPLE__)"
}
]
}, It seems that dear_bindings is able to do it. The main reason is that does preprocessing itself with lex and yacc while cimgui takes the preprocessed output. That make things extraordinary more complex and prone to failures but is the way to go if you want to handle things like that. (That way still has to prove some things as imgui_internal, implot, etc parsing). The way to go for cimgui would be to make generation and compilation in the same machine. That is the same situation as with freetype, wchar32, obsolete functions or other preprocesor options (even options in imconfig.h) |
Just found https://github.com/ocornut/imgui/blob/master/imgui.h#L1928 where |
I will look into the possibility of making that change. I am not entirely sure it is easily .
Yes. This specific occurrence was more difficult to do at runtime. I agree it is inconsistent to use the define it was just much simpler. I realized that we almost never take advantage of the dynamic nature |
I experimented with various approach, and decided toward implementing a redirect without storage:
The other approach, which I have also implemented and tried is to store the alias, it felt slightly more complicated and the only value of doing it was to make it easier to expose e.g. (Also committed cc3a220 which is internal refactor only, designed to make it easy to switch between both approach) Let me know if it works! EDIT: Interestingly if we decide to store a variant of KeyMods with ImGuiMod_Shortcut inside, we can actually still do it with first approach anyway. |
Version/Branch of Dear ImGui:
Version: 1.89.1
Branch: master
My Issue/Question:
See here:
imgui/imgui.h
Lines 1456 to 1460 in a8df192
In its header file, as part of the core API, imgui now has a value that depends on the system that it's being compiled on.
The first issue I see with this is that this might not be representable in bindings to other languages. Or if it is, the binding generators can be not smart enough to discern this and instead just paste the value of the system on which the generator happens to be running.
cimgui already straight up defines it as the non-Mac value, presumably because that's where it was generated.
https://github.com/cimgui/cimgui/blob/68483775b3d7594eb14d296ec002ac11683882c9/cimgui.h#L643
Maybe this is an oversight that can be fixed, so cc @sonoro1234. But still there's no good way to expose it in the JSON info files of cimgui.
Based on this, in crystal-imgui I intend to also ignore the Mac value for the foreseeable future. Though I could manually code the conditional into my generator.
The 2nd concern again comes from the fact that this is in a header file, so even in C++, the value gets baked into the destination executable, not into imgui (built as a shared library). Or well, it probably also gets baked into imgui, which is even less good.
Either way, because I believe this is the first ever occurrence of a platform-specific API value in a header, maybe it warrants some discussion or reconsideration.
Perhaps turning
ImGuiMod_Shortcut
into its own unique value (but then handling the difference on.cpp
side) would be the approach that's less prone to cause issues down the line. Although... that's not possible to apply to equality checks against the value :/The text was updated successfully, but these errors were encountered: