Browse Source

Internals: removed GetContentRegionMaxAbs() which was only meaningfully used in place of GetContentRegionAvail().

pull/7820/head
ocornut 3 months ago
parent
commit
4227402b2f
  1. 36
      imgui.cpp
  2. 1
      imgui_internal.h

36
imgui.cpp

@ -10313,7 +10313,6 @@ IM_MSVC_RUNTIME_CHECKS_RESTORE
// - GetFrameHeight()
// - GetFrameHeightWithSpacing()
// - GetContentRegionMax()
// - GetContentRegionMaxAbs() [Internal]
// - GetContentRegionAvail(),
// - BeginGroup()
// - EndGroup()
@ -10530,8 +10529,8 @@ float ImGui::CalcItemWidth()
w = window->DC.ItemWidth;
if (w < 0.0f)
{
float region_max_x = GetContentRegionMaxAbs().x;
w = ImMax(1.0f, region_max_x - window->DC.CursorPos.x + w);
float region_avail_x = GetContentRegionAvail().x;
w = ImMax(1.0f, region_avail_x + w);
}
w = IM_TRUNC(w);
return w;
@ -10543,22 +10542,19 @@ float ImGui::CalcItemWidth()
// The 4.0f here may be changed to match CalcItemWidth() and/or BeginChild() (right now we have a mismatch which is harmless but undesirable)
ImVec2 ImGui::CalcItemSize(ImVec2 size, float default_w, float default_h)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
ImVec2 region_max;
ImVec2 avail;
if (size.x < 0.0f || size.y < 0.0f)
region_max = GetContentRegionMaxAbs();
avail = GetContentRegionAvail();
if (size.x == 0.0f)
size.x = default_w;
else if (size.x < 0.0f)
size.x = ImMax(4.0f, region_max.x - window->DC.CursorPos.x + size.x);
size.x = ImMax(4.0f, avail.x + size.x); // <-- size.x is negative here so we are subtracting
if (size.y == 0.0f)
size.y = default_h;
else if (size.y < 0.0f)
size.y = ImMax(4.0f, region_max.y - window->DC.CursorPos.y + size.y);
size.y = ImMax(4.0f, avail.y + size.y); // <-- size.y is negative here so we are subtracting
return size;
}
@ -10587,30 +10583,22 @@ float ImGui::GetFrameHeightWithSpacing()
return g.FontSize + g.Style.FramePadding.y * 2.0f + g.Style.ItemSpacing.y;
}
// FIXME: All the Contents Region function are messy or misleading. WE WILL AIM TO OBSOLETE ALL OF THEM WITH A NEW "WORK RECT" API. Thanks for your patience!
// FIXME: This is in window space (not screen space!).
ImVec2 ImGui::GetContentRegionMax()
ImVec2 ImGui::GetContentRegionAvail()
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
ImVec2 mx = (window->DC.CurrentColumns || g.CurrentTable) ? window->WorkRect.Max : window->ContentRegionRect.Max;
return mx - window->Pos;
return mx - window->DC.CursorPos;
}
// [Internal] Absolute coordinate. Saner. This is not exposed until we finishing refactoring work rect features.
ImVec2 ImGui::GetContentRegionMaxAbs()
// FIXME: All the Contents Region function are messy or misleading. WE WILL AIM TO OBSOLETE ALL OF THEM WITH A NEW "WORK RECT" API. Thanks for your patience!
// FIXME: This is in window space (not screen space!).
ImVec2 ImGui::GetContentRegionMax()
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
ImVec2 mx = (window->DC.CurrentColumns || g.CurrentTable) ? window->WorkRect.Max : window->ContentRegionRect.Max;
return mx;
}
ImVec2 ImGui::GetContentRegionAvail()
{
ImGuiWindow* window = GImGui->CurrentWindow;
return GetContentRegionMaxAbs() - window->DC.CursorPos;
return mx - window->Pos;
}
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS

1
imgui_internal.h

@ -3217,7 +3217,6 @@ namespace ImGui
IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_w, float default_h);
IMGUI_API float CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x);
IMGUI_API void PushMultiItemsWidths(int components, float width_full);
IMGUI_API ImVec2 GetContentRegionMaxAbs();
IMGUI_API void ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_excess);
// Parameter stacks (shared)

Loading…
Cancel
Save