summaryrefslogtreecommitdiff
path: root/editor/editor_inspector.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_inspector.cpp')
-rw-r--r--editor/editor_inspector.cpp40
1 files changed, 24 insertions, 16 deletions
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index c705f9af2b..ecb9ea5f35 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -211,12 +211,14 @@ void EditorProperty::_notification(int p_what) {
}
int ofs = 0;
+ int text_limit = text_size;
+
if (checkable) {
Ref<Texture> checkbox;
if (checked)
- checkbox = get_icon("checked", "CheckBox");
+ checkbox = get_icon("GuiChecked", "EditorIcons");
else
- checkbox = get_icon("unchecked", "CheckBox");
+ checkbox = get_icon("GuiUnchecked", "EditorIcons");
Color color2(1, 1, 1);
if (check_hover) {
@@ -228,12 +230,11 @@ void EditorProperty::_notification(int p_what) {
draw_texture(checkbox, check_rect.position, color2);
ofs += get_constant("hseparator", "Tree");
ofs += checkbox->get_width();
+ text_limit -= ofs;
} else {
check_rect = Rect2();
}
- int text_limit = text_size;
-
if (can_revert) {
Ref<Texture> reload_icon = get_icon("ReloadSmall", "EditorIcons");
text_limit -= reload_icon->get_width() + get_constant("hseparator", "Tree") * 2;
@@ -433,7 +434,7 @@ bool EditorPropertyRevert::is_node_property_different(Node *p_node, const Varian
float a = p_current;
float b = p_orig;
- return Math::abs(a - b) > CMP_EPSILON; //this must be done because, as some scenes save as text, there might be a tiny difference in floats due to numerical error
+ return !Math::is_equal_approx(a, b); //this must be done because, as some scenes save as text, there might be a tiny difference in floats due to numerical error
}
return bool(Variant::evaluate(Variant::OP_NOT_EQUAL, p_current, p_orig));
@@ -470,10 +471,12 @@ bool EditorPropertyRevert::can_property_revert(Object *p_object, const StringNam
if (!has_revert && !p_object->get_script().is_null()) {
Ref<Script> scr = p_object->get_script();
- Variant orig_value;
- if (scr->get_property_default_value(p_property, orig_value)) {
- if (orig_value != p_object->get(p_property)) {
- has_revert = true;
+ if (scr.is_valid()) {
+ Variant orig_value;
+ if (scr->get_property_default_value(p_property, orig_value)) {
+ if (orig_value != p_object->get(p_property)) {
+ has_revert = true;
+ }
}
}
}
@@ -668,11 +671,13 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
if (!object->get_script().is_null()) {
Ref<Script> scr = object->get_script();
- Variant orig_value;
- if (scr->get_property_default_value(property, orig_value)) {
- emit_changed(property, orig_value);
- update_property();
- return;
+ if (scr.is_valid()) {
+ Variant orig_value;
+ if (scr->get_property_default_value(property, orig_value)) {
+ emit_changed(property, orig_value);
+ update_property();
+ return;
+ }
}
}
@@ -800,6 +805,9 @@ void EditorProperty::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_tooltip_text"), &EditorProperty::get_tooltip_text);
+ ClassDB::bind_method(D_METHOD("add_focusable", "control"), &EditorProperty::add_focusable);
+ ClassDB::bind_method(D_METHOD("set_bottom_editor", "editor"), &EditorProperty::set_bottom_editor);
+
ClassDB::bind_method(D_METHOD("emit_changed", "property", "value", "field", "changing"), &EditorProperty::emit_changed, DEFVAL(StringName()), DEFVAL(false));
ADD_PROPERTY(PropertyInfo(Variant::STRING, "label"), "set_label", "get_label");
@@ -1523,7 +1531,7 @@ void EditorInspector::update_tree() {
if (E) {
descr = E->get().brief_description;
}
- class_descr_cache[type2] = descr.word_wrap(80);
+ class_descr_cache[type2] = descr;
}
category->set_tooltip(p.name + "::" + (class_descr_cache[type2] == "" ? "" : class_descr_cache[type2]));
@@ -1675,7 +1683,7 @@ void EditorInspector::update_tree() {
while (F && descr == String()) {
for (int i = 0; i < F->get().properties.size(); i++) {
if (F->get().properties[i].name == propname.operator String()) {
- descr = F->get().properties[i].description.strip_edges().word_wrap(80);
+ descr = F->get().properties[i].description.strip_edges();
break;
}
}