MCPcopy Create free account
hub / github.com/Aegel5/SimpleSwitcher / DockNodeCalcSplitRects

Method DockNodeCalcSplitRects

imgui_tiny_app/imgui/imgui.cpp:19796–19827  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19794}
19795
19796void ImGui::DockNodeCalcSplitRects(ImVec2& pos_old, ImVec2& size_old, ImVec2& pos_new, ImVec2& size_new, ImGuiDir dir, ImVec2 size_new_desired)
19797{
19798 ImGuiContext& g = *GImGui;
19799 const float dock_spacing = g.Style.ItemInnerSpacing.x;
19800 const ImGuiAxis axis = (dir == ImGuiDir_Left || dir == ImGuiDir_Right) ? ImGuiAxis_X : ImGuiAxis_Y;
19801 pos_new[axis ^ 1] = pos_old[axis ^ 1];
19802 size_new[axis ^ 1] = size_old[axis ^ 1];
19803
19804 // Distribute size on given axis (with a desired size or equally)
19805 const float w_avail = size_old[axis] - dock_spacing;
19806 if (size_new_desired[axis] > 0.0f && size_new_desired[axis] <= w_avail * 0.5f)
19807 {
19808 size_new[axis] = size_new_desired[axis];
19809 size_old[axis] = IM_TRUNC(w_avail - size_new[axis]);
19810 }
19811 else
19812 {
19813 size_new[axis] = IM_TRUNC(w_avail * 0.5f);
19814 size_old[axis] = IM_TRUNC(w_avail - size_new[axis]);
19815 }
19816
19817 // Position each node
19818 if (dir == ImGuiDir_Right || dir == ImGuiDir_Down)
19819 {
19820 pos_new[axis] = pos_old[axis] + size_old[axis] + dock_spacing;
19821 }
19822 else if (dir == ImGuiDir_Left || dir == ImGuiDir_Up)
19823 {
19824 pos_new[axis] = pos_old[axis];
19825 pos_old[axis] = pos_new[axis] + size_new[axis] + dock_spacing;
19826 }
19827}
19828
19829// Retrieve the drop rectangles for a given direction or for the center + perform hit testing.
19830bool ImGui::DockNodeCalcDropRectsAndTestMousePos(const ImRect& parent, ImGuiDir dir, ImRect& out_r, bool outer_docking, ImVec2* test_mouse_pos)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected