mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
ux: add Color.DecoratorHead
for current branch head (#395)
This commit is contained in:
parent
3569e1696f
commit
a717dc1876
4 changed files with 30 additions and 13 deletions
|
@ -16,7 +16,8 @@
|
||||||
<Color x:Key="Color.DecoratorIconBG">#FF6F6F6F</Color>
|
<Color x:Key="Color.DecoratorIconBG">#FF6F6F6F</Color>
|
||||||
<Color x:Key="Color.DecoratorIcon">#FFF8F8F8</Color>
|
<Color x:Key="Color.DecoratorIcon">#FFF8F8F8</Color>
|
||||||
<Color x:Key="Color.DecoratorBranch">#FFFFB835</Color>
|
<Color x:Key="Color.DecoratorBranch">#FFFFB835</Color>
|
||||||
<Color x:Key="Color.DecoratorTag">#FF02C302</Color>
|
<Color x:Key="Color.DecoratorHead">#fb5607</Color>
|
||||||
|
<Color x:Key="Color.DecoratorTag">#669900</Color>
|
||||||
<Color x:Key="Color.DecoratorFG">Black</Color>
|
<Color x:Key="Color.DecoratorFG">Black</Color>
|
||||||
<Color x:Key="Color.Conflict">#FF836C2E</Color>
|
<Color x:Key="Color.Conflict">#FF836C2E</Color>
|
||||||
<Color x:Key="Color.ConflictForeground">#FFFFFFFF</Color>
|
<Color x:Key="Color.ConflictForeground">#FFFFFFFF</Color>
|
||||||
|
@ -50,7 +51,8 @@
|
||||||
<Color x:Key="Color.DecoratorIconBG">#FF505050</Color>
|
<Color x:Key="Color.DecoratorIconBG">#FF505050</Color>
|
||||||
<Color x:Key="Color.DecoratorIcon">#FFF8F8F8</Color>
|
<Color x:Key="Color.DecoratorIcon">#FFF8F8F8</Color>
|
||||||
<Color x:Key="Color.DecoratorBranch">#FFFFB835</Color>
|
<Color x:Key="Color.DecoratorBranch">#FFFFB835</Color>
|
||||||
<Color x:Key="Color.DecoratorTag">#FF02C302</Color>
|
<Color x:Key="Color.DecoratorHead">#f4f1de</Color>
|
||||||
|
<Color x:Key="Color.DecoratorTag">#669900</Color>
|
||||||
<Color x:Key="Color.DecoratorFG">Black</Color>
|
<Color x:Key="Color.DecoratorFG">Black</Color>
|
||||||
<Color x:Key="Color.Conflict">#FFFAFAD2</Color>
|
<Color x:Key="Color.Conflict">#FFFAFAD2</Color>
|
||||||
<Color x:Key="Color.ConflictForeground">#FF252525</Color>
|
<Color x:Key="Color.ConflictForeground">#FF252525</Color>
|
||||||
|
@ -84,6 +86,7 @@
|
||||||
<SolidColorBrush x:Key="Brush.DecoratorIconBG" Color="{DynamicResource Color.DecoratorIconBG}"/>
|
<SolidColorBrush x:Key="Brush.DecoratorIconBG" Color="{DynamicResource Color.DecoratorIconBG}"/>
|
||||||
<SolidColorBrush x:Key="Brush.DecoratorIcon" Color="{DynamicResource Color.DecoratorIcon}"/>
|
<SolidColorBrush x:Key="Brush.DecoratorIcon" Color="{DynamicResource Color.DecoratorIcon}"/>
|
||||||
<SolidColorBrush x:Key="Brush.DecoratorBranch" Color="{DynamicResource Color.DecoratorBranch}"/>
|
<SolidColorBrush x:Key="Brush.DecoratorBranch" Color="{DynamicResource Color.DecoratorBranch}"/>
|
||||||
|
<SolidColorBrush x:Key="Brush.DecoratorHead" Color="{DynamicResource Color.DecoratorHead}"/>
|
||||||
<SolidColorBrush x:Key="Brush.DecoratorTag" Color="{DynamicResource Color.DecoratorTag}"/>
|
<SolidColorBrush x:Key="Brush.DecoratorTag" Color="{DynamicResource Color.DecoratorTag}"/>
|
||||||
<SolidColorBrush x:Key="Brush.DecoratorFG" Color="{DynamicResource Color.DecoratorFG}"/>
|
<SolidColorBrush x:Key="Brush.DecoratorFG" Color="{DynamicResource Color.DecoratorFG}"/>
|
||||||
<SolidColorBrush x:Key="Brush.Conflict" Color="{DynamicResource Color.Conflict}"/>
|
<SolidColorBrush x:Key="Brush.Conflict" Color="{DynamicResource Color.Conflict}"/>
|
||||||
|
|
|
@ -98,6 +98,7 @@
|
||||||
<v:CommitRefsPresenter IconBackground="{DynamicResource Brush.DecoratorIconBG}"
|
<v:CommitRefsPresenter IconBackground="{DynamicResource Brush.DecoratorIconBG}"
|
||||||
IconForeground="{DynamicResource Brush.DecoratorIcon}"
|
IconForeground="{DynamicResource Brush.DecoratorIcon}"
|
||||||
BranchNameBackground="{DynamicResource Brush.DecoratorBranch}"
|
BranchNameBackground="{DynamicResource Brush.DecoratorBranch}"
|
||||||
|
HeadBranchNameBackground="{DynamicResource Brush.DecoratorHead}"
|
||||||
TagNameBackground="{DynamicResource Brush.DecoratorTag}"
|
TagNameBackground="{DynamicResource Brush.DecoratorTag}"
|
||||||
LabelForeground="{DynamicResource Brush.DecoratorFG}"
|
LabelForeground="{DynamicResource Brush.DecoratorFG}"
|
||||||
FontFamily="{DynamicResource Fonts.Primary}"
|
FontFamily="{DynamicResource Fonts.Primary}"
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace SourceGit.Views
|
||||||
{
|
{
|
||||||
public Geometry Icon { get; set; } = null;
|
public Geometry Icon { get; set; } = null;
|
||||||
public FormattedText Label { get; set; } = null;
|
public FormattedText Label { get; set; } = null;
|
||||||
public bool IsTag { get; set; } = false;
|
public IBrush LabelBG { get; set; } = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly StyledProperty<List<Models.Decorator>> RefsProperty =
|
public static readonly StyledProperty<List<Models.Decorator>> RefsProperty =
|
||||||
|
@ -80,6 +80,15 @@ namespace SourceGit.Views
|
||||||
set => SetValue(BranchNameBackgroundProperty, value);
|
set => SetValue(BranchNameBackgroundProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static readonly StyledProperty<IBrush> HeadBranchNameBackgroundProperty =
|
||||||
|
AvaloniaProperty.Register<CommitRefsPresenter, IBrush>(nameof(HeadBranchNameBackground), Brushes.White);
|
||||||
|
|
||||||
|
public IBrush HeadBranchNameBackground
|
||||||
|
{
|
||||||
|
get => GetValue(HeadBranchNameBackgroundProperty);
|
||||||
|
set => SetValue(HeadBranchNameBackgroundProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
public static readonly StyledProperty<IBrush> TagNameBackgroundProperty =
|
public static readonly StyledProperty<IBrush> TagNameBackgroundProperty =
|
||||||
AvaloniaProperty.Register<CommitRefsPresenter, IBrush>(nameof(TagNameBackground), Brushes.White);
|
AvaloniaProperty.Register<CommitRefsPresenter, IBrush>(nameof(TagNameBackground), Brushes.White);
|
||||||
|
|
||||||
|
@ -111,8 +120,6 @@ namespace SourceGit.Views
|
||||||
|
|
||||||
var iconFG = IconForeground;
|
var iconFG = IconForeground;
|
||||||
var iconBG = IconBackground;
|
var iconBG = IconBackground;
|
||||||
var branchBG = BranchNameBackground;
|
|
||||||
var tagBG = TagNameBackground;
|
|
||||||
var x = 0.0;
|
var x = 0.0;
|
||||||
|
|
||||||
foreach (var item in _items)
|
foreach (var item in _items)
|
||||||
|
@ -121,7 +128,7 @@ namespace SourceGit.Views
|
||||||
var labelRect = new RoundedRect(new Rect(x + 16, 0, item.Label.Width + 8, 16), new CornerRadius(0, 2, 2, 0));
|
var labelRect = new RoundedRect(new Rect(x + 16, 0, item.Label.Width + 8, 16), new CornerRadius(0, 2, 2, 0));
|
||||||
|
|
||||||
context.DrawRectangle(iconBG, null, iconRect);
|
context.DrawRectangle(iconBG, null, iconRect);
|
||||||
context.DrawRectangle(item.IsTag ? tagBG : branchBG, null, labelRect);
|
context.DrawRectangle(item.LabelBG, null, labelRect);
|
||||||
context.DrawText(item.Label, new Point(x + 20, 8.0 - item.Label.Height * 0.5));
|
context.DrawText(item.Label, new Point(x + 20, 8.0 - item.Label.Height * 0.5));
|
||||||
|
|
||||||
using (context.PushTransform(Matrix.CreateTranslation(x + 4, 4)))
|
using (context.PushTransform(Matrix.CreateTranslation(x + 4, 4)))
|
||||||
|
@ -141,6 +148,9 @@ namespace SourceGit.Views
|
||||||
var typeface = new Typeface(FontFamily);
|
var typeface = new Typeface(FontFamily);
|
||||||
var typefaceBold = new Typeface(FontFamily, FontStyle.Normal, FontWeight.Bold);
|
var typefaceBold = new Typeface(FontFamily, FontStyle.Normal, FontWeight.Bold);
|
||||||
var labelFG = LabelForeground;
|
var labelFG = LabelForeground;
|
||||||
|
var branchBG = BranchNameBackground;
|
||||||
|
var headBG = HeadBranchNameBackground;
|
||||||
|
var tagBG = TagNameBackground;
|
||||||
var labelSize = FontSize;
|
var labelSize = FontSize;
|
||||||
var requiredWidth = 0.0;
|
var requiredWidth = 0.0;
|
||||||
|
|
||||||
|
@ -154,29 +164,31 @@ namespace SourceGit.Views
|
||||||
CultureInfo.CurrentCulture,
|
CultureInfo.CurrentCulture,
|
||||||
FlowDirection.LeftToRight,
|
FlowDirection.LeftToRight,
|
||||||
isHead ? typefaceBold : typeface,
|
isHead ? typefaceBold : typeface,
|
||||||
isHead ? labelSize + 0.5 : labelSize,
|
labelSize,
|
||||||
labelFG);
|
labelFG);
|
||||||
|
|
||||||
var item = new RenderItem()
|
var item = new RenderItem() { Label = label };
|
||||||
{
|
|
||||||
Label = label,
|
|
||||||
IsTag = decorator.Type == Models.DecoratorType.Tag,
|
|
||||||
};
|
|
||||||
|
|
||||||
StreamGeometry geo;
|
StreamGeometry geo;
|
||||||
switch (decorator.Type)
|
switch (decorator.Type)
|
||||||
{
|
{
|
||||||
case Models.DecoratorType.CurrentBranchHead:
|
case Models.DecoratorType.CurrentBranchHead:
|
||||||
|
item.LabelBG = headBG;
|
||||||
|
geo = this.FindResource("Icons.Check") as StreamGeometry;
|
||||||
|
break;
|
||||||
case Models.DecoratorType.CurrentCommitHead:
|
case Models.DecoratorType.CurrentCommitHead:
|
||||||
|
item.LabelBG = branchBG;
|
||||||
geo = this.FindResource("Icons.Check") as StreamGeometry;
|
geo = this.FindResource("Icons.Check") as StreamGeometry;
|
||||||
break;
|
break;
|
||||||
case Models.DecoratorType.RemoteBranchHead:
|
case Models.DecoratorType.RemoteBranchHead:
|
||||||
|
item.LabelBG = branchBG;
|
||||||
geo = this.FindResource("Icons.Remote") as StreamGeometry;
|
geo = this.FindResource("Icons.Remote") as StreamGeometry;
|
||||||
break;
|
break;
|
||||||
case Models.DecoratorType.Tag:
|
case Models.DecoratorType.Tag:
|
||||||
|
item.LabelBG = tagBG;
|
||||||
geo = this.FindResource("Icons.Tag") as StreamGeometry;
|
geo = this.FindResource("Icons.Tag") as StreamGeometry;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
item.LabelBG = branchBG;
|
||||||
geo = this.FindResource("Icons.Branch") as StreamGeometry;
|
geo = this.FindResource("Icons.Branch") as StreamGeometry;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,7 @@
|
||||||
<v:CommitRefsPresenter IconBackground="{DynamicResource Brush.DecoratorIconBG}"
|
<v:CommitRefsPresenter IconBackground="{DynamicResource Brush.DecoratorIconBG}"
|
||||||
IconForeground="{DynamicResource Brush.DecoratorIcon}"
|
IconForeground="{DynamicResource Brush.DecoratorIcon}"
|
||||||
BranchNameBackground="{DynamicResource Brush.DecoratorBranch}"
|
BranchNameBackground="{DynamicResource Brush.DecoratorBranch}"
|
||||||
|
HeadBranchNameBackground="{DynamicResource Brush.DecoratorHead}"
|
||||||
TagNameBackground="{DynamicResource Brush.DecoratorTag}"
|
TagNameBackground="{DynamicResource Brush.DecoratorTag}"
|
||||||
LabelForeground="{DynamicResource Brush.DecoratorFG}"
|
LabelForeground="{DynamicResource Brush.DecoratorFG}"
|
||||||
FontFamily="{DynamicResource Fonts.Primary}"
|
FontFamily="{DynamicResource Fonts.Primary}"
|
||||||
|
|
Loading…
Reference in a new issue