Browse Source

Scrollbar: layout needs to take account of window border size, so a border size will slightly reduce scrollbar size. (#2522)

Rework/revert intent of c1a61d25a.
ocornut 2 years ago
parent
commit
b7cdb5a31e
2 changed files with 5 additions and 2 deletions
  1. 3 0
      docs/CHANGELOG.txt
  2. 2 2
      imgui_widgets.cpp

+ 3 - 0
docs/CHANGELOG.txt

@@ -47,6 +47,9 @@ Other changes:
 - InputText: Fixed a case where deactivation frame would write to underlying
 - InputText: Fixed a case where deactivation frame would write to underlying
   buffer or call CallbackResize although unnecessary, in a frame where the
   buffer or call CallbackResize although unnecessary, in a frame where the
   return value was false.
   return value was false.
+- Scrollbar: layout needs to take account of window border size, so a border size
+  will slightly reduce scrollbar size. Generally we tried to make it that window
+  border size has no incidence on layout but this can't work with thick borders. (#2522)
 - IO: Added io.ClearEventsQueue() to clear incoming inputs events. (#4921)
 - IO: Added io.ClearEventsQueue() to clear incoming inputs events. (#4921)
   May be useful in conjunction with io.ClearInputsKeys() if you need to clear
   May be useful in conjunction with io.ClearInputsKeys() if you need to clear
   both current inputs state and queued events (e.g. when using blocking native
   both current inputs state and queued events (e.g. when using blocking native

+ 2 - 2
imgui_widgets.cpp

@@ -875,9 +875,9 @@ ImRect ImGui::GetWindowScrollbarRect(ImGuiWindow* window, ImGuiAxis axis)
     const float scrollbar_size = window->ScrollbarSizes[axis ^ 1]; // (ScrollbarSizes.x = width of Y scrollbar; ScrollbarSizes.y = height of X scrollbar)
     const float scrollbar_size = window->ScrollbarSizes[axis ^ 1]; // (ScrollbarSizes.x = width of Y scrollbar; ScrollbarSizes.y = height of X scrollbar)
     IM_ASSERT(scrollbar_size > 0.0f);
     IM_ASSERT(scrollbar_size > 0.0f);
     if (axis == ImGuiAxis_X)
     if (axis == ImGuiAxis_X)
-        return ImRect(inner_rect.Min.x, ImMax(outer_rect.Min.y, outer_rect.Max.y - border_size - scrollbar_size), inner_rect.Max.x, outer_rect.Max.y);
+        return ImRect(inner_rect.Min.x, ImMax(outer_rect.Min.y, outer_rect.Max.y - border_size - scrollbar_size), inner_rect.Max.x - border_size, outer_rect.Max.y - border_size);
     else
     else
-        return ImRect(ImMax(outer_rect.Min.x, outer_rect.Max.x - border_size - scrollbar_size), inner_rect.Min.y, outer_rect.Max.x, inner_rect.Max.y);
+        return ImRect(ImMax(outer_rect.Min.x, outer_rect.Max.x - border_size - scrollbar_size), inner_rect.Min.y, outer_rect.Max.x - border_size, inner_rect.Max.y - border_size);
 }
 }
 
 
 void ImGui::Scrollbar(ImGuiAxis axis)
 void ImGui::Scrollbar(ImGuiAxis axis)