Forge
csharpdeeb25a2
1#nullable enable
2
3using CascadeIDE.Features.Chat;
4using SkiaSharp;
5
6namespace CascadeIDE.Views.SkiaKit;
7
8/// <summary>Slash-команда в TCI: обёртка над <see cref="SkiaStatusChip"/>.</summary>
9internal static class SkiaSlashCommandChip
10{
11 internal static SkiaStatusChipIconPlacement IconPlacement { get; private set; } =
12 SkiaStatusChipIconPlacement.Right;
13
14 public static void ConfigureIconPlacement(string? tomlValue) =>
15 IconPlacement = TciValidationIconPlacementParser.Parse(tomlValue);
16
17 public static bool ShouldDraw(SlashCommandPreviewKind kind, string? text) =>
18 SlashCommandPreviewVisualMapper.ShouldDrawChip(kind, text);
19
20 public static float MeasureLabelWidth(string label, float fontSize, bool monoFont = true)
21 {
22 using var font = monoFont ? SkiaKitFonts.CreateMono(fontSize) : SkiaKitFonts.CreateUi(fontSize);
23 return font.MeasureText(label);
24 }
25
26 public static SKRect ComputeChipRect(
27 float textLeft,
28 float textTop,
29 float textLineHeight,
30 float labelWidth) =>
31 SkiaStatusChip.ComputeRectAroundTextStart(
32 textLeft,
33 textTop,
34 textLineHeight,
35 labelWidth,
36 IconPlacement);
37
38 public static void Draw(
39 SKCanvas canvas,
40 SKRect chipRect,
41 ISkiaKitPaintTheme theme,
42 SlashCommandPreviewKind kind,
43 float fontSize) =>
44 SkiaStatusChip.DrawChrome(
45 canvas,
46 chipRect,
47 theme,
48 SkiaSlashPreviewChrome.ToChipSeverity(kind),
49 fontSize,
50 IconPlacement);
51}
52
View only · write via MCP/CIDE