Vixen
dd8b0a81
csharp
public sealed class ImageView

A 2D image at zoom: pan, zoom about the pointer, fit, channels and an overlay.

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

Remarks

Doc 48 § B6: nothing in the editor views an image at zoom. TexturePreview shows an imported texture at one size and NodePreview draws a swatch under a node; the texture graph, the layer stack and the 2D paint view all need the same pannable, zoomable, channel-isolating pane, and building it three times is how three of them end up disagreeing about which way y goes.

The pixels belong to the host, exactly as Viewport's do. Image is a number this assembly cannot interpret — the same number UiRenderer.RegisterImage was given — and ImageWidth and ImageHeight are what make it a *coordinate space* rather than a rectangle. Without the extent there is no texel to zoom about, no fit, and no image space for an overlay to be in.

⚠ Channels and ColorSpace used to be a request that changed no pixel, and that was the one thing about this control worth reading twice. The draw list's image command carried a tint and a source rectangle and nothing else: a tint can multiply, and neither isolating the alpha as a grey nor undoing a transfer function is a multiply, so the control raised ViewChanged and drew whatever Image it was then given. #611 gave the command a UiImageView and both toggles now reach the picture on their own — see Drawn for the translation, and ViewChanged for what answering it still buys.

⚠ The chequerboard is in screen pixels and bounded to the visible part of the image. Fixed-size squares are the only thing that reads as transparency at any zoom — squares that scaled with the image would be a pattern an author would take for content — and drawing it only where the image actually is means a transparent texture reads as see-through rather than as a hole, without the surrounding pane pretending to be see-through too.

Fields and properties (28)

  • protected override string TagName

    The element name this type answers to when a caller does not choose one.

  • protected override bool AcceptsFocus

    Whether the focus can rest on this kind of control at all.

  • protected override AccessibleRole NativeRole
  • public ulong Image

    The renderer's name for the texture being viewed. Zero draws nothing.

  • public int ImageWidth

    How wide the image is, in texels.

  • public int ImageHeight

    How tall it is, in texels.

  • public Vector2 Pan
  • public float Zoom
  • public float MinimumZoom
  • public float MaximumZoom
  • public ImageChannels Channels
  • public ImageColorSpace ColorSpace
  • public bool ShowCheckerboard
  • public float CheckerSize
  • public float OverlayThickness
  • public List<ImageOverlaySegment> Overlay

    The line segments drawn over the image, in image space.

  • public ImageViewRequest Requested

    What is being asked for: the pair a host prepares an image from.

  • public UiImageView Drawn

    The same request as the draw list carries it.

  • public Rectangle ImageBounds

    Where the image lands, in document space.

  • public static readonly UiPropertyKey PanProperty

    Identity for Pan.

  • public static readonly UiPropertyKey ZoomProperty

    Identity for Zoom.

  • public static readonly UiPropertyKey MinimumZoomProperty

    Identity for MinimumZoom.

  • public static readonly UiPropertyKey MaximumZoomProperty

    Identity for MaximumZoom.

  • public static readonly UiPropertyKey ChannelsProperty

    Identity for Channels.

  • public static readonly UiPropertyKey ColorSpaceProperty

    Identity for ColorSpace.

  • public static readonly UiPropertyKey ShowCheckerboardProperty

    Identity for ShowCheckerboard.

  • public static readonly UiPropertyKey CheckerSizeProperty

    Identity for CheckerSize.

  • public static readonly UiPropertyKey OverlayThicknessProperty

    Identity for OverlayThickness.

Events (1)

  • public Action<ImageView>? ViewChanged

    Raised when Channels or ColorSpace moved.

Methods (14)

  • public Vector2 ToScreen(Vector2 point)

    Where an image point is, in document space.

  • public Vector2 ToImage(float x, float y)

    Where a document-space point is, in texels.

  • public bool Fit()

    Zooms and pans so the whole image is visible and centred.

  • protected override void OnCreated()

    Builds whatever this element is made of, once, as it joins a document.

  • protected override void OnDraw(DrawContext context)

    Draws whatever this element is, beyond what a stylesheet can describe.

  • public void ClearPan()

    Unsets Pan, so it takes its default or its ancestor's value again.

  • public void ClearZoom()

    Unsets Zoom, so it takes its default or its ancestor's value again.

  • public void ClearMinimumZoom()

    Unsets MinimumZoom, so it takes its default or its ancestor's value again.

  • public void ClearMaximumZoom()

    Unsets MaximumZoom, so it takes its default or its ancestor's value again.

  • public void ClearChannels()

    Unsets Channels, so it takes its default or its ancestor's value again.

  • public void ClearColorSpace()

    Unsets ColorSpace, so it takes its default or its ancestor's value again.

  • public void ClearShowCheckerboard()

    Unsets ShowCheckerboard, so it takes its default or its ancestor's value again.

  • public void ClearCheckerSize()

    Unsets CheckerSize, so it takes its default or its ancestor's value again.

  • public void ClearOverlayThickness()

    Unsets OverlayThickness, so it takes its default or its ancestor's value again.

Used by (20)

  • AccessibilityTreeTestsVixen.Ui.Controls.Advanced.Tests
  • ImageViewBarVixen.Ui.Controls.Advanced
  • ImageViewBarTestsVixen.Ui.Controls.Advanced.Tests
  • ImageViewTestsVixen.Ui.Controls.Advanced.Tests
  • ImageViewBarWiringTestsVixen.Editor.Texturing.Tests
  • LayerStackBindingTestsVixen.Editor.Texturing.Tests
  • LayerStackChromeVixen.Editor.Texturing
  • LayerStackEditingTestsVixen.Editor.Texturing.Tests
  • LayerStackPanelDeviceTestsVixen.Editor.Texturing.Tests
  • LayerStackViewVixen.Editor.Texturing
  • PaintCanvasStoreWiringTestsVixen.Editor.Texturing.Tests
  • PaintMeshViewVixen.Editor.Texturing
  • PaintMeshViewTestsVixen.Editor.Texturing.Tests
  • PaintThemeTestsVixen.Editor.Texturing.Tests
  • PaintUvViewVixen.Editor.Texturing
  • PaintUvViewTestsVixen.Editor.Texturing.Tests
  • TextureGraphPanelTestsVixen.Editor.Texturing.Tests
  • TextureGraphViewVixen.Editor.Texturing
  • TexturePreviewDeviceTestsVixen.Editor.Texturing.Tests
  • TexturingModuleVixen.Editor.Texturing