class_range.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/Range.xml.
  6. .. _class_Range:
  7. Range
  8. =====
  9. **Inherits:** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`EditorSpinSlider<class_EditorSpinSlider>`, :ref:`ProgressBar<class_ProgressBar>`, :ref:`ScrollBar<class_ScrollBar>`, :ref:`Slider<class_Slider>`, :ref:`SpinBox<class_SpinBox>`, :ref:`TextureProgress<class_TextureProgress>`
  11. Abstract base class for range-based controls.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. Range is a base class for :ref:`Control<class_Control>` nodes that change a floating-point :ref:`value<class_Range_property_value>` between a :ref:`min_value<class_Range_property_min_value>` and :ref:`max_value<class_Range_property_max_value>`, using a configured :ref:`step<class_Range_property_step>` and :ref:`page<class_Range_property_page>` size. See e.g. :ref:`ScrollBar<class_ScrollBar>` and :ref:`Slider<class_Slider>` for examples of higher level nodes using Range.
  16. .. rst-class:: classref-reftable-group
  17. Properties
  18. ----------
  19. .. table::
  20. :widths: auto
  21. +---------------------------+----------------------------------------------------------+-----------+
  22. | :ref:`bool<class_bool>` | :ref:`allow_greater<class_Range_property_allow_greater>` | ``false`` |
  23. +---------------------------+----------------------------------------------------------+-----------+
  24. | :ref:`bool<class_bool>` | :ref:`allow_lesser<class_Range_property_allow_lesser>` | ``false`` |
  25. +---------------------------+----------------------------------------------------------+-----------+
  26. | :ref:`bool<class_bool>` | :ref:`exp_edit<class_Range_property_exp_edit>` | ``false`` |
  27. +---------------------------+----------------------------------------------------------+-----------+
  28. | :ref:`float<class_float>` | :ref:`max_value<class_Range_property_max_value>` | ``100.0`` |
  29. +---------------------------+----------------------------------------------------------+-----------+
  30. | :ref:`float<class_float>` | :ref:`min_value<class_Range_property_min_value>` | ``0.0`` |
  31. +---------------------------+----------------------------------------------------------+-----------+
  32. | :ref:`float<class_float>` | :ref:`page<class_Range_property_page>` | ``0.0`` |
  33. +---------------------------+----------------------------------------------------------+-----------+
  34. | :ref:`float<class_float>` | :ref:`ratio<class_Range_property_ratio>` | |
  35. +---------------------------+----------------------------------------------------------+-----------+
  36. | :ref:`bool<class_bool>` | :ref:`rounded<class_Range_property_rounded>` | ``false`` |
  37. +---------------------------+----------------------------------------------------------+-----------+
  38. | :ref:`float<class_float>` | :ref:`step<class_Range_property_step>` | ``1.0`` |
  39. +---------------------------+----------------------------------------------------------+-----------+
  40. | :ref:`float<class_float>` | :ref:`value<class_Range_property_value>` | ``0.0`` |
  41. +---------------------------+----------------------------------------------------------+-----------+
  42. .. rst-class:: classref-reftable-group
  43. Methods
  44. -------
  45. .. table::
  46. :widths: auto
  47. +------+----------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`set_value_no_signal<class_Range_method_set_value_no_signal>` **(** :ref:`float<class_float>` value **)** |
  49. +------+----------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`share<class_Range_method_share>` **(** :ref:`Node<class_Node>` with **)** |
  51. +------+----------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`unshare<class_Range_method_unshare>` **(** **)** |
  53. +------+----------------------------------------------------------------------------------------------------------------+
  54. .. rst-class:: classref-section-separator
  55. ----
  56. .. rst-class:: classref-descriptions-group
  57. Signals
  58. -------
  59. .. _class_Range_signal_changed:
  60. .. rst-class:: classref-signal
  61. **changed** **(** **)**
  62. Emitted when :ref:`min_value<class_Range_property_min_value>`, :ref:`max_value<class_Range_property_max_value>`, :ref:`page<class_Range_property_page>`, or :ref:`step<class_Range_property_step>` change.
  63. .. rst-class:: classref-item-separator
  64. ----
  65. .. _class_Range_signal_value_changed:
  66. .. rst-class:: classref-signal
  67. **value_changed** **(** :ref:`float<class_float>` value **)**
  68. Emitted when :ref:`value<class_Range_property_value>` changes. When used on a :ref:`Slider<class_Slider>`, this is called continuously while dragging (potentially every frame). If you are performing an expensive operation in a function connected to :ref:`value_changed<class_Range_signal_value_changed>`, consider using a *debouncing* :ref:`Timer<class_Timer>` to call the function less often.
  69. \ **Note:** Unlike signals such as :ref:`LineEdit.text_changed<class_LineEdit_signal_text_changed>`, :ref:`value_changed<class_Range_signal_value_changed>` is also emitted when ``value`` is set directly via code.
  70. .. rst-class:: classref-section-separator
  71. ----
  72. .. rst-class:: classref-descriptions-group
  73. Property Descriptions
  74. ---------------------
  75. .. _class_Range_property_allow_greater:
  76. .. rst-class:: classref-property
  77. :ref:`bool<class_bool>` **allow_greater** = ``false``
  78. .. rst-class:: classref-property-setget
  79. - void **set_allow_greater** **(** :ref:`bool<class_bool>` value **)**
  80. - :ref:`bool<class_bool>` **is_greater_allowed** **(** **)**
  81. If ``true``, :ref:`value<class_Range_property_value>` may be greater than :ref:`max_value<class_Range_property_max_value>`.
  82. .. rst-class:: classref-item-separator
  83. ----
  84. .. _class_Range_property_allow_lesser:
  85. .. rst-class:: classref-property
  86. :ref:`bool<class_bool>` **allow_lesser** = ``false``
  87. .. rst-class:: classref-property-setget
  88. - void **set_allow_lesser** **(** :ref:`bool<class_bool>` value **)**
  89. - :ref:`bool<class_bool>` **is_lesser_allowed** **(** **)**
  90. If ``true``, :ref:`value<class_Range_property_value>` may be less than :ref:`min_value<class_Range_property_min_value>`.
  91. .. rst-class:: classref-item-separator
  92. ----
  93. .. _class_Range_property_exp_edit:
  94. .. rst-class:: classref-property
  95. :ref:`bool<class_bool>` **exp_edit** = ``false``
  96. .. rst-class:: classref-property-setget
  97. - void **set_exp_ratio** **(** :ref:`bool<class_bool>` value **)**
  98. - :ref:`bool<class_bool>` **is_ratio_exp** **(** **)**
  99. If ``true``, and ``min_value`` is greater than 0, ``value`` will be represented exponentially rather than linearly.
  100. .. rst-class:: classref-item-separator
  101. ----
  102. .. _class_Range_property_max_value:
  103. .. rst-class:: classref-property
  104. :ref:`float<class_float>` **max_value** = ``100.0``
  105. .. rst-class:: classref-property-setget
  106. - void **set_max** **(** :ref:`float<class_float>` value **)**
  107. - :ref:`float<class_float>` **get_max** **(** **)**
  108. Maximum value. Range is clamped if ``value`` is greater than ``max_value``.
  109. .. rst-class:: classref-item-separator
  110. ----
  111. .. _class_Range_property_min_value:
  112. .. rst-class:: classref-property
  113. :ref:`float<class_float>` **min_value** = ``0.0``
  114. .. rst-class:: classref-property-setget
  115. - void **set_min** **(** :ref:`float<class_float>` value **)**
  116. - :ref:`float<class_float>` **get_min** **(** **)**
  117. Minimum value. Range is clamped if ``value`` is less than ``min_value``.
  118. .. rst-class:: classref-item-separator
  119. ----
  120. .. _class_Range_property_page:
  121. .. rst-class:: classref-property
  122. :ref:`float<class_float>` **page** = ``0.0``
  123. .. rst-class:: classref-property-setget
  124. - void **set_page** **(** :ref:`float<class_float>` value **)**
  125. - :ref:`float<class_float>` **get_page** **(** **)**
  126. Page size. Used mainly for :ref:`ScrollBar<class_ScrollBar>`. ScrollBar's length is its size multiplied by ``page`` over the difference between ``min_value`` and ``max_value``.
  127. .. rst-class:: classref-item-separator
  128. ----
  129. .. _class_Range_property_ratio:
  130. .. rst-class:: classref-property
  131. :ref:`float<class_float>` **ratio**
  132. .. rst-class:: classref-property-setget
  133. - void **set_as_ratio** **(** :ref:`float<class_float>` value **)**
  134. - :ref:`float<class_float>` **get_as_ratio** **(** **)**
  135. The value mapped between 0 and 1.
  136. .. rst-class:: classref-item-separator
  137. ----
  138. .. _class_Range_property_rounded:
  139. .. rst-class:: classref-property
  140. :ref:`bool<class_bool>` **rounded** = ``false``
  141. .. rst-class:: classref-property-setget
  142. - void **set_use_rounded_values** **(** :ref:`bool<class_bool>` value **)**
  143. - :ref:`bool<class_bool>` **is_using_rounded_values** **(** **)**
  144. If ``true``, ``value`` will always be rounded to the nearest integer.
  145. .. rst-class:: classref-item-separator
  146. ----
  147. .. _class_Range_property_step:
  148. .. rst-class:: classref-property
  149. :ref:`float<class_float>` **step** = ``1.0``
  150. .. rst-class:: classref-property-setget
  151. - void **set_step** **(** :ref:`float<class_float>` value **)**
  152. - :ref:`float<class_float>` **get_step** **(** **)**
  153. If greater than 0, ``value`` will always be rounded to a multiple of ``step``. If ``rounded`` is also ``true``, ``value`` will first be rounded to a multiple of ``step`` then rounded to the nearest integer.
  154. .. rst-class:: classref-item-separator
  155. ----
  156. .. _class_Range_property_value:
  157. .. rst-class:: classref-property
  158. :ref:`float<class_float>` **value** = ``0.0``
  159. .. rst-class:: classref-property-setget
  160. - void **set_value** **(** :ref:`float<class_float>` value **)**
  161. - :ref:`float<class_float>` **get_value** **(** **)**
  162. Range's current value. Changing this property (even via code) will trigger :ref:`value_changed<class_Range_signal_value_changed>` signal. Use :ref:`set_value_no_signal<class_Range_method_set_value_no_signal>` if you want to avoid it.
  163. .. rst-class:: classref-section-separator
  164. ----
  165. .. rst-class:: classref-descriptions-group
  166. Method Descriptions
  167. -------------------
  168. .. _class_Range_method_set_value_no_signal:
  169. .. rst-class:: classref-method
  170. void **set_value_no_signal** **(** :ref:`float<class_float>` value **)**
  171. Sets the **Range**'s current value to the specified :ref:`value<class_Range_property_value>`, without emitting the :ref:`value_changed<class_Range_signal_value_changed>` signal.
  172. .. rst-class:: classref-item-separator
  173. ----
  174. .. _class_Range_method_share:
  175. .. rst-class:: classref-method
  176. void **share** **(** :ref:`Node<class_Node>` with **)**
  177. Binds two **Range**\ s together along with any ranges previously grouped with either of them. When any of range's member variables change, it will share the new value with all other ranges in its group.
  178. .. rst-class:: classref-item-separator
  179. ----
  180. .. _class_Range_method_unshare:
  181. .. rst-class:: classref-method
  182. void **unshare** **(** **)**
  183. Stops the **Range** from sharing its member variables with any other.
  184. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  185. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  186. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  187. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`