StyleBox
Abstract base class for defining stylized boxes for UI elements.
StyleBox.swift:14class StyleBox
StyleBox
is an abstract base class for drawing stylized boxes for UI elements. It is used for panels, buttons, LineEdit
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.
Superclasses
class Resource
Base class for serializable objects.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Type members
Instance members
var contentMarginBottom: Double
The bottom margin for the contents of this style box. Increasing this value reduces the space available to the contents from the bottom.
var contentMarginLeft: Double
The left margin for the contents of this style box. Increasing this value reduces the space available to the contents from the left.
var contentMarginRight: Double
The right margin for the contents of this style box. Increasing this value reduces the space available to the contents from the right.
var contentMarginTop: Double
The top margin for the contents of this style box. Increasing this value reduces the space available to the contents from the top.
func draw(canvasItem: RID, rect: Rect2
) Draws this stylebox using a canvas item identified by the given
RID
.func getCurrentItemDrawn(
) -> CanvasItem? Returns the
CanvasItem
that handles itsCanvasItem
notificationDraw```` or_draw
callback at this moment.func getMargin(Side
) -> Double Returns the content margin offset for the specified
Side
.func getMinimumSize(
) -> Vector2 Returns the minimum size that this stylebox can be shrunk to.
func 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))
.func setContentMarginAll(offset: Double
) Sets the default margin to
offset
pixels for all sides.func testMask(point: Vector2, rect: Rect2
) -> Bool Test a position in a rectangle, return whether it passes the mask test.
Show implementation details (4)
Hide implementation details
func _draw(toCanvasItem: RID, rect: Rect2
) func _getDrawRect(Rect2
) -> Rect2 func _getMinimumSize(
) -> Vector2 Virtual method to be implemented by the user. Returns a custom minimum size that the stylebox must respect when drawing. By default
getMinimumSize
only takes content margins into account. This method can be overridden to add another size restriction. A combination of the default behavior and the output of this method will be used, to account for both sizes.func _testMask(point: Vector2, rect: Rect2
) -> Bool
Subclasses
class StyleBoxEmpty
An empty
StyleBox
(does not display anything).class StyleBoxFlat
A customizable
StyleBox
that doesn’t use a texture.class StyleBoxLine
A
StyleBox
that displays a single line of a given color and thickness.class StyleBoxTexture
A texture-based nine-patch
StyleBox
.