API ReferenceSandbox.UI

CanvasPanelclass

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.

object→Panel→CanvasPanel
Namespace
Sandbox.UI
Assembly
Sandbox.Engine
Declaration
public class Sandbox.UI.CanvasPanel : Sandbox.UI.Panel

Constructors1

Showing 1 constructors

Methods15

Showing 15 methods

protected void BeginBoxSelection(bool additive)PROTECTED

Start a box gesture after a custom canvas has checked its own hit targets.

ParameterTypeDescription
additivebool—
Returns:void—

protected void FinishBoxSelection(bool cancelled = False)PROTECTED

Complete or cancel the active selection gesture.

ParameterTypeDescription
cancelled = Falsebool—
Returns:void—

public void FitBounds(Sandbox.Rect bounds, Vector2 padding = null, Vector2 minimumPadding = null)PUBLIC

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.

ParameterTypeDescription
boundsRect—
padding = nullVector2—
minimumPadding = nullVector2—
Returns:void—

protected virtual void OnBlur(Sandbox.UI.PanelEvent e)PROTECTEDVIRTUAL

ParameterTypeDescription
ePanelEvent—
Returns:void—

public virtual void OnButtonTyped(Sandbox.UI.ButtonEvent e)PUBLICVIRTUAL

ParameterTypeDescription
eButtonEvent—
Returns:void—

public virtual void OnMouseWheel(Vector2 value)PUBLICVIRTUAL

ParameterTypeDescription
valueVector2—
Returns:void—

public void Pan(Vector2 screenDelta)PUBLIC

ParameterTypeDescription
screenDeltaVector2—
Returns:void—

public void SetView(Vector2 min, Vector2 max)PUBLIC

Set finite, increasing bounds to fit in the viewport without modifying the content.

ParameterTypeDescription
minVector2—
maxVector2—
Returns:void—

public virtual void Tick()PUBLICVIRTUAL

Returns:void—

public void ZoomAt(Vector2 screenAnchor, float factor)PUBLIC

Scale the visible span while keeping the screen anchor fixed.

ParameterTypeDescription
screenAnchorVector2—
factorfloat—
Returns:void—

Properties16

Showing 16 properties

public bool Sandbox.UI.CanvasPanel.BoxSelectionEnabled { get; set; }PUBLICGETSET

Allow left-dragging empty canvas space to draw a selection rectangle. Off by default.

Returns:bool—

protected virtual bool Sandbox.UI.CanvasPanel.CanNavigate { get; set; }PROTECTEDVIRTUALGETSET

Returns:bool—

public bool Sandbox.UI.CanvasPanel.ConstrainHorizontalNavigation { get; set; }PUBLICGETSET

Apply the horizontal limits of NavigationBounds. Enabled by default.

Returns:bool—

public bool Sandbox.UI.CanvasPanel.ConstrainVerticalNavigation { get; set; }PUBLICGETSET

Apply the vertical limits of NavigationBounds. Disable to pan and zoom freely above and below them.

Returns:bool—

public Sandbox.UI.Panel Sandbox.UI.CanvasPanel.Content { get; set; }PUBLICGETSET

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.

Returns:Panel—

public bool Sandbox.UI.CanvasPanel.IsBoxSelecting { get; set; }PUBLICGETSET

Returns:bool—

public bool Sandbox.UI.CanvasPanel.IsPanning { get; set; }PUBLICGETSET

Returns:bool—

public float Sandbox.UI.CanvasPanel.MaximumViewSpan { get; set; }PUBLICGETSET

Returns:float—

public float Sandbox.UI.CanvasPanel.MinimumViewSpan { get; set; }PUBLICGETSET

Returns:float—

public bool Sandbox.UI.CanvasPanel.PreserveAspectRatio { get; set; }PUBLICGETSET

Fit the requested view uniformly, revealing extra space around its centre. Disable for independent graph axes.

Returns:bool—

public System.Nullable`1<Sandbox.Rect> Sandbox.UI.CanvasPanel.SelectionBox { get; set; }PUBLICGETSET

The current selection rectangle in canvas coordinates, or null when not selecting.

Returns:Nullable<Rect>—

protected virtual Sandbox.Rect Sandbox.UI.CanvasPanel.Viewport { get; set; }PROTECTEDVIRTUALGETSET

Returns:Rect—

public bool Sandbox.UI.CanvasPanel.YAxisUp { get; set; }PUBLICGETSET

Returns:bool—

On this page

Constructorspublic CanvasPanel()Methodsprotected System.Void BeginBoxSelection(System.Boolean additive)public Vector2 CanvasToScreen(Vector2 point)protected System.Void FinishBoxSelection(System.Boolean cancelled = False)public System.Void FitBounds(Sandbox.Rect bounds, Vector2 padding = null, Vector2 minimumPadding = null)protected virtual System.Void OnBlur(Sandbox.UI.PanelEvent e)public virtual System.Void OnButtonTyped(Sandbox.UI.ButtonEvent e)protected virtual System.Void OnMouseDown(Sandbox.UI.MousePanelEvent e)protected virtual System.Void OnMouseMove(Sandbox.UI.MousePanelEvent e)protected virtual System.Void OnMouseUp(Sandbox.UI.MousePanelEvent e)public virtual System.Void OnMouseWheel(Vector2 value)public System.Void Pan(Vector2 screenDelta)public Vector2 ScreenToCanvas(Vector2 point)public System.Void SetView(Vector2 min, Vector2 max)public virtual System.Void Tick()public System.Void ZoomAt(Vector2 screenAnchor, System.Single factor)Propertiespublic System.Boolean Sandbox.UI.CanvasPanel.BoxSelectionEnabled { get; set; }protected virtual System.Boolean Sandbox.UI.CanvasPanel.CanNavigate { get; set; }public System.Boolean Sandbox.UI.CanvasPanel.ConstrainHorizontalNavigation { get; set; }public System.Boolean Sandbox.UI.CanvasPanel.ConstrainVerticalNavigation { get; set; }public Sandbox.UI.Panel Sandbox.UI.CanvasPanel.Content { get; set; }public System.Boolean Sandbox.UI.CanvasPanel.IsBoxSelecting { get; set; }public System.Boolean Sandbox.UI.CanvasPanel.IsPanning { get; set; }public System.Single Sandbox.UI.CanvasPanel.MaximumViewSpan { get; set; }public System.Single Sandbox.UI.CanvasPanel.MinimumViewSpan { get; set; }public System.Nullable`1<Sandbox.Rect> Sandbox.UI.CanvasPanel.NavigationBounds { get; set; }public System.Boolean Sandbox.UI.CanvasPanel.PreserveAspectRatio { get; set; }public System.Nullable`1<Sandbox.Rect> Sandbox.UI.CanvasPanel.SelectionBox { get; set; }public Vector2 Sandbox.UI.CanvasPanel.ViewMax { get; set; }public Vector2 Sandbox.UI.CanvasPanel.ViewMin { get; set; }protected virtual Sandbox.Rect Sandbox.UI.CanvasPanel.Viewport { get; set; }public System.Boolean Sandbox.UI.CanvasPanel.YAxisUp { get; set; }Metadata