Browse Source

Scrollbar: Avoid overlapping the opposite side when window (often a child window) is forcibly too small.

pull/2670/head
omar 5 years ago
parent
commit
e16564e67a
  1. 1
      docs/CHANGELOG.txt
  2. 4
      imgui_demo.cpp
  3. 4
      imgui_widgets.cpp

1
docs/CHANGELOG.txt

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

4
imgui_demo.cpp

@ -2079,8 +2079,8 @@ static void ShowDemoWindowLayout()
ImGuiStyle& style = ImGui::GetStyle(); ImGuiStyle& style = ImGui::GetStyle();
float child_w = (ImGui::GetContentRegionAvail().x - 4 * style.ItemSpacing.x) / 5; float child_w = (ImGui::GetContentRegionAvail().x - 4 * style.ItemSpacing.x) / 5;
if (child_w < 20.0f) if (child_w < 1.0f)
child_w = 20.0f; child_w = 1.0f;
ImGui::PushID("##VerticalScrolling"); ImGui::PushID("##VerticalScrolling");
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {

4
imgui_widgets.cpp

@ -895,13 +895,13 @@ void ImGui::Scrollbar(ImGuiAxis axis)
ImRect bb; ImRect bb;
if (axis == ImGuiAxis_X) if (axis == ImGuiAxis_X)
{ {
bb.Min = ImVec2(inner_rect.Min.x, outer_rect.Max.y - border_size - scrollbar_size); bb.Min = ImVec2(inner_rect.Min.x, ImMax(outer_rect.Min.y, outer_rect.Max.y - border_size - scrollbar_size));
bb.Max = ImVec2(inner_rect.Max.x, outer_rect.Max.y); bb.Max = ImVec2(inner_rect.Max.x, outer_rect.Max.y);
rounding_corners |= ImDrawCornerFlags_BotLeft; rounding_corners |= ImDrawCornerFlags_BotLeft;
} }
else else
{ {
bb.Min = ImVec2(outer_rect.Max.x - border_size - scrollbar_size, inner_rect.Min.y); bb.Min = ImVec2(ImMax(outer_rect.Min.x, outer_rect.Max.x - border_size - scrollbar_size), inner_rect.Min.y);
bb.Max = ImVec2(outer_rect.Max.x, window->InnerRect.Max.y); bb.Max = ImVec2(outer_rect.Max.x, window->InnerRect.Max.y);
rounding_corners |= ((window->Flags & ImGuiWindowFlags_NoTitleBar) && !(window->Flags & ImGuiWindowFlags_MenuBar)) ? ImDrawCornerFlags_TopRight : 0; rounding_corners |= ((window->Flags & ImGuiWindowFlags_NoTitleBar) && !(window->Flags & ImGuiWindowFlags_MenuBar)) ? ImDrawCornerFlags_TopRight : 0;
} }

Loading…
Cancel
Save