:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/StyleBox.xml. .. _class_StyleBox: StyleBox ======== **Inherits:** :ref:`Resource` **<** :ref:`RefCounted` **<** :ref:`Object` **Inherited By:** :ref:`StyleBoxEmpty`, :ref:`StyleBoxFlat`, :ref:`StyleBoxLine`, :ref:`StyleBoxTexture` Abstract base class for defining stylized boxes for UI elements. .. rst-class:: classref-introduction-group Description ----------- **StyleBox** is an abstract base class for drawing stylized boxes for UI elements. It is used for panels, buttons, :ref:`LineEdit` backgrounds, :ref:`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. .. rst-class:: classref-reftable-group Properties ---------- .. table:: :widths: auto +---------------------------+-----------------------------------------------------------------------------+----------+ | :ref:`float` | :ref:`content_margin_bottom` | ``-1.0`` | +---------------------------+-----------------------------------------------------------------------------+----------+ | :ref:`float` | :ref:`content_margin_left` | ``-1.0`` | +---------------------------+-----------------------------------------------------------------------------+----------+ | :ref:`float` | :ref:`content_margin_right` | ``-1.0`` | +---------------------------+-----------------------------------------------------------------------------+----------+ | :ref:`float` | :ref:`content_margin_top` | ``-1.0`` | +---------------------------+-----------------------------------------------------------------------------+----------+ .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`_draw`\ (\ to_canvas_item\: :ref:`RID`, rect\: :ref:`Rect2`\ ) |virtual| |const| | +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Rect2` | :ref:`_get_draw_rect`\ (\ rect\: :ref:`Rect2`\ ) |virtual| |const| | +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`_get_minimum_size`\ (\ ) |virtual| |const| | +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`_test_mask`\ (\ point\: :ref:`Vector2`, rect\: :ref:`Rect2`\ ) |virtual| |const| | +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`draw`\ (\ canvas_item\: :ref:`RID`, rect\: :ref:`Rect2`\ ) |const| | +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_content_margin`\ (\ margin\: :ref:`Side`\ ) |const| | +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`CanvasItem` | :ref:`get_current_item_drawn`\ (\ ) |const| | +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_margin`\ (\ margin\: :ref:`Side`\ ) |const| | +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_minimum_size`\ (\ ) |const| | +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_offset`\ (\ ) |const| | +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_content_margin`\ (\ margin\: :ref:`Side`, offset\: :ref:`float`\ ) | +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_content_margin_all`\ (\ offset\: :ref:`float`\ ) | +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`test_mask`\ (\ point\: :ref:`Vector2`, rect\: :ref:`Rect2`\ ) |const| | +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Property Descriptions --------------------- .. _class_StyleBox_property_content_margin_bottom: .. rst-class:: classref-property :ref:`float` **content_margin_bottom** = ``-1.0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_content_margin**\ (\ margin\: :ref:`Side`, offset\: :ref:`float`\ ) - :ref:`float` **get_content_margin**\ (\ margin\: :ref:`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 :ref:`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 :ref:`Button` respects this content margin for the textual contents of the button. \ :ref:`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. .. rst-class:: classref-item-separator ---- .. _class_StyleBox_property_content_margin_left: .. rst-class:: classref-property :ref:`float` **content_margin_left** = ``-1.0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_content_margin**\ (\ margin\: :ref:`Side`, offset\: :ref:`float`\ ) - :ref:`float` **get_content_margin**\ (\ margin\: :ref:`Side`\ ) |const| 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 :ref:`content_margin_bottom` for extra considerations. .. rst-class:: classref-item-separator ---- .. _class_StyleBox_property_content_margin_right: .. rst-class:: classref-property :ref:`float` **content_margin_right** = ``-1.0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_content_margin**\ (\ margin\: :ref:`Side`, offset\: :ref:`float`\ ) - :ref:`float` **get_content_margin**\ (\ margin\: :ref:`Side`\ ) |const| 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 :ref:`content_margin_bottom` for extra considerations. .. rst-class:: classref-item-separator ---- .. _class_StyleBox_property_content_margin_top: .. rst-class:: classref-property :ref:`float` **content_margin_top** = ``-1.0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_content_margin**\ (\ margin\: :ref:`Side`, offset\: :ref:`float`\ ) - :ref:`float` **get_content_margin**\ (\ margin\: :ref:`Side`\ ) |const| 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 :ref:`content_margin_bottom` for extra considerations. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_StyleBox_private_method__draw: .. rst-class:: classref-method |void| **_draw**\ (\ to_canvas_item\: :ref:`RID`, rect\: :ref:`Rect2`\ ) |virtual| |const| :ref:`🔗` .. container:: contribute There is currently no description for this method. Please help us by :ref:`contributing one `! .. rst-class:: classref-item-separator ---- .. _class_StyleBox_private_method__get_draw_rect: .. rst-class:: classref-method :ref:`Rect2` **_get_draw_rect**\ (\ rect\: :ref:`Rect2`\ ) |virtual| |const| :ref:`🔗` .. container:: contribute There is currently no description for this method. Please help us by :ref:`contributing one `! .. rst-class:: classref-item-separator ---- .. _class_StyleBox_private_method__get_minimum_size: .. rst-class:: classref-method :ref:`Vector2` **_get_minimum_size**\ (\ ) |virtual| |const| :ref:`🔗` Virtual method to be implemented by the user. Returns a custom minimum size that the stylebox must respect when drawing. By default :ref:`get_minimum_size` 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. .. rst-class:: classref-item-separator ---- .. _class_StyleBox_private_method__test_mask: .. rst-class:: classref-method :ref:`bool` **_test_mask**\ (\ point\: :ref:`Vector2`, rect\: :ref:`Rect2`\ ) |virtual| |const| :ref:`🔗` .. container:: contribute There is currently no description for this method. Please help us by :ref:`contributing one `! .. rst-class:: classref-item-separator ---- .. _class_StyleBox_method_draw: .. rst-class:: classref-method |void| **draw**\ (\ canvas_item\: :ref:`RID`, rect\: :ref:`Rect2`\ ) |const| :ref:`🔗` Draws this stylebox using a canvas item identified by the given :ref:`RID`. The :ref:`RID` value can either be the result of :ref:`CanvasItem.get_canvas_item` called on an existing :ref:`CanvasItem`-derived node, or directly from creating a canvas item in the :ref:`RenderingServer` with :ref:`RenderingServer.canvas_item_create`. .. rst-class:: classref-item-separator ---- .. _class_StyleBox_method_get_content_margin: .. rst-class:: classref-method :ref:`float` **get_content_margin**\ (\ margin\: :ref:`Side`\ ) |const| :ref:`🔗` Returns the default margin of the specified :ref:`Side`. .. rst-class:: classref-item-separator ---- .. _class_StyleBox_method_get_current_item_drawn: .. rst-class:: classref-method :ref:`CanvasItem` **get_current_item_drawn**\ (\ ) |const| :ref:`🔗` Returns the :ref:`CanvasItem` that handles its :ref:`CanvasItem.NOTIFICATION_DRAW` or :ref:`CanvasItem._draw` callback at this moment. .. rst-class:: classref-item-separator ---- .. _class_StyleBox_method_get_margin: .. rst-class:: classref-method :ref:`float` **get_margin**\ (\ margin\: :ref:`Side`\ ) |const| :ref:`🔗` Returns the content margin offset for the specified :ref:`Side`. Positive values reduce size inwards, unlike :ref:`Control`'s margin values. .. rst-class:: classref-item-separator ---- .. _class_StyleBox_method_get_minimum_size: .. rst-class:: classref-method :ref:`Vector2` **get_minimum_size**\ (\ ) |const| :ref:`🔗` Returns the minimum size that this stylebox can be shrunk to. .. rst-class:: classref-item-separator ---- .. _class_StyleBox_method_get_offset: .. rst-class:: classref-method :ref:`Vector2` **get_offset**\ (\ ) |const| :ref:`🔗` 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))``. .. rst-class:: classref-item-separator ---- .. _class_StyleBox_method_set_content_margin: .. rst-class:: classref-method |void| **set_content_margin**\ (\ margin\: :ref:`Side`, offset\: :ref:`float`\ ) :ref:`🔗` Sets the default value of the specified :ref:`Side` to ``offset`` pixels. .. rst-class:: classref-item-separator ---- .. _class_StyleBox_method_set_content_margin_all: .. rst-class:: classref-method |void| **set_content_margin_all**\ (\ offset\: :ref:`float`\ ) :ref:`🔗` Sets the default margin to ``offset`` pixels for all sides. .. rst-class:: classref-item-separator ---- .. _class_StyleBox_method_test_mask: .. rst-class:: classref-method :ref:`bool` **test_mask**\ (\ point\: :ref:`Vector2`, rect\: :ref:`Rect2`\ ) |const| :ref:`🔗` Test a position in a rectangle, return whether it passes the mask test. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)` .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)` .. |void| replace:: :abbr:`void (No return value.)`