Inspector: Make default float step configurable
Also allow lifting the decimal step formatting with a hint range step of 0. A new `range_step_decimals()` is added for this to avoid breaking compatibility on the general purpose `step_decimals()` (which still returns 0 for an input step of 0). Supersedes #25470. Partial fix for #18251.
This commit is contained in:
parent
4c943cca2c
commit
d844e30614
8 changed files with 31 additions and 17 deletions
|
|
@ -2904,6 +2904,8 @@ void EditorInspectorDefaultPlugin::parse_begin(Object *p_object) {
|
|||
|
||||
bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage) {
|
||||
|
||||
float default_float_step = EDITOR_GET("interface/inspector/default_float_step");
|
||||
|
||||
switch (p_type) {
|
||||
|
||||
// atomic types
|
||||
|
|
@ -3010,7 +3012,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
|
|||
|
||||
} else {
|
||||
EditorPropertyFloat *editor = memnew(EditorPropertyFloat);
|
||||
double min = -65535, max = 65535, step = 0.001;
|
||||
double min = -65535, max = 65535, step = default_float_step;
|
||||
bool hide_slider = true;
|
||||
bool exp_range = false;
|
||||
bool greater = true, lesser = true;
|
||||
|
|
@ -3107,7 +3109,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
|
|||
|
||||
case Variant::VECTOR2: {
|
||||
EditorPropertyVector2 *editor = memnew(EditorPropertyVector2);
|
||||
double min = -65535, max = 65535, step = 0.001;
|
||||
double min = -65535, max = 65535, step = default_float_step;
|
||||
bool hide_slider = true;
|
||||
|
||||
if (p_hint == PROPERTY_HINT_RANGE && p_hint_text.get_slice_count(",") >= 2) {
|
||||
|
|
@ -3125,7 +3127,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
|
|||
} break; // 5
|
||||
case Variant::RECT2: {
|
||||
EditorPropertyRect2 *editor = memnew(EditorPropertyRect2);
|
||||
double min = -65535, max = 65535, step = 0.001;
|
||||
double min = -65535, max = 65535, step = default_float_step;
|
||||
bool hide_slider = true;
|
||||
|
||||
if (p_hint == PROPERTY_HINT_RANGE && p_hint_text.get_slice_count(",") >= 2) {
|
||||
|
|
@ -3142,7 +3144,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
|
|||
} break;
|
||||
case Variant::VECTOR3: {
|
||||
EditorPropertyVector3 *editor = memnew(EditorPropertyVector3);
|
||||
double min = -65535, max = 65535, step = 0.001;
|
||||
double min = -65535, max = 65535, step = default_float_step;
|
||||
bool hide_slider = true;
|
||||
|
||||
if (p_hint == PROPERTY_HINT_RANGE && p_hint_text.get_slice_count(",") >= 2) {
|
||||
|
|
@ -3160,7 +3162,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
|
|||
} break;
|
||||
case Variant::TRANSFORM2D: {
|
||||
EditorPropertyTransform2D *editor = memnew(EditorPropertyTransform2D);
|
||||
double min = -65535, max = 65535, step = 0.001;
|
||||
double min = -65535, max = 65535, step = default_float_step;
|
||||
bool hide_slider = true;
|
||||
|
||||
if (p_hint == PROPERTY_HINT_RANGE && p_hint_text.get_slice_count(",") >= 2) {
|
||||
|
|
@ -3178,7 +3180,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
|
|||
} break;
|
||||
case Variant::PLANE: {
|
||||
EditorPropertyPlane *editor = memnew(EditorPropertyPlane);
|
||||
double min = -65535, max = 65535, step = 0.001;
|
||||
double min = -65535, max = 65535, step = default_float_step;
|
||||
bool hide_slider = true;
|
||||
|
||||
if (p_hint == PROPERTY_HINT_RANGE && p_hint_text.get_slice_count(",") >= 2) {
|
||||
|
|
@ -3195,7 +3197,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
|
|||
} break;
|
||||
case Variant::QUAT: {
|
||||
EditorPropertyQuat *editor = memnew(EditorPropertyQuat);
|
||||
double min = -65535, max = 65535, step = 0.001;
|
||||
double min = -65535, max = 65535, step = default_float_step;
|
||||
bool hide_slider = true;
|
||||
|
||||
if (p_hint == PROPERTY_HINT_RANGE && p_hint_text.get_slice_count(",") >= 2) {
|
||||
|
|
@ -3212,7 +3214,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
|
|||
} break; // 10
|
||||
case Variant::AABB: {
|
||||
EditorPropertyAABB *editor = memnew(EditorPropertyAABB);
|
||||
double min = -65535, max = 65535, step = 0.001;
|
||||
double min = -65535, max = 65535, step = default_float_step;
|
||||
bool hide_slider = true;
|
||||
|
||||
if (p_hint == PROPERTY_HINT_RANGE && p_hint_text.get_slice_count(",") >= 2) {
|
||||
|
|
@ -3229,7 +3231,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
|
|||
} break;
|
||||
case Variant::BASIS: {
|
||||
EditorPropertyBasis *editor = memnew(EditorPropertyBasis);
|
||||
double min = -65535, max = 65535, step = 0.001;
|
||||
double min = -65535, max = 65535, step = default_float_step;
|
||||
bool hide_slider = true;
|
||||
|
||||
if (p_hint == PROPERTY_HINT_RANGE && p_hint_text.get_slice_count(",") >= 2) {
|
||||
|
|
@ -3246,7 +3248,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
|
|||
} break;
|
||||
case Variant::TRANSFORM: {
|
||||
EditorPropertyTransform *editor = memnew(EditorPropertyTransform);
|
||||
double min = -65535, max = 65535, step = 0.001;
|
||||
double min = -65535, max = 65535, step = default_float_step;
|
||||
bool hide_slider = true;
|
||||
|
||||
if (p_hint == PROPERTY_HINT_RANGE && p_hint_text.get_slice_count(",") >= 2) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue