8000 ux: new style for inline code in commit subject · sourcegit-scm/sourcegit@6df38ad · GitHub
[go: up one dir, main page]

8000
Skip to content

Commit 6df38ad

Browse files
committed
ux: new style for inline code in commit subject
Signed-off-by: leo <longshuang@msn.cn>
1 parent 0a7b973 commit 6df38ad

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

src/Resources/Themes.axaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<Color x:Key="Color.Diff.AddedHighlight">#A7E1A7</Color>
2626
<Color x:Key="Color.Diff.DeletedHighlight">#F19B9D</Color>
2727
<Color x:Key="Color.Link">#0000EE</Color>
28-
<Color x:Key="Color.InlineCode">#FFE5E5E5</Color>
28+
<Color x:Key="Color.InlineCode">#FFE4E4E4</Color>
2929
</ResourceDictionary>
3030

3131
<ResourceDictionary x:Key="Dark">
@@ -52,7 +52,7 @@
5252
<Color x:Key="Color.Diff.AddedHighlight">#A0308D3C</Color>
5353
<Color x:Key="Color.Diff.DeletedHighlight">#A09F4247</Color>
5454
<Color x:Key="Color.Link">#4DAAFC</Color>
55-
<Color x:Key="Color.InlineCode">#FF2E2E2E</Color>
55+
<Color x:Key="Color.InlineCode">#FF383838</Color>
5656
</ResourceDictionary>
5757
</ResourceDictionary.ThemeDictionaries>
5858

src/Views/CommitSubjectPresenter.cs

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,23 +104,32 @@ public override void Render(DrawingContext context)
104104
if (_inlines.Count == 0)
105105
return;
106106

107-
var height = Bounds.Height;
108-
var width = Bounds.Width;
109-
foreach (var inline in _inlines)
107+
var ro = new RenderOptions()
110108
{
111-
if (inline.X > width)
112-
return;
109+
TextRenderingMode = TextRenderingMode.SubpixelAntialias,
110+
EdgeMode = EdgeMode.Antialias
111+
};
113112

114-
if (inline.Element is { Type: Models.InlineElementType.Code })
115-
{
116-
var rect = new Rect(inline.X, (height - inline.Text.Height - 2) * 0.5, inline.Text.WidthIncludingTrailingWhitespace + 8, inline.Text.Height + 2);
117-
var roundedRect = new RoundedRect(rect, new CornerRadius(4));
118-
context.DrawRectangle(InlineCodeBackground, null, roundedRect);
119-
context.DrawText(inline.Text, new Point(inline.X + 4, (height - inline.Text.Height) * 0.5));
120-
}
121-
else
113+
using (context.PushRenderOptions(ro))
114+
{
115+
var height = Bounds.Height;
116+
var width = Bounds.Width;
117+
foreach (var inline in _inlines)
122118
{
123-
context.DrawText(inline.Text, new Point(inline.X, (height - inline.Text.Height) * 0.5));
119+
if (inline.X > width)
120+
return;
121+
122+
if (inline.Element is { Type: Models.InlineElementType.Code })
123+
{
124+
var rect = new Rect(inline.X, (height - inline.Text.Height - 2) * 0.5, inline.Text.WidthIncludingTrailingWhitespace + 8, inline.Text.Height + 2);
125+
var roundedRect = new RoundedRect(rect, new CornerRadius(4));
126+
context.DrawRectangle(InlineCodeBackground, null, roundedRect);
127+
context.DrawText(inline.Text, new Point(inline.X + 4, (height - inline.Text.Height) * 0.5));
128+
}
129+
else
130+
{
131+
context.DrawText(inline.Text, new Point(inline.X, (height - inline.Text.Height) * 0.5));
132+
}
124133
}
125134
}
126135
}

0 commit comments

Comments
 (0)
0