Files
godot-docs/classes/class_styleboxtexture.rst
2024-05-31 13:54:35 +00:00

471 lines
22 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

: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/StyleBoxTexture.xml.
.. _class_StyleBoxTexture:
StyleBoxTexture
===============
**Inherits:** :ref:`StyleBox<class_StyleBox>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
A texture-based nine-patch :ref:`StyleBox<class_StyleBox>`.
.. rst-class:: classref-introduction-group
Description
-----------
A texture-based nine-patch :ref:`StyleBox<class_StyleBox>`, in a way similar to :ref:`NinePatchRect<class_NinePatchRect>`. This stylebox performs a 3×3 scaling of a texture, where only the center cell is fully stretched. This makes it possible to design bordered styles regardless of the stylebox's size.
.. rst-class:: classref-reftable-group
Properties
----------
.. table::
:widths: auto
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`AxisStretchMode<enum_StyleBoxTexture_AxisStretchMode>` | :ref:`axis_stretch_horizontal<class_StyleBoxTexture_property_axis_stretch_horizontal>` | ``0`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`AxisStretchMode<enum_StyleBoxTexture_AxisStretchMode>` | :ref:`axis_stretch_vertical<class_StyleBoxTexture_property_axis_stretch_vertical>` | ``0`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`bool<class_bool>` | :ref:`draw_center<class_StyleBoxTexture_property_draw_center>` | ``true`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`float<class_float>` | :ref:`expand_margin_bottom<class_StyleBoxTexture_property_expand_margin_bottom>` | ``0.0`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`float<class_float>` | :ref:`expand_margin_left<class_StyleBoxTexture_property_expand_margin_left>` | ``0.0`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`float<class_float>` | :ref:`expand_margin_right<class_StyleBoxTexture_property_expand_margin_right>` | ``0.0`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`float<class_float>` | :ref:`expand_margin_top<class_StyleBoxTexture_property_expand_margin_top>` | ``0.0`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`Color<class_Color>` | :ref:`modulate_color<class_StyleBoxTexture_property_modulate_color>` | ``Color(1, 1, 1, 1)`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`Rect2<class_Rect2>` | :ref:`region_rect<class_StyleBoxTexture_property_region_rect>` | ``Rect2(0, 0, 0, 0)`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`Texture2D<class_Texture2D>` | :ref:`texture<class_StyleBoxTexture_property_texture>` | |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`float<class_float>` | :ref:`texture_margin_bottom<class_StyleBoxTexture_property_texture_margin_bottom>` | ``0.0`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`float<class_float>` | :ref:`texture_margin_left<class_StyleBoxTexture_property_texture_margin_left>` | ``0.0`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`float<class_float>` | :ref:`texture_margin_right<class_StyleBoxTexture_property_texture_margin_right>` | ``0.0`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`float<class_float>` | :ref:`texture_margin_top<class_StyleBoxTexture_property_texture_margin_top>` | ``0.0`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
.. rst-class:: classref-reftable-group
Methods
-------
.. table::
:widths: auto
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`get_expand_margin<class_StyleBoxTexture_method_get_expand_margin>`\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`get_texture_margin<class_StyleBoxTexture_method_get_texture_margin>`\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`set_expand_margin<class_StyleBoxTexture_method_set_expand_margin>`\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, size\: :ref:`float<class_float>`\ ) |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`set_expand_margin_all<class_StyleBoxTexture_method_set_expand_margin_all>`\ (\ size\: :ref:`float<class_float>`\ ) |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`set_texture_margin<class_StyleBoxTexture_method_set_texture_margin>`\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, size\: :ref:`float<class_float>`\ ) |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`set_texture_margin_all<class_StyleBoxTexture_method_set_texture_margin_all>`\ (\ size\: :ref:`float<class_float>`\ ) |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Enumerations
------------
.. _enum_StyleBoxTexture_AxisStretchMode:
.. rst-class:: classref-enumeration
enum **AxisStretchMode**: :ref:`🔗<enum_StyleBoxTexture_AxisStretchMode>`
.. _class_StyleBoxTexture_constant_AXIS_STRETCH_MODE_STRETCH:
.. rst-class:: classref-enumeration-constant
:ref:`AxisStretchMode<enum_StyleBoxTexture_AxisStretchMode>` **AXIS_STRETCH_MODE_STRETCH** = ``0``
Stretch the stylebox's texture. This results in visible distortion unless the texture size matches the stylebox's size perfectly.
.. _class_StyleBoxTexture_constant_AXIS_STRETCH_MODE_TILE:
.. rst-class:: classref-enumeration-constant
:ref:`AxisStretchMode<enum_StyleBoxTexture_AxisStretchMode>` **AXIS_STRETCH_MODE_TILE** = ``1``
Repeats the stylebox's texture to match the stylebox's size according to the nine-patch system.
.. _class_StyleBoxTexture_constant_AXIS_STRETCH_MODE_TILE_FIT:
.. rst-class:: classref-enumeration-constant
:ref:`AxisStretchMode<enum_StyleBoxTexture_AxisStretchMode>` **AXIS_STRETCH_MODE_TILE_FIT** = ``2``
Repeats the stylebox's texture to match the stylebox's size according to the nine-patch system. Unlike :ref:`AXIS_STRETCH_MODE_TILE<class_StyleBoxTexture_constant_AXIS_STRETCH_MODE_TILE>`, the texture may be slightly stretched to make the nine-patch texture tile seamlessly.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Property Descriptions
---------------------
.. _class_StyleBoxTexture_property_axis_stretch_horizontal:
.. rst-class:: classref-property
:ref:`AxisStretchMode<enum_StyleBoxTexture_AxisStretchMode>` **axis_stretch_horizontal** = ``0`` :ref:`🔗<class_StyleBoxTexture_property_axis_stretch_horizontal>`
.. rst-class:: classref-property-setget
- |void| **set_h_axis_stretch_mode**\ (\ value\: :ref:`AxisStretchMode<enum_StyleBoxTexture_AxisStretchMode>`\ )
- :ref:`AxisStretchMode<enum_StyleBoxTexture_AxisStretchMode>` **get_h_axis_stretch_mode**\ (\ )
Controls how the stylebox's texture will be stretched or tiled horizontally. See :ref:`AxisStretchMode<enum_StyleBoxTexture_AxisStretchMode>` for possible values.
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_axis_stretch_vertical:
.. rst-class:: classref-property
:ref:`AxisStretchMode<enum_StyleBoxTexture_AxisStretchMode>` **axis_stretch_vertical** = ``0`` :ref:`🔗<class_StyleBoxTexture_property_axis_stretch_vertical>`
.. rst-class:: classref-property-setget
- |void| **set_v_axis_stretch_mode**\ (\ value\: :ref:`AxisStretchMode<enum_StyleBoxTexture_AxisStretchMode>`\ )
- :ref:`AxisStretchMode<enum_StyleBoxTexture_AxisStretchMode>` **get_v_axis_stretch_mode**\ (\ )
Controls how the stylebox's texture will be stretched or tiled vertically. See :ref:`AxisStretchMode<enum_StyleBoxTexture_AxisStretchMode>` for possible values.
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_draw_center:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **draw_center** = ``true`` :ref:`🔗<class_StyleBoxTexture_property_draw_center>`
.. rst-class:: classref-property-setget
- |void| **set_draw_center**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **is_draw_center_enabled**\ (\ )
If ``true``, the nine-patch texture's center tile will be drawn.
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_expand_margin_bottom:
.. rst-class:: classref-property
:ref:`float<class_float>` **expand_margin_bottom** = ``0.0`` :ref:`🔗<class_StyleBoxTexture_property_expand_margin_bottom>`
.. rst-class:: classref-property-setget
- |void| **set_expand_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, size\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_expand_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
Expands the bottom margin of this style box when drawing, causing it to be drawn larger than requested.
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_expand_margin_left:
.. rst-class:: classref-property
:ref:`float<class_float>` **expand_margin_left** = ``0.0`` :ref:`🔗<class_StyleBoxTexture_property_expand_margin_left>`
.. rst-class:: classref-property-setget
- |void| **set_expand_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, size\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_expand_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
Expands the left margin of this style box when drawing, causing it to be drawn larger than requested.
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_expand_margin_right:
.. rst-class:: classref-property
:ref:`float<class_float>` **expand_margin_right** = ``0.0`` :ref:`🔗<class_StyleBoxTexture_property_expand_margin_right>`
.. rst-class:: classref-property-setget
- |void| **set_expand_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, size\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_expand_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
Expands the right margin of this style box when drawing, causing it to be drawn larger than requested.
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_expand_margin_top:
.. rst-class:: classref-property
:ref:`float<class_float>` **expand_margin_top** = ``0.0`` :ref:`🔗<class_StyleBoxTexture_property_expand_margin_top>`
.. rst-class:: classref-property-setget
- |void| **set_expand_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, size\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_expand_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
Expands the top margin of this style box when drawing, causing it to be drawn larger than requested.
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_modulate_color:
.. rst-class:: classref-property
:ref:`Color<class_Color>` **modulate_color** = ``Color(1, 1, 1, 1)`` :ref:`🔗<class_StyleBoxTexture_property_modulate_color>`
.. rst-class:: classref-property-setget
- |void| **set_modulate**\ (\ value\: :ref:`Color<class_Color>`\ )
- :ref:`Color<class_Color>` **get_modulate**\ (\ )
Modulates the color of the texture when this style box is drawn.
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_region_rect:
.. rst-class:: classref-property
:ref:`Rect2<class_Rect2>` **region_rect** = ``Rect2(0, 0, 0, 0)`` :ref:`🔗<class_StyleBoxTexture_property_region_rect>`
.. rst-class:: classref-property-setget
- |void| **set_region_rect**\ (\ value\: :ref:`Rect2<class_Rect2>`\ )
- :ref:`Rect2<class_Rect2>` **get_region_rect**\ (\ )
Species a sub-region of the texture to use.
This is equivalent to first wrapping the texture in an :ref:`AtlasTexture<class_AtlasTexture>` with the same region.
If empty (``Rect2(0, 0, 0, 0)``), the whole texture will be used.
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_texture:
.. rst-class:: classref-property
:ref:`Texture2D<class_Texture2D>` **texture** :ref:`🔗<class_StyleBoxTexture_property_texture>`
.. rst-class:: classref-property-setget
- |void| **set_texture**\ (\ value\: :ref:`Texture2D<class_Texture2D>`\ )
- :ref:`Texture2D<class_Texture2D>` **get_texture**\ (\ )
The texture to use when drawing this style box.
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_texture_margin_bottom:
.. rst-class:: classref-property
:ref:`float<class_float>` **texture_margin_bottom** = ``0.0`` :ref:`🔗<class_StyleBoxTexture_property_texture_margin_bottom>`
.. rst-class:: classref-property-setget
- |void| **set_texture_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, size\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_texture_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
Increases the bottom margin of the 3×3 texture box.
A higher value means more of the source texture is considered to be part of the bottom border of the 3×3 box.
This is also the value used as fallback for :ref:`StyleBox.content_margin_bottom<class_StyleBox_property_content_margin_bottom>` if it is negative.
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_texture_margin_left:
.. rst-class:: classref-property
:ref:`float<class_float>` **texture_margin_left** = ``0.0`` :ref:`🔗<class_StyleBoxTexture_property_texture_margin_left>`
.. rst-class:: classref-property-setget
- |void| **set_texture_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, size\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_texture_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
Increases the left margin of the 3×3 texture box.
A higher value means more of the source texture is considered to be part of the left border of the 3×3 box.
This is also the value used as fallback for :ref:`StyleBox.content_margin_left<class_StyleBox_property_content_margin_left>` if it is negative.
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_texture_margin_right:
.. rst-class:: classref-property
:ref:`float<class_float>` **texture_margin_right** = ``0.0`` :ref:`🔗<class_StyleBoxTexture_property_texture_margin_right>`
.. rst-class:: classref-property-setget
- |void| **set_texture_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, size\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_texture_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
Increases the right margin of the 3×3 texture box.
A higher value means more of the source texture is considered to be part of the right border of the 3×3 box.
This is also the value used as fallback for :ref:`StyleBox.content_margin_right<class_StyleBox_property_content_margin_right>` if it is negative.
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_texture_margin_top:
.. rst-class:: classref-property
:ref:`float<class_float>` **texture_margin_top** = ``0.0`` :ref:`🔗<class_StyleBoxTexture_property_texture_margin_top>`
.. rst-class:: classref-property-setget
- |void| **set_texture_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, size\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_texture_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
Increases the top margin of the 3×3 texture box.
A higher value means more of the source texture is considered to be part of the top border of the 3×3 box.
This is also the value used as fallback for :ref:`StyleBox.content_margin_top<class_StyleBox_property_content_margin_top>` if it is negative.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Method Descriptions
-------------------
.. _class_StyleBoxTexture_method_get_expand_margin:
.. rst-class:: classref-method
:ref:`float<class_float>` **get_expand_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| :ref:`🔗<class_StyleBoxTexture_method_get_expand_margin>`
Returns the expand margin size of the specified :ref:`Side<enum_@GlobalScope_Side>`.
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_method_get_texture_margin:
.. rst-class:: classref-method
:ref:`float<class_float>` **get_texture_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| :ref:`🔗<class_StyleBoxTexture_method_get_texture_margin>`
Returns the margin size of the specified :ref:`Side<enum_@GlobalScope_Side>`.
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_method_set_expand_margin:
.. rst-class:: classref-method
|void| **set_expand_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, size\: :ref:`float<class_float>`\ ) :ref:`🔗<class_StyleBoxTexture_method_set_expand_margin>`
Sets the expand margin to ``size`` pixels for the specified :ref:`Side<enum_@GlobalScope_Side>`.
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_method_set_expand_margin_all:
.. rst-class:: classref-method
|void| **set_expand_margin_all**\ (\ size\: :ref:`float<class_float>`\ ) :ref:`🔗<class_StyleBoxTexture_method_set_expand_margin_all>`
Sets the expand margin to ``size`` pixels for all sides.
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_method_set_texture_margin:
.. rst-class:: classref-method
|void| **set_texture_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, size\: :ref:`float<class_float>`\ ) :ref:`🔗<class_StyleBoxTexture_method_set_texture_margin>`
Sets the margin to ``size`` pixels for the specified :ref:`Side<enum_@GlobalScope_Side>`.
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_method_set_texture_margin_all:
.. rst-class:: classref-method
|void| **set_texture_margin_all**\ (\ size\: :ref:`float<class_float>`\ ) :ref:`🔗<class_StyleBoxTexture_method_set_texture_margin_all>`
Sets the margin to ``size`` pixels for all sides.
.. |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.)`