ocornut / imgui_club

Nice things to use along dear imgui
MIT License
899 stars 103 forks source link

Making p_open a parameter instead of a member? #33

Open Flinterpop opened 10 months ago

Flinterpop commented 10 months ago

I am new to GitHub and am not yet sure how to upload a suggested code change. Thus I've just provided it as an issue:
I fixed this for my purposes but it is a breakings change. On the other hand it now seems to match your overall system for handling window closing.

Clicking close window 'X' on DrawWindow() doesn't close the window. Fix as follows:

  1. Add bool p_open to parameter list of DrawOpen on line 188 as follows: Line 188 void DrawWindow(bool p_open, const char title, void mem_data, size_t mem_size, size_t base_display_addr = 0x0000)

  2. Change Lines 195 as follows: (replace &Open with p_open) if (ImGui::Begin(title, &Open, ImGuiWindowFlags_NoScrollbar)) if (ImGui::Begin(title, p_open, ImGuiWindowFlags_NoScrollbar))

  3. You could remove boolean Open from the remainder of the file.

Brad

ocornut commented 3 months ago

The way it was initially designed it that you can read and write to that bool Open flag in the structure, but you are correct this is quite non-idiomatic with how we do most things in imgui land (generally speaking memory editor is old code at this point).