class_range.rst 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/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:`TextureProgressBar<class_TextureProgressBar>`
  11. Abstract base class for controls that represent a number within a range.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. Range is an abstract base class for controls that represent a number within a range, 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. | |bitfield|\[:ref:`SizeFlags<enum_Control_SizeFlags>`\] | size_flags_vertical | ``0`` (overrides :ref:`Control<class_Control_property_size_flags_vertical>`) |
  39. +--------------------------------------------------------+----------------------------------------------------------+------------------------------------------------------------------------------+
  40. | :ref:`float<class_float>` | :ref:`step<class_Range_property_step>` | ``0.01`` |
  41. +--------------------------------------------------------+----------------------------------------------------------+------------------------------------------------------------------------------+
  42. | :ref:`float<class_float>` | :ref:`value<class_Range_property_value>` | ``0.0`` |
  43. +--------------------------------------------------------+----------------------------------------------------------+------------------------------------------------------------------------------+
  44. .. rst-class:: classref-reftable-group
  45. Methods
  46. -------
  47. .. table::
  48. :widths: auto
  49. +--------+-------------------------------------------------------------------------------------------------------------------------+
  50. | |void| | :ref:`_value_changed<class_Range_private_method__value_changed>`\ (\ new_value\: :ref:`float<class_float>`\ ) |virtual| |
  51. +--------+-------------------------------------------------------------------------------------------------------------------------+
  52. | |void| | :ref:`set_value_no_signal<class_Range_method_set_value_no_signal>`\ (\ value\: :ref:`float<class_float>`\ ) |
  53. +--------+-------------------------------------------------------------------------------------------------------------------------+
  54. | |void| | :ref:`share<class_Range_method_share>`\ (\ with\: :ref:`Node<class_Node>`\ ) |
  55. +--------+-------------------------------------------------------------------------------------------------------------------------+
  56. | |void| | :ref:`unshare<class_Range_method_unshare>`\ (\ ) |
  57. +--------+-------------------------------------------------------------------------------------------------------------------------+
  58. .. rst-class:: classref-section-separator
  59. ----
  60. .. rst-class:: classref-descriptions-group
  61. Signals
  62. -------
  63. .. _class_Range_signal_changed:
  64. .. rst-class:: classref-signal
  65. **changed**\ (\ ) :ref:`🔗<class_Range_signal_changed>`
  66. 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.
  67. .. rst-class:: classref-item-separator
  68. ----
  69. .. _class_Range_signal_value_changed:
  70. .. rst-class:: classref-signal
  71. **value_changed**\ (\ value\: :ref:`float<class_float>`\ ) :ref:`🔗<class_Range_signal_value_changed>`
  72. 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.
  73. \ **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.
  74. .. rst-class:: classref-section-separator
  75. ----
  76. .. rst-class:: classref-descriptions-group
  77. Property Descriptions
  78. ---------------------
  79. .. _class_Range_property_allow_greater:
  80. .. rst-class:: classref-property
  81. :ref:`bool<class_bool>` **allow_greater** = ``false`` :ref:`🔗<class_Range_property_allow_greater>`
  82. .. rst-class:: classref-property-setget
  83. - |void| **set_allow_greater**\ (\ value\: :ref:`bool<class_bool>`\ )
  84. - :ref:`bool<class_bool>` **is_greater_allowed**\ (\ )
  85. If ``true``, :ref:`value<class_Range_property_value>` may be greater than :ref:`max_value<class_Range_property_max_value>`.
  86. .. rst-class:: classref-item-separator
  87. ----
  88. .. _class_Range_property_allow_lesser:
  89. .. rst-class:: classref-property
  90. :ref:`bool<class_bool>` **allow_lesser** = ``false`` :ref:`🔗<class_Range_property_allow_lesser>`
  91. .. rst-class:: classref-property-setget
  92. - |void| **set_allow_lesser**\ (\ value\: :ref:`bool<class_bool>`\ )
  93. - :ref:`bool<class_bool>` **is_lesser_allowed**\ (\ )
  94. If ``true``, :ref:`value<class_Range_property_value>` may be less than :ref:`min_value<class_Range_property_min_value>`.
  95. .. rst-class:: classref-item-separator
  96. ----
  97. .. _class_Range_property_exp_edit:
  98. .. rst-class:: classref-property
  99. :ref:`bool<class_bool>` **exp_edit** = ``false`` :ref:`🔗<class_Range_property_exp_edit>`
  100. .. rst-class:: classref-property-setget
  101. - |void| **set_exp_ratio**\ (\ value\: :ref:`bool<class_bool>`\ )
  102. - :ref:`bool<class_bool>` **is_ratio_exp**\ (\ )
  103. If ``true``, and :ref:`min_value<class_Range_property_min_value>` is greater than 0, :ref:`value<class_Range_property_value>` will be represented exponentially rather than linearly.
  104. .. rst-class:: classref-item-separator
  105. ----
  106. .. _class_Range_property_max_value:
  107. .. rst-class:: classref-property
  108. :ref:`float<class_float>` **max_value** = ``100.0`` :ref:`🔗<class_Range_property_max_value>`
  109. .. rst-class:: classref-property-setget
  110. - |void| **set_max**\ (\ value\: :ref:`float<class_float>`\ )
  111. - :ref:`float<class_float>` **get_max**\ (\ )
  112. Maximum value. Range is clamped if :ref:`value<class_Range_property_value>` is greater than :ref:`max_value<class_Range_property_max_value>`.
  113. .. rst-class:: classref-item-separator
  114. ----
  115. .. _class_Range_property_min_value:
  116. .. rst-class:: classref-property
  117. :ref:`float<class_float>` **min_value** = ``0.0`` :ref:`🔗<class_Range_property_min_value>`
  118. .. rst-class:: classref-property-setget
  119. - |void| **set_min**\ (\ value\: :ref:`float<class_float>`\ )
  120. - :ref:`float<class_float>` **get_min**\ (\ )
  121. Minimum value. Range is clamped if :ref:`value<class_Range_property_value>` is less than :ref:`min_value<class_Range_property_min_value>`.
  122. .. rst-class:: classref-item-separator
  123. ----
  124. .. _class_Range_property_page:
  125. .. rst-class:: classref-property
  126. :ref:`float<class_float>` **page** = ``0.0`` :ref:`🔗<class_Range_property_page>`
  127. .. rst-class:: classref-property-setget
  128. - |void| **set_page**\ (\ value\: :ref:`float<class_float>`\ )
  129. - :ref:`float<class_float>` **get_page**\ (\ )
  130. Page size. Used mainly for :ref:`ScrollBar<class_ScrollBar>`. A :ref:`ScrollBar<class_ScrollBar>`'s grabber length is the :ref:`ScrollBar<class_ScrollBar>`'s size multiplied by :ref:`page<class_Range_property_page>` over the difference between :ref:`min_value<class_Range_property_min_value>` and :ref:`max_value<class_Range_property_max_value>`.
  131. .. rst-class:: classref-item-separator
  132. ----
  133. .. _class_Range_property_ratio:
  134. .. rst-class:: classref-property
  135. :ref:`float<class_float>` **ratio** :ref:`🔗<class_Range_property_ratio>`
  136. .. rst-class:: classref-property-setget
  137. - |void| **set_as_ratio**\ (\ value\: :ref:`float<class_float>`\ )
  138. - :ref:`float<class_float>` **get_as_ratio**\ (\ )
  139. The value mapped between 0 and 1.
  140. .. rst-class:: classref-item-separator
  141. ----
  142. .. _class_Range_property_rounded:
  143. .. rst-class:: classref-property
  144. :ref:`bool<class_bool>` **rounded** = ``false`` :ref:`🔗<class_Range_property_rounded>`
  145. .. rst-class:: classref-property-setget
  146. - |void| **set_use_rounded_values**\ (\ value\: :ref:`bool<class_bool>`\ )
  147. - :ref:`bool<class_bool>` **is_using_rounded_values**\ (\ )
  148. If ``true``, :ref:`value<class_Range_property_value>` will always be rounded to the nearest integer.
  149. .. rst-class:: classref-item-separator
  150. ----
  151. .. _class_Range_property_step:
  152. .. rst-class:: classref-property
  153. :ref:`float<class_float>` **step** = ``0.01`` :ref:`🔗<class_Range_property_step>`
  154. .. rst-class:: classref-property-setget
  155. - |void| **set_step**\ (\ value\: :ref:`float<class_float>`\ )
  156. - :ref:`float<class_float>` **get_step**\ (\ )
  157. If greater than 0, :ref:`value<class_Range_property_value>` will always be rounded to a multiple of this property's value. If :ref:`rounded<class_Range_property_rounded>` is also ``true``, :ref:`value<class_Range_property_value>` will first be rounded to a multiple of this property's value, then rounded to the nearest integer.
  158. .. rst-class:: classref-item-separator
  159. ----
  160. .. _class_Range_property_value:
  161. .. rst-class:: classref-property
  162. :ref:`float<class_float>` **value** = ``0.0`` :ref:`🔗<class_Range_property_value>`
  163. .. rst-class:: classref-property-setget
  164. - |void| **set_value**\ (\ value\: :ref:`float<class_float>`\ )
  165. - :ref:`float<class_float>` **get_value**\ (\ )
  166. 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.
  167. .. rst-class:: classref-section-separator
  168. ----
  169. .. rst-class:: classref-descriptions-group
  170. Method Descriptions
  171. -------------------
  172. .. _class_Range_private_method__value_changed:
  173. .. rst-class:: classref-method
  174. |void| **_value_changed**\ (\ new_value\: :ref:`float<class_float>`\ ) |virtual| :ref:`🔗<class_Range_private_method__value_changed>`
  175. Called when the **Range**'s value is changed (following the same conditions as :ref:`value_changed<class_Range_signal_value_changed>`).
  176. .. rst-class:: classref-item-separator
  177. ----
  178. .. _class_Range_method_set_value_no_signal:
  179. .. rst-class:: classref-method
  180. |void| **set_value_no_signal**\ (\ value\: :ref:`float<class_float>`\ ) :ref:`🔗<class_Range_method_set_value_no_signal>`
  181. Sets the **Range**'s current value to the specified ``value``, without emitting the :ref:`value_changed<class_Range_signal_value_changed>` signal.
  182. .. rst-class:: classref-item-separator
  183. ----
  184. .. _class_Range_method_share:
  185. .. rst-class:: classref-method
  186. |void| **share**\ (\ with\: :ref:`Node<class_Node>`\ ) :ref:`🔗<class_Range_method_share>`
  187. 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.
  188. .. rst-class:: classref-item-separator
  189. ----
  190. .. _class_Range_method_unshare:
  191. .. rst-class:: classref-method
  192. |void| **unshare**\ (\ ) :ref:`🔗<class_Range_method_unshare>`
  193. Stops the **Range** from sharing its member variables with any other.
  194. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  195. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  196. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  197. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  198. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  199. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  200. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  201. .. |void| replace:: :abbr:`void (No return value.)`