StyleBox

Hereda: Resource < RefCounted < Object

Heredado por: StyleBoxEmpty, StyleBoxFlat, StyleBoxLine, StyleBoxTexture

Clase base abstracta para definir cuadros estilizados para elementos de la interfaz de usuario.

Descripción

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.

Note: For control nodes that have Theme Properties, the focus StyleBox is displayed over the normal, hover or pressed StyleBox. This makes the focus StyleBox more reusable across different nodes.

Propiedades

float

content_margin_bottom

-1.0

float

content_margin_left

-1.0

float

content_margin_right

-1.0

float

content_margin_top

-1.0

Métodos

void

_draw(to_canvas_item: RID, rect: Rect2) virtual required const

Rect2

_get_draw_rect(rect: Rect2) virtual const

Vector2

_get_minimum_size() virtual const

bool

_test_mask(point: Vector2, rect: Rect2) virtual const

void

draw(canvas_item: RID, rect: Rect2) const

float

get_content_margin(margin: Side) const

CanvasItem

get_current_item_drawn() const

float

get_margin(margin: Side) const

Vector2

get_minimum_size() const

Vector2

get_offset() const

void

set_content_margin(margin: Side, offset: float)

void

set_content_margin_all(offset: float)

bool

test_mask(point: Vector2, rect: Rect2) const


Descripciones de Propiedades

float content_margin_bottom = -1.0 🔗

  • void set_content_margin(margin: Side, offset: float)

  • float get_content_margin(margin: Side) const

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 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 Button respects this content margin for the textual contents of the button.

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


float content_margin_left = -1.0 🔗

  • void set_content_margin(margin: Side, offset: float)

  • float get_content_margin(margin: Side) const

El margen izquierdo para el contenido de esta caja de estilo. Aumentar este valor reduce el espacio disponible para el contenido desde la izquierda.

Véase content_margin_bottom para consideraciones adicionales.


float content_margin_right = -1.0 🔗

  • void set_content_margin(margin: Side, offset: float)

  • float get_content_margin(margin: Side) const

El margen derecho para el contenido de esta caja de estilo. Aumentando este valor se reduce el espacio disponible para los contenidos de la derecha.

Véase content_margin_bottom para consideraciones adicionales.


float content_margin_top = -1.0 🔗

  • void set_content_margin(margin: Side, offset: float)

  • float get_content_margin(margin: Side) const

El margen superior para el contenido de esta caja de estilo. Aumentando este valor se reduce el espacio disponible para los contenidos desde la parte superior.

Véase content_margin_bottom para consideraciones adicionales.


Descripciones de Métodos

void _draw(to_canvas_item: RID, rect: Rect2) virtual required const 🔗

There is currently no description for this method. Please help us by contributing one!


Rect2 _get_draw_rect(rect: Rect2) virtual const 🔗

There is currently no description for this method. Please help us by contributing one!


Vector2 _get_minimum_size() virtual const 🔗

Método virtual para ser implementado por el usuario. Devuelve un tamaño mínimo personalizado que el stylebox debe respetar al dibujar. Por defecto, get_minimum_size() solo tiene en cuenta los márgenes de contenido. Este método puede ser sobreescrito para añadir otra restricción de tamaño. Se utilizará una combinación del comportamiento por defecto y la salida de este método, para tener en cuenta ambos tamaños.


bool _test_mask(point: Vector2, rect: Rect2) virtual const 🔗

There is currently no description for this method. Please help us by contributing one!


void draw(canvas_item: RID, rect: Rect2) const 🔗

Dibuja este stylebox usando un elemento del canvas identificado por el RID dado.

El valor de RID puede ser el resultado de CanvasItem.get_canvas_item() llamado en un nodo derivado de CanvasItem existente, o directamente de la creación de un elemento del canvas en el RenderingServer con RenderingServer.canvas_item_create().


float get_content_margin(margin: Side) const 🔗

Devuelve el margen por defecto del Side especificado.


CanvasItem get_current_item_drawn() const 🔗

Devuelve el CanvasItem que maneja su CanvasItem.NOTIFICATION_DRAW o CanvasItem._draw() llamada en este momento.


float get_margin(margin: Side) const 🔗

Devuelve el desplazamiento del margen de contenido para el Side especificado.

Los valores positivos reducen el tamaño hacia adentro, a diferencia de los valores de margen de Control.


Vector2 get_minimum_size() const 🔗

Devuelve el tamaño mínimo al que se puede reducir esta caja de estilo.


Vector2 get_offset() const 🔗

Devuelve el "desplazamiento" de una caja de estilo. Esta función de ayuda devuelve un valor equivalente a Vector2(style.get_margin(MARGIN_LEFT), style.get_margin(MARGIN_TOP)).


void set_content_margin(margin: Side, offset: float) 🔗

Establece el valor por defecto del Side especificado a offset píxeles.


void set_content_margin_all(offset: float) 🔗

Establece el margen por defecto a offset píxeles para todos los lados.


bool test_mask(point: Vector2, rect: Rect2) const 🔗

Prueba una posición en un rectángulo, devolver si pasa la prueba de máscara.