mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-27 17:10:57 +01:00
Internals: removed GetContentRegionMaxAbs() which was only meaningfully used in place of GetContentRegionAvail().
This commit is contained in:
parent
055b2e80fb
commit
4227402b2f
40
imgui.cpp
40
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,8 +10583,15 @@ 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!
|
||||
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->DC.CursorPos;
|
||||
}
|
||||
|
||||
// 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()
|
||||
{
|
||||
@ -10598,21 +10601,6 @@ ImVec2 ImGui::GetContentRegionMax()
|
||||
return mx - window->Pos;
|
||||
}
|
||||
|
||||
// [Internal] Absolute coordinate. Saner. This is not exposed until we finishing refactoring work rect features.
|
||||
ImVec2 ImGui::GetContentRegionMaxAbs()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
// You should never need those functions. Always use GetCursorScreenPos() and GetContentRegionAvail()!
|
||||
// They are bizarre local-coordinates which don't play well with scrolling.
|
||||
|
@ -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…
Reference in New Issue
Block a user