Using 'hover_visibility_delay' allows us to hide the highlight and mouse cursor for a short time, which can be convenient to reduce visual noise.
| 1800 | |
| 1801 | // Using 'hover_visibility_delay' allows us to hide the highlight and mouse cursor for a short time, which can be convenient to reduce visual noise. |
| 1802 | bool ImGui::SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* size1, float* size2, float min_size1, float min_size2, float hover_extend, float hover_visibility_delay, ImU32 bg_col) |
| 1803 | { |
| 1804 | ImGuiContext& g = *GImGui; |
| 1805 | ImGuiWindow* window = g.CurrentWindow; |
| 1806 | |
| 1807 | if (!ItemAdd(bb, id, NULL, ImGuiItemFlags_NoNav)) |
| 1808 | return false; |
| 1809 | |
| 1810 | // FIXME: AFAIK the only leftover reason for passing ImGuiButtonFlags_AllowOverlap here is |
| 1811 | // to allow caller of SplitterBehavior() to call SetItemAllowOverlap() after the item. |
| 1812 | // Nowadays we would instead want to use SetNextItemAllowOverlap() before the item. |
| 1813 | ImGuiButtonFlags button_flags = ImGuiButtonFlags_FlattenChildren; |
| 1814 | #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS |
| 1815 | button_flags |= ImGuiButtonFlags_AllowOverlap; |
| 1816 | #endif |
| 1817 | |
| 1818 | bool hovered, held; |
| 1819 | ImRect bb_interact = bb; |
| 1820 | bb_interact.Expand(axis == ImGuiAxis_Y ? ImVec2(0.0f, hover_extend) : ImVec2(hover_extend, 0.0f)); |
| 1821 | ButtonBehavior(bb_interact, id, &hovered, &held, button_flags); |
| 1822 | if (hovered) |
| 1823 | g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HoveredRect; // for IsItemHovered(), because bb_interact is larger than bb |
| 1824 | |
| 1825 | if (held || (hovered && g.HoveredIdPreviousFrame == id && g.HoveredIdTimer >= hover_visibility_delay)) |
| 1826 | SetMouseCursor(axis == ImGuiAxis_Y ? ImGuiMouseCursor_ResizeNS : ImGuiMouseCursor_ResizeEW); |
| 1827 | |
| 1828 | ImRect bb_render = bb; |
| 1829 | if (held) |
| 1830 | { |
| 1831 | float mouse_delta = (g.IO.MousePos - g.ActiveIdClickOffset - bb_interact.Min)[axis]; |
| 1832 | |
| 1833 | // Minimum pane size |
| 1834 | float size_1_maximum_delta = ImMax(0.0f, *size1 - min_size1); |
| 1835 | float size_2_maximum_delta = ImMax(0.0f, *size2 - min_size2); |
| 1836 | if (mouse_delta < -size_1_maximum_delta) |
| 1837 | mouse_delta = -size_1_maximum_delta; |
| 1838 | if (mouse_delta > size_2_maximum_delta) |
| 1839 | mouse_delta = size_2_maximum_delta; |
| 1840 | |
| 1841 | // Apply resize |
| 1842 | if (mouse_delta != 0.0f) |
| 1843 | { |
| 1844 | *size1 = ImMax(*size1 + mouse_delta, min_size1); |
| 1845 | *size2 = ImMax(*size2 - mouse_delta, min_size2); |
| 1846 | bb_render.Translate((axis == ImGuiAxis_X) ? ImVec2(mouse_delta, 0.0f) : ImVec2(0.0f, mouse_delta)); |
| 1847 | MarkItemEdited(id); |
| 1848 | } |
| 1849 | } |
| 1850 | |
| 1851 | // Render at new position |
| 1852 | if (bg_col & IM_COL32_A_MASK) |
| 1853 | window->DrawList->AddRectFilled(bb_render.Min, bb_render.Max, bg_col, 0.0f); |
| 1854 | const ImU32 col = GetColorU32(held ? ImGuiCol_SeparatorActive : (hovered && g.HoveredIdTimer >= hover_visibility_delay) ? ImGuiCol_SeparatorHovered : ImGuiCol_Separator); |
| 1855 | window->DrawList->AddRectFilled(bb_render.Min, bb_render.Max, col, 0.0f); |
| 1856 | |
| 1857 | return held; |
| 1858 | } |
| 1859 |
nothing calls this directly
no test coverage detected