class_texturebutton.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the TextureButton.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_TextureButton:
  5. TextureButton
  6. =============
  7. **Inherits:** :ref:`BaseButton<class_basebutton>` **<** :ref:`Control<class_control>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Texture-based button. Supports Pressed, Hover, Disabled and Focused states.
  12. Member Functions
  13. ----------------
  14. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  15. | :ref:`BitMap<class_bitmap>` | :ref:`get_click_mask<class_TextureButton_get_click_mask>` **(** **)** const |
  16. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  17. | :ref:`Texture<class_texture>` | :ref:`get_disabled_texture<class_TextureButton_get_disabled_texture>` **(** **)** const |
  18. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`bool<class_bool>` | :ref:`get_expand<class_TextureButton_get_expand>` **(** **)** const |
  20. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`Texture<class_texture>` | :ref:`get_focused_texture<class_TextureButton_get_focused_texture>` **(** **)** const |
  22. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`Texture<class_texture>` | :ref:`get_hover_texture<class_TextureButton_get_hover_texture>` **(** **)** const |
  24. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`Texture<class_texture>` | :ref:`get_normal_texture<class_TextureButton_get_normal_texture>` **(** **)** const |
  26. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Texture<class_texture>` | :ref:`get_pressed_texture<class_TextureButton_get_pressed_texture>` **(** **)** const |
  28. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`int<class_int>` | :ref:`get_stretch_mode<class_TextureButton_get_stretch_mode>` **(** **)** const |
  30. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  31. | void | :ref:`set_click_mask<class_TextureButton_set_click_mask>` **(** :ref:`BitMap<class_bitmap>` mask **)** |
  32. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  33. | void | :ref:`set_disabled_texture<class_TextureButton_set_disabled_texture>` **(** :ref:`Texture<class_texture>` texture **)** |
  34. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`set_expand<class_TextureButton_set_expand>` **(** :ref:`bool<class_bool>` p_expand **)** |
  36. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`set_focused_texture<class_TextureButton_set_focused_texture>` **(** :ref:`Texture<class_texture>` texture **)** |
  38. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`set_hover_texture<class_TextureButton_set_hover_texture>` **(** :ref:`Texture<class_texture>` texture **)** |
  40. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`set_normal_texture<class_TextureButton_set_normal_texture>` **(** :ref:`Texture<class_texture>` texture **)** |
  42. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`set_pressed_texture<class_TextureButton_set_pressed_texture>` **(** :ref:`Texture<class_texture>` texture **)** |
  44. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`set_stretch_mode<class_TextureButton_set_stretch_mode>` **(** :ref:`int<class_int>` p_mode **)** |
  46. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  47. Member Variables
  48. ----------------
  49. - :ref:`bool<class_bool>` **expand** - If ``true`` the texture stretches to the edges of the node's bounding rectangle using the member stretch_mode. If ``false`` the texture will not scale with the node. Default value: ``false``.
  50. - :ref:`int<class_int>` **stretch_mode** - Controls the texture's behavior when you resize the node's bounding rectangle, **only if** member expand is ``true``. Set it to one of the ``STRETCH\_\*`` constants. See the constants to learn more.
  51. - :ref:`BitMap<class_bitmap>` **texture_click_mask** - Pure black and white Bitmap image to use for click detection. On the mask, white pixels represent the button's clickable area. Use it to create buttons with curved shapes.
  52. - :ref:`Texture<class_texture>` **texture_disabled** - Texture to display when the node is disabled. See member BaseButton.disabled.
  53. - :ref:`Texture<class_texture>` **texture_focused** - Texture to display when the node has mouse or keyboard focus.
  54. - :ref:`Texture<class_texture>` **texture_hover** - Texture to display when the mouse hovers the node.
  55. - :ref:`Texture<class_texture>` **texture_normal** - Texture to display by default, when the node is **not** in the disabled, focused, hover or pressed state.
  56. - :ref:`Texture<class_texture>` **texture_pressed** - Texture to display on mouse down over the node, if the node has keyboard focus and the player presses the enter key or if the player presses the member BaseButton.shortcut key.
  57. Numeric Constants
  58. -----------------
  59. - **STRETCH_SCALE** = **0** --- Scale to fit the node's bounding rectangle.
  60. - **STRETCH_TILE** = **1** --- Tile inside the node's bounding rectangle.
  61. - **STRETCH_KEEP** = **2** --- The texture keeps its original size and stays in the bounding rectangle's top-left corner.
  62. - **STRETCH_KEEP_CENTERED** = **3** --- The texture keeps its original size and stays centered in the node's bounding rectangle.
  63. - **STRETCH_KEEP_ASPECT** = **4** --- Scale the texture to fit the node's bounding rectangle, but maintain the texture's aspect ratio.
  64. - **STRETCH_KEEP_ASPECT_CENTERED** = **5** --- Scale the texture to fit the node's bounding rectangle, center it, and maintain its aspect ratio.
  65. - **STRETCH_KEEP_ASPECT_COVERED** = **6** --- Scale the texture so that the shorter side fits the bounding rectangle. The other side clips to the node's limits.
  66. Description
  67. -----------
  68. ``TextureButton`` has the same functionality as :ref:`Button<class_button>`, except it uses sprites instead of Godot's :ref:`Theme<class_theme>` resource. It is faster to create, but it doesn't support localization like more complex Controls.
  69. The Normal state's texture is required. Others are optional.
  70. Member Function Description
  71. ---------------------------
  72. .. _class_TextureButton_get_click_mask:
  73. - :ref:`BitMap<class_bitmap>` **get_click_mask** **(** **)** const
  74. .. _class_TextureButton_get_disabled_texture:
  75. - :ref:`Texture<class_texture>` **get_disabled_texture** **(** **)** const
  76. .. _class_TextureButton_get_expand:
  77. - :ref:`bool<class_bool>` **get_expand** **(** **)** const
  78. .. _class_TextureButton_get_focused_texture:
  79. - :ref:`Texture<class_texture>` **get_focused_texture** **(** **)** const
  80. .. _class_TextureButton_get_hover_texture:
  81. - :ref:`Texture<class_texture>` **get_hover_texture** **(** **)** const
  82. .. _class_TextureButton_get_normal_texture:
  83. - :ref:`Texture<class_texture>` **get_normal_texture** **(** **)** const
  84. .. _class_TextureButton_get_pressed_texture:
  85. - :ref:`Texture<class_texture>` **get_pressed_texture** **(** **)** const
  86. .. _class_TextureButton_get_stretch_mode:
  87. - :ref:`int<class_int>` **get_stretch_mode** **(** **)** const
  88. .. _class_TextureButton_set_click_mask:
  89. - void **set_click_mask** **(** :ref:`BitMap<class_bitmap>` mask **)**
  90. .. _class_TextureButton_set_disabled_texture:
  91. - void **set_disabled_texture** **(** :ref:`Texture<class_texture>` texture **)**
  92. .. _class_TextureButton_set_expand:
  93. - void **set_expand** **(** :ref:`bool<class_bool>` p_expand **)**
  94. .. _class_TextureButton_set_focused_texture:
  95. - void **set_focused_texture** **(** :ref:`Texture<class_texture>` texture **)**
  96. .. _class_TextureButton_set_hover_texture:
  97. - void **set_hover_texture** **(** :ref:`Texture<class_texture>` texture **)**
  98. .. _class_TextureButton_set_normal_texture:
  99. - void **set_normal_texture** **(** :ref:`Texture<class_texture>` texture **)**
  100. .. _class_TextureButton_set_pressed_texture:
  101. - void **set_pressed_texture** **(** :ref:`Texture<class_texture>` texture **)**
  102. .. _class_TextureButton_set_stretch_mode:
  103. - void **set_stretch_mode** **(** :ref:`int<class_int>` p_mode **)**