summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-02-16 11:01:52 +0100
committerRémi Verschelde <rverschelde@gmail.com>2023-02-16 11:01:52 +0100
commit9f07643c8c42cb3239556f77c4fb9fa8d75bd690 (patch)
tree0ba7a35ed98874a6b2c6b03adffd79b4727913fd
parent373cbbe7b20621795e3a09dd9e1d501894db72b1 (diff)
parent840675ee0704368f13ef79467b4ff7b4461065b6 (diff)
Merge pull request #73361 from akien-mga/your-ints-aint-gonna-increment-themselves
EditorProperty: Fix missing increment buttons for integers
-rw-r--r--editor/editor_properties.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 33bba90c70..30c7d2b85f 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -4174,9 +4174,12 @@ struct EditorPropertyRangeHint {
bool radians = false;
};
-static EditorPropertyRangeHint _parse_range_hint(PropertyHint p_hint, const String &p_hint_text, double p_default_step) {
+static EditorPropertyRangeHint _parse_range_hint(PropertyHint p_hint, const String &p_hint_text, double p_default_step, bool is_int = false) {
EditorPropertyRangeHint hint;
hint.step = p_default_step;
+ if (is_int) {
+ hint.hide_slider = false; // Always show slider for ints, unless specified in hint range.
+ }
Vector<String> slices = p_hint_text.split(",");
if (p_hint == PROPERTY_HINT_RANGE) {
ERR_FAIL_COND_V_MSG(slices.size() < 2, hint,
@@ -4294,7 +4297,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
} else {
EditorPropertyInteger *editor = memnew(EditorPropertyInteger);
- EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1);
+ 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);
return editor;
@@ -4383,7 +4386,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
} break;
case Variant::VECTOR2I: {
EditorPropertyVector2i *editor = memnew(EditorPropertyVector2i(p_wide));
- EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1);
+ EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1, true);
editor->setup(hint.min, hint.max, p_hint == PROPERTY_HINT_LINK, hint.suffix);
return editor;
@@ -4396,7 +4399,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
} break;
case Variant::RECT2I: {
EditorPropertyRect2i *editor = memnew(EditorPropertyRect2i(p_wide));
- EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1);
+ EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1, true);
editor->setup(hint.min, hint.max, hint.suffix);
return editor;
@@ -4410,7 +4413,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
} break;
case Variant::VECTOR3I: {
EditorPropertyVector3i *editor = memnew(EditorPropertyVector3i(p_wide));
- EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1);
+ EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1, true);
editor->setup(hint.min, hint.max, p_hint == PROPERTY_HINT_LINK, hint.suffix);
return editor;
@@ -4424,7 +4427,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
} break;
case Variant::VECTOR4I: {
EditorPropertyVector4i *editor = memnew(EditorPropertyVector4i);
- EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1);
+ EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1, true);
editor->setup(hint.min, hint.max, hint.suffix);
return editor;