reckfellENGINE

StyleBox

Style resource separating content padding from drawing.

On this page
class StyleBoxReckfellSharpInherits Resource

StyleBox is a resource rather than a Control or container. Assign it to an appropriate theme slot, such as panel on PanelContainer or normal on Button. Multiple elements can share one resource; editing that StyleBox affects all consumers. Duplicate for individual styling.

ContentMarginLeft/Top/Right/Bottom default to -1. Negative values mean derived-style automatic margins rather than negative padding. GetContentMargin returns stored input; GetMargin returns resolved padding. For example, StyleBoxTexture raw -1 can resolve to 4 from TextureMargin. Explicit 0 disables automatic padding on that side.

GetMinimumSize sums resolved opposite margins and takes a componentwise maximum with a custom script’s _GetMinimumSize. GetOffset returns resolved left/top margins only. Style minimum is not necessarily full Control minimum: text, icons and explicit constraints contribute separately.

Drawing and padding differ. Texture ExpandMargin enlarges drawing without reserving room; StyleBoxEmpty can add padding without drawing. Keep button-state margins consistent to avoid unexpected size changes on hover/press. A margin setter can emit Changed even for repeated identical values.

Implement _Draw with its supplied RID and rectangle for a custom StyleBox. Styles are normally invoked through CanvasItem.DrawStyleBox during an element’s _Draw. GetCurrentItemDrawn returns the current CanvasItem in draw context and can be null outside it. This is a shared reference rather than an object to free. _GetDrawRect describes drawing bounds and _TestMask separately tests points; do not call callbacks instead of ordinary getters on existing styles.

TestMask without a custom callback returns true even outside rect. It does not itself enforce Control bounds or exclude transparent texture pixels from input. Configure a TextureButton Bitmap mask separately for shaped hits.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

StyleBoxConstructor
# StyleBox
C#
public StyleBox();

Creates a base resource with ContentMargin = -1 on every side. Does not supply visuals itself: use a concrete style or implement _Draw.

Properties4

ContentMarginBottomProperty
# ContentMarginBottom
C#
public float ContentMarginBottom { get; set; }

Stored Bottom content margin: default -1 uses derived automatic padding. 0 is explicit zero. GetMargin returns the resolved value.

ContentMarginLeftProperty
# ContentMarginLeft
C#
public float ContentMarginLeft { get; set; }

Stored Left content margin: default -1 uses derived automatic padding. 0 is explicit zero. GetMargin returns the resolved value.

ContentMarginRightProperty
# ContentMarginRight
C#
public float ContentMarginRight { get; set; }

Stored Right content margin: default -1 uses derived automatic padding. 0 is explicit zero. GetMargin returns the resolved value.

ContentMarginTopProperty
# ContentMarginTop
C#
public float ContentMarginTop { get; set; }

Stored Top content margin: default -1 uses derived automatic padding. 0 is explicit zero. GetMargin returns the resolved value.

Methods13

Drawvoid
# Draw
C#
public void Draw(Rid canvasItem, Rect2 rect);

Draws into the supplied canvas-item RID and Rect2. Normally use CanvasItem.DrawStyleBox from the element’s _Draw. RID must belong to a live drawing item. Does not lay out child Controls.

Parameters
NameTypeDefault
canvasItemRid—
rectRect2—
canvasItem

Live canvas-item RID receiving draw commands.

rect

Style rectangle in drawing-target coordinates.

GetContentMarginfloat
# GetContentMargin
C#
public float GetContentMargin(Side margin);

Returns stored margin, including negative automatic values. Use GetMargin for resolved padding.

Parameters
NameTypeDefault
marginSide—
margin

Side.Left, Top, Right or Bottom.

Returns float

Stored margin, including negative auto value.

GetCurrentItemDrawnCanvasItem
# GetCurrentItemDrawn
C#
public CanvasItem GetCurrentItemDrawn();

Returns the current drawing-context CanvasItem, or null outside drawing. Do not free the shared object. It is not a StyleBox resource owner.

Returns CanvasItem

Shared current CanvasItem, or null.

GetMarginfloat
# GetMargin
C#
public float GetMargin(Side margin);

Returns resolved padding: negative ContentMargin uses derived-style margins. Explicit 0 remains zero.

Parameters
NameTypeDefault
marginSide—
margin

Side.Left, Top, Right or Bottom.

Returns float

Resolved selected-side padding in pixels.

GetMinimumSizeVector2
# GetMinimumSize
C#
public Vector2 GetMinimumSize();

Returns opposite resolved-margin sums with a componentwise maximum against custom _GetMinimumSize. Style minimum rather than full Control minimum.

Returns Vector2

Style minimum Vector2 from margins/custom callback.

GetOffsetVector2
# GetOffset
C#
public Vector2 GetOffset();

Returns resolved left/top padding. Does not include decorative ExpandMargin and is not a global position.

Returns Vector2

Resolved (Left, Top) padding.

SetContentMarginvoid
# SetContentMargin
C#
public void SetContentMargin(Side margin, float offset);

Stores side padding and emits Changed even for the same value. Negative means derived automatic margin; nonnegative means explicit padding.

Parameters
NameTypeDefault
marginSide—
offsetfloat—
margin

Side.Left, Top, Right or Bottom.

offset

Stores side padding and emits Changed even for the same value. Negative means derived automatic margin; nonnegative means explicit padding.

SetContentMarginAllvoid
# SetContentMarginAll
C#
public void SetContentMarginAll(float offset);

Sets one value on all four sides, emitting Changed once. Negative selects automatic margins; 0 supplies explicit zeroes.

Parameters
NameTypeDefault
offsetfloat—
offset

Sets one value on all four sides, emitting Changed once. Negative selects automatic margins; 0 supplies explicit zeroes.

TestMaskbool
# TestMask
C#
public bool TestMask(Vector2 point, Rect2 rect);

Calls custom _TestMask, otherwise returns true even outside rect. Does not automatically enforce rectangle containment or test texture alpha.

Parameters
NameTypeDefault
pointVector2—
rectRect2—
point

Test point in the same coordinate space as rect.

rect

Style rectangle in drawing-target coordinates.

Returns bool

Callback result, or true without it; not automatic rect containment.

_Drawvoid
# _Draw
C#
public virtual void _Draw(Rid toCanvasItem, Rect2 rect);

Custom StyleBox drawing callback for supplied RID/Rect2. Implement visuals in a subclass; not an ordinary getter or signal.

Parameters
NameTypeDefault
toCanvasItemRid—
rectRect2—
toCanvasItem

Live canvas-item RID receiving draw commands.

rect

Style rectangle in drawing-target coordinates.

_GetDrawRectRect2
# _GetDrawRect
C#
public virtual Rect2 _GetDrawRect(Rect2 rect);

Custom-style drawing-bounds callback, for example decorative overflow beyond rect. Does not replace _Draw or change content padding. Not a getter for a native concrete style.

Parameters
NameTypeDefault
rectRect2—
rect

Style rectangle in drawing-target coordinates.

Returns Rect2

Drawing area supplied by the custom style.

_GetMinimumSizeVector2
# _GetMinimumSize
C#
public virtual Vector2 _GetMinimumSize();

Custom-style extra minimum lower-bound callback. Result combines componentwise with padding sums rather than replacing them with smaller values.

Returns Vector2

Additional minimum-size lower bound.

_TestMaskbool
# _TestMask
C#
public virtual bool _TestMask(Vector2 point, Rect2 rect);

Custom point-test callback against supplied rect. Implement containment explicitly; base StyleBox without a callback accepts any point.

Parameters
NameTypeDefault
pointVector2—
rectRect2—
point

Test point in the same coordinate space as rect.

rect

Style rectangle in drawing-target coordinates.

Returns bool

Custom point-test result.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.