diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2019-07-23 17:27:55 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2019-07-23 17:31:38 +0200 |
commit | d844e306147689c3f02473b3dd5d592bdf141023 (patch) | |
tree | 1124a98e2d55dfe351b490b7839bc96de811457e /editor | |
parent | 4c943cca2c6d6cd7a197cb1601a6356e65254837 (diff) |
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.
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_node.cpp | 2 | ||||
-rw-r--r-- | editor/editor_properties.cpp | 22 | ||||
-rw-r--r-- | editor/editor_spin_slider.cpp | 4 |
3 files changed, 16 insertions, 12 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index f1944bf63f..5705629c56 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -5557,6 +5557,8 @@ EditorNode::EditorNode() { EDITOR_DEF_RST("interface/scene_tabs/restore_scenes_on_load", false); EDITOR_DEF_RST("interface/scene_tabs/show_thumbnail_on_hover", true); EDITOR_DEF_RST("interface/inspector/capitalize_properties", true); + EDITOR_DEF_RST("interface/inspector/default_float_step", 0.001); + EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::REAL, "interface/inspector/default_float_step", PROPERTY_HINT_EXP_RANGE, "0,1,0")); EDITOR_DEF_RST("interface/inspector/disable_folding", false); EDITOR_DEF_RST("interface/inspector/auto_unfold_foreign_scenes", true); EDITOR_DEF("interface/inspector/horizontal_vector2_editing", false); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index d54f72382c..3300228921 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -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) { diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index dcb106899e..9966394025 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -38,9 +38,9 @@ String EditorSpinSlider::get_tooltip(const Point2 &p_pos) const { } String EditorSpinSlider::get_text_value() const { - int zeros = Math::step_decimals(get_step()); - return String::num(get_value(), zeros); + return String::num(get_value(), Math::range_step_decimals(get_step())); } + void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) { if (read_only) |