refactor: rewrite the way to get local & remote branch tree height

This commit is contained in:
leo 2024-07-04 18:11:10 +08:00
parent 8faa8c7378
commit 6553e27d36
No known key found for this signature in database

View file

@ -404,29 +404,20 @@ namespace SourceGit.Views
worktreeList.Height = desiredHeight; worktreeList.Height = desiredHeight;
} }
var desiredLocalBranchHeight = GetTreeRowsCount(vm.LocalBranchTrees) * 24; if (vm.IsLocalBranchGroupExpanded)
var desiredRemoteHeight = GetTreeRowsCount(vm.RemoteBranchTrees) * 24;
if (!vm.IsRemoteGroupExpanded)
{ {
if (vm.IsLocalBranchGroupExpanded) var localBranchMax = vm.IsRemoteGroupExpanded ? leftHeight * 0.5 : leftHeight;
{ var desiredHeight = GetTreeRowsCount(vm.LocalBranchTrees) * 24;
var localBranchHeight = Math.Min(leftHeight, desiredLocalBranchHeight); var localBranchHeight = Math.Min(localBranchMax, desiredHeight);
if (!localBranchTree.Height.IsClose(localBranchHeight))
localBranchTree.Height = localBranchHeight; localBranchTree.Height = localBranchHeight;
} leftHeight -= localBranchHeight;
} }
else
if (vm.IsRemoteGroupExpanded)
{ {
if (vm.IsLocalBranchGroupExpanded) var desiredHeight = GetTreeRowsCount(vm.RemoteBranchTrees) * 24;
{ var remoteHeight = Math.Min(leftHeight, desiredHeight);
var localBranchHeight = Math.Min(leftHeight * 0.5, desiredLocalBranchHeight);
if (!localBranchTree.Height.IsClose(localBranchHeight))
localBranchTree.Height = localBranchHeight;
leftHeight -= localBranchHeight;
}
var remoteHeight = Math.Min(leftHeight, desiredRemoteHeight);
if (!remoteBranchTree.Height.IsClose(remoteHeight)) if (!remoteBranchTree.Height.IsClose(remoteHeight))
remoteBranchTree.Height = remoteHeight; remoteBranchTree.Height = remoteHeight;
} }