| 1 | using CascadeIDE.Models; |
| 2 | |
| 3 | namespace CascadeIDE.Services.Presentation; |
| 4 | |
| 5 | /// <summary>Resolves effective presentation tier from settings, topology, and monitors (ADR 0171).</summary> |
| 6 | public static class PresentationTierResolver |
| 7 | { |
| 8 | public static PresentationTierKind Resolve( |
| 9 | DisplayPresentationSettings settings, |
| 10 | PresentationParseResult parse, |
| 11 | PresentationMonitorSnapshot monitors) |
| 12 | { |
| 13 | var configured = settings.Tier?.Trim() ?? PresentationTierKindExtensions.AutoValue; |
| 14 | if (string.Equals(configured, PresentationTierKindExtensions.CompactValue, StringComparison.OrdinalIgnoreCase)) |
| 15 | return PresentationTierKind.Compact; |
| 16 | if (string.Equals(configured, PresentationTierKindExtensions.CockpitValue, StringComparison.OrdinalIgnoreCase)) |
| 17 | return PresentationTierKind.Cockpit; |
| 18 | |
| 19 | return ResolveAuto(settings, parse, monitors); |
| 20 | } |
| 21 | |
| 22 | public static PresentationTierKind ResolveAuto( |
| 23 | DisplayPresentationSettings settings, |
| 24 | PresentationParseResult parse, |
| 25 | PresentationMonitorSnapshot monitors) |
| 26 | { |
| 27 | if (parse.IsSuccess |
| 28 | && PresentationLayoutAnalyzer.IsTripleOneAnchorPerZonePreset(parse.Screens) |
| 29 | && monitors.PhysicalScreenCount >= 3) |
| 30 | return PresentationTierKind.Cockpit; |
| 31 | |
| 32 | if (monitors.PhysicalScreenCount >= 3) |
| 33 | return PresentationTierKind.Cockpit; |
| 34 | |
| 35 | if (monitors.PhysicalScreenCount == 1 |
| 36 | && settings.UltrawideCockpitEnabled |
| 37 | && IsUltrawideCockpitCapable(settings, monitors)) |
| 38 | return PresentationTierKind.Cockpit; |
| 39 | |
| 40 | return PresentationTierKind.Compact; |
| 41 | } |
| 42 | |
| 43 | public static bool IsUltrawideCockpitCapable( |
| 44 | DisplayPresentationSettings settings, |
| 45 | PresentationMonitorSnapshot monitors) => |
| 46 | monitors.PrimaryWorkingAreaWidthPx >= settings.CockpitMinTotalWidthPx |
| 47 | && monitors.PrimaryWorkingAreaWidthPx >= settings.CockpitMinAnchorWidthPx * 3; |
| 48 | |
| 49 | /// <summary>Recommendation text for first-run wizard.</summary> |
| 50 | public static PresentationTierKind RecommendForFirstRun( |
| 51 | DisplayPresentationSettings settings, |
| 52 | PresentationParseResult parse, |
| 53 | PresentationMonitorSnapshot monitors) => |
| 54 | ResolveAuto(settings, parse, monitors); |
| 55 | } |
| 56 | |