Merge pull request #110459 from YeldhamDev/let_the_poor_ints_slide

Allow to use sliders for integers in `EditorSpinSlider`
This commit is contained in:
Thaddeus Crews 2025-09-22 13:28:52 -05:00
commit a20ca7bbfe
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC
21 changed files with 189 additions and 97 deletions

View file

@ -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."));

View file

@ -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<InputEvent> &p_event) {
@ -109,17 +114,8 @@ void EditorSpinSlider::gui_input(const Ref<InputEvent> &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<InputEvent> &p_event) {
grab_focus(true);
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<Texture2D> 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<Texture2D> 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"));

View file

@ -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)

View file

@ -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<String> 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;

View file

@ -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();
};

View file

@ -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);

View file

@ -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);
};

View file

@ -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);

View file

@ -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: {

View file

@ -550,6 +550,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> 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);