StyleBoxFlat
A customizable StyleBox
that doesn’t use a texture.
class StyleBoxFlat
By configuring various properties of this style box, you can achieve many common looks without the need of a texture. This includes optionally rounded borders, antialiasing, shadows, and skew.
Setting corner radius to high values is allowed. As soon as corners overlap, the stylebox will switch to a relative system.
Example:
The relative system now would take the 1:2 ratio of the two left corners to calculate the actual corner width. Both corners added will never be more than the height. Result:
Superclasses
class StyleBox
Abstract base class for defining stylized boxes for UI elements.
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 antiAliasing: Bool
Antialiasing draws a small ring around the edges, which fades to transparency. As a result, edges look much smoother. This is only noticeable when using rounded corners or
skew
.var antiAliasingSize: Double
This changes the size of the antialiasing effect.
1.0
is recommended for an optimal result at 100% scale, identical to how rounded rectangles are rendered in web browsers and most vector drawing software.var bgColor: Color
The background color of the stylebox.
var borderBlend: Bool
If
true
, the border will fade into the background color.var borderColor: Color
Sets the color of the border.
var borderWidthBottom: Int32
Border width for the bottom border.
var borderWidthLeft: Int32
Border width for the left border.
var borderWidthRight: Int32
Border width for the right border.
var borderWidthTop: Int32
Border width for the top border.
var cornerDetail: Int32
This sets the number of vertices used for each corner. Higher values result in rounder corners but take more processing power to compute. When choosing a value, you should take the corner radius (
setCornerRadiusAll(radius:)
) into account.var cornerRadiusBottomLeft: Int32
The bottom-left corner’s radius. If
0
, the corner is not rounded.var cornerRadiusBottomRight: Int32
The bottom-right corner’s radius. If
0
, the corner is not rounded.var cornerRadiusTopLeft: Int32
The top-left corner’s radius. If
0
, the corner is not rounded.var cornerRadiusTopRight: Int32
The top-right corner’s radius. If
0
, the corner is not rounded.var drawCenter: Bool
Toggles drawing of the inner part of the stylebox.
var expandMarginBottom: Double
Expands the stylebox outside of the control rect on the bottom edge. Useful in combination with
borderWidthBottom
to draw a border outside the control rect.var expandMarginLeft: Double
Expands the stylebox outside of the control rect on the left edge. Useful in combination with
borderWidthLeft
to draw a border outside the control rect.var expandMarginRight: Double
Expands the stylebox outside of the control rect on the right edge. Useful in combination with
borderWidthRight
to draw a border outside the control rect.var expandMarginTop: Double
Expands the stylebox outside of the control rect on the top edge. Useful in combination with
borderWidthTop
to draw a border outside the control rect.var shadowColor: Color
The color of the shadow. This has no effect if
shadowSize
is lower than 1.var shadowOffset: Vector2
The shadow offset in pixels. Adjusts the position of the shadow relatively to the stylebox.
var shadowSize: Int32
The shadow size in pixels.
var skew: Vector2
If set to a non-zero value on either axis,
skew
distorts the StyleBox horizontally and/or vertically. This can be used for “futuristic”-style UIs. Positive values skew the StyleBox towards the right (X axis) and upwards (Y axis), while negative values skew the StyleBox towards the left (X axis) and downwards (Y axis).func getBorderWidthMin(
) -> Int32 Returns the smallest border width out of all four borders.
func setBorderWidthAll(width: Int32
) Sets the border width to
width
pixels for all sides.func setCornerRadiusAll(radius: Int32
) Sets the corner radius to
radius
pixels for all corners.func setExpandMarginAll(size: Double
) Sets the expand margin to
size
pixels for all sides.