mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-14 17:07:01 +00:00
SplitterBehavior: tweak to not assert due to floating point precision.
Not guaranting behavior: clamping makes output lossy, size_1+size_2 in theory may be instable but couldn't repro. API probably needs rework anyhow (should redistribute from provided available space).
This commit is contained in:
parent
afadf74a53
commit
5de1312e1c
@ -1564,8 +1564,7 @@ bool ImGui::SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float
|
||||
ImRect bb_render = bb;
|
||||
if (held)
|
||||
{
|
||||
ImVec2 mouse_delta_2d = g.IO.MousePos - g.ActiveIdClickOffset - bb_interact.Min;
|
||||
float mouse_delta = (axis == ImGuiAxis_Y) ? mouse_delta_2d.y : mouse_delta_2d.x;
|
||||
float mouse_delta = (g.IO.MousePos - g.ActiveIdClickOffset - bb_interact.Min)[axis];
|
||||
|
||||
// Minimum pane size
|
||||
float size_1_maximum_delta = ImMax(0.0f, *size1 - min_size1);
|
||||
@ -1578,12 +1577,8 @@ bool ImGui::SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float
|
||||
// Apply resize
|
||||
if (mouse_delta != 0.0f)
|
||||
{
|
||||
if (mouse_delta < 0.0f)
|
||||
IM_ASSERT(*size1 + mouse_delta >= min_size1);
|
||||
if (mouse_delta > 0.0f)
|
||||
IM_ASSERT(*size2 - mouse_delta >= min_size2);
|
||||
*size1 += mouse_delta;
|
||||
*size2 -= mouse_delta;
|
||||
*size1 = ImMax(*size1 + mouse_delta, min_size1);
|
||||
*size2 = ImMax(*size2 - mouse_delta, min_size2);
|
||||
bb_render.Translate((axis == ImGuiAxis_X) ? ImVec2(mouse_delta, 0.0f) : ImVec2(0.0f, mouse_delta));
|
||||
MarkItemEdited(id);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user