From f16ff829f0509ae2ce4222b249a56b581a114641 Mon Sep 17 00:00:00 2001 From: Michael Alexsander Date: Fri, 12 Sep 2025 12:40:07 -0300 Subject: [PATCH] Allow to use sliders for integers in `EditorSpinSlider` --- core/config/project_settings.cpp | 2 +- core/object/object.h | 2 +- doc/classes/@GlobalScope.xml | 2 +- doc/classes/EditorSettings.xml | 3 + doc/classes/EditorSpinSlider.xml | 18 ++- editor/animation/animation_track_editor.cpp | 4 +- editor/gui/editor_spin_slider.cpp | 74 ++++++++---- editor/gui/editor_spin_slider.h | 17 ++- editor/inspector/editor_properties.cpp | 106 +++++++++++------- editor/inspector/editor_properties.h | 20 ++-- editor/inspector/editor_properties_vector.cpp | 6 +- editor/inspector/editor_properties_vector.h | 2 +- .../2d/tiles/tile_proxies_manager_dialog.cpp | 8 +- editor/scene/gui/font_config_plugin.cpp | 4 +- editor/settings/editor_settings.cpp | 1 + modules/gdscript/doc_classes/@GDScript.xml | 2 +- modules/gdscript/gdscript_editor.cpp | 5 +- scene/2d/node_2d.cpp | 2 +- scene/3d/node_3d.cpp | 2 +- scene/3d/spring_bone_simulator_3d.cpp | 2 +- scene/animation/animation_blend_tree.cpp | 4 +- 21 files changed, 189 insertions(+), 97 deletions(-) diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 75dfdaaa136..c81c296ce55 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -1698,7 +1698,7 @@ ProjectSettings::ProjectSettings() { // installed by the scripts provided in the repository // (check `misc/scripts/install_d3d12_sdk_windows.py`). // For example, if the script installs 1.613.3, the default value must be 613. - GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/rendering_device/d3d12/agility_sdk_version", PROPERTY_HINT_RANGE, "0,10000,1,or_greater,hide_slider"), 613); + GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/rendering_device/d3d12/agility_sdk_version", PROPERTY_HINT_RANGE, "0,10000,1,or_greater,hide_control"), 613); GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "rendering/textures/canvas_textures/default_texture_filter", PROPERTY_HINT_ENUM, "Nearest,Linear,Linear Mipmap,Nearest Mipmap"), 1); GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "rendering/textures/canvas_textures/default_texture_repeat", PROPERTY_HINT_ENUM, "Disable,Enable,Mirror"), 0); diff --git a/core/object/object.h b/core/object/object.h index c0e33457973..49f490a66a6 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -51,7 +51,7 @@ class Ref; enum PropertyHint { PROPERTY_HINT_NONE, ///< no hint provided. - PROPERTY_HINT_RANGE, ///< hint_text = "min,max[,step][,or_greater][,or_less][,hide_slider][,radians_as_degrees][,degrees][,exp][,suffix:] range. + PROPERTY_HINT_RANGE, ///< hint_text = "min,max[,step][,or_greater][,or_less][,prefer_slider][,hide_control][,radians_as_degrees][,degrees][,exp][,suffix:] range. PROPERTY_HINT_ENUM, ///< hint_text= "val1,val2,val3,etc" PROPERTY_HINT_ENUM_SUGGESTION, ///< hint_text= "val1,val2,val3,etc" PROPERTY_HINT_EXP_EASING, /// exponential easing function (Math::ease) use "attenuation" hint string to revert (flip h), "positive_only" to exclude in-out and out-in. (ie: "attenuation,positive_only") diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index f04f500f823..66d31907bd5 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -2771,7 +2771,7 @@ Hints that an [int] or [float] property should be within a range specified via the hint string [code]"min,max"[/code] or [code]"min,max,step"[/code]. The hint string can optionally include [code]"or_greater"[/code] and/or [code]"or_less"[/code] to allow manual input going respectively above the max or below the min values. [b]Example:[/b] [code]"-360,360,1,or_greater,or_less"[/code]. - Additionally, other keywords can be included: [code]"exp"[/code] for exponential range editing, [code]"radians_as_degrees"[/code] for editing radian angles in degrees (the range values are also in degrees), [code]"degrees"[/code] to hint at an angle and [code]"hide_slider"[/code] to hide the slider. + Additionally, other keywords can be included: [code]"exp"[/code] for exponential range editing, [code]"radians_as_degrees"[/code] for editing radian angles in degrees (the range values are also in degrees), [code]"degrees"[/code] to hint at an angle, [code]"prefer_slider"[/code] to show the slider for integers, and [code]"hide_control"[/code] to hide the slider or up-down arrows. Hints that an [int] or [String] property is an enumerated value to pick in a list specified via a hint string. diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml index 9f0472d683f..f11bd0f0202 100644 --- a/doc/classes/EditorSettings.xml +++ b/doc/classes/EditorSettings.xml @@ -1027,6 +1027,9 @@ If [code]true[/code], [Vector3], [Vector3i], [Vector4], [Vector4i], [Rect2], [Rect2i], [Plane], and [Quaternion] properties are shown on a single line in the inspector instead of multiple lines. This is overall more compact, but it can be harder to view and edit large values without expanding the inspector horizontally. + + Base speed for increasing/decreasing integer values by dragging them in the inspector. + The number of [Array] or [Dictionary] items to display on each "page" in the inspector. Higher values allow viewing more values per page, but take more time to load. This increased load time is noticeable when selecting nodes that have array or dictionary properties in the editor. diff --git a/doc/classes/EditorSpinSlider.xml b/doc/classes/EditorSpinSlider.xml index b0b3f0faf76..c9762c40fff 100644 --- a/doc/classes/EditorSpinSlider.xml +++ b/doc/classes/EditorSpinSlider.xml @@ -10,14 +10,17 @@ + + The state in which the control used to manipulate the value will be. + - If [code]true[/code], the [EditorSpinSlider] is considered to be editing an integer value. If [code]false[/code], the [EditorSpinSlider] is considered to be editing a floating-point value. This is used to determine whether a slider should be drawn. The slider is only drawn for floats; integers use up-down arrows similar to [SpinBox] instead. + If [code]true[/code], the [EditorSpinSlider] is considered to be editing an integer value. If [code]false[/code], the [EditorSpinSlider] is considered to be editing a floating-point value. This is used to determine whether a slider should be drawn by default. The slider is only drawn for floats; integers use up-down arrows similar to [SpinBox] instead, unless [member control_state] is set to [constant CONTROL_STATE_PREFER_SLIDER]. It will also use [member EditorSettings.interface/inspector/integer_drag_speed] instead of [member EditorSettings.interface/inspector/float_drag_speed] if the slider is available. If [code]true[/code], the slider will not draw background. - + If [code]true[/code], the slider and up/down arrows are hidden. @@ -59,6 +62,17 @@ + + + The type of control used will depend on the value of [member editing_integer]. Up-down arrows if [code]true[/code], a slider if [code]false[/code]. + + + A slider will always be used, even if [member editing_integer] is enabled. + + + Neither the up-down arrows nor the slider will be shown. + + Single texture representing both the up and down buttons. diff --git a/editor/animation/animation_track_editor.cpp b/editor/animation/animation_track_editor.cpp index ecec00a4884..c26f65dc3fe 100644 --- a/editor/animation/animation_track_editor.cpp +++ b/editor/animation/animation_track_editor.cpp @@ -2051,7 +2051,7 @@ AnimationTimelineEdit::AnimationTimelineEdit() { length->set_step(SECOND_DECIMAL); length->set_allow_greater(true); length->set_custom_minimum_size(Vector2(70 * EDSCALE, 0)); - length->set_hide_slider(true); + length->set_control_state(EditorSpinSlider::CONTROL_STATE_HIDE); length->set_tooltip_text(TTR("Animation length (seconds)")); length->set_accessibility_name(TTRC("Animation length (seconds)")); length->connect(SceneStringName(value_changed), callable_mp(this, &AnimationTimelineEdit::_anim_length_changed)); @@ -7970,7 +7970,7 @@ AnimationTrackEditor::AnimationTrackEditor() { step->set_min(0); step->set_max(1000000); step->set_step(SECOND_DECIMAL); - step->set_hide_slider(true); + step->set_control_state(EditorSpinSlider::CONTROL_STATE_HIDE); step->set_custom_minimum_size(Size2(100, 0) * EDSCALE); step->set_tooltip_text(TTR("Animation step value.")); step->set_accessibility_name(TTRC("Animation step value.")); diff --git a/editor/gui/editor_spin_slider.cpp b/editor/gui/editor_spin_slider.cpp index ed3afd07d6e..9cf43c1e66d 100644 --- a/editor/gui/editor_spin_slider.cpp +++ b/editor/gui/editor_spin_slider.cpp @@ -38,15 +38,20 @@ #include "scene/theme/theme_db.h" String EditorSpinSlider::get_tooltip(const Point2 &p_pos) const { + String value = get_text_value() + suffix; if (!read_only && grabber->is_visible()) { + String tooltip = value; Key key = (OS::get_singleton()->has_feature("macos") || OS::get_singleton()->has_feature("web_macos") || OS::get_singleton()->has_feature("web_ios")) ? Key::META : Key::CTRL; - return TS->format_number(rtos(get_value())) + suffix + "\n\n" + vformat(TTR("Hold %s to round to integers.\nHold Shift for more precise changes."), find_keycode_name(key)); + if (!editing_integer) { + tooltip += "\n\n" + vformat(TTR("Hold %s to round to integers."), find_keycode_name(key)); + } + return tooltip + "\n" + TTR("Hold Shift for more precise changes."); } - return TS->format_number(rtos(get_value())) + suffix; + return value; } String EditorSpinSlider::get_text_value() const { - return TS->format_number(String::num(get_value(), Math::range_step_decimals(get_step()))); + return TS->format_number(editing_integer ? itos(get_value()) : rtos(get_value())); } void EditorSpinSlider::gui_input(const Ref &p_event) { @@ -109,17 +114,8 @@ void EditorSpinSlider::gui_input(const Ref &p_event) { pre_grab_value = get_max(); } - if (mm->is_command_or_control_pressed()) { - // If control was just pressed, don't make the value do a huge jump in magnitude. - if (grabbing_spinner_dist_cache != 0) { - pre_grab_value += grabbing_spinner_dist_cache * get_step(); - grabbing_spinner_dist_cache = 0; - } - - set_value(Math::round(pre_grab_value + get_step() * grabbing_spinner_dist_cache * 10)); - } else { - set_value(pre_grab_value + get_step() * grabbing_spinner_dist_cache); - } + double new_value = pre_grab_value + get_step() * grabbing_spinner_dist_cache; + set_value((mm->is_command_or_control_pressed() && !editing_integer) ? Math::round(new_value) : new_value); } } else if (updown_offset != -1) { bool new_hover = (!is_layout_rtl() && mm->get_position().x > updown_offset) || (is_layout_rtl() && mm->get_position().x < updown_offset); @@ -158,6 +154,7 @@ void EditorSpinSlider::_grab_end() { if (grabbing_spinner) { Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE); Input::get_singleton()->warp_mouse(grabbing_spinner_mouse_pos); + mouse_over_grabber = true; queue_redraw(); grabbing_spinner = false; emit_signal("ungrabbed"); @@ -207,7 +204,12 @@ void EditorSpinSlider::_grabber_gui_input(const Ref &p_event) { grab_focus(); emit_signal("grabbed"); } else { - grabbing_grabber = false; + if (grabbing_grabber) { + grabbing_grabber = false; + if (!mouse_over_grabber) { + queue_redraw(); + } + } mousewheel_over_grabber = false; emit_signal("ungrabbed"); } @@ -377,8 +379,8 @@ void EditorSpinSlider::_draw_spin_slider() { } TS->free_rid(num_rid); - if (!hide_slider) { - if (editing_integer) { + if (control_state != CONTROL_STATE_HIDE) { + if (editing_integer && control_state == CONTROL_STATE_DEFAULT) { Ref updown2 = read_only ? theme_cache.updown_disabled_icon : theme_cache.updown_icon; int updown_vofs = (size.height - updown2->get_height()) / 2; if (rtl) { @@ -427,7 +429,7 @@ void EditorSpinSlider::_draw_spin_slider() { if (display_grabber) { Ref grabber_tex; - if (mouse_over_grabber) { + if (mouse_over_grabber || grabbing_grabber) { grabber_tex = get_theme_icon(SNAME("grabber_highlight"), SNAME("HSlider")); } else { grabber_tex = get_theme_icon(SNAME("grabber"), SNAME("HSlider")); @@ -453,7 +455,7 @@ void EditorSpinSlider::_draw_spin_slider() { void EditorSpinSlider::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - grabbing_spinner_speed = EDITOR_GET("interface/inspector/float_drag_speed"); + grabbing_spinner_speed = editing_integer ? EDITOR_GET("interface/inspector/integer_drag_speed") : EDITOR_GET("interface/inspector/float_drag_speed"); _update_value_input_stylebox(); } break; @@ -523,22 +525,35 @@ Size2 EditorSpinSlider::get_minimum_size() const { return ms; } -void EditorSpinSlider::set_hide_slider(bool p_hide) { - hide_slider = p_hide; +void EditorSpinSlider::set_control_state(ControlState p_state) { + control_state = p_state; queue_redraw(); } -bool EditorSpinSlider::is_hiding_slider() const { - return hide_slider; +EditorSpinSlider::ControlState EditorSpinSlider::get_control_state() const { + return control_state; } +#ifndef DISABLE_DEPRECATED +void EditorSpinSlider::set_hide_slider(bool p_hide) { + set_control_state(p_hide ? CONTROL_STATE_HIDE : CONTROL_STATE_DEFAULT); +} + +bool EditorSpinSlider::is_hiding_slider() const { + return control_state == CONTROL_STATE_HIDE; +} +#endif + void EditorSpinSlider::set_editing_integer(bool p_editing_integer) { if (p_editing_integer == editing_integer) { return; } editing_integer = p_editing_integer; - queue_redraw(); + if (is_inside_tree()) { + grabbing_spinner_speed = editing_integer ? EDITOR_GET("interface/inspector/integer_drag_speed") : EDITOR_GET("interface/inspector/float_drag_speed"); + queue_redraw(); + } } bool EditorSpinSlider::is_editing_integer() const { @@ -701,8 +716,12 @@ void EditorSpinSlider::_bind_methods() { ClassDB::bind_method(D_METHOD("set_flat", "flat"), &EditorSpinSlider::set_flat); ClassDB::bind_method(D_METHOD("is_flat"), &EditorSpinSlider::is_flat); + ClassDB::bind_method(D_METHOD("set_control_state", "state"), &EditorSpinSlider::set_control_state); + ClassDB::bind_method(D_METHOD("get_control_state"), &EditorSpinSlider::get_control_state); +#ifndef DISABLE_DEPRECATED ClassDB::bind_method(D_METHOD("set_hide_slider", "hide_slider"), &EditorSpinSlider::set_hide_slider); ClassDB::bind_method(D_METHOD("is_hiding_slider"), &EditorSpinSlider::is_hiding_slider); +#endif ClassDB::bind_method(D_METHOD("set_editing_integer", "editing_integer"), &EditorSpinSlider::set_editing_integer); ClassDB::bind_method(D_METHOD("is_editing_integer"), &EditorSpinSlider::is_editing_integer); @@ -711,9 +730,16 @@ void EditorSpinSlider::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::STRING, "suffix"), "set_suffix", "get_suffix"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "read_only"), "set_read_only", "is_read_only"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flat"), "set_flat", "is_flat"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "control_state"), "set_control_state", "get_control_state"); +#ifndef DISABLE_DEPRECATED ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hide_slider"), "set_hide_slider", "is_hiding_slider"); +#endif ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editing_integer"), "set_editing_integer", "is_editing_integer"); + BIND_ENUM_CONSTANT(CONTROL_STATE_DEFAULT); + BIND_ENUM_CONSTANT(CONTROL_STATE_PREFER_SLIDER); + BIND_ENUM_CONSTANT(CONTROL_STATE_HIDE); + ADD_SIGNAL(MethodInfo("grabbed")); ADD_SIGNAL(MethodInfo("ungrabbed")); ADD_SIGNAL(MethodInfo("updown_pressed")); diff --git a/editor/gui/editor_spin_slider.h b/editor/gui/editor_spin_slider.h index d6a4c171b86..396a2b2e227 100644 --- a/editor/gui/editor_spin_slider.h +++ b/editor/gui/editor_spin_slider.h @@ -68,7 +68,15 @@ class EditorSpinSlider : public Range { uint64_t value_input_closed_frame = 0; bool value_input_dirty = false; - bool hide_slider = false; +public: + enum ControlState { + CONTROL_STATE_DEFAULT, + CONTROL_STATE_PREFER_SLIDER, + CONTROL_STATE_HIDE, + }; + +private: + ControlState control_state = CONTROL_STATE_DEFAULT; bool flat = false; bool editing_integer = false; @@ -110,8 +118,13 @@ public: void set_suffix(const String &p_suffix); String get_suffix() const; + void set_control_state(ControlState p_type); + ControlState get_control_state() const; + +#ifndef DISABLE_DEPRECATED void set_hide_slider(bool p_hide); bool is_hiding_slider() const; +#endif void set_editing_integer(bool p_editing_integer); bool is_editing_integer() const; @@ -130,3 +143,5 @@ public: virtual Size2 get_minimum_size() const override; EditorSpinSlider(); }; + +VARIANT_ENUM_CAST(EditorSpinSlider::ControlState) diff --git a/editor/inspector/editor_properties.cpp b/editor/inspector/editor_properties.cpp index 3c7bb98700f..93384bda9c3 100644 --- a/editor/inspector/editor_properties.cpp +++ b/editor/inspector/editor_properties.cpp @@ -1466,11 +1466,15 @@ void EditorPropertyInteger::update_property() { #endif } -void EditorPropertyInteger::setup(int64_t p_min, int64_t p_max, int64_t p_step, bool p_hide_slider, bool p_allow_greater, bool p_allow_lesser, const String &p_suffix) { +void EditorPropertyInteger::setup(int64_t p_min, int64_t p_max, int64_t p_step, bool p_prefer_slider, bool p_hide_control, bool p_allow_greater, bool p_allow_lesser, const String &p_suffix) { spin->set_min(p_min); spin->set_max(p_max); spin->set_step(p_step); - spin->set_hide_slider(p_hide_slider); + if (p_hide_control) { + spin->set_control_state(EditorSpinSlider::CONTROL_STATE_HIDE); + } else { + spin->set_control_state(p_prefer_slider ? EditorSpinSlider::CONTROL_STATE_PREFER_SLIDER : EditorSpinSlider::CONTROL_STATE_DEFAULT); + } spin->set_allow_greater(p_allow_greater); spin->set_allow_lesser(p_allow_lesser); spin->set_suffix(p_suffix); @@ -1593,12 +1597,14 @@ void EditorPropertyFloat::update_property() { spin->set_value_no_signal(val); } -void EditorPropertyFloat::setup(double p_min, double p_max, double p_step, bool p_hide_slider, bool p_exp_range, bool p_greater, bool p_lesser, const String &p_suffix, bool p_radians_as_degrees) { +void EditorPropertyFloat::setup(double p_min, double p_max, double p_step, bool p_hide_control, bool p_exp_range, bool p_greater, bool p_lesser, const String &p_suffix, bool p_radians_as_degrees) { radians_as_degrees = p_radians_as_degrees; spin->set_min(p_min); spin->set_max(p_max); spin->set_step(p_step); - spin->set_hide_slider(p_hide_slider); + if (p_hide_control) { + spin->set_control_state(EditorSpinSlider::CONTROL_STATE_HIDE); + } spin->set_exp_ratio(p_exp_range); spin->set_allow_greater(p_greater); spin->set_allow_lesser(p_lesser); @@ -1815,7 +1821,7 @@ EditorPropertyEasing::EditorPropertyEasing() { spin->set_min(-100); spin->set_max(100); spin->set_step(0); - spin->set_hide_slider(true); + spin->set_control_state(EditorSpinSlider::CONTROL_STATE_HIDE); spin->set_allow_lesser(true); spin->set_allow_greater(true); spin->connect(SceneStringName(value_changed), callable_mp(this, &EditorPropertyEasing::_spin_value_changed)); @@ -1860,12 +1866,14 @@ void EditorPropertyRect2::_notification(int p_what) { } } -void EditorPropertyRect2::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix) { +void EditorPropertyRect2::setup(double p_min, double p_max, double p_step, bool p_hide_control, const String &p_suffix) { for (int i = 0; i < 4; i++) { spin[i]->set_min(p_min); spin[i]->set_max(p_max); spin[i]->set_step(p_step); - spin[i]->set_hide_slider(p_hide_slider); + if (p_hide_control) { + spin[i]->set_control_state(EditorSpinSlider::CONTROL_STATE_HIDE); + } spin[i]->set_allow_greater(true); spin[i]->set_allow_lesser(true); spin[i]->set_suffix(p_suffix); @@ -2048,12 +2056,14 @@ void EditorPropertyPlane::_notification(int p_what) { } } -void EditorPropertyPlane::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix) { +void EditorPropertyPlane::setup(double p_min, double p_max, double p_step, bool p_hide_control, const String &p_suffix) { for (int i = 0; i < 4; i++) { spin[i]->set_min(p_min); spin[i]->set_max(p_max); spin[i]->set_step(p_step); - spin[i]->set_hide_slider(p_hide_slider); + if (p_hide_control) { + spin[i]->set_control_state(EditorSpinSlider::CONTROL_STATE_HIDE); + } spin[i]->set_allow_greater(true); spin[i]->set_allow_lesser(true); } @@ -2197,12 +2207,14 @@ void EditorPropertyQuaternion::_notification(int p_what) { } } -void EditorPropertyQuaternion::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix, bool p_hide_editor) { +void EditorPropertyQuaternion::setup(double p_min, double p_max, double p_step, bool p_hide_control, const String &p_suffix, bool p_hide_editor) { for (int i = 0; i < 4; i++) { spin[i]->set_min(p_min); spin[i]->set_max(p_max); spin[i]->set_step(p_step); - spin[i]->set_hide_slider(p_hide_slider); + if (p_hide_control) { + spin[i]->set_control_state(EditorSpinSlider::CONTROL_STATE_HIDE); + } spin[i]->set_allow_greater(true); spin[i]->set_allow_lesser(true); // Quaternion is inherently unitless, however someone may want to use it as @@ -2214,7 +2226,6 @@ void EditorPropertyQuaternion::setup(double p_min, double p_max, double p_step, euler[i]->set_min(-360); euler[i]->set_max(360); euler[i]->set_step(0.1); - euler[i]->set_hide_slider(false); euler[i]->set_allow_greater(true); euler[i]->set_allow_lesser(true); euler[i]->set_suffix(U"\u00B0"); @@ -2343,12 +2354,14 @@ void EditorPropertyAABB::_notification(int p_what) { } } -void EditorPropertyAABB::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix) { +void EditorPropertyAABB::setup(double p_min, double p_max, double p_step, bool p_hide_control, const String &p_suffix) { for (int i = 0; i < 6; i++) { spin[i]->set_min(p_min); spin[i]->set_max(p_max); spin[i]->set_step(p_step); - spin[i]->set_hide_slider(p_hide_slider); + if (p_hide_control) { + spin[i]->set_control_state(EditorSpinSlider::CONTROL_STATE_HIDE); + } spin[i]->set_allow_greater(true); spin[i]->set_allow_lesser(true); spin[i]->set_suffix(p_suffix); @@ -2421,12 +2434,14 @@ void EditorPropertyTransform2D::_notification(int p_what) { } } -void EditorPropertyTransform2D::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix) { +void EditorPropertyTransform2D::setup(double p_min, double p_max, double p_step, bool p_hide_control, const String &p_suffix) { for (int i = 0; i < 6; i++) { spin[i]->set_min(p_min); spin[i]->set_max(p_max); spin[i]->set_step(p_step); - spin[i]->set_hide_slider(p_hide_slider); + if (p_hide_control) { + spin[i]->set_control_state(EditorSpinSlider::CONTROL_STATE_HIDE); + } spin[i]->set_allow_greater(true); spin[i]->set_allow_lesser(true); if (i % 3 == 2) { @@ -2503,12 +2518,14 @@ void EditorPropertyBasis::_notification(int p_what) { } } -void EditorPropertyBasis::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix) { +void EditorPropertyBasis::setup(double p_min, double p_max, double p_step, bool p_hide_control, const String &p_suffix) { for (int i = 0; i < 9; i++) { spin[i]->set_min(p_min); spin[i]->set_max(p_max); spin[i]->set_step(p_step); - spin[i]->set_hide_slider(p_hide_slider); + if (p_hide_control) { + spin[i]->set_control_state(EditorSpinSlider::CONTROL_STATE_HIDE); + } spin[i]->set_allow_greater(true); spin[i]->set_allow_lesser(true); // Basis is inherently unitless, however someone may want to use it as @@ -2592,12 +2609,14 @@ void EditorPropertyTransform3D::_notification(int p_what) { } } -void EditorPropertyTransform3D::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix) { +void EditorPropertyTransform3D::setup(double p_min, double p_max, double p_step, bool p_hide_control, const String &p_suffix) { for (int i = 0; i < 12; i++) { spin[i]->set_min(p_min); spin[i]->set_max(p_max); spin[i]->set_step(p_step); - spin[i]->set_hide_slider(p_hide_slider); + if (p_hide_control) { + spin[i]->set_control_state(EditorSpinSlider::CONTROL_STATE_HIDE); + } spin[i]->set_allow_greater(true); spin[i]->set_allow_lesser(true); if (i % 4 == 3) { @@ -2689,12 +2708,14 @@ void EditorPropertyProjection::_notification(int p_what) { } } -void EditorPropertyProjection::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix) { +void EditorPropertyProjection::setup(double p_min, double p_max, double p_step, bool p_hide_control, const String &p_suffix) { for (int i = 0; i < 16; i++) { spin[i]->set_min(p_min); spin[i]->set_max(p_max); spin[i]->set_step(p_step); - spin[i]->set_hide_slider(p_hide_slider); + if (p_hide_control) { + spin[i]->set_control_state(EditorSpinSlider::CONTROL_STATE_HIDE); + } spin[i]->set_allow_greater(true); spin[i]->set_allow_lesser(true); if (i % 4 == 3) { @@ -3603,7 +3624,8 @@ struct EditorPropertyRangeHint { double step = 1.0; String suffix; bool exp_range = false; - bool hide_slider = true; + bool prefer_slider = false; + bool hide_control = true; bool radians_as_degrees = false; }; @@ -3611,7 +3633,7 @@ static EditorPropertyRangeHint _parse_range_hint(PropertyHint p_hint, const Stri EditorPropertyRangeHint hint; hint.step = p_default_step; if (is_int) { - hint.hide_slider = false; // Always show slider for ints, unless specified in hint range. + hint.hide_control = false; // Always show controls for ints, unless specified in hint range. } Vector slices = p_hint_text.split(","); if (p_hint == PROPERTY_HINT_RANGE) { @@ -3628,15 +3650,21 @@ static EditorPropertyRangeHint _parse_range_hint(PropertyHint p_hint, const Stri // Step is optional, could be something else if not a number. hint.step = slices[2].to_float(); } - hint.hide_slider = false; + hint.hide_control = false; for (int i = 2; i < slices.size(); i++) { String slice = slices[i].strip_edges(); if (slice == "or_greater") { hint.or_greater = true; } else if (slice == "or_less") { hint.or_less = true; + } else if (slice == "prefer_slider") { + hint.prefer_slider = true; + } else if (slice == "hide_control") { + hint.hide_control = true; +#ifndef DISABLE_DEPRECATED } else if (slice == "hide_slider") { - hint.hide_slider = true; + hint.hide_control = true; +#endif } else if (slice == "exp") { hint.exp_range = true; } @@ -3774,7 +3802,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ EditorPropertyInteger *editor = memnew(EditorPropertyInteger); EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1, true); - editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, hint.or_greater, hint.or_less, hint.suffix); + editor->setup(hint.min, hint.max, hint.step, hint.prefer_slider, hint.hide_control, hint.or_greater, hint.or_less, hint.suffix); return editor; } @@ -3802,7 +3830,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ EditorPropertyFloat *editor = memnew(EditorPropertyFloat); EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, default_float_step); - editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, hint.exp_range, hint.or_greater, hint.or_less, hint.suffix, hint.radians_as_degrees); + editor->setup(hint.min, hint.max, hint.step, hint.hide_control, hint.exp_range, hint.or_greater, hint.or_less, hint.suffix, hint.radians_as_degrees); return editor; } @@ -3859,7 +3887,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ EditorPropertyVector2 *editor = memnew(EditorPropertyVector2(p_wide)); EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, default_float_step); - editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, p_hint == PROPERTY_HINT_LINK, hint.suffix, hint.radians_as_degrees); + editor->setup(hint.min, hint.max, hint.step, hint.hide_control, p_hint == PROPERTY_HINT_LINK, hint.suffix, hint.radians_as_degrees); return editor; } break; @@ -3873,7 +3901,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ case Variant::RECT2: { EditorPropertyRect2 *editor = memnew(EditorPropertyRect2(p_wide)); EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, default_float_step); - editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, hint.suffix); + editor->setup(hint.min, hint.max, hint.step, hint.hide_control, hint.suffix); return editor; } break; case Variant::RECT2I: { @@ -3886,7 +3914,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ case Variant::VECTOR3: { EditorPropertyVector3 *editor = memnew(EditorPropertyVector3(p_wide)); EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, default_float_step); - editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, p_hint == PROPERTY_HINT_LINK, hint.suffix, hint.radians_as_degrees); + editor->setup(hint.min, hint.max, hint.step, hint.hide_control, p_hint == PROPERTY_HINT_LINK, hint.suffix, hint.radians_as_degrees); return editor; } break; @@ -3900,7 +3928,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ case Variant::VECTOR4: { EditorPropertyVector4 *editor = memnew(EditorPropertyVector4); EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, default_float_step); - editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, p_hint == PROPERTY_HINT_LINK, hint.suffix, hint.radians_as_degrees); + editor->setup(hint.min, hint.max, hint.step, hint.hide_control, p_hint == PROPERTY_HINT_LINK, hint.suffix, hint.radians_as_degrees); return editor; } break; @@ -3914,44 +3942,44 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ case Variant::TRANSFORM2D: { EditorPropertyTransform2D *editor = memnew(EditorPropertyTransform2D); EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, default_float_step); - editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, hint.suffix); + editor->setup(hint.min, hint.max, hint.step, hint.hide_control, hint.suffix); return editor; } break; case Variant::PLANE: { EditorPropertyPlane *editor = memnew(EditorPropertyPlane(p_wide)); EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, default_float_step); - editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, hint.suffix); + editor->setup(hint.min, hint.max, hint.step, hint.hide_control, hint.suffix); return editor; } break; case Variant::QUATERNION: { EditorPropertyQuaternion *editor = memnew(EditorPropertyQuaternion); EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, default_float_step); - editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, hint.suffix, p_hint == PROPERTY_HINT_HIDE_QUATERNION_EDIT); + editor->setup(hint.min, hint.max, hint.step, hint.hide_control, hint.suffix, p_hint == PROPERTY_HINT_HIDE_QUATERNION_EDIT); return editor; } break; case Variant::AABB: { EditorPropertyAABB *editor = memnew(EditorPropertyAABB); EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, default_float_step); - editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, hint.suffix); + editor->setup(hint.min, hint.max, hint.step, hint.hide_control, hint.suffix); return editor; } break; case Variant::BASIS: { EditorPropertyBasis *editor = memnew(EditorPropertyBasis); EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, default_float_step); - editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, hint.suffix); + editor->setup(hint.min, hint.max, hint.step, hint.hide_control, hint.suffix); return editor; } break; case Variant::TRANSFORM3D: { EditorPropertyTransform3D *editor = memnew(EditorPropertyTransform3D); EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, default_float_step); - editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, hint.suffix); + editor->setup(hint.min, hint.max, hint.step, hint.hide_control, hint.suffix); return editor; } break; case Variant::PROJECTION: { EditorPropertyProjection *editor = memnew(EditorPropertyProjection); EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, default_float_step); - editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, hint.suffix); + editor->setup(hint.min, hint.max, hint.step, hint.hide_control, hint.suffix); return editor; } break; diff --git a/editor/inspector/editor_properties.h b/editor/inspector/editor_properties.h index 541d717eb69..6713ede3dac 100644 --- a/editor/inspector/editor_properties.h +++ b/editor/inspector/editor_properties.h @@ -370,7 +370,7 @@ protected: public: virtual void update_property() override; - void setup(int64_t p_min, int64_t p_max, int64_t p_step, bool p_hide_slider, bool p_allow_greater, bool p_allow_lesser, const String &p_suffix = String()); + void setup(int64_t p_min, int64_t p_max, int64_t p_step, bool p_prefer_slider, bool p_hide_control, bool p_allow_greater, bool p_allow_lesser, const String &p_suffix = String()); EditorPropertyInteger(); }; @@ -421,7 +421,7 @@ protected: public: virtual void update_property() override; - void setup(double p_min, double p_max, double p_step, bool p_hide_slider, bool p_exp_range, bool p_greater, bool p_lesser, const String &p_suffix = String(), bool p_radians_as_degrees = false); + void setup(double p_min, double p_max, double p_step, bool p_hide_control, bool p_exp_range, bool p_greater, bool p_lesser, const String &p_suffix = String(), bool p_radians_as_degrees = false); EditorPropertyFloat(); }; @@ -477,7 +477,7 @@ protected: public: virtual void update_property() override; - void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String()); + void setup(double p_min, double p_max, double p_step, bool p_hide_control, const String &p_suffix = String()); EditorPropertyRect2(bool p_force_wide = false); }; @@ -507,7 +507,7 @@ protected: public: virtual void update_property() override; - void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String()); + void setup(double p_min, double p_max, double p_step, bool p_hide_control, const String &p_suffix = String()); EditorPropertyPlane(bool p_force_wide = false); }; @@ -539,7 +539,7 @@ protected: public: virtual void update_property() override; - void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String(), bool p_hide_editor = false); + void setup(double p_min, double p_max, double p_step, bool p_hide_control, const String &p_suffix = String(), bool p_hide_editor = false); EditorPropertyQuaternion(); }; @@ -554,7 +554,7 @@ protected: public: virtual void update_property() override; - void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String()); + void setup(double p_min, double p_max, double p_step, bool p_hide_control, const String &p_suffix = String()); EditorPropertyAABB(); }; @@ -569,7 +569,7 @@ protected: public: virtual void update_property() override; - void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String()); + void setup(double p_min, double p_max, double p_step, bool p_hide_control, const String &p_suffix = String()); EditorPropertyTransform2D(bool p_include_origin = true); }; @@ -584,7 +584,7 @@ protected: public: virtual void update_property() override; - void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String()); + void setup(double p_min, double p_max, double p_step, bool p_hide_control, const String &p_suffix = String()); EditorPropertyBasis(); }; @@ -600,7 +600,7 @@ protected: public: virtual void update_property() override; virtual void update_using_transform(Transform3D p_transform); - void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String()); + void setup(double p_min, double p_max, double p_step, bool p_hide_control, const String &p_suffix = String()); EditorPropertyTransform3D(); }; @@ -616,7 +616,7 @@ protected: public: virtual void update_property() override; virtual void update_using_transform(Projection p_transform); - void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String()); + void setup(double p_min, double p_max, double p_step, bool p_hide_control, const String &p_suffix = String()); EditorPropertyProjection(); }; diff --git a/editor/inspector/editor_properties_vector.cpp b/editor/inspector/editor_properties_vector.cpp index a6bfd85f3f1..163170a8463 100644 --- a/editor/inspector/editor_properties_vector.cpp +++ b/editor/inspector/editor_properties_vector.cpp @@ -153,14 +153,16 @@ void EditorPropertyVectorN::_notification(int p_what) { } } -void EditorPropertyVectorN::setup(double p_min, double p_max, double p_step, bool p_hide_slider, bool p_link, const String &p_suffix, bool p_radians_as_degrees, bool p_is_int) { +void EditorPropertyVectorN::setup(double p_min, double p_max, double p_step, bool p_hide_control, bool p_link, const String &p_suffix, bool p_radians_as_degrees, bool p_is_int) { radians_as_degrees = p_radians_as_degrees; for (EditorSpinSlider *spin : spin_sliders) { spin->set_min(p_min); spin->set_max(p_max); spin->set_step(p_step); - spin->set_hide_slider(p_hide_slider); + if (p_hide_control) { + spin->set_control_state(EditorSpinSlider::CONTROL_STATE_HIDE); + } spin->set_allow_greater(true); spin->set_allow_lesser(true); spin->set_suffix(p_suffix); diff --git a/editor/inspector/editor_properties_vector.h b/editor/inspector/editor_properties_vector.h index 2dceb4e6c6c..95cb8918df0 100644 --- a/editor/inspector/editor_properties_vector.h +++ b/editor/inspector/editor_properties_vector.h @@ -61,7 +61,7 @@ protected: public: virtual void update_property() override; - void setup(double p_min, double p_max, double p_step = 1.0, bool p_hide_slider = true, bool p_link = false, const String &p_suffix = String(), bool p_radians_as_degrees = false, bool p_is_int = false); + void setup(double p_min, double p_max, double p_step = 1.0, bool p_hide_control = true, bool p_link = false, const String &p_suffix = String(), bool p_radians_as_degrees = false, bool p_is_int = false); EditorPropertyVectorN(Variant::Type p_type, bool p_force_wide, bool p_horizontal); }; diff --git a/editor/scene/2d/tiles/tile_proxies_manager_dialog.cpp b/editor/scene/2d/tiles/tile_proxies_manager_dialog.cpp index 5e38bc586d5..5d4595f4663 100644 --- a/editor/scene/2d/tiles/tile_proxies_manager_dialog.cpp +++ b/editor/scene/2d/tiles/tile_proxies_manager_dialog.cpp @@ -401,7 +401,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() { source_from_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed)); source_from_property_editor->set_selectable(false); source_from_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL); - source_from_property_editor->setup(-1, 99999, 1, false, true, false); + source_from_property_editor->setup(-1, 99999, 1, false, false, true, false); vboxcontainer_from->add_child(source_from_property_editor); coords_from_property_editor = memnew(EditorPropertyVector2i); @@ -420,7 +420,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() { alternative_from_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed)); alternative_from_property_editor->set_selectable(false); alternative_from_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL); - alternative_from_property_editor->setup(-1, 99999, 1, false, true, false); + alternative_from_property_editor->setup(-1, 99999, 1, false, false, true, false); alternative_from_property_editor->hide(); vboxcontainer_from->add_child(alternative_from_property_editor); @@ -435,7 +435,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() { source_to_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed)); source_to_property_editor->set_selectable(false); source_to_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL); - source_to_property_editor->setup(-1, 99999, 1, false, true, false); + source_to_property_editor->setup(-1, 99999, 1, false, false, true, false); vboxcontainer_to->add_child(source_to_property_editor); coords_to_property_editor = memnew(EditorPropertyVector2i); @@ -454,7 +454,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() { alternative_to_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed)); alternative_to_property_editor->set_selectable(false); alternative_to_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL); - alternative_to_property_editor->setup(-1, 99999, 1, false, true, false); + alternative_to_property_editor->setup(-1, 99999, 1, false, false, true, false); alternative_to_property_editor->hide(); vboxcontainer_to->add_child(alternative_to_property_editor); diff --git a/editor/scene/gui/font_config_plugin.cpp b/editor/scene/gui/font_config_plugin.cpp index 8b2fb5acdae..24dafe521a4 100644 --- a/editor/scene/gui/font_config_plugin.cpp +++ b/editor/scene/gui/font_config_plugin.cpp @@ -465,7 +465,7 @@ void EditorPropertyOTVariation::update_property() { Vector3i range = supported.get_value_at_index(i); EditorPropertyInteger *prop = memnew(EditorPropertyInteger); - prop->setup(range.x, range.y, false, true, false, false); + prop->setup(range.x, range.y, 1, false, true, false, false); prop->set_object_and_property(object.ptr(), "keys/" + itos(name_tag)); String name = TS->tag_to_name(name_tag); @@ -746,7 +746,7 @@ void EditorPropertyOTFeatures::update_property() { } break; case Variant::INT: { EditorPropertyInteger *editor = memnew(EditorPropertyInteger); - editor->setup(0, 255, 1, false, false, false); + editor->setup(0, 255, 1, false, false, false, false); prop = editor; } break; default: { diff --git a/editor/settings/editor_settings.cpp b/editor/settings/editor_settings.cpp index 062ebd73ecd..46e4fbee19f 100644 --- a/editor/settings/editor_settings.cpp +++ b/editor/settings/editor_settings.cpp @@ -550,6 +550,7 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_RANGE, "interface/inspector/max_array_dictionary_items_per_page", 20, "10,100,1") EDITOR_SETTING(Variant::BOOL, PROPERTY_HINT_NONE, "interface/inspector/show_low_level_opentype_features", false, "") EDITOR_SETTING_BASIC(Variant::FLOAT, PROPERTY_HINT_RANGE, "interface/inspector/float_drag_speed", 5.0, "0.1,100,0.01") + EDITOR_SETTING_BASIC(Variant::FLOAT, PROPERTY_HINT_RANGE, "interface/inspector/integer_drag_speed", 0.5, "0.1,10,0.01") EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_ENUM, "interface/inspector/nested_color_mode", 0, "Containers & Resources,Resources,External Resources") EDITOR_SETTING(Variant::BOOL, PROPERTY_HINT_NONE, "interface/inspector/delimitate_all_container_and_resources", true, "") EDITOR_SETTING_USAGE(Variant::INT, PROPERTY_HINT_ENUM, "interface/inspector/default_property_name_style", EditorPropertyNameProcessor::STYLE_CAPITALIZED, "Raw (e.g. \"z_index\"),Capitalized (e.g. \"Z Index\"),Localized (e.g. \"Z Index\")", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index 234dfd2b512..ab3363ab4c4 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -665,7 +665,7 @@ Export an [int], [float], [Array][lb][int][rb], [Array][lb][float][rb], [PackedByteArray], [PackedInt32Array], [PackedInt64Array], [PackedFloat32Array], or [PackedFloat64Array] property as a range value. The range must be defined by [param min] and [param max], as well as an optional [param step] and a variety of extra hints. The [param step] defaults to [code]1[/code] for integer properties. For floating-point numbers this value depends on your [member EditorSettings.interface/inspector/default_float_step] setting. - If hints [code]"or_greater"[/code] and [code]"or_less"[/code] are provided, the editor widget will not cap the value at range boundaries. The [code]"exp"[/code] hint will make the edited values on range to change exponentially. The [code]"hide_slider"[/code] hint will hide the slider element of the editor widget. + If hints [code]"or_greater"[/code] and [code]"or_less"[/code] are provided, the editor widget will not cap the value at range boundaries. The [code]"exp"[/code] hint will make the edited values on range to change exponentially. The [code]"prefer_slider"[/code] hint will make integer values use the slider instead of arrows for editing, while [code]"hide_control"[/code] will hide the element controlling the value of the editor widget. Hints also allow to indicate the units for the edited value. Using [code]"radians_as_degrees"[/code] you can specify that the actual value is in radians, but should be displayed in degrees in the Inspector dock (the range values are also in degrees). [code]"degrees"[/code] allows to add a degree sign as a unit suffix (the value is unchanged). Finally, a custom suffix can be provided using [code]"suffix:unit"[/code], where "unit" can be any string. See also [constant PROPERTY_HINT_RANGE]. [codeblock] diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 3f21f434023..d1447a34baa 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -925,9 +925,12 @@ static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_a ScriptLanguage::CodeCompletionOption slider2("or_less", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); slider2.insert_text = slider2.display.quote(p_quote_style); r_result.insert(slider2.display, slider2); - ScriptLanguage::CodeCompletionOption slider3("hide_slider", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); + ScriptLanguage::CodeCompletionOption slider3("prefer_slider", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); slider3.insert_text = slider3.display.quote(p_quote_style); r_result.insert(slider3.display, slider3); + ScriptLanguage::CodeCompletionOption slider4("hide_control", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); + slider4.insert_text = slider4.display.quote(p_quote_style); + r_result.insert(slider4.display, slider4); } } else if (p_annotation->name == SNAME("@export_exp_easing")) { if (p_argument == 0 || p_argument == 1) { diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index 9bbeeb28e7d..7ac698c9fcb 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -496,7 +496,7 @@ void Node2D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_relative_transform_to_parent", "parent"), &Node2D::get_relative_transform_to_parent); ADD_GROUP("Transform", ""); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position", PROPERTY_HINT_RANGE, "-99999,99999,or_less,or_greater,hide_slider,suffix:px"), "set_position", "get_position"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position", PROPERTY_HINT_RANGE, "-99999,99999,or_less,or_greater,hide_control,suffix:px"), "set_position", "get_position"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation", PROPERTY_HINT_RANGE, "-360,360,0.1,or_less,or_greater,radians_as_degrees"), "set_rotation", "get_rotation"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_rotation_degrees", "get_rotation_degrees"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale", PROPERTY_HINT_LINK), "set_scale", "get_scale"); diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp index 60e47a11103..cd4d2532f3f 100644 --- a/scene/3d/node_3d.cpp +++ b/scene/3d/node_3d.cpp @@ -1523,7 +1523,7 @@ void Node3D::_bind_methods() { ADD_GROUP("Transform", ""); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "transform", PROPERTY_HINT_NONE, "suffix:m", PROPERTY_USAGE_NO_EDITOR), "set_transform", "get_transform"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "global_transform", PROPERTY_HINT_NONE, "suffix:m", PROPERTY_USAGE_NONE), "set_global_transform", "get_global_transform"); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "position", PROPERTY_HINT_RANGE, "-99999,99999,or_greater,or_less,hide_slider,suffix:m", PROPERTY_USAGE_EDITOR), "set_position", "get_position"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "position", PROPERTY_HINT_RANGE, "-99999,99999,or_greater,or_less,hide_control,suffix:m", PROPERTY_USAGE_EDITOR), "set_position", "get_position"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation", PROPERTY_HINT_RANGE, "-360,360,0.1,or_less,or_greater,radians_as_degrees", PROPERTY_USAGE_EDITOR), "set_rotation", "get_rotation"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_rotation_degrees", "get_rotation_degrees"); ADD_PROPERTY(PropertyInfo(Variant::QUATERNION, "quaternion", PROPERTY_HINT_HIDE_QUATERNION_EDIT, "", PROPERTY_USAGE_EDITOR), "set_quaternion", "get_quaternion"); diff --git a/scene/3d/spring_bone_simulator_3d.cpp b/scene/3d/spring_bone_simulator_3d.cpp index 5659238cf12..a1b24f6f058 100644 --- a/scene/3d/spring_bone_simulator_3d.cpp +++ b/scene/3d/spring_bone_simulator_3d.cpp @@ -1312,7 +1312,7 @@ void SpringBoneSimulator3D::_bind_methods() { // To process manually. ClassDB::bind_method(D_METHOD("reset"), &SpringBoneSimulator3D::reset); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "external_force", PROPERTY_HINT_RANGE, "-99999,99999,or_greater,or_less,hide_slider,suffix:m/s"), "set_external_force", "get_external_force"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "external_force", PROPERTY_HINT_RANGE, "-99999,99999,or_greater,or_less,hide_control,suffix:m/s"), "set_external_force", "get_external_force"); ADD_ARRAY_COUNT("Settings", "setting_count", "set_setting_count", "get_setting_count", "settings/"); BIND_ENUM_CONSTANT(BONE_DIRECTION_PLUS_X); diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp index 36a247a3d46..440f8bb4731 100644 --- a/scene/animation/animation_blend_tree.cpp +++ b/scene/animation/animation_blend_tree.cpp @@ -384,9 +384,9 @@ void AnimationNodeAnimation::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "play_mode", PROPERTY_HINT_ENUM, "Forward,Backward"), "set_play_mode", "get_play_mode"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "advance_on_start"), "set_advance_on_start", "is_advance_on_start"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_custom_timeline"), "set_use_custom_timeline", "is_using_custom_timeline"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "timeline_length", PROPERTY_HINT_RANGE, "0.001,60,0.001,or_greater,or_less,hide_slider,suffix:s"), "set_timeline_length", "get_timeline_length"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "timeline_length", PROPERTY_HINT_RANGE, "0.001,60,0.001,or_greater,or_less,hide_control,suffix:s"), "set_timeline_length", "get_timeline_length"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stretch_time_scale"), "set_stretch_time_scale", "is_stretching_time_scale"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "start_offset", PROPERTY_HINT_RANGE, "-60,60,0.001,or_greater,or_less,hide_slider,suffix:s"), "set_start_offset", "get_start_offset"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "start_offset", PROPERTY_HINT_RANGE, "-60,60,0.001,or_greater,or_less,hide_control,suffix:s"), "set_start_offset", "get_start_offset"); ADD_PROPERTY(PropertyInfo(Variant::INT, "loop_mode", PROPERTY_HINT_ENUM, "None,Linear,Ping-Pong"), "set_loop_mode", "get_loop_mode"); BIND_ENUM_CONSTANT(PLAY_MODE_FORWARD);