Forge
csharpa2ee7322
1using CascadeIDE.Features.Agent.Environment;
2
3namespace CascadeIDE.Cockpit.Composition.HostSurface;
4
5internal readonly record struct InstrumentPlacementRule(
6 string InstrumentId,
7 string SlotId,
8 IInstrumentPlacementSpecification Specification);
9
10internal static class CockpitInstrumentPlacementRules
11{
12 public static bool IsAllowed(in InstrumentPlacementContext context)
13 {
14 foreach (var rule in MainWindow)
15 {
16 if (!string.Equals(rule.InstrumentId, context.InstrumentId, StringComparison.OrdinalIgnoreCase))
17 continue;
18 if (!string.Equals(rule.SlotId, context.SlotId, StringComparison.OrdinalIgnoreCase))
19 continue;
20 if (rule.Specification.IsSatisfiedBy(in context))
21 return true;
22 }
23
24 return false;
25 }
26
27 public static readonly IReadOnlyList<InstrumentPlacementRule> MainWindow =
28 [
29 // v1: solution tree stays on PFD, on supported host surfaces and standard safety levels.
30 new InstrumentPlacementRule(
31 CockpitStandardInstrumentIds.SolutionExplorerTree,
32 CockpitSlotIds.Pfd,
33 new AndInstrumentPlacementSpecification(
34 new AllowedSurfaceSpecification(
35 "main_window_docked_grid",
36 "main_window_plus_mfd_host_top_level"),
37 new AllowedSlotSpecification(CockpitSlotIds.Pfd),
38 new AllowedSafetyLevelsSpecification(
39 AgentSafetyLevel.Observe,
40 AgentSafetyLevel.Confirm,
41 AgentSafetyLevel.Autonomous)))
42 ];
43}
44
View only · write via MCP/CIDE