Docking: Rework size allocation to allow user code to override node sizes. Not all edge cases will be properly handled but this is a step toward toolbar emitting size constraints.
This commit is contained in:
parent
2b9d88196e
commit
4bdbea8375
15
imgui.cpp
15
imgui.cpp
@ -13790,20 +13790,27 @@ void ImGui::DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 si
|
|||||||
const float size_min_each = ImFloor(ImMin(size_avail, g.Style.WindowMinSize[axis] * 2.0f) * 0.5f);
|
const float size_min_each = ImFloor(ImMin(size_avail, g.Style.WindowMinSize[axis] * 2.0f) * 0.5f);
|
||||||
|
|
||||||
// 2) Process locked absolute size (during a splitter resize we preserve the child of nodes not touching the splitter edge)
|
// 2) Process locked absolute size (during a splitter resize we preserve the child of nodes not touching the splitter edge)
|
||||||
IM_ASSERT(!(child_0->WantLockSizeOnce && child_1->WantLockSizeOnce));
|
if (child_0->WantLockSizeOnce && !child_1->WantLockSizeOnce)
|
||||||
if (child_0->WantLockSizeOnce)
|
|
||||||
{
|
{
|
||||||
child_0_size[axis] = child_0->SizeRef[axis] = ImMin(size_avail - 1.0f, child_0->Size[axis]);
|
child_0_size[axis] = child_0->SizeRef[axis] = ImMin(size_avail - 1.0f, child_0->Size[axis]);
|
||||||
child_1_size[axis] = child_1->SizeRef[axis] = (size_avail - child_0_size[axis]);
|
child_1_size[axis] = child_1->SizeRef[axis] = (size_avail - child_0_size[axis]);
|
||||||
IM_ASSERT(child_0->SizeRef[axis] > 0.0f && child_1->SizeRef[axis] > 0.0f);
|
IM_ASSERT(child_0->SizeRef[axis] > 0.0f && child_1->SizeRef[axis] > 0.0f);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (child_1->WantLockSizeOnce)
|
else if (child_1->WantLockSizeOnce && !child_0->WantLockSizeOnce)
|
||||||
{
|
{
|
||||||
child_1_size[axis] = child_1->SizeRef[axis] = ImMin(size_avail - 1.0f, child_1->Size[axis]);
|
child_1_size[axis] = child_1->SizeRef[axis] = ImMin(size_avail - 1.0f, child_1->Size[axis]);
|
||||||
child_0_size[axis] = child_0->SizeRef[axis] = (size_avail - child_1_size[axis]);
|
child_0_size[axis] = child_0->SizeRef[axis] = (size_avail - child_1_size[axis]);
|
||||||
IM_ASSERT(child_0->SizeRef[axis] > 0.0f && child_1->SizeRef[axis] > 0.0f);
|
IM_ASSERT(child_0->SizeRef[axis] > 0.0f && child_1->SizeRef[axis] > 0.0f);
|
||||||
}
|
}
|
||||||
|
else if (child_0->WantLockSizeOnce && child_1->WantLockSizeOnce)
|
||||||
|
{
|
||||||
|
// FIXME-DOCK: We cannot honor the requested size, so apply ratio.
|
||||||
|
// Currently this path will only be taken if code programmatically sets WantLockSizeOnce
|
||||||
|
float ratio_0 = child_0_size[axis] / (child_0_size[axis] + child_1_size[axis]);
|
||||||
|
child_0_size[axis] = child_0->SizeRef[axis] = ImFloor(size_avail * ratio_0);
|
||||||
|
child_1_size[axis] = child_1->SizeRef[axis] = (size_avail - child_0_size[axis]);
|
||||||
|
IM_ASSERT(child_0->SizeRef[axis] > 0.0f && child_1->SizeRef[axis] > 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
// 3) If one window is the central node (~ use remaining space, should be made explicit!), use explicit size from the other, and remainder for the central node
|
// 3) If one window is the central node (~ use remaining space, should be made explicit!), use explicit size from the other, and remainder for the central node
|
||||||
else if (child_1->IsCentralNode() && child_0->SizeRef[axis] != 0.0f)
|
else if (child_1->IsCentralNode() && child_0->SizeRef[axis] != 0.0f)
|
||||||
|
Loading…
Reference in New Issue
Block a user