// Draw_list overloads. All positions are in relative coordinates (relative to top-left of the current window) public static void DrawLine(Vector2f a, Vector2f b, Color col, float thickness = 1.0f) { var drawList = ImGui.GetWindowDrawList(); var pos = ImGui.GetCursorScreenPos(); drawList.AddLine(new Vector2(a.X + pos.X, a.Y + pos.Y), new Vector2(b.X + pos.X, b.Y + pos.Y), ColorConvertFloat4ToU32(ToImColor(col).Value), thickness); }
// Taken from https://github.com/ocornut/imgui/issues/1496#issuecomment-655048353 private static void BeginGroupPanel(string name, Vector2 size) { ImGui.BeginGroup(); var cursorPos = ImGui.GetCursorScreenPos(); var itemSpacing = ImGui.GetStyle().ItemSpacing; ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, 0f); ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, 0f); var frameHeight = ImGui.GetFrameHeight(); ImGui.BeginGroup(); Vector2 effectiveSize = size; if (size.X < 0.0f) { effectiveSize.X = ImGui.GetContentRegionAvail().X; } else { effectiveSize.X = size.X; } ImGui.Dummy(new Vector2(effectiveSize.X, 0.0f)); ImGui.Dummy(new Vector2(frameHeight * 0.5f, 0.0f)); ImGui.SameLine(0.0f, 0.0f); ImGui.BeginGroup(); ImGui.Dummy(new Vector2(frameHeight * 0.5f, 0.0f)); ImGui.SameLine(0.0f, 0.0f); ImGui.TextUnformatted(name); var labelMin = ImGui.GetItemRectMin(); var labelMax = ImGui.GetItemRectMax(); ImGui.SameLine(0.0f, 0.0f); ImGui.Dummy(new Vector2(0.0f, frameHeight + itemSpacing.Y)); ImGui.BeginGroup(); ImGui.PopStyleVar(2); }
private static Vector2 GetDownRightAbsolute(FloatRect rect) { var pos = ImGui.GetCursorScreenPos(); return(new Vector2(rect.Left + rect.Width + pos.X, rect.Top + rect.Height + pos.Y)); }
private static Vector2 GetTopLeftAbsolute(FloatRect rect) { var pos = ImGui.GetCursorScreenPos(); return(new Vector2(rect.Left + pos.X, rect.Top + pos.Y)); }