class StyleBox
package godot
extends Resource › Reference › Object
extended by StyleBoxEmpty, StyleBoxFlat, StyleBoxLine, StyleBoxTexture
StyleBox is godot.Resource
that provides an abstract base class for drawing stylized boxes for the UI. StyleBoxes are used for drawing the styles of buttons, line edit backgrounds, tree backgrounds, etc. and also for testing a transparency mask for pointer signals. If mask test fails on a StyleBox assigned as mask to a control, clicks and motion signals will go through it to the one below.
Note: For children of godot.Control
that have Theme Properties, the focus
godot.StyleBox
is displayed over the normal
, hover
or pressed
godot.StyleBox
. This makes the focus
godot.StyleBox
more reusable across different nodes.
Variables
contentMarginBottom:Single
The bottom margin for the contents of this style box. Increasing this value reduces the space available to the contents from the bottom.
If this value is negative, it is ignored and a child-specific margin is used instead. For example for godot.StyleBoxFlat
the border thickness (if any) is used instead.
It is up to the code using this style box to decide what these contents are: for example, a godot.Button
respects this content margin for the textual contents of the button.
godot.StyleBox.getMargin
should be used to fetch this value as consumer instead of reading these properties directly. This is because it correctly respects negative values and the fallback mentioned above.
contentMarginLeft:Single
The left margin for the contents of this style box.Increasing this value reduces the space available to the contents from the left.
Refer to godot.StyleBox.contentMarginBottom
for extra considerations.
contentMarginRight:Single
The right margin for the contents of this style box. Increasing this value reduces the space available to the contents from the right.
Refer to godot.StyleBox.contentMarginBottom
for extra considerations.
contentMarginTop:Single
The top margin for the contents of this style box. Increasing this value reduces the space available to the contents from the top.
Refer to godot.StyleBox.contentMarginBottom
for extra considerations.
Methods
draw(canvasItem:RID, rect:Rect2):Void
Draws this stylebox using a godot.CanvasItem
with given godot.RID
.
You can get a godot.RID
value using godot.Object.getInstanceId
on a godot.CanvasItem
-derived node.
getCurrentItemDrawn():CanvasItem
Returns the godot.CanvasItem
that handles its godot.CanvasItem.notificationDraw
or godot.CanvasItem._Draw
callback at this moment.
getMargin(margin:Margin):Single
Returns the content margin offset for the specified godot.Margin
.
Positive values reduce size inwards, unlike godot.Control
's margin values.
getOffset():Vector2
Returns the "offset" of a stylebox. This helper function returns a value equivalent to Vector2(style.get_margin(MARGIN_LEFT), style.get_margin(MARGIN_TOP))
.
setDefaultMargin(margin:Margin, offset:Single):Void
Sets the default value of the specified godot.Margin
to given offset
in pixels.