Skip to content

Commit

Permalink
Windows: adjust default ClipRect to better match rendering of thick b…
Browse files Browse the repository at this point in the history
…orders. (#7887, #7888 + #3312, #7540, #3756, #6170, #6365)
  • Loading branch information
ocornut committed Aug 20, 2024
1 parent eb7201b commit e471206
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ Other changes:
- IO, InputText: fixed an issue where typing text in a InputText() would defer character
processing by one frame, because of the trickling input queue. Reworked interleaved
keys<>char trickling to take account for keys known to input characters. (#7889, #4921, #4858)
- Windows: adjust default ClipRect to better match rendering of thick borders (which are in
theory not supported). Compensate for the fact that borders are centered around the windows
edge rather than inner. (#7887, #7888 + #3312, #7540, #3756, #6170, #6365)
- MultiSelect+TreeNode+Drag and Drop: fixed an issue where carrying a drag and drop
payload over an already open tree node would incorrectly select it. (#7850)
- MultiSelect+TreeNode: default open behavior is OpenOnDoubleClick + OpenOnArrow
Expand Down
12 changes: 8 additions & 4 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7066,10 +7066,14 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
// 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 + 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 - window->WindowBorderSize);
window->InnerClipRect.Max.y = ImFloor(0.5f + window->InnerRect.Max.y - window->WindowBorderSize);

// Try to match the fact that our border is drawn centered over the window rectangle, rather than inner.
// This is why we do a *0.5f here. We don't currently even technically support large values for WindowBorderSize,
// see e.g #7887 #7888, but may do after we move the window border to become an inner border (and then we can remove the 0.5f here).
window->InnerClipRect.Min.x = ImFloor(0.5f + window->InnerRect.Min.x + window->WindowBorderSize * 0.5f);
window->InnerClipRect.Min.y = ImFloor(0.5f + window->InnerRect.Min.y + top_border_size * 0.5f);
window->InnerClipRect.Max.x = ImFloor(window->InnerRect.Max.x - window->WindowBorderSize * 0.5f);
window->InnerClipRect.Max.y = ImFloor(window->InnerRect.Max.y - window->WindowBorderSize * 0.5f);
window->InnerClipRect.ClipWithFull(host_rect);

// Default item width. Make it proportional to window size if window manually resizes
Expand Down

0 comments on commit e471206

Please sign in to comment.