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.
Constructors1
Showing 1 constructors
public CanvasPanel()
No results match this filter.
Methods15
Showing 15 methods
protected void BeginBoxSelection(bool additive)
Start a box gesture after a custom canvas has checked its own hit targets.
| Parameter | Type | Description |
|---|---|---|
| additive | bool | — |
void—protected void FinishBoxSelection(bool cancelled = False)
Complete or cancel the active selection gesture.
| Parameter | Type | Description |
|---|---|---|
| cancelled = False | bool | — |
void—public void FitBounds(Sandbox.Rect bounds, Vector2 padding = null, Vector2 minimumPadding = null)
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.
| Parameter | Type | Description |
|---|---|---|
| bounds | Rect | — |
| padding = null | Vector2 | — |
| minimumPadding = null | Vector2 | — |
void—protected virtual void OnBlur(Sandbox.UI.PanelEvent e)
| Parameter | Type | Description |
|---|---|---|
| e | PanelEvent | — |
void—public virtual void OnButtonTyped(Sandbox.UI.ButtonEvent e)
| Parameter | Type | Description |
|---|---|---|
| e | ButtonEvent | — |
void—protected virtual void OnMouseDown(Sandbox.UI.MousePanelEvent e)
| Parameter | Type | Description |
|---|---|---|
| e | MousePanelEvent | — |
void—protected virtual void OnMouseMove(Sandbox.UI.MousePanelEvent e)
| Parameter | Type | Description |
|---|---|---|
| e | MousePanelEvent | — |
void—protected virtual void OnMouseUp(Sandbox.UI.MousePanelEvent e)
| Parameter | Type | Description |
|---|---|---|
| e | MousePanelEvent | — |
void—public void SetView(Vector2 min, Vector2 max)
Set finite, increasing bounds to fit in the viewport without modifying the content.
| Parameter | Type | Description |
|---|---|---|
| min | Vector2 | — |
| max | Vector2 | — |
void—public virtual void Tick()
void—No results match this filter.
Properties16
Showing 16 properties
public bool Sandbox.UI.CanvasPanel.BoxSelectionEnabled { get; set; }
Allow left-dragging empty canvas space to draw a selection rectangle. Off by default.
bool—protected virtual bool Sandbox.UI.CanvasPanel.CanNavigate { get; set; }
bool—public bool Sandbox.UI.CanvasPanel.ConstrainHorizontalNavigation { get; set; }
Apply the horizontal limits of NavigationBounds. Enabled by default.
bool—public bool Sandbox.UI.CanvasPanel.ConstrainVerticalNavigation { get; set; }
Apply the vertical limits of NavigationBounds. Disable to pan and zoom freely above and below them.
bool—public Sandbox.UI.Panel Sandbox.UI.CanvasPanel.Content { get; set; }
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.
public bool Sandbox.UI.CanvasPanel.IsBoxSelecting { get; set; }
bool—public bool Sandbox.UI.CanvasPanel.IsPanning { get; set; }
bool—public float Sandbox.UI.CanvasPanel.MaximumViewSpan { get; set; }
float—public float Sandbox.UI.CanvasPanel.MinimumViewSpan { get; set; }
float—public System.Nullable`1<Sandbox.Rect> Sandbox.UI.CanvasPanel.NavigationBounds { get; set; }
Optional limits in canvas coordinates. Enabled axes stay inside this rectangle when panning, zooming or resizing.
public bool Sandbox.UI.CanvasPanel.PreserveAspectRatio { get; set; }
Fit the requested view uniformly, revealing extra space around its centre. Disable for independent graph axes.
bool—public System.Nullable`1<Sandbox.Rect> Sandbox.UI.CanvasPanel.SelectionBox { get; set; }
The current selection rectangle in canvas coordinates, or null when not selecting.
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 bool Sandbox.UI.CanvasPanel.YAxisUp { get; set; }
bool—No results match this filter.