code_style: calculate bounds only when it is needed

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-05-08 13:42:21 +08:00
parent 2c8370fa92
commit 6986e1ac24
No known key found for this signature in database

View file

@ -55,11 +55,6 @@ namespace SourceGit.Views
if (list == null)
return;
// Calculate drawing area.
var width = histories.CommitListHeader.ColumnDefinitions[0].ActualWidth;
var height = Bounds.Height;
// Calculate row height
var container = list.ItemsPanelRoot as VirtualizingStackPanel;
if (container == null)
return;
@ -68,15 +63,15 @@ namespace SourceGit.Views
if (item == null)
return;
var width = histories.CommitListHeader.ColumnDefinitions[0].ActualWidth;
var height = Bounds.Height;
var rowHeight = item.Bounds.Height;
var startY = container.FirstRealizedIndex * rowHeight - item.TranslatePoint(new Point(0, 0), list).Value!.Y;
var endY = startY + height + 28;
// Apply scroll offset and clip.
using (context.PushClip(new Rect(0, 0, width, height)))
using (context.PushTransform(Matrix.CreateTranslation(0, -startY)))
{
// Draw contents
DrawCurves(context, graph, startY, endY, rowHeight);
DrawAnchors(context, graph, startY, endY, rowHeight);
}