Table of Contents

Class StyleBoxFlat

Namespace
Godot
Assembly
GodotSharp.dll

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:

height = 30
  corner_radius_top_left = 50
  corner_radius_bottom_left = 100

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:

corner_radius_top_left: 10
  corner_radius_bottom_left: 20
public class StyleBoxFlat : StyleBox, IDisposable
Inheritance
StyleBoxFlat
Implements
Inherited Members

Constructors

StyleBoxFlat()

public StyleBoxFlat()

Properties

AntiAliasing

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.

Note: When using beveled corners with 45-degree angles (CornerDetail = 1), it is recommended to set AntiAliasing to false to ensure crisp visuals and avoid possible visual glitches.

public bool AntiAliasing { get; set; }

Property Value

bool

AntiAliasingSize

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.

Note: Higher values may produce a blur effect but can also create undesired artifacts on small boxes with large-radius corners.

public float AntiAliasingSize { get; set; }

Property Value

float

BgColor

The background color of the stylebox.

public Color BgColor { get; set; }

Property Value

Color

BorderBlend

If true, the border will fade into the background color.

public bool BorderBlend { get; set; }

Property Value

bool

BorderColor

Sets the color of the border.

public Color BorderColor { get; set; }

Property Value

Color

BorderWidthBottom

Border width for the bottom border.

public int BorderWidthBottom { get; set; }

Property Value

int

BorderWidthLeft

Border width for the left border.

public int BorderWidthLeft { get; set; }

Property Value

int

BorderWidthRight

Border width for the right border.

public int BorderWidthRight { get; set; }

Property Value

int

BorderWidthTop

Border width for the top border.

public int BorderWidthTop { get; set; }

Property Value

int

CornerDetail

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(int)) into account.

For corner radii less than 10, 4 or 5 should be enough. For corner radii less than 30, values between 8 and 12 should be enough.

A corner detail of 1 will result in chamfered corners instead of rounded corners, which is useful for some artistic effects.

public int CornerDetail { get; set; }

Property Value

int

CornerRadiusBottomLeft

The bottom-left corner's radius. If 0, the corner is not rounded.

public int CornerRadiusBottomLeft { get; set; }

Property Value

int

CornerRadiusBottomRight

The bottom-right corner's radius. If 0, the corner is not rounded.

public int CornerRadiusBottomRight { get; set; }

Property Value

int

CornerRadiusTopLeft

The top-left corner's radius. If 0, the corner is not rounded.

public int CornerRadiusTopLeft { get; set; }

Property Value

int

CornerRadiusTopRight

The top-right corner's radius. If 0, the corner is not rounded.

public int CornerRadiusTopRight { get; set; }

Property Value

int

DrawCenter

Toggles drawing of the inner part of the stylebox.

public bool DrawCenter { get; set; }

Property Value

bool

ExpandMarginBottom

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.

Note: Unlike ContentMarginBottom, ExpandMarginBottom does not affect the size of the clickable area for Controls. This can negatively impact usability if used wrong, as the user may try to click an area of the StyleBox that cannot actually receive clicks.

public float ExpandMarginBottom { get; set; }

Property Value

float

ExpandMarginLeft

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.

Note: Unlike ContentMarginLeft, ExpandMarginLeft does not affect the size of the clickable area for Controls. This can negatively impact usability if used wrong, as the user may try to click an area of the StyleBox that cannot actually receive clicks.

public float ExpandMarginLeft { get; set; }

Property Value

float

ExpandMarginRight

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.

Note: Unlike ContentMarginRight, ExpandMarginRight does not affect the size of the clickable area for Controls. This can negatively impact usability if used wrong, as the user may try to click an area of the StyleBox that cannot actually receive clicks.

public float ExpandMarginRight { get; set; }

Property Value

float

ExpandMarginTop

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.

Note: Unlike ContentMarginTop, ExpandMarginTop does not affect the size of the clickable area for Controls. This can negatively impact usability if used wrong, as the user may try to click an area of the StyleBox that cannot actually receive clicks.

public float ExpandMarginTop { get; set; }

Property Value

float

ShadowColor

The color of the shadow. This has no effect if ShadowSize is lower than 1.

public Color ShadowColor { get; set; }

Property Value

Color

ShadowOffset

The shadow offset in pixels. Adjusts the position of the shadow relatively to the stylebox.

public Vector2 ShadowOffset { get; set; }

Property Value

Vector2

ShadowSize

The shadow size in pixels.

public int ShadowSize { get; set; }

Property Value

int

Skew

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).

Note: To ensure text does not touch the StyleBox's edges, consider increasing the StyleBox's content margin (see ContentMarginBottom). It is preferable to increase the content margin instead of the expand margin (see ExpandMarginBottom), as increasing the expand margin does not increase the size of the clickable area for Controls.

public Vector2 Skew { get; set; }

Property Value

Vector2

Methods

GetBorderWidthMin()

Returns the smallest border width out of all four borders.

public int GetBorderWidthMin()

Returns

int

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

SetBorderWidthAll(int)

Sets the border width to width pixels for all sides.

public void SetBorderWidthAll(int width)

Parameters

width int

SetCornerRadiusAll(int)

Sets the corner radius to radius pixels for all corners.

public void SetCornerRadiusAll(int radius)

Parameters

radius int

SetExpandMarginAll(float)

Sets the expand margin to size pixels for all sides.

public void SetExpandMarginAll(float size)

Parameters

size float