Windows: Changed default ClipRect to extend to windows' left and right borders. (#3312, #7540, #3756, #6170, #6365)

This commit is contained in:
ocornut 2024-05-03 16:00:20 +02:00
parent 0c9c12c1bb
commit 0b309471f2
3 changed files with 14 additions and 6 deletions

View File

@ -56,6 +56,12 @@ Breaking changes:
Other changes:
- Windows: Changed default ClipRect to extend to windows' left and right borders,
instead of adding arbitrary WindowPadding.x * 0.5f space on left and right.
That ClipRect half-padding was arbitrary/confusing and inconsistent with Y axis.
It also made it harder to draw items covering whole window without pushing an
extended ClipRect. Some items near windows left and right edge that used to be clipped
may be partly more visible. (#3312, #7540, #3756, #6170, #6365)
- Windows: Fixed subsequent Begin() append calls from setting last item information
for title bar, making it impossible to use IsItemHovered() on a Begin()-to-append,
and causing issue bypassing hover detection on collapsed windows. (#7506, #823)

View File

@ -6838,16 +6838,18 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
window->InnerRect.Max.y = window->Pos.y + window->Size.y - window->DecoOuterSizeY2;
// Inner clipping rectangle.
// Will extend a little bit outside the normal work region.
// This is to allow e.g. Selectable or CollapsingHeader or some separators to cover that space.
// Force round operator last to ensure that e.g. (int)(max.x-min.x) in user's render code produce correct result.
// - Extend a outside of normal work region up to borders.
// - This is to allow e.g. Selectable or CollapsingHeader or some separators to cover that space.
// - It also makes clipped items be more noticeable.
// - And is consistent on both axis (prior to 2024/05/03 ClipRect used WindowPadding.x * 0.5f on left and right edge), see #3312
// - Force round operator last to ensure that e.g. (int)(max.x-min.x) in user's render code produce correct result.
// Note that if our window is collapsed we will end up with an inverted (~null) clipping rectangle which is the correct behavior.
// Affected by window/frame border size. Used by:
// - Begin() initial clip rect
float top_border_size = (((flags & ImGuiWindowFlags_MenuBar) || !(flags & ImGuiWindowFlags_NoTitleBar)) ? style.FrameBorderSize : window->WindowBorderSize);
window->InnerClipRect.Min.x = ImFloor(0.5f + window->InnerRect.Min.x + ImMax(ImTrunc(window->WindowPadding.x * 0.5f), window->WindowBorderSize));
window->InnerClipRect.Min.x = ImFloor(0.5f + window->InnerRect.Min.x + window->WindowBorderSize);
window->InnerClipRect.Min.y = ImFloor(0.5f + window->InnerRect.Min.y + top_border_size);
window->InnerClipRect.Max.x = ImFloor(0.5f + window->InnerRect.Max.x - ImMax(ImTrunc(window->WindowPadding.x * 0.5f), window->WindowBorderSize));
window->InnerClipRect.Max.x = ImFloor(0.5f + window->InnerRect.Max.x - window->WindowBorderSize);
window->InnerClipRect.Max.y = ImFloor(0.5f + window->InnerRect.Max.y - window->WindowBorderSize);
window->InnerClipRect.ClipWithFull(host_rect);

View File

@ -28,7 +28,7 @@
// Library Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
#define IMGUI_VERSION "1.90.6 WIP"
#define IMGUI_VERSION_NUM 19053
#define IMGUI_VERSION_NUM 19054
#define IMGUI_HAS_TABLE
/*