Make debug windows right edge sticky - #455
Conversation
Codecov ReportBase: 86.71% // Head: 86.71% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## master #455 +/- ##
=======================================
Coverage 86.71% 86.71%
=======================================
Files 83 83
Lines 3981 3981
=======================================
Hits 3452 3452
Misses 529 529 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
650f702 to
ed19a7f
Compare
| NULL, | ||
| }; | ||
|
|
||
| int delta = k_width - size.width; |
There was a problem hiding this comment.
This is UB on the first call to this function since k_width isn't initialized.
There was a problem hiding this comment.
Aren't integer members 0 if NOS in c++?
There was a problem hiding this comment.
No, unless set in e.g. a constructor they're uninitialized and reading from them is UB.
| break; | ||
| } | ||
| ImGuiWindow *win = ImGui::FindWindowByName(name); | ||
| if (!win) { |
There was a problem hiding this comment.
Isn't this a programming error if it ever happens? Until we have a saner way of keeping the names in sync, just assert() that we have the window we're looking for.
There was a problem hiding this comment.
Isn't this a programming error if it ever happens?
No, because we might decide that windows are ephemeral. I can think of plenty of reasons we might want to destroy some # of them at runtime.
Assert will crash the app, window stickiness should be a "best effort" feature. No reason to make the app user hostile when it doesn't need to be.
There was a problem hiding this comment.
Right now, all windows always exist. If that changes in the future it will be because a developer changes it and they probably need to have a look at this code and think about what they're doing.
Since you made me look at the imgui internals now, did you have a look at using GImGui.Windows for this so we don't have to hard-code a list of window names?
1b8ca1e to
20866b7
Compare
Now when the right edge of any debug window in the list is at the edge of the viewport width, it will stick there through resizes. There's a bug where if the resize change is enough to "capture" a window that wasn't intended to be sticky it will capture. Given this didn't happen much during testing, I don't think the extra state + code required is worth it for these windows.
Now when the right edge of any debug window in the list is at the edge
of the viewport width, it will stick there through resizes.
There's a bug where if the resize change is enough to "capture" a window
that wasn't intended to be sticky it will capture. Given this didn't
happen much during testing, I don't think the extra state + code
required is worth it for these windows.