mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
theme: add ThemeOverrides.OpacityForNotMergedCommits
to customize the opacity of commits that not belongs (haven't been merged) to current branch in histories (#268)
This commit is contained in:
parent
b2ed1b283a
commit
14469b1399
5 changed files with 22 additions and 16 deletions
|
@ -188,6 +188,8 @@ namespace SourceGit
|
||||||
else
|
else
|
||||||
Models.CommitGraph.SetDefaultPens(overrides.GraphPenThickness);
|
Models.CommitGraph.SetDefaultPens(overrides.GraphPenThickness);
|
||||||
|
|
||||||
|
Models.Commit.OpacityForNotMerged = overrides.OpacityForNotMergedCommits;
|
||||||
|
|
||||||
app.Resources.MergedDictionaries.Add(resDic);
|
app.Resources.MergedDictionaries.Add(resDic);
|
||||||
app._themeOverrides = resDic;
|
app._themeOverrides = resDic;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using Avalonia.Data.Converters;
|
using Avalonia.Data.Converters;
|
||||||
using Avalonia.Media;
|
|
||||||
|
|
||||||
namespace SourceGit.Converters
|
namespace SourceGit.Converters
|
||||||
{
|
{
|
||||||
|
@ -7,11 +6,5 @@ namespace SourceGit.Converters
|
||||||
{
|
{
|
||||||
public static readonly FuncValueConverter<bool, double> ToPageTabWidth =
|
public static readonly FuncValueConverter<bool, double> ToPageTabWidth =
|
||||||
new FuncValueConverter<bool, double>(x => x ? 200 : double.NaN);
|
new FuncValueConverter<bool, double>(x => x ? 200 : double.NaN);
|
||||||
|
|
||||||
public static readonly FuncValueConverter<bool, double> HalfIfFalse =
|
|
||||||
new FuncValueConverter<bool, double>(x => x ? 1 : 0.5);
|
|
||||||
|
|
||||||
public static readonly FuncValueConverter<bool, FontWeight> BoldIfTrue =
|
|
||||||
new FuncValueConverter<bool, FontWeight>(x => x ? FontWeight.Bold : FontWeight.Regular);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,18 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
|
using Avalonia.Media;
|
||||||
|
|
||||||
namespace SourceGit.Models
|
namespace SourceGit.Models
|
||||||
{
|
{
|
||||||
public class Commit
|
public class Commit
|
||||||
{
|
{
|
||||||
|
public static double OpacityForNotMerged
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
} = 0.5;
|
||||||
|
|
||||||
public string SHA { get; set; } = string.Empty;
|
public string SHA { get; set; } = string.Empty;
|
||||||
public User Author { get; set; } = User.Invalid;
|
public User Author { get; set; } = User.Invalid;
|
||||||
public ulong AuthorTime { get; set; } = 0;
|
public ulong AuthorTime { get; set; } = 0;
|
||||||
|
@ -25,5 +32,8 @@ namespace SourceGit.Models
|
||||||
|
|
||||||
public bool IsCommitterVisible => !Author.Equals(Committer) || AuthorTime != CommitterTime;
|
public bool IsCommitterVisible => !Author.Equals(Committer) || AuthorTime != CommitterTime;
|
||||||
public bool IsCurrentHead => Decorators.Find(x => x.Type is DecoratorType.CurrentBranchHead or DecoratorType.CurrentCommitHead) != null;
|
public bool IsCurrentHead => Decorators.Find(x => x.Type is DecoratorType.CurrentBranchHead or DecoratorType.CurrentCommitHead) != null;
|
||||||
|
|
||||||
|
public double Opacity => IsMerged ? 1 : OpacityForNotMerged;
|
||||||
|
public FontWeight FontWeight => IsCurrentHead ? FontWeight.Bold : FontWeight.Regular;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ namespace SourceGit.Models
|
||||||
{
|
{
|
||||||
public Dictionary<string, Color> BasicColors { get; set; } = new Dictionary<string, Color>();
|
public Dictionary<string, Color> BasicColors { get; set; } = new Dictionary<string, Color>();
|
||||||
public double GraphPenThickness { get; set; } = 2;
|
public double GraphPenThickness { get; set; } = 2;
|
||||||
|
public double OpacityForNotMergedCommits { get; set; } = 0.5;
|
||||||
public List<Color> GraphColors { get; set; } = new List<Color>();
|
public List<Color> GraphColors { get; set; } = new List<Color>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,8 +103,8 @@
|
||||||
|
|
||||||
<TextBlock Classes="monospace"
|
<TextBlock Classes="monospace"
|
||||||
Text="{Binding Subject}"
|
Text="{Binding Subject}"
|
||||||
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.HalfIfFalse}}"
|
Opacity="{Binding Opacity}"
|
||||||
FontWeight="{Binding IsCurrentHead, Converter={x:Static c:BoolConverters.BoldIfTrue}}"/>
|
FontWeight="{Binding FontWeight}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
@ -124,13 +124,13 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
IsHitTestVisible="False"
|
IsHitTestVisible="False"
|
||||||
User="{Binding Author}"
|
User="{Binding Author}"
|
||||||
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.HalfIfFalse}}"/>
|
Opacity="{Binding Opacity}"/>
|
||||||
<TextBlock Grid.Column="1"
|
<TextBlock Grid.Column="1"
|
||||||
Classes="monospace"
|
Classes="monospace"
|
||||||
Text="{Binding Author.Name}"
|
Text="{Binding Author.Name}"
|
||||||
Margin="8,0,0,0"
|
Margin="8,0,0,0"
|
||||||
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.HalfIfFalse}}"
|
Opacity="{Binding Opacity}"
|
||||||
FontWeight="{Binding IsCurrentHead, Converter={x:Static c:BoolConverters.BoldIfTrue}}"/>
|
FontWeight="{Binding FontWeight}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
|
@ -147,8 +147,8 @@
|
||||||
Text="{Binding SHA, Converter={x:Static c:StringConverters.ToShortSHA}}"
|
Text="{Binding SHA, Converter={x:Static c:StringConverters.ToShortSHA}}"
|
||||||
Margin="8,0"
|
Margin="8,0"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.HalfIfFalse}}"
|
Opacity="{Binding Opacity}"
|
||||||
FontWeight="{Binding IsCurrentHead, Converter={x:Static c:BoolConverters.BoldIfTrue}}"/>
|
FontWeight="{Binding FontWeight}"/>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
</DataGridTemplateColumn>
|
</DataGridTemplateColumn>
|
||||||
|
@ -169,8 +169,8 @@
|
||||||
<v:CommitTimeTextBlock Classes="monospace"
|
<v:CommitTimeTextBlock Classes="monospace"
|
||||||
Margin="8,0"
|
Margin="8,0"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.HalfIfFalse}}"
|
Opacity="{Binding Opacity}"
|
||||||
FontWeight="{Binding IsCurrentHead, Converter={x:Static c:BoolConverters.BoldIfTrue}}"
|
FontWeight="{Binding FontWeight}"
|
||||||
Timestamp="{Binding CommitterTime}"
|
Timestamp="{Binding CommitterTime}"
|
||||||
ShowAsDateTime="{Binding Source={x:Static vm:Preference.Instance}, Path=!DisplayTimeAsPeriodInHistories}"/>
|
ShowAsDateTime="{Binding Source={x:Static vm:Preference.Instance}, Path=!DisplayTimeAsPeriodInHistories}"/>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|
Loading…
Reference in a new issue