Closed xposure closed 6 years ago
Still learning here...
Guessing this is how its supposed to be implemented, I modified your sample window inside memory editor to have a public bool? isOpened = true;
and inside Draw I added...
if (isOpened.HasValue && !isOpened.Value)
return;
Then inside SampleWindow
I just have the About
menu item setting _memoryEditor.isOpened = true
This correctly handles collapsing and hiding of the window when the close button is clicked and showing when the About
menu is clicked. Is this the correct work flow for ImGui?
I think having the Begin() method take a nullable by-reference boolean would be a bit odd. If I were doing something here, I would rather have the p_opened
parameter be null by default, rather than a pointer to true.
public static class ImGui
{
public static bool BeginWindow(string name)
=> igBegin(name, null, WindowFlags.Default);
public static bool BeginWindow(string name, WindowFlags flags)
=> igBegin(name, null, flags);
public static unsafe bool BeginWindow(string name, WIndowFlags flags, ref bool opened)
{
byte openedByte = opened ? (byte)1 : (byte)0;
bool result = igBegin(name, &openedByte, flags);
opened = openedByte == 1;
return result;
}
}
I may throw these changes into the next release, and note that it is sort of a breaking change.
Makes sense. Haven't had a chance to sit down and go through it like I wanted with the holidays.
Hey @mellinoe !
Has this change made it into any builds yet? I need to hide the close button on some of my windows and can't (currently) see how to do so (in comparision to "native" ImGui).
Thanks for your continued work on this :)
@DannyGlover It hasn't gotten in yet, but I have some time tonight that I can spend on it. It shouldn't take long to fix.
This should be fixed with https://github.com/mellinoe/ImGui.NET/commit/1f35b5ae9b36ddc33a93ff2197b9fd7fe6095ffd, and I've also put up a new version on nuget.org:
@mellinoe You are a legend my friend.
Works great. Thank you so much :)
ImGui supports hiding the close button on BeginWindow by passing in a null pointer to the
p_opened
value. I made the following change to support this in the .NET bindings but it would break the existing API if anyone is using it and not sure if thats something you would want a PR on.It looks like some of the native structs don't have real wrappings to them (especially the window struct). There is some functionality I need and was thinking about implementing them.
Also some of the lower level imgui functions are missing from the cimgui library like the
XYZBehavior
methods creating a lot of hacks to get around this with setting positions and using invisible buttons.ImGui.cs
ImGuiNative.cs
Edit: Corrected the code to use
p_opened
instead of the result of the call.