Scrollbar overlap an extra WindowBorderSize amount on the left to make all distances consistent. Reverted to BorderSize not affecting work/contents rectangles. Scrollbar, Style: Changed default style.ScrollbarSize from 16 to 14.

This commit is contained in:
omar
2019-06-05 15:23:01 +02:00
parent 15282261dd
commit c1a61d25a7
4 changed files with 45 additions and 22 deletions

View File

@ -884,21 +884,22 @@ void ImGui::Scrollbar(ImGuiAxis axis)
// Calculate scrollbar bounding box
const ImRect outer_rect = window->Rect();
const ImRect inner_rect = window->InnerRect;
const float border_size = window->WindowBorderSize;
const float scrollbar_size = window->ScrollbarSizes[axis ^ 1];
IM_ASSERT(scrollbar_size > 0.0f); IM_UNUSED(scrollbar_size);
IM_ASSERT(scrollbar_size > 0.0f);
const float other_scrollbar_size = window->ScrollbarSizes[axis];
ImDrawCornerFlags rounding_corners = (other_scrollbar_size <= 0.0f) ? ImDrawCornerFlags_BotRight : 0;
ImRect bb;
if (axis == ImGuiAxis_X)
{
bb.Min = ImVec2(inner_rect.Min.x, inner_rect.Max.y);
bb.Max = ImVec2(inner_rect.Max.x, outer_rect.Max.y - window->WindowBorderSize);
bb.Min = ImVec2(inner_rect.Min.x, outer_rect.Max.y - border_size - scrollbar_size);
bb.Max = ImVec2(inner_rect.Max.x, outer_rect.Max.y);
rounding_corners |= ImDrawCornerFlags_BotLeft;
}
else
{
bb.Min = ImVec2(inner_rect.Max.x, inner_rect.Min.y);
bb.Max = ImVec2(outer_rect.Max.x - window->WindowBorderSize, window->InnerRect.Max.y);
bb.Min = ImVec2(outer_rect.Max.x - border_size - scrollbar_size, inner_rect.Min.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;
}
ScrollbarEx(bb, id, axis, &window->Scroll[axis], inner_rect.Max[axis] - inner_rect.Min[axis], window->ContentSize[axis] + window->WindowPadding[axis] * 2.0f, rounding_corners);