Vixen
dd8b0a81
csharp
public sealed class UiSurface

One rectangle a document is laid out into, drawn onto and clicked in.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

A document is a tree; a surface is a place to show part of one. Until this existed the two were the same thing — one root, one size, one draw list — and a second window therefore meant a second document. It cannot: a panel dragged from the main window into a torn-off one has to keep its scroll offset, its selection and whatever the user has half-typed, and the only operation that preserves those is Reparent, which is within a document by construction. Making a window a surface rather than a document turns "move a panel to another window" into the reparent the docking host already performs.

⚠ Every surface after the first is an ordinary element under Root, and that is deliberate. It keeps one style tree, so a torn-off panel inherits the theme, matches the same stylesheets and resolves rem against the same root — and it keeps one focus, one pointer capture and one gesture recogniser, which is what lets a drag that starts in one window finish in another. What the surface root does not do is take part in its parent's flex layout: it is removed from the layout tree's child list and laid out on its own, against its own size.

⚠ DpiScale is per surface, because two windows are routinely on two displays. It is not a scale the document applies to anything — lengths stay in logical points everywhere above the renderer — it is the grid the finished layout is snapped to, so that a one-pixel border on a 2× display is one physical pixel rather than one and a half.

⚠ And Media is per surface for the same reason, which took longer to arrive. 50vw in a torn-off inspector has always meant half of that window, while @media (min-width: 640px) meant the main one — the size was read off the surface and the breakpoint was read off the document. The inconsistency was not an oversight but a consequence: @media was decided at load, so its verdict lived in the rule set, and a rule set is shared by every surface. The verdict is a MediaScopes entry now, and the two questions finally answer about the same rectangle.

Fields and properties (16)

  • public int Id

    What tells the surfaces of one document apart.

  • public UiDocument Document

    The document it shows part of.

  • public UiElement Root

    The element it is laid out from.

  • public bool IsPrimary

    Whether this is the surface the document was created with.

  • public float Width

    Its width in device-independent pixels.

  • public float Height

    Its height.

  • public float DpiScale

    How many physical pixels one device-independent one is here.

  • public DrawList Drawing

    The commands the last draw produced for it.

  • public bool IsRemoved

    Whether it has been taken out of the document.

  • public UiElement? Focused

    The element the keyboard is talking to in this window.

  • public UiElement? CommandFocus

    Where a command id resolves from in this window — its focus, ignoring command surfaces.

  • public LengthContext Metrics

    The lengths vw, vh and rem measure against here.

  • public ColorGamut Gamut

    What this surface can actually show, which decides @media (color-gamut: …) here.

  • public ColorSchemePreference ColorScheme

    Whether the platform's appearance is light or dark for this window.

  • public MediaPreferences Preferences

    The platform's accessibility settings, as this window's @media answers them.

  • public MediaContext Media

    What @media is answered against in this window.

Used by (43, showing 40)

  • AccessibilityWiringTestsVixen.Platform.Ui.Tests
  • AdvancedFixtureVixen.Ui.Controls.Advanced.Tests
  • ColorSchemeWiringTestsVixen.Ui.Desktop.Tests
  • CommandRouteVixen.Ui
  • CommandRouteTestsVixen.Ui.Tests
  • ContainerWiringTestsVixen.Ui.Tests
  • DockingHostVixen.Ui.Controls.Advanced
  • DocumentLifetimeTestsVixen.Ui.Tests
  • DrawListBuilderVixen.Ui
  • EditableDocumentTestsVixen.Ui.Tests
  • FakeWindowVixen.Ui.Controls.Advanced.Tests
  • FakeWindowVixen.Ui.Tests
  • FakeWindowsVixen.Ui.Controls.Advanced.Tests
  • ForcedColorsTestsVixen.Ui.Tests
  • IUiWindowVixen.Ui
  • IUiWindowHostVixen.Ui
  • KeyWindowTestsVixen.Ui.Tests
  • NoWindowsVixen.Ui.Tests
  • OneWindowVixen.Ui.Tests
  • PerSurfaceMediaTestsVixen.Ui.Tests
  • PlatformCursorTestsVixen.Platform.Ui.Tests
  • PlatformInputVixen.Platform.Ui
  • PlatformUiWindowVixen.Platform.Ui
  • PlatformWindowHostVixen.Platform.Ui
  • PlatformWindowHostTestsVixen.Platform.Ui.Tests
  • RootFontSizeTestsVixen.Ui.Tests
  • SurfaceIndexTestsVixen.Ui.Tests
  • SurfaceTestsVixen.Ui.Tests
  • TextWindowRoutingTestsVixen.Platform.Ui.Tests
  • UiApplicationVixen.Ui.Desktop
  • UiDocumentVixen.Ui
  • UiElementVixen.Ui
  • UiWindowSurfaceVixen.Ui.Desktop
  • UtilityConsumptionProbeVixen.Ui.Styling.Utilities.Tests
  • WindowVixen.Ui.Controls.Advanced.Tests
  • WindowVixen.Ui.Tests
  • WindowFocusRoutingTestsVixen.Platform.Ui.Tests
  • WindowsVixen.Ui.Controls.Advanced.Tests
  • EditorHostVixen.Editor.Host
  • FakeWindowVixen.Editor.App.Tests