# Sandbox.UI.CanvasPanel

A navigable drawing surface. Owns the view transform, cursor-anchored zoom and middle-button
panning. Add ordinary panels to Content, or draw directly with Painter. Coordinates returned
by CanvasToScreen are local screen pixels, matching Painter and MousePosition.

- Kind: class
- Namespace: `Sandbox.UI`
- Assembly: `Sandbox.Engine`
- Inherits: [Sandbox.UI.Panel](/api/Sandbox.UI.Panel)

## Constructors

- [`CanvasPanel`](/api/Sandbox.UI.CanvasPanel/.ctor)

## Properties

- [`BoxSelectionEnabled`](/api/Sandbox.UI.CanvasPanel/BoxSelectionEnabled): Allow left-dragging empty canvas space to draw a selection rectangle. Off by default.
- [`ConstrainHorizontalNavigation`](/api/Sandbox.UI.CanvasPanel/ConstrainHorizontalNavigation): Apply the horizontal limits of NavigationBounds. Enabled by default.
- [`ConstrainVerticalNavigation`](/api/Sandbox.UI.CanvasPanel/ConstrainVerticalNavigation): Apply the vertical limits of NavigationBounds. Disable to pan and zoom freely above and below them.
- [`Content`](/api/Sandbox.UI.CanvasPanel/Content): Ordinary panels placed in canvas coordinates. Their CSS transforms, layout, focus and input work normally. The content has a stable 1000 x 1000 layout size (set its Style to change it), with visible overflow so panels can also be placed at negative or larger coordinates. Pan/zoom transform the whole subtree without changing its layout. Created only when used.
- [`IsBoxSelecting`](/api/Sandbox.UI.CanvasPanel/IsBoxSelecting)
- [`IsPanning`](/api/Sandbox.UI.CanvasPanel/IsPanning)
- [`MaximumViewSpan`](/api/Sandbox.UI.CanvasPanel/MaximumViewSpan)
- [`MinimumViewSpan`](/api/Sandbox.UI.CanvasPanel/MinimumViewSpan)
- [`NavigationBounds`](/api/Sandbox.UI.CanvasPanel/NavigationBounds): Optional limits in canvas coordinates. Enabled axes stay inside this rectangle when panning, zooming or resizing.
- [`PreserveAspectRatio`](/api/Sandbox.UI.CanvasPanel/PreserveAspectRatio): Fit the requested view uniformly, revealing extra space around its centre. Disable for independent graph axes.
- [`SelectionBox`](/api/Sandbox.UI.CanvasPanel/SelectionBox): The current selection rectangle in canvas coordinates, or null when not selecting.
- [`ViewMax`](/api/Sandbox.UI.CanvasPanel/ViewMax)
- [`ViewMin`](/api/Sandbox.UI.CanvasPanel/ViewMin)
- [`YAxisUp`](/api/Sandbox.UI.CanvasPanel/YAxisUp)

## Methods

- [`CanvasToScreen`](/api/Sandbox.UI.CanvasPanel/CanvasToScreen)
- [`FitBounds`](/api/Sandbox.UI.CanvasPanel/FitBounds): Frame bounds in canvas coordinates with padding on each side, expressed as a fraction of their size. Minimum padding is in canvas units. Navigation limits take precedence.
- [`OnButtonTyped`](/api/Sandbox.UI.CanvasPanel/OnButtonTyped)
- [`OnMouseWheel`](/api/Sandbox.UI.CanvasPanel/OnMouseWheel)
- [`Pan`](/api/Sandbox.UI.CanvasPanel/Pan)
- [`ScreenToCanvas`](/api/Sandbox.UI.CanvasPanel/ScreenToCanvas)
- [`SetView`](/api/Sandbox.UI.CanvasPanel/SetView): Set finite, increasing bounds to fit in the viewport without modifying the content.
- [`Tick`](/api/Sandbox.UI.CanvasPanel/Tick)
- [`ZoomAt`](/api/Sandbox.UI.CanvasPanel/ZoomAt): Scale the visible span while keeping the screen anchor fixed.
