Skip to content

Commit e16564e

Browse files
committed
Scrollbar: Avoid overlapping the opposite side when window (often a child window) is forcibly too small.
1 parent 58c9f8a commit e16564e

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

docs/CHANGELOG.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Breaking Changes:
4343

4444
Other Changes:
4545
- Window: Fixed InnerClipRect right-most coordinates using wrong padding setting (introduced in 1.71).
46+
- Scrollbar: Avoid overlapping the opposite side when window (often a child window) is forcibly too small.
4647
- Word-wrapping: Fixed overzealous word-wrapping when glyph edge lands exactly on the limit. Because
4748
of this, auto-fitting exactly unwrapped text would make it wrap. (fixes initial 1.15 commit, 78645a7d).
4849
- Scrolling: Added SetScrollHereX(), SetScrollFromPosX() for completeness. (#1580) [@kevreco]

imgui_demo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,8 +2079,8 @@ static void ShowDemoWindowLayout()
20792079

20802080
ImGuiStyle& style = ImGui::GetStyle();
20812081
float child_w = (ImGui::GetContentRegionAvail().x - 4 * style.ItemSpacing.x) / 5;
2082-
if (child_w < 20.0f)
2083-
child_w = 20.0f;
2082+
if (child_w < 1.0f)
2083+
child_w = 1.0f;
20842084
ImGui::PushID("##VerticalScrolling");
20852085
for (int i = 0; i < 5; i++)
20862086
{

imgui_widgets.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -895,13 +895,13 @@ void ImGui::Scrollbar(ImGuiAxis axis)
895895
ImRect bb;
896896
if (axis == ImGuiAxis_X)
897897
{
898-
bb.Min = ImVec2(inner_rect.Min.x, outer_rect.Max.y - border_size - scrollbar_size);
898+
bb.Min = ImVec2(inner_rect.Min.x, ImMax(outer_rect.Min.y, outer_rect.Max.y - border_size - scrollbar_size));
899899
bb.Max = ImVec2(inner_rect.Max.x, outer_rect.Max.y);
900900
rounding_corners |= ImDrawCornerFlags_BotLeft;
901901
}
902902
else
903903
{
904-
bb.Min = ImVec2(outer_rect.Max.x - border_size - scrollbar_size, inner_rect.Min.y);
904+
bb.Min = ImVec2(ImMax(outer_rect.Min.x, outer_rect.Max.x - border_size - scrollbar_size), inner_rect.Min.y);
905905
bb.Max = ImVec2(outer_rect.Max.x, window->InnerRect.Max.y);
906906
rounding_corners |= ((window->Flags & ImGuiWindowFlags_NoTitleBar) && !(window->Flags & ImGuiWindowFlags_MenuBar)) ? ImDrawCornerFlags_TopRight : 0;
907907
}

0 commit comments

Comments
 (0)