-
Notifications
You must be signed in to change notification settings - Fork 47
Description
As you can see (ImageView.cs)
stc.RenderBackground(cr, 0, 0, allocation.Width, allocation.Height);
is currently commented out, why i have tried it and it works?
Also why is ther unreachable Code, is it needed?
`
protected override bool OnDrawn(Context cr)
{
var allocation = Allocation;
var stc = this.StyleContext;
//stc.RenderBackground(cr, 0, 0, allocation.Width, allocation.Height);
if (Image is not { } image)
return true;
// HACK: Gtk sends sometimes a draw event while the widget reallocates.
// In that case we would draw in the wrong area, which may lead to artifacts
// if no other widget updates it. Alternative: we could clip the
// allocation bounds, but this may have other issues.
if (allocation.Width == 1 && allocation.Height == 1 && allocation.X == -1 && allocation.Y == -1) // the allocation coordinates on reallocation
return base.OnDrawn(cr);
var imgSize = Measure(Aspect, new Size(image.Width, image.Height), allocation.Width, allocation.Height);
var x = (allocation.Width - imgSize.Width) / 2;
var y = (allocation.Height - imgSize.Height) / 2;
if (false)
#pragma warning disable CS0162 // Unreachable code detected
{
using var region = Window.VisibleRegion;
using var frame = Window.BeginDrawFrame(region);
using var crr = frame.CairoContext;
crr.DrawPixbuf(image, x, y, allocation.Width, allocation.Height);
Window.EndDrawFrame(frame);
}
#pragma warning restore CS0162 // Unreachable code detected
else
{
cr.DrawPixbuf(image, x, y, imgSize.Width, imgSize.Height);
}
return false;
}
`