Nullable (`None`) flag value cannot be easily `or`ed with other values
nlbuescher opened this issue · 6 comments
None
is a perfectly valid option to pass as a flag for ImGui, but the code generator doesn't translate it into an enum value
cf ImGuiDockNodeFlags_None
vs no equivalent in enum class ImGuiDockNodeFlags
I'm realizing now that a nullable is likely intended to replace the None
value. Then I noticed that or
ing a Nullable with any other value isn't possible.
None
is indeed supposed to be null
in Kotlin. Is there a use case for or
ing with None
? It's a no-op anyway.
or
ing with None is how you add new flags to a variable that was declared as empty. and
ing with None is a no-op
usecase:
var windowFlags: ImGuiWindowFlags? = null
// possibly add other conditional flags
if (isFullScreen) {
windowFlags = windowFlags or ImGuiWindowFlags.NoTitleBar or ImGuiWindowFlags.NoCollapse or
ImGuiWindowFlags.NoResize or ImGuiWindowFlags.NoMove or
ImGuiWindowFlags.NoBringToFrontOnFocus or ImGuiWindowFlags.NoNavFocus
}
val value: Flag<ImGuiWindowFlags>? = null or ImGuiWindowFlags.NoTitleBar
is possible.
Your example is already possible, with the wrapper class.
EDIT:
Like so
var windowFlags: Flag<ImGuiWindowFlags>? = null
// possibly add other conditional flags
if (isFullScreen) {
windowFlags = windowFlags or ImGuiWindowFlags.NoTitleBar or ImGuiWindowFlags.NoCollapse or
ImGuiWindowFlags.NoResize or ImGuiWindowFlags.NoMove or
ImGuiWindowFlags.NoBringToFrontOnFocus or ImGuiWindowFlags.NoNavFocus
}
I see. Thanks for that. Closing cause derp.