The following minimal examples puts a DrawingArea inside a ScrolledWindow. In the Drawn event reaction a (partial) disk is drawn. When the line args.Cr.IdentityMatrix(); is used, the drawing does not work correctly, although one should expect no effect. Without the line, things work fine. The problem occurs during scrolling. It seems that some rectangular portions of the area are not updated. This is with GtkSharp 3.24.24 and .NET 6.0 on a Windows 11 machine (but I could also see the same effect on a Mac).
MinimalExample.cs
using Gtk; // GtkSharp (3.24.24.*), .NET 6.0, Windows 11
public class MainWindow : Window
{
public MainWindow() : base(WindowType.Toplevel)
{
DrawingArea Area = new DrawingArea();
Area.SetSizeRequest(1000, 1000);
Area.Drawn += AreaDrawn;
ScrolledWindow Win = new ScrolledWindow { Area };
Win.SetSizeRequest(500, 500);
Add(Win);
ShowAll();
}
void AreaDrawn(object sender, DrawnArgs args)
{
args.Cr.IdentityMatrix();
args.Cr.SetSourceRGB(1.0, 0.0, 0.0);
args.Cr.NewPath();
args.Cr.Arc(120, 120, 120, 0, 5);
args.Cr.Fill();
args.Cr.Dispose();
}
}
class Program
{
public static void Main()
{
Application.Init();
Window mainWindow = new MainWindow();
Application.Run();
}
}
It should look like:correct rendering but often looks more like bad rendering. Am I doing something wrong? I know, that in this minimal example I might just skip the IdentiyMatrix() call, but in the greater projectect from which this minimal example is extracted, I need it.
Expectation: Rendering some drawings on a Gtk DrawingArea iside a ScrolledWindow should appear correctly also during scrolling. Observation: The drawing is messed up.