mirror of https://github.com/ocornut/imgui
Misc: Fixed PushItemWidth(-width) (for right-side alignment) laying out certain items (button, listbox, etc.) with negative sizes if the 'width' argument was smaller than the available width at the time of item submission,
This commit is contained in:
parent
a1cf7d636d
commit
0e46d65b03
|
@ -53,6 +53,8 @@ Other Changes:
|
|||
- Window: Window close button is horizontally aligned with style.FramePadding.x.
|
||||
- Columns: Fixed boundary of clipping being off by 1 pixel within the left column.
|
||||
- Combo, Slider, Scrollbar: Improve rendering in situation when there's only a few pixels available (<3 pixels).
|
||||
- Misc: Fixed PushItemWidth(-width) (for right-side alignment) laying out certain items (button, listbox, etc.)
|
||||
with negative sizes if the 'width' argument was smaller than the available width at the time of item submission,
|
||||
- Misc: Added IM_MALLOC/IM_FREE macros mimicking IM_NEW/IM_DELETE so user doesn't need to revert
|
||||
to using the ImGui::MemAlloc()/MemFree() calls directly.
|
||||
- Metrics: Added "Show windows rectangles" tool to visualize the different rectangles.
|
||||
|
|
|
@ -5789,6 +5789,7 @@ float ImGui::CalcItemWidth()
|
|||
// [Internal] Calculate full item size given user provided 'size' parameter and default width/height. Default width is often == CalcItemWidth().
|
||||
// Those two functions CalcItemWidth vs CalcItemSize are awkwardly named because they are not fully symmetrical.
|
||||
// Note that only CalcItemWidth() is publicly exposed.
|
||||
// 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)
|
||||
{
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
|
@ -5800,12 +5801,12 @@ ImVec2 ImGui::CalcItemSize(ImVec2 size, float default_w, float default_h)
|
|||
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, region_max.x - window->DC.CursorPos.x + size.x);
|
||||
|
||||
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, region_max.y - window->DC.CursorPos.y + size.y);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue