class_theme.rst 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Theme.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Theme:
  6. Theme
  7. =====
  8. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. Theme for controls.
  10. Description
  11. -----------
  12. A theme for skinning controls. Controls can be skinned individually, but for complex applications, it's more practical to just create a global theme that defines everything. This theme can be applied to any :ref:`Control<class_Control>`; the Control and its children will automatically use it.
  13. Theme resources can alternatively be loaded by writing them in a ``.theme`` file, see the documentation for more information.
  14. Tutorials
  15. ---------
  16. - :doc:`../tutorials/gui/gui_skinning`
  17. Properties
  18. ----------
  19. +-------------------------+--------------------------------------------------------+
  20. | :ref:`Font<class_Font>` | :ref:`default_font<class_Theme_property_default_font>` |
  21. +-------------------------+--------------------------------------------------------+
  22. Methods
  23. -------
  24. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | void | :ref:`clear<class_Theme_method_clear>` **(** **)** |
  26. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | void | :ref:`clear_color<class_Theme_method_clear_color>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |
  28. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | void | :ref:`clear_constant<class_Theme_method_clear_constant>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |
  30. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | void | :ref:`clear_font<class_Theme_method_clear_font>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |
  32. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | void | :ref:`clear_icon<class_Theme_method_clear_icon>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |
  34. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`clear_stylebox<class_Theme_method_clear_stylebox>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |
  36. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`copy_default_theme<class_Theme_method_copy_default_theme>` **(** **)** |
  38. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`copy_theme<class_Theme_method_copy_theme>` **(** :ref:`Theme<class_Theme>` other **)** |
  40. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`Color<class_Color>` | :ref:`get_color<class_Theme_method_get_color>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |const| |
  42. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`PoolStringArray<class_PoolStringArray>` | :ref:`get_color_list<class_Theme_method_get_color_list>` **(** :ref:`String<class_String>` type **)** |const| |
  44. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`int<class_int>` | :ref:`get_constant<class_Theme_method_get_constant>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |const| |
  46. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`PoolStringArray<class_PoolStringArray>` | :ref:`get_constant_list<class_Theme_method_get_constant_list>` **(** :ref:`String<class_String>` type **)** |const| |
  48. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`Font<class_Font>` | :ref:`get_font<class_Theme_method_get_font>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |const| |
  50. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`PoolStringArray<class_PoolStringArray>` | :ref:`get_font_list<class_Theme_method_get_font_list>` **(** :ref:`String<class_String>` type **)** |const| |
  52. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`Texture<class_Texture>` | :ref:`get_icon<class_Theme_method_get_icon>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |const| |
  54. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`PoolStringArray<class_PoolStringArray>` | :ref:`get_icon_list<class_Theme_method_get_icon_list>` **(** :ref:`String<class_String>` type **)** |const| |
  56. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`StyleBox<class_StyleBox>` | :ref:`get_stylebox<class_Theme_method_get_stylebox>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |const| |
  58. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`PoolStringArray<class_PoolStringArray>` | :ref:`get_stylebox_list<class_Theme_method_get_stylebox_list>` **(** :ref:`String<class_String>` type **)** |const| |
  60. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`PoolStringArray<class_PoolStringArray>` | :ref:`get_stylebox_types<class_Theme_method_get_stylebox_types>` **(** **)** |const| |
  62. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`PoolStringArray<class_PoolStringArray>` | :ref:`get_type_list<class_Theme_method_get_type_list>` **(** :ref:`String<class_String>` type **)** |const| |
  64. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`bool<class_bool>` | :ref:`has_color<class_Theme_method_has_color>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |const| |
  66. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`bool<class_bool>` | :ref:`has_constant<class_Theme_method_has_constant>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |const| |
  68. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`bool<class_bool>` | :ref:`has_font<class_Theme_method_has_font>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |const| |
  70. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`bool<class_bool>` | :ref:`has_icon<class_Theme_method_has_icon>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |const| |
  72. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`bool<class_bool>` | :ref:`has_stylebox<class_Theme_method_has_stylebox>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |const| |
  74. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | void | :ref:`set_color<class_Theme_method_set_color>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type, :ref:`Color<class_Color>` color **)** |
  76. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | void | :ref:`set_constant<class_Theme_method_set_constant>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type, :ref:`int<class_int>` constant **)** |
  78. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | void | :ref:`set_font<class_Theme_method_set_font>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type, :ref:`Font<class_Font>` font **)** |
  80. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | void | :ref:`set_icon<class_Theme_method_set_icon>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type, :ref:`Texture<class_Texture>` texture **)** |
  82. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | void | :ref:`set_stylebox<class_Theme_method_set_stylebox>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type, :ref:`StyleBox<class_StyleBox>` texture **)** |
  84. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. Property Descriptions
  86. ---------------------
  87. .. _class_Theme_property_default_font:
  88. - :ref:`Font<class_Font>` **default_font**
  89. +----------+-------------------------+
  90. | *Setter* | set_default_font(value) |
  91. +----------+-------------------------+
  92. | *Getter* | get_default_font() |
  93. +----------+-------------------------+
  94. The theme's default font.
  95. Method Descriptions
  96. -------------------
  97. .. _class_Theme_method_clear:
  98. - void **clear** **(** **)**
  99. Clears all values on the theme.
  100. ----
  101. .. _class_Theme_method_clear_color:
  102. - void **clear_color** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)**
  103. Clears the :ref:`Color<class_Color>` at ``name`` if the theme has ``type``.
  104. ----
  105. .. _class_Theme_method_clear_constant:
  106. - void **clear_constant** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)**
  107. Clears the constant at ``name`` if the theme has ``type``.
  108. ----
  109. .. _class_Theme_method_clear_font:
  110. - void **clear_font** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)**
  111. Clears the :ref:`Font<class_Font>` at ``name`` if the theme has ``type``.
  112. ----
  113. .. _class_Theme_method_clear_icon:
  114. - void **clear_icon** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)**
  115. Clears the icon at ``name`` if the theme has ``type``.
  116. ----
  117. .. _class_Theme_method_clear_stylebox:
  118. - void **clear_stylebox** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)**
  119. Clears :ref:`StyleBox<class_StyleBox>` at ``name`` if the theme has ``type``.
  120. ----
  121. .. _class_Theme_method_copy_default_theme:
  122. - void **copy_default_theme** **(** **)**
  123. Sets the theme's values to a copy of the default theme values.
  124. ----
  125. .. _class_Theme_method_copy_theme:
  126. - void **copy_theme** **(** :ref:`Theme<class_Theme>` other **)**
  127. Sets the theme's values to a copy of a given theme.
  128. ----
  129. .. _class_Theme_method_get_color:
  130. - :ref:`Color<class_Color>` **get_color** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |const|
  131. Returns the :ref:`Color<class_Color>` at ``name`` if the theme has ``type``.
  132. ----
  133. .. _class_Theme_method_get_color_list:
  134. - :ref:`PoolStringArray<class_PoolStringArray>` **get_color_list** **(** :ref:`String<class_String>` type **)** |const|
  135. Returns all the :ref:`Color<class_Color>`\ s as a :ref:`PoolStringArray<class_PoolStringArray>` filled with each :ref:`Color<class_Color>`'s name, for use in :ref:`get_color<class_Theme_method_get_color>`, if the theme has ``type``.
  136. ----
  137. .. _class_Theme_method_get_constant:
  138. - :ref:`int<class_int>` **get_constant** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |const|
  139. Returns the constant at ``name`` if the theme has ``type``.
  140. ----
  141. .. _class_Theme_method_get_constant_list:
  142. - :ref:`PoolStringArray<class_PoolStringArray>` **get_constant_list** **(** :ref:`String<class_String>` type **)** |const|
  143. Returns all the constants as a :ref:`PoolStringArray<class_PoolStringArray>` filled with each constant's name, for use in :ref:`get_constant<class_Theme_method_get_constant>`, if the theme has ``type``.
  144. ----
  145. .. _class_Theme_method_get_font:
  146. - :ref:`Font<class_Font>` **get_font** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |const|
  147. Returns the :ref:`Font<class_Font>` at ``name`` if the theme has ``type``.
  148. ----
  149. .. _class_Theme_method_get_font_list:
  150. - :ref:`PoolStringArray<class_PoolStringArray>` **get_font_list** **(** :ref:`String<class_String>` type **)** |const|
  151. Returns all the :ref:`Font<class_Font>`\ s as a :ref:`PoolStringArray<class_PoolStringArray>` filled with each :ref:`Font<class_Font>`'s name, for use in :ref:`get_font<class_Theme_method_get_font>`, if the theme has ``type``.
  152. ----
  153. .. _class_Theme_method_get_icon:
  154. - :ref:`Texture<class_Texture>` **get_icon** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |const|
  155. Returns the icon :ref:`Texture<class_Texture>` at ``name`` if the theme has ``type``.
  156. ----
  157. .. _class_Theme_method_get_icon_list:
  158. - :ref:`PoolStringArray<class_PoolStringArray>` **get_icon_list** **(** :ref:`String<class_String>` type **)** |const|
  159. Returns all the icons as a :ref:`PoolStringArray<class_PoolStringArray>` filled with each :ref:`Texture<class_Texture>`'s name, for use in :ref:`get_icon<class_Theme_method_get_icon>`, if the theme has ``type``.
  160. ----
  161. .. _class_Theme_method_get_stylebox:
  162. - :ref:`StyleBox<class_StyleBox>` **get_stylebox** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |const|
  163. Returns the icon :ref:`StyleBox<class_StyleBox>` at ``name`` if the theme has ``type``.
  164. ----
  165. .. _class_Theme_method_get_stylebox_list:
  166. - :ref:`PoolStringArray<class_PoolStringArray>` **get_stylebox_list** **(** :ref:`String<class_String>` type **)** |const|
  167. Returns all the :ref:`StyleBox<class_StyleBox>`\ s as a :ref:`PoolStringArray<class_PoolStringArray>` filled with each :ref:`StyleBox<class_StyleBox>`'s name, for use in :ref:`get_stylebox<class_Theme_method_get_stylebox>`, if the theme has ``type``.
  168. ----
  169. .. _class_Theme_method_get_stylebox_types:
  170. - :ref:`PoolStringArray<class_PoolStringArray>` **get_stylebox_types** **(** **)** |const|
  171. Returns all the :ref:`StyleBox<class_StyleBox>` types as a :ref:`PoolStringArray<class_PoolStringArray>` filled with each :ref:`StyleBox<class_StyleBox>`'s type, for use in :ref:`get_stylebox<class_Theme_method_get_stylebox>` and/or :ref:`get_stylebox_list<class_Theme_method_get_stylebox_list>`, if the theme has ``type``.
  172. ----
  173. .. _class_Theme_method_get_type_list:
  174. - :ref:`PoolStringArray<class_PoolStringArray>` **get_type_list** **(** :ref:`String<class_String>` type **)** |const|
  175. Returns all the types in ``type`` as a :ref:`PoolStringArray<class_PoolStringArray>` for use in any of the ``get_*`` functions, if the theme has ``type``.
  176. ----
  177. .. _class_Theme_method_has_color:
  178. - :ref:`bool<class_bool>` **has_color** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |const|
  179. Returns ``true`` if :ref:`Color<class_Color>` with ``name`` is in ``type``.
  180. Returns ``false`` if the theme does not have ``type``.
  181. ----
  182. .. _class_Theme_method_has_constant:
  183. - :ref:`bool<class_bool>` **has_constant** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |const|
  184. Returns ``true`` if constant with ``name`` is in ``type``.
  185. Returns ``false`` if the theme does not have ``type``.
  186. ----
  187. .. _class_Theme_method_has_font:
  188. - :ref:`bool<class_bool>` **has_font** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |const|
  189. Returns ``true`` if :ref:`Font<class_Font>` with ``name`` is in ``type``.
  190. Returns ``false`` if the theme does not have ``type``.
  191. ----
  192. .. _class_Theme_method_has_icon:
  193. - :ref:`bool<class_bool>` **has_icon** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |const|
  194. Returns ``true`` if icon :ref:`Texture<class_Texture>` with ``name`` is in ``type``.
  195. Returns ``false`` if the theme does not have ``type``.
  196. ----
  197. .. _class_Theme_method_has_stylebox:
  198. - :ref:`bool<class_bool>` **has_stylebox** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type **)** |const|
  199. Returns ``true`` if :ref:`StyleBox<class_StyleBox>` with ``name`` is in ``type``.
  200. Returns ``false`` if the theme does not have ``type``.
  201. ----
  202. .. _class_Theme_method_set_color:
  203. - void **set_color** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type, :ref:`Color<class_Color>` color **)**
  204. Sets the theme's :ref:`Color<class_Color>` to ``color`` at ``name`` in ``type``.
  205. Does nothing if the theme does not have ``type``.
  206. ----
  207. .. _class_Theme_method_set_constant:
  208. - void **set_constant** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type, :ref:`int<class_int>` constant **)**
  209. Sets the theme's constant to ``constant`` at ``name`` in ``type``.
  210. Does nothing if the theme does not have ``type``.
  211. ----
  212. .. _class_Theme_method_set_font:
  213. - void **set_font** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type, :ref:`Font<class_Font>` font **)**
  214. Sets the theme's :ref:`Font<class_Font>` to ``font`` at ``name`` in ``type``.
  215. Does nothing if the theme does not have ``type``.
  216. ----
  217. .. _class_Theme_method_set_icon:
  218. - void **set_icon** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type, :ref:`Texture<class_Texture>` texture **)**
  219. Sets the theme's icon :ref:`Texture<class_Texture>` to ``texture`` at ``name`` in ``type``.
  220. Does nothing if the theme does not have ``type``.
  221. ----
  222. .. _class_Theme_method_set_stylebox:
  223. - void **set_stylebox** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` type, :ref:`StyleBox<class_StyleBox>` texture **)**
  224. Sets theme's :ref:`StyleBox<class_StyleBox>` to ``stylebox`` at ``name`` in ``type``.
  225. Does nothing if the theme does not have ``type``.
  226. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  227. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  228. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`