Forge
csharpdeeb25a2
1#nullable enable
2using Avalonia.Media;
3using CascadeIDE.Cockpit.Graph.Layout;
4using CascadeIDE.Cockpit.PrimitivesKit;
5
6namespace CascadeIDE.Views.SkiaKit.Graph;
7
8/// <summary>Цвета и перья graph-backed surface (SkiaKit / Avalonia DrawingContext). ADR 0117, 0067.</summary>
9public sealed class SkiaGraphVisualTheme
10{
11 private SkiaGraphVisualTheme(
12 Color anchorFill,
13 Color conditionFill,
14 Color exitFill,
15 Color callFill,
16 Color handlerFill,
17 Color sideLabel,
18 Color baseEdge,
19 Color conditionalEdge,
20 Color multiBranchEdge,
21 Color loopEdge,
22 Color highlightedEdge,
23 Color highlightedLoopEdge,
24 Color highlightedNode,
25 Color nodeStroke)
26 {
27 AnchorFill = new SolidColorBrush(anchorFill);
28 ConditionFill = new SolidColorBrush(conditionFill);
29 ExitFill = new SolidColorBrush(exitFill);
30 CallFill = new SolidColorBrush(callFill);
31 HandlerFill = new SolidColorBrush(handlerFill);
32 SideLabelBrush = new SolidColorBrush(sideLabel);
33 BaseEdgePen = new(new SolidColorBrush(baseEdge), 1);
34 ConditionalEdgePen = new(new SolidColorBrush(conditionalEdge), 1.2)
35 {
36 DashStyle = new DashStyle([3, 2], 0)
37 };
38 MultiBranchEdgePen = new(new SolidColorBrush(multiBranchEdge), 1)
39 {
40 DashStyle = new DashStyle([2, 2], 0)
41 };
42 LoopEdgePen = new(new SolidColorBrush(loopEdge), 1.8);
43 HighlightedEdgePen = new(new SolidColorBrush(highlightedEdge), 1.8);
44 HighlightedLoopEdgePen = new(new SolidColorBrush(highlightedLoopEdge), 2.2);
45 HighlightedNodePen = new(new SolidColorBrush(highlightedNode), 1.2);
46 NodeStrokePen = new(new SolidColorBrush(nodeStroke), 1);
47 }
48
49 public static SkiaGraphVisualTheme Default { get; } = new(
50 CockpitPrimitivesPalette.CodeNavigationMap.AnchorFill,
51 CockpitPrimitivesPalette.CodeNavigationMap.ConditionFill,
52 CockpitPrimitivesPalette.CodeNavigationMap.ExitFill,
53 CockpitPrimitivesPalette.CodeNavigationMap.CallFill,
54 CockpitPrimitivesPalette.CodeNavigationMap.HandlerFill,
55 CockpitPrimitivesPalette.CodeNavigationMap.SideLabel,
56 CockpitPrimitivesPalette.CodeNavigationMap.BaseEdge,
57 CockpitPrimitivesPalette.CodeNavigationMap.ConditionalEdge,
58 CockpitPrimitivesPalette.CodeNavigationMap.MultiBranchEdge,
59 CockpitPrimitivesPalette.CodeNavigationMap.LoopEdge,
60 CockpitPrimitivesPalette.CodeNavigationMap.HighlightedEdge,
61 CockpitPrimitivesPalette.CodeNavigationMap.HighlightedLoopEdge,
62 CockpitPrimitivesPalette.CodeNavigationMap.HighlightedNode,
63 CockpitPrimitivesPalette.CodeNavigationMap.NodeStroke);
64
65 private static readonly SkiaGraphVisualTheme WorkspaceRelated = new(
66 CockpitPrimitivesPalette.CodeNavigationMapWorkspace.AnchorFill,
67 CockpitPrimitivesPalette.CodeNavigationMapWorkspace.ConditionFill,
68 CockpitPrimitivesPalette.CodeNavigationMapWorkspace.ExitFill,
69 CockpitPrimitivesPalette.CodeNavigationMapWorkspace.PeerFill,
70 CockpitPrimitivesPalette.CodeNavigationMapWorkspace.HandlerFill,
71 CockpitPrimitivesPalette.CodeNavigationMapWorkspace.SideLabel,
72 CockpitPrimitivesPalette.CodeNavigationMapWorkspace.BaseEdge,
73 CockpitPrimitivesPalette.CodeNavigationMapWorkspace.ConditionalEdge,
74 CockpitPrimitivesPalette.CodeNavigationMapWorkspace.MultiBranchEdge,
75 CockpitPrimitivesPalette.CodeNavigationMapWorkspace.LoopEdge,
76 CockpitPrimitivesPalette.CodeNavigationMapWorkspace.HighlightedEdge,
77 CockpitPrimitivesPalette.CodeNavigationMapWorkspace.HighlightedLoopEdge,
78 CockpitPrimitivesPalette.CodeNavigationMapWorkspace.HighlightedNode,
79 CockpitPrimitivesPalette.CodeNavigationMapWorkspace.NodeStroke);
80
81 public static SkiaGraphVisualTheme ForPresentation(GraphLayoutPresentation presentation) =>
82 presentation == GraphLayoutPresentation.WorkspaceRelatedFiles
83 ? WorkspaceRelated
84 : Default;
85
86 public IBrush AnchorFill { get; }
87 public IBrush ConditionFill { get; }
88 public IBrush ExitFill { get; }
89 public IBrush CallFill { get; }
90 public IBrush HandlerFill { get; }
91 public IBrush GlyphBrush { get; } = Brushes.White;
92 public IBrush SideLabelBrush { get; }
93 public Pen BaseEdgePen { get; }
94 public Pen ConditionalEdgePen { get; }
95 public Pen MultiBranchEdgePen { get; }
96 public Pen LoopEdgePen { get; }
97 public Pen HighlightedEdgePen { get; }
98 public Pen HighlightedLoopEdgePen { get; }
99 public Pen HighlightedNodePen { get; }
100 public Pen NodeStrokePen { get; }
101 public Typeface GlyphTypeface { get; } = new("Segoe UI", FontStyle.Normal, FontWeight.SemiBold);
102 public Typeface SideLabelTypeface { get; } = new("Segoe UI", FontStyle.Normal, FontWeight.Medium);
103}
104
View only · write via MCP/CIDE