mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
enhance: better sidebar layout
This commit is contained in:
parent
3193693d77
commit
1c524cf310
1 changed files with 92 additions and 25 deletions
|
@ -414,46 +414,113 @@ namespace SourceGit.Views
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var leftHeight = leftSidebarGroups.Bounds.Height - 28.0 * 5;
|
var leftHeight = leftSidebarGroups.Bounds.Height - 28.0 * 5;
|
||||||
|
var localBranchRows = vm.IsLocalBranchGroupExpanded ? GetTreeRowsCount(vm.LocalBranchTrees) : 0;
|
||||||
|
var remoteBranchRows = vm.IsRemoteGroupExpanded ? GetTreeRowsCount(vm.RemoteBranchTrees) : 0;
|
||||||
|
var desiredBranches = (localBranchRows + remoteBranchRows) * 24.0;
|
||||||
|
var desiredTag = vm.IsTagGroupExpanded ? tagsList.RowHeight * vm.VisibleTags.Count : 0;
|
||||||
|
var desiredSubmodule = vm.IsSubmoduleGroupExpanded ? submoduleList.RowHeight * vm.Submodules.Count : 0;
|
||||||
|
var desiredWorktree = vm.IsWorktreeGroupExpanded ? worktreeList.RowHeight * vm.Worktrees.Count : 0;
|
||||||
|
var desiredOthers = desiredTag + desiredSubmodule + desiredWorktree;
|
||||||
|
var hasOverflow = (desiredBranches + desiredOthers > leftHeight);
|
||||||
|
|
||||||
if (vm.IsTagGroupExpanded)
|
if (vm.IsTagGroupExpanded)
|
||||||
{
|
{
|
||||||
var desiredHeight = Math.Min(200.0, tagsList.RowHeight * vm.VisibleTags.Count);
|
var height = desiredTag;
|
||||||
leftHeight -= desiredHeight;
|
if (hasOverflow)
|
||||||
if (!tagsList.Height.IsClose(desiredHeight))
|
{
|
||||||
tagsList.Height = desiredHeight;
|
var test = leftHeight - desiredBranches - desiredSubmodule - desiredWorktree;
|
||||||
|
if (test < 0)
|
||||||
|
height = Math.Min(200, height);
|
||||||
|
else
|
||||||
|
height = Math.Max(200, test);
|
||||||
|
}
|
||||||
|
|
||||||
|
leftHeight -= height;
|
||||||
|
tagsList.Height = height;
|
||||||
|
hasOverflow = (desiredBranches + desiredSubmodule + desiredWorktree) > leftHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm.IsSubmoduleGroupExpanded)
|
if (vm.IsSubmoduleGroupExpanded)
|
||||||
{
|
{
|
||||||
var desiredHeight = Math.Min(200.0, submoduleList.RowHeight * vm.Submodules.Count);
|
var height = desiredSubmodule;
|
||||||
leftHeight -= desiredHeight;
|
if (hasOverflow)
|
||||||
if (!submoduleList.Height.IsClose(desiredHeight))
|
{
|
||||||
submoduleList.Height = desiredHeight;
|
var test = leftHeight - desiredBranches - desiredWorktree;
|
||||||
|
if (test < 0)
|
||||||
|
height = Math.Min(200, height);
|
||||||
|
else
|
||||||
|
height = Math.Max(200, test);
|
||||||
|
}
|
||||||
|
|
||||||
|
leftHeight -= height;
|
||||||
|
submoduleList.Height = height;
|
||||||
|
hasOverflow = (desiredBranches + desiredWorktree) > leftHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm.IsWorktreeGroupExpanded)
|
if (vm.IsWorktreeGroupExpanded)
|
||||||
{
|
{
|
||||||
var desiredHeight = Math.Min(200.0, worktreeList.RowHeight * vm.Worktrees.Count);
|
var height = desiredWorktree;
|
||||||
leftHeight -= desiredHeight;
|
if (hasOverflow)
|
||||||
if (!worktreeList.Height.IsClose(desiredHeight))
|
{
|
||||||
worktreeList.Height = desiredHeight;
|
var test = leftHeight - desiredBranches;
|
||||||
|
if (test < 0)
|
||||||
|
height = Math.Min(200, height);
|
||||||
|
else
|
||||||
|
height = Math.Max(200, test);
|
||||||
|
}
|
||||||
|
|
||||||
|
leftHeight -= height;
|
||||||
|
worktreeList.Height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm.IsLocalBranchGroupExpanded)
|
if (desiredBranches > leftHeight)
|
||||||
{
|
{
|
||||||
var localBranchMax = vm.IsRemoteGroupExpanded ? leftHeight * 0.5 : leftHeight;
|
var local = localBranchRows * 24.0;
|
||||||
var desiredHeight = GetTreeRowsCount(vm.LocalBranchTrees) * 24;
|
var remote = remoteBranchRows * 24.0;
|
||||||
var localBranchHeight = Math.Min(localBranchMax, desiredHeight);
|
var half = leftHeight / 2;
|
||||||
if (!localBranchTree.Height.IsClose(localBranchHeight))
|
if (vm.IsLocalBranchGroupExpanded)
|
||||||
localBranchTree.Height = localBranchHeight;
|
{
|
||||||
leftHeight -= localBranchHeight;
|
if (vm.IsRemoteGroupExpanded)
|
||||||
|
{
|
||||||
|
if (local < half)
|
||||||
|
{
|
||||||
|
localBranchTree.Height = local;
|
||||||
|
remoteBranchTree.Height = leftHeight - local;
|
||||||
|
}
|
||||||
|
else if (remote < half)
|
||||||
|
{
|
||||||
|
remoteBranchTree.Height = remote;
|
||||||
|
localBranchTree.Height = leftHeight - remote;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
localBranchTree.Height = half;
|
||||||
|
remoteBranchTree.Height = half;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
localBranchTree.Height = leftHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (vm.IsRemoteGroupExpanded)
|
||||||
|
{
|
||||||
|
remoteBranchTree.Height = leftHeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (vm.IsRemoteGroupExpanded)
|
|
||||||
{
|
{
|
||||||
var desiredHeight = GetTreeRowsCount(vm.RemoteBranchTrees) * 24;
|
if (vm.IsLocalBranchGroupExpanded)
|
||||||
var remoteHeight = Math.Min(leftHeight, desiredHeight);
|
{
|
||||||
if (!remoteBranchTree.Height.IsClose(remoteHeight))
|
var height = localBranchRows * 24;
|
||||||
remoteBranchTree.Height = remoteHeight;
|
localBranchTree.Height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vm.IsRemoteGroupExpanded)
|
||||||
|
{
|
||||||
|
var height = remoteBranchRows * 24;
|
||||||
|
remoteBranchTree.Height = height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue