123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346 |
- :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<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
- **Inherited By:** :ref:`StyleBoxEmpty<class_StyleBoxEmpty>`, :ref:`StyleBoxFlat<class_StyleBoxFlat>`, :ref:`StyleBoxLine<class_StyleBoxLine>`, :ref:`StyleBoxTexture<class_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<class_LineEdit>` backgrounds, :ref:`Tree<class_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<class_float>` | :ref:`content_margin_bottom<class_StyleBox_property_content_margin_bottom>` | ``-1.0`` |
- +---------------------------+-----------------------------------------------------------------------------+----------+
- | :ref:`float<class_float>` | :ref:`content_margin_left<class_StyleBox_property_content_margin_left>` | ``-1.0`` |
- +---------------------------+-----------------------------------------------------------------------------+----------+
- | :ref:`float<class_float>` | :ref:`content_margin_right<class_StyleBox_property_content_margin_right>` | ``-1.0`` |
- +---------------------------+-----------------------------------------------------------------------------+----------+
- | :ref:`float<class_float>` | :ref:`content_margin_top<class_StyleBox_property_content_margin_top>` | ``-1.0`` |
- +---------------------------+-----------------------------------------------------------------------------+----------+
- .. rst-class:: classref-reftable-group
- Methods
- -------
- .. table::
- :widths: auto
- +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`_draw<class_StyleBox_private_method__draw>`\ (\ to_canvas_item\: :ref:`RID<class_RID>`, rect\: :ref:`Rect2<class_Rect2>`\ ) |virtual| |const| |
- +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Rect2<class_Rect2>` | :ref:`_get_draw_rect<class_StyleBox_private_method__get_draw_rect>`\ (\ rect\: :ref:`Rect2<class_Rect2>`\ ) |virtual| |const| |
- +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector2<class_Vector2>` | :ref:`_get_minimum_size<class_StyleBox_private_method__get_minimum_size>`\ (\ ) |virtual| |const| |
- +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`_test_mask<class_StyleBox_private_method__test_mask>`\ (\ point\: :ref:`Vector2<class_Vector2>`, rect\: :ref:`Rect2<class_Rect2>`\ ) |virtual| |const| |
- +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`draw<class_StyleBox_method_draw>`\ (\ canvas_item\: :ref:`RID<class_RID>`, rect\: :ref:`Rect2<class_Rect2>`\ ) |const| |
- +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`float<class_float>` | :ref:`get_content_margin<class_StyleBox_method_get_content_margin>`\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| |
- +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`CanvasItem<class_CanvasItem>` | :ref:`get_current_item_drawn<class_StyleBox_method_get_current_item_drawn>`\ (\ ) |const| |
- +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`float<class_float>` | :ref:`get_margin<class_StyleBox_method_get_margin>`\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| |
- +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector2<class_Vector2>` | :ref:`get_minimum_size<class_StyleBox_method_get_minimum_size>`\ (\ ) |const| |
- +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector2<class_Vector2>` | :ref:`get_offset<class_StyleBox_method_get_offset>`\ (\ ) |const| |
- +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`set_content_margin<class_StyleBox_method_set_content_margin>`\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, offset\: :ref:`float<class_float>`\ ) |
- +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`set_content_margin_all<class_StyleBox_method_set_content_margin_all>`\ (\ offset\: :ref:`float<class_float>`\ ) |
- +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`test_mask<class_StyleBox_method_test_mask>`\ (\ point\: :ref:`Vector2<class_Vector2>`, rect\: :ref:`Rect2<class_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<class_float>` **content_margin_bottom** = ``-1.0`` :ref:`🔗<class_StyleBox_property_content_margin_bottom>`
- .. rst-class:: classref-property-setget
- - |void| **set_content_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, offset\: :ref:`float<class_float>`\ )
- - :ref:`float<class_float>` **get_content_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_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<class_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<class_Button>` respects this content margin for the textual contents of the button.
- \ :ref:`get_margin<class_StyleBox_method_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<class_float>` **content_margin_left** = ``-1.0`` :ref:`🔗<class_StyleBox_property_content_margin_left>`
- .. rst-class:: classref-property-setget
- - |void| **set_content_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, offset\: :ref:`float<class_float>`\ )
- - :ref:`float<class_float>` **get_content_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_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<class_StyleBox_property_content_margin_bottom>` for extra considerations.
- .. rst-class:: classref-item-separator
- ----
- .. _class_StyleBox_property_content_margin_right:
- .. rst-class:: classref-property
- :ref:`float<class_float>` **content_margin_right** = ``-1.0`` :ref:`🔗<class_StyleBox_property_content_margin_right>`
- .. rst-class:: classref-property-setget
- - |void| **set_content_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, offset\: :ref:`float<class_float>`\ )
- - :ref:`float<class_float>` **get_content_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_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<class_StyleBox_property_content_margin_bottom>` for extra considerations.
- .. rst-class:: classref-item-separator
- ----
- .. _class_StyleBox_property_content_margin_top:
- .. rst-class:: classref-property
- :ref:`float<class_float>` **content_margin_top** = ``-1.0`` :ref:`🔗<class_StyleBox_property_content_margin_top>`
- .. rst-class:: classref-property-setget
- - |void| **set_content_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, offset\: :ref:`float<class_float>`\ )
- - :ref:`float<class_float>` **get_content_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_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<class_StyleBox_property_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<class_RID>`, rect\: :ref:`Rect2<class_Rect2>`\ ) |virtual| |const| :ref:`🔗<class_StyleBox_private_method__draw>`
- .. container:: contribute
- There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
- .. rst-class:: classref-item-separator
- ----
- .. _class_StyleBox_private_method__get_draw_rect:
- .. rst-class:: classref-method
- :ref:`Rect2<class_Rect2>` **_get_draw_rect**\ (\ rect\: :ref:`Rect2<class_Rect2>`\ ) |virtual| |const| :ref:`🔗<class_StyleBox_private_method__get_draw_rect>`
- .. container:: contribute
- There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
- .. rst-class:: classref-item-separator
- ----
- .. _class_StyleBox_private_method__get_minimum_size:
- .. rst-class:: classref-method
- :ref:`Vector2<class_Vector2>` **_get_minimum_size**\ (\ ) |virtual| |const| :ref:`🔗<class_StyleBox_private_method__get_minimum_size>`
- 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<class_StyleBox_method_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<class_bool>` **_test_mask**\ (\ point\: :ref:`Vector2<class_Vector2>`, rect\: :ref:`Rect2<class_Rect2>`\ ) |virtual| |const| :ref:`🔗<class_StyleBox_private_method__test_mask>`
- .. container:: contribute
- There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
- .. rst-class:: classref-item-separator
- ----
- .. _class_StyleBox_method_draw:
- .. rst-class:: classref-method
- |void| **draw**\ (\ canvas_item\: :ref:`RID<class_RID>`, rect\: :ref:`Rect2<class_Rect2>`\ ) |const| :ref:`🔗<class_StyleBox_method_draw>`
- Draws this stylebox using a canvas item identified by the given :ref:`RID<class_RID>`.
- The :ref:`RID<class_RID>` value can either be the result of :ref:`CanvasItem.get_canvas_item<class_CanvasItem_method_get_canvas_item>` called on an existing :ref:`CanvasItem<class_CanvasItem>`-derived node, or directly from creating a canvas item in the :ref:`RenderingServer<class_RenderingServer>` with :ref:`RenderingServer.canvas_item_create<class_RenderingServer_method_canvas_item_create>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_StyleBox_method_get_content_margin:
- .. rst-class:: classref-method
- :ref:`float<class_float>` **get_content_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| :ref:`🔗<class_StyleBox_method_get_content_margin>`
- Returns the default margin of the specified :ref:`Side<enum_@GlobalScope_Side>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_StyleBox_method_get_current_item_drawn:
- .. rst-class:: classref-method
- :ref:`CanvasItem<class_CanvasItem>` **get_current_item_drawn**\ (\ ) |const| :ref:`🔗<class_StyleBox_method_get_current_item_drawn>`
- Returns the :ref:`CanvasItem<class_CanvasItem>` that handles its :ref:`CanvasItem.NOTIFICATION_DRAW<class_CanvasItem_constant_NOTIFICATION_DRAW>` or :ref:`CanvasItem._draw<class_CanvasItem_private_method__draw>` callback at this moment.
- .. rst-class:: classref-item-separator
- ----
- .. _class_StyleBox_method_get_margin:
- .. rst-class:: classref-method
- :ref:`float<class_float>` **get_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| :ref:`🔗<class_StyleBox_method_get_margin>`
- Returns the content margin offset for the specified :ref:`Side<enum_@GlobalScope_Side>`.
- Positive values reduce size inwards, unlike :ref:`Control<class_Control>`'s margin values.
- .. rst-class:: classref-item-separator
- ----
- .. _class_StyleBox_method_get_minimum_size:
- .. rst-class:: classref-method
- :ref:`Vector2<class_Vector2>` **get_minimum_size**\ (\ ) |const| :ref:`🔗<class_StyleBox_method_get_minimum_size>`
- 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<class_Vector2>` **get_offset**\ (\ ) |const| :ref:`🔗<class_StyleBox_method_get_offset>`
- 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<enum_@GlobalScope_Side>`, offset\: :ref:`float<class_float>`\ ) :ref:`🔗<class_StyleBox_method_set_content_margin>`
- Sets the default value of the specified :ref:`Side<enum_@GlobalScope_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<class_float>`\ ) :ref:`🔗<class_StyleBox_method_set_content_margin_all>`
- 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<class_bool>` **test_mask**\ (\ point\: :ref:`Vector2<class_Vector2>`, rect\: :ref:`Rect2<class_Rect2>`\ ) |const| :ref:`🔗<class_StyleBox_method_test_mask>`
- 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.)`
|