Skip to content

StyleBox

Eduard Gushchin edited this page Jun 24, 2026 · 3 revisions

Home | API by Category | Complete API Index | API Compatibility

Field Value
Full name Electron2D.StyleBox
Namespace Electron2D
Kind class
Category UI and Text

Overview

Provides the base resource for drawing themed UI boxes.

Syntax

public class Electron2D.StyleBox : Electron2D.Resource

Godot 4.7 C# profile compatibility

Profile: Electron2D 0.1.0 2D
Status: Supported / Parity verified
Out of profile: no
Godot reference: StyleBox

Base UI style-box resource with minimum-size margins and draw hooks for themed controls.

Remarks

StyleBox stores content margins and exposes a drawing hook used by controls that resolve style box theme items.

The base implementation does not submit draw commands. Use Electron2D.StyleBoxFlat when a rectangular background and borders are needed.

Thread Safety

This type is not synchronized. Create and mutate style boxes on the main scene thread.

Since

This type is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.StyleBoxFlat
  • Electron2D.Theme

Members

Member Kind Summary
ContentMarginBottom Property Gets or sets the bottom content margin.
ContentMarginLeft Property Gets or sets the left content margin.
ContentMarginRight Property Gets or sets the right content margin.
ContentMarginTop Property Gets or sets the top content margin.
Electron2D.StyleBox() Constructor Initializes a new instance of the Electron2D.StyleBox class.
Draw(Electron2D.CanvasItem, Electron2D.Rect2) Method Draws this style box into a canvas item.
GetMinimumSize() Method Gets the minimum size contributed by content margins.

Member Details

ContentMarginBottom

Kind: Property

public System.Single ContentMarginBottom { get; set; }

Summary

Gets or sets the bottom content margin.

Remarks

Controls can use this margin when computing a minimum content area.

Value

The bottom margin in UI units. The value must be finite and non-negative.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the assigned value is negative or not finite.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.StyleBox.GetMinimumSize

ContentMarginLeft

Kind: Property

public System.Single ContentMarginLeft { get; set; }

Summary

Gets or sets the left content margin.

Remarks

Controls can use this margin when computing a minimum content area.

Value

The left margin in UI units. The value must be finite and non-negative.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the assigned value is negative or not finite.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.StyleBox.GetMinimumSize

ContentMarginRight

Kind: Property

public System.Single ContentMarginRight { get; set; }

Summary

Gets or sets the right content margin.

Remarks

Controls can use this margin when computing a minimum content area.

Value

The right margin in UI units. The value must be finite and non-negative.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the assigned value is negative or not finite.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.StyleBox.GetMinimumSize

ContentMarginTop

Kind: Property

public System.Single ContentMarginTop { get; set; }

Summary

Gets or sets the top content margin.

Remarks

Controls can use this margin when computing a minimum content area.

Value

The top margin in UI units. The value must be finite and non-negative.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the assigned value is negative or not finite.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.StyleBox.GetMinimumSize

Electron2D.StyleBox()

Kind: Constructor

public Electron2D.StyleBox()

Summary

Initializes a new instance of the Electron2D.StyleBox class.

Remarks

The new style box starts with zero content margins and no drawing output.

Thread Safety

This constructor is not synchronized. Call it from the main scene thread.

Since

This constructor is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.StyleBox

Draw(Electron2D.CanvasItem, Electron2D.Rect2)

Kind: Method

public System.Void Draw(Electron2D.CanvasItem, Electron2D.Rect2)(Electron2D.CanvasItem canvasItem, Electron2D.Rect2 rect)

Summary

Draws this style box into a canvas item.

Remarks

The base implementation validates the input and submits no commands. Derived style boxes override this method to draw their visuals.

Parameters

  • canvasItem: The canvas item that receives draw commands.
  • rect: The local rectangle to draw into.

Exceptions

  • System.ArgumentNullException: Thrown when canvasItem is null.
  • System.ArgumentOutOfRangeException: Thrown when rect contains non-finite components.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CanvasItem.DrawRect(Electron2D.Rect2,Electron2D.Color,System.Boolean,System.Single,System.Boolean)

GetMinimumSize()

Kind: Method

public Electron2D.Vector2 GetMinimumSize()()

Summary

Gets the minimum size contributed by content margins.

Remarks

The base style box has no intrinsic graphic size beyond its margins.

Returns

The sum of horizontal and vertical content margins.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.StyleBox.ContentMarginLeft
  • Electron2D.StyleBox.ContentMarginRight

Clone this wiki locally