mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
ux: more flex layout for left siderbar groups
This commit is contained in:
parent
3ce580b682
commit
8faa8c7378
4 changed files with 480 additions and 394 deletions
|
@ -24,7 +24,6 @@ namespace SourceGit.ViewModels
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public BranchTreeNodeType Type { get; set; }
|
public BranchTreeNodeType Type { get; set; }
|
||||||
public object Backend { get; set; }
|
public object Backend { get; set; }
|
||||||
public bool IsExpanded { get; set; }
|
|
||||||
public bool IsFiltered { get; set; }
|
public bool IsFiltered { get; set; }
|
||||||
public List<BranchTreeNode> Children { get; set; } = new List<BranchTreeNode>();
|
public List<BranchTreeNode> Children { get; set; } = new List<BranchTreeNode>();
|
||||||
|
|
||||||
|
@ -69,6 +68,12 @@ namespace SourceGit.ViewModels
|
||||||
set => SetProperty(ref _isSelected, value);
|
set => SetProperty(ref _isSelected, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsExpanded
|
||||||
|
{
|
||||||
|
get => _isExpanded;
|
||||||
|
set => SetProperty(ref _isExpanded, value);
|
||||||
|
}
|
||||||
|
|
||||||
public string Tooltip
|
public string Tooltip
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -108,7 +113,9 @@ namespace SourceGit.ViewModels
|
||||||
child.UpdateCornerRadius(ref prev);
|
child.UpdateCornerRadius(ref prev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _isSelected = false;
|
private bool _isSelected = false;
|
||||||
|
private bool _isExpanded = false;
|
||||||
private CornerRadius _cornerRadius = new CornerRadius(DEFAULT_CORNER);
|
private CornerRadius _cornerRadius = new CornerRadius(DEFAULT_CORNER);
|
||||||
|
|
||||||
public class Builder
|
public class Builder
|
||||||
|
|
|
@ -271,6 +271,18 @@ namespace SourceGit.ViewModels
|
||||||
set => SetProperty(ref _searchedCommits, value);
|
set => SetProperty(ref _searchedCommits, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsLocalBranchGroupExpanded
|
||||||
|
{
|
||||||
|
get => _isLocalBranchGroupExpanded;
|
||||||
|
set => SetProperty(ref _isLocalBranchGroupExpanded, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsRemoteGroupExpanded
|
||||||
|
{
|
||||||
|
get => _isRemoteGroupExpanded;
|
||||||
|
set => SetProperty(ref _isRemoteGroupExpanded, value);
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsTagGroupExpanded
|
public bool IsTagGroupExpanded
|
||||||
{
|
{
|
||||||
get => _isTagGroupExpanded;
|
get => _isTagGroupExpanded;
|
||||||
|
@ -355,14 +367,7 @@ namespace SourceGit.ViewModels
|
||||||
_histories = null;
|
_histories = null;
|
||||||
_workingCopy = null;
|
_workingCopy = null;
|
||||||
_stashesPage = null;
|
_stashesPage = null;
|
||||||
_isSearching = false;
|
|
||||||
_searchCommitFilter = string.Empty;
|
|
||||||
|
|
||||||
_isTagGroupExpanded = false;
|
|
||||||
_isSubmoduleGroupExpanded = false;
|
|
||||||
|
|
||||||
_inProgressContext = null;
|
_inProgressContext = null;
|
||||||
_hasUnsolvedConflicts = false;
|
|
||||||
|
|
||||||
_remotes.Clear();
|
_remotes.Clear();
|
||||||
_branches.Clear();
|
_branches.Clear();
|
||||||
|
@ -1941,6 +1946,8 @@ namespace SourceGit.ViewModels
|
||||||
private string _searchCommitFilter = string.Empty;
|
private string _searchCommitFilter = string.Empty;
|
||||||
private List<Models.Commit> _searchedCommits = new List<Models.Commit>();
|
private List<Models.Commit> _searchedCommits = new List<Models.Commit>();
|
||||||
|
|
||||||
|
private bool _isLocalBranchGroupExpanded = true;
|
||||||
|
private bool _isRemoteGroupExpanded = false;
|
||||||
private bool _isTagGroupExpanded = false;
|
private bool _isTagGroupExpanded = false;
|
||||||
private bool _isSubmoduleGroupExpanded = false;
|
private bool _isSubmoduleGroupExpanded = false;
|
||||||
private bool _isWorktreeGroupExpanded = false;
|
private bool _isWorktreeGroupExpanded = false;
|
||||||
|
|
|
@ -119,7 +119,7 @@
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<!-- Dashboard -->
|
<!-- Dashboard -->
|
||||||
<Grid Grid.Row="1" Margin="0,0,0,8" RowDefinitions="Auto,Auto,28,Auto,28,*,28,Auto,28,Auto,28,Auto" IsVisible="{Binding !IsSearching}">
|
<Grid Grid.Row="1" Margin="0,0,0,8" RowDefinitions="Auto,Auto,*" IsVisible="{Binding !IsSearching}">
|
||||||
<!-- Page Switcher for Right Panel -->
|
<!-- Page Switcher for Right Panel -->
|
||||||
<Border Grid.Row="0" Margin="8,0,4,0" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}" CornerRadius="6">
|
<Border Grid.Row="0" Margin="8,0,4,0" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}" CornerRadius="6">
|
||||||
<Border CornerRadius="6" ClipToBounds="True">
|
<Border CornerRadius="6" ClipToBounds="True">
|
||||||
|
@ -231,14 +231,17 @@
|
||||||
</TextBox.InnerRightContent>
|
</TextBox.InnerRightContent>
|
||||||
</TextBox>
|
</TextBox>
|
||||||
|
|
||||||
|
<Grid Grid.Row="2" RowDefinitions="28,Auto,28,Auto,28,Auto,28,Auto,28,Auto" LayoutUpdated="OnDashboardLayoutUpdated">
|
||||||
<!-- Local Branches -->
|
<!-- Local Branches -->
|
||||||
<TextBlock Grid.Row="2" Classes="group_header_label" Text="{DynamicResource Text.Repository.LocalBranches}"/>
|
<ToggleButton Grid.Row="0" Classes="group_expander" IsChecked="{Binding IsLocalBranchGroupExpanded, Mode=TwoWay}">
|
||||||
<TreeView Grid.Row="3"
|
<TextBlock Classes="group_header_label" Margin="0" Text="{DynamicResource Text.Repository.LocalBranches}"/>
|
||||||
|
</ToggleButton>
|
||||||
|
<TreeView Grid.Row="1"
|
||||||
x:Name="localBranchTree"
|
x:Name="localBranchTree"
|
||||||
MaxHeight="400"
|
|
||||||
Margin="8,0,4,0"
|
Margin="8,0,4,0"
|
||||||
SelectionMode="Multiple"
|
SelectionMode="Multiple"
|
||||||
ItemsSource="{Binding LocalBranchTrees}"
|
ItemsSource="{Binding LocalBranchTrees}"
|
||||||
|
IsVisible="{Binding IsLocalBranchGroupExpanded}"
|
||||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||||
ContextRequested="OnLocalBranchContextMenuRequested"
|
ContextRequested="OnLocalBranchContextMenuRequested"
|
||||||
|
@ -305,17 +308,20 @@
|
||||||
</TreeView>
|
</TreeView>
|
||||||
|
|
||||||
<!-- Remotes -->
|
<!-- Remotes -->
|
||||||
<Grid Grid.Row="4" ColumnDefinitions="*,Auto">
|
<ToggleButton Grid.Row="2" Classes="group_expander" IsChecked="{Binding IsRemoteGroupExpanded, Mode=TwoWay}">
|
||||||
<TextBlock Grid.Column="0" Classes="group_header_label" Text="{DynamicResource Text.Repository.Remotes}"/>
|
<Grid ColumnDefinitions="*,Auto">
|
||||||
|
<TextBlock Grid.Column="0" Classes="group_header_label" Margin="0" Text="{DynamicResource Text.Repository.Remotes}"/>
|
||||||
<Button Grid.Column="1" Classes="icon_button" Width="14" Margin="8,0" Command="{Binding AddRemote}" ToolTip.Tip="{DynamicResource Text.Repository.Remotes.Add}">
|
<Button Grid.Column="1" Classes="icon_button" Width="14" Margin="8,0" Command="{Binding AddRemote}" ToolTip.Tip="{DynamicResource Text.Repository.Remotes.Add}">
|
||||||
<Path Width="12" Height="12" Data="{StaticResource Icons.Remote.Add}"/>
|
<Path Width="12" Height="12" Data="{StaticResource Icons.Remote.Add}"/>
|
||||||
</Button>
|
</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
<TreeView Grid.Row="5"
|
</ToggleButton>
|
||||||
|
<TreeView Grid.Row="3"
|
||||||
x:Name="remoteBranchTree"
|
x:Name="remoteBranchTree"
|
||||||
Margin="8,0,4,0"
|
Margin="8,0,4,0"
|
||||||
SelectionMode="Multiple"
|
SelectionMode="Multiple"
|
||||||
ItemsSource="{Binding RemoteBranchTrees}"
|
ItemsSource="{Binding RemoteBranchTrees}"
|
||||||
|
IsVisible="{Binding IsRemoteGroupExpanded}"
|
||||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||||
ContextRequested="OnRemoteBranchContextMenuRequested"
|
ContextRequested="OnRemoteBranchContextMenuRequested"
|
||||||
|
@ -369,7 +375,7 @@
|
||||||
</TreeView>
|
</TreeView>
|
||||||
|
|
||||||
<!-- Tags -->
|
<!-- Tags -->
|
||||||
<ToggleButton Grid.Row="6" Classes="group_expander" IsChecked="{Binding IsTagGroupExpanded, Mode=TwoWay}">
|
<ToggleButton Grid.Row="4" Classes="group_expander" IsChecked="{Binding IsTagGroupExpanded, Mode=TwoWay}">
|
||||||
<Grid ColumnDefinitions="Auto,*,Auto">
|
<Grid ColumnDefinitions="Auto,*,Auto">
|
||||||
<TextBlock Grid.Column="0" Classes="group_header_label" Margin="0" Text="{DynamicResource Text.Repository.Tags}"/>
|
<TextBlock Grid.Column="0" Classes="group_header_label" Margin="0" Text="{DynamicResource Text.Repository.Tags}"/>
|
||||||
<TextBlock Grid.Column="1" Text="{Binding Tags, Converter={x:Static c:ListConverters.ToCount}}" Foreground="{DynamicResource Brush.FG2}" FontWeight="Bold"/>
|
<TextBlock Grid.Column="1" Text="{Binding Tags, Converter={x:Static c:ListConverters.ToCount}}" Foreground="{DynamicResource Brush.FG2}" FontWeight="Bold"/>
|
||||||
|
@ -378,7 +384,7 @@
|
||||||
</Button>
|
</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
<DataGrid Grid.Row="7"
|
<DataGrid Grid.Row="5"
|
||||||
x:Name="tagsList"
|
x:Name="tagsList"
|
||||||
Margin="8,0,4,0"
|
Margin="8,0,4,0"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
|
@ -395,8 +401,7 @@
|
||||||
VerticalScrollBarVisibility="Auto"
|
VerticalScrollBarVisibility="Auto"
|
||||||
IsVisible="{Binding IsTagGroupExpanded, Mode=OneWay}"
|
IsVisible="{Binding IsTagGroupExpanded, Mode=OneWay}"
|
||||||
SelectionChanged="OnTagDataGridSelectionChanged"
|
SelectionChanged="OnTagDataGridSelectionChanged"
|
||||||
ContextRequested="OnTagContextRequested"
|
ContextRequested="OnTagContextRequested">
|
||||||
PropertyChanged="OnTagPropertyChanged">
|
|
||||||
<DataGrid.Styles>
|
<DataGrid.Styles>
|
||||||
<Style Selector="DataGridRow">
|
<Style Selector="DataGridRow">
|
||||||
<Setter Property="CornerRadius" Value="4" />
|
<Setter Property="CornerRadius" Value="4" />
|
||||||
|
@ -458,7 +463,7 @@
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
|
|
||||||
<!-- Submodules -->
|
<!-- Submodules -->
|
||||||
<ToggleButton Grid.Row="8" Classes="group_expander" IsChecked="{Binding IsSubmoduleGroupExpanded, Mode=TwoWay}">
|
<ToggleButton Grid.Row="6" Classes="group_expander" IsChecked="{Binding IsSubmoduleGroupExpanded, Mode=TwoWay}">
|
||||||
<Grid ColumnDefinitions="Auto,*,Auto,Auto">
|
<Grid ColumnDefinitions="Auto,*,Auto,Auto">
|
||||||
<TextBlock Grid.Column="0" Classes="group_header_label" Margin="0" Text="{DynamicResource Text.Repository.Submodules}"/>
|
<TextBlock Grid.Column="0" Classes="group_header_label" Margin="0" Text="{DynamicResource Text.Repository.Submodules}"/>
|
||||||
<TextBlock Grid.Column="1" Text="{Binding Submodules, Converter={x:Static c:ListConverters.ToCount}}" Foreground="{DynamicResource Brush.FG2}" FontWeight="Bold"/>
|
<TextBlock Grid.Column="1" Text="{Binding Submodules, Converter={x:Static c:ListConverters.ToCount}}" Foreground="{DynamicResource Brush.FG2}" FontWeight="Bold"/>
|
||||||
|
@ -481,7 +486,8 @@
|
||||||
</Button>
|
</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
<DataGrid Grid.Row="9"
|
<DataGrid Grid.Row="7"
|
||||||
|
x:Name="submoduleList"
|
||||||
MaxHeight="200"
|
MaxHeight="200"
|
||||||
Margin="8,0,4,0"
|
Margin="8,0,4,0"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
|
@ -539,7 +545,7 @@
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
|
|
||||||
<!-- Worktrees -->
|
<!-- Worktrees -->
|
||||||
<ToggleButton Grid.Row="10" Classes="group_expander" IsChecked="{Binding IsWorktreeGroupExpanded, Mode=TwoWay}">
|
<ToggleButton Grid.Row="8" Classes="group_expander" IsChecked="{Binding IsWorktreeGroupExpanded, Mode=TwoWay}">
|
||||||
<Grid ColumnDefinitions="Auto,*,Auto,Auto">
|
<Grid ColumnDefinitions="Auto,*,Auto,Auto">
|
||||||
<TextBlock Grid.Column="0" Classes="group_header_label" Margin="0" Text="{DynamicResource Text.Repository.Worktrees}"/>
|
<TextBlock Grid.Column="0" Classes="group_header_label" Margin="0" Text="{DynamicResource Text.Repository.Worktrees}"/>
|
||||||
<TextBlock Grid.Column="1" Text="{Binding Worktrees, Converter={x:Static c:ListConverters.ToCount}}" Foreground="{DynamicResource Brush.FG2}" FontWeight="Bold"/>
|
<TextBlock Grid.Column="1" Text="{Binding Worktrees, Converter={x:Static c:ListConverters.ToCount}}" Foreground="{DynamicResource Brush.FG2}" FontWeight="Bold"/>
|
||||||
|
@ -562,8 +568,8 @@
|
||||||
</Button>
|
</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
<DataGrid Grid.Row="11"
|
<DataGrid Grid.Row="9"
|
||||||
MaxHeight="200"
|
x:Name="worktreeList"
|
||||||
Margin="8,0,4,0"
|
Margin="8,0,4,0"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
ItemsSource="{Binding Worktrees}"
|
ItemsSource="{Binding Worktrees}"
|
||||||
|
@ -628,6 +634,7 @@
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
<!-- Commit Search Panel -->
|
<!-- Commit Search Panel -->
|
||||||
<Grid Grid.Row="1" RowDefinitions="Auto,32,*" Margin="8,0,4,8" IsVisible="{Binding IsSearching}" PropertyChanged="OnSearchCommitPanelPropertyChanged">
|
<Grid Grid.Row="1" RowDefinitions="Auto,32,*" Margin="8,0,4,8" IsVisible="{Binding IsSearching}" PropertyChanged="OnSearchCommitPanelPropertyChanged">
|
||||||
|
|
|
@ -7,6 +7,7 @@ using Avalonia.Controls.Primitives;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.VisualTree;
|
using Avalonia.VisualTree;
|
||||||
|
using AvaloniaEdit.Utils;
|
||||||
|
|
||||||
namespace SourceGit.Views
|
namespace SourceGit.Views
|
||||||
{
|
{
|
||||||
|
@ -280,18 +281,6 @@ namespace SourceGit.Views
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTagPropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Property == DataGrid.ItemsSourceProperty && DataContext is ViewModels.Repository vm)
|
|
||||||
{
|
|
||||||
if (vm.VisibleTags == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var desiredHeight = tagsList.RowHeight * vm.VisibleTags.Count;
|
|
||||||
tagsList.Height = Math.Min(200, desiredHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnToggleFilter(object sender, RoutedEventArgs e)
|
private void OnToggleFilter(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is ToggleButton toggle)
|
if (sender is ToggleButton toggle)
|
||||||
|
@ -379,5 +368,81 @@ namespace SourceGit.Views
|
||||||
outs.Add(b);
|
outs.Add(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnDashboardLayoutUpdated(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var vm = DataContext as ViewModels.Repository;
|
||||||
|
if (vm == null || vm.Settings == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var grid = sender as Grid;
|
||||||
|
if (grid == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var leftHeight = grid.Bounds.Height - 28.0 * 5;
|
||||||
|
if (vm.IsTagGroupExpanded)
|
||||||
|
{
|
||||||
|
var desiredHeight = Math.Min(200.0, tagsList.RowHeight * vm.VisibleTags.Count);
|
||||||
|
leftHeight -= desiredHeight;
|
||||||
|
if (!tagsList.Height.IsClose(desiredHeight))
|
||||||
|
tagsList.Height = desiredHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vm.IsSubmoduleGroupExpanded)
|
||||||
|
{
|
||||||
|
var desiredHeight = Math.Min(200.0, submoduleList.RowHeight * vm.Submodules.Count);
|
||||||
|
leftHeight -= desiredHeight;
|
||||||
|
if (!submoduleList.Height.IsClose(desiredHeight))
|
||||||
|
submoduleList.Height = desiredHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vm.IsWorktreeGroupExpanded)
|
||||||
|
{
|
||||||
|
var desiredHeight = Math.Min(200.0, worktreeList.RowHeight * vm.Worktrees.Count);
|
||||||
|
leftHeight -= desiredHeight;
|
||||||
|
if (!worktreeList.Height.IsClose(desiredHeight))
|
||||||
|
worktreeList.Height = desiredHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
var desiredLocalBranchHeight = GetTreeRowsCount(vm.LocalBranchTrees) * 24;
|
||||||
|
var desiredRemoteHeight = GetTreeRowsCount(vm.RemoteBranchTrees) * 24;
|
||||||
|
|
||||||
|
if (!vm.IsRemoteGroupExpanded)
|
||||||
|
{
|
||||||
|
if (vm.IsLocalBranchGroupExpanded)
|
||||||
|
{
|
||||||
|
var localBranchHeight = Math.Min(leftHeight, desiredLocalBranchHeight);
|
||||||
|
localBranchTree.Height = localBranchHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (vm.IsLocalBranchGroupExpanded)
|
||||||
|
{
|
||||||
|
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))
|
||||||
|
remoteBranchTree.Height = remoteHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int GetTreeRowsCount(List<ViewModels.BranchTreeNode> nodes)
|
||||||
|
{
|
||||||
|
int count = nodes.Count;
|
||||||
|
|
||||||
|
foreach (var node in nodes)
|
||||||
|
{
|
||||||
|
if (!node.IsBranch && node.IsExpanded)
|
||||||
|
count += GetTreeRowsCount(node.Children);
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue