Merge pull request #49338 from Chaosus/fix_property_editor_remake

Fix property editor to make changes if popup closed (remake)
This commit is contained in:
Rémi Verschelde 2021-06-11 14:56:35 +02:00 committed by GitHub
commit e82a1113ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1446,6 +1446,8 @@ void CustomPropertyEditor::_modified(String p_string) {
return; return;
} }
Variant prev_v = v;
updating = true; updating = true;
switch (type) { switch (type) {
case Variant::INT: { case Variant::INT: {
@ -1459,14 +1461,18 @@ void CustomPropertyEditor::_modified(String p_string) {
} else { } else {
v = expr->execute(Array(), nullptr, false); v = expr->execute(Array(), nullptr, false);
} }
emit_signal("variant_changed");
if (v != prev_v) {
emit_signal("variant_changed");
}
} break; } break;
case Variant::FLOAT: { case Variant::FLOAT: {
if (hint != PROPERTY_HINT_EXP_EASING) { if (hint != PROPERTY_HINT_EXP_EASING) {
String text = TS->parse_number(value_editor[0]->get_text()); String text = TS->parse_number(value_editor[0]->get_text());
v = _parse_real_expression(text); v = _parse_real_expression(text);
emit_signal("variant_changed"); if (v != prev_v) {
emit_signal("variant_changed");
}
} }
} break; } break;
@ -1479,7 +1485,9 @@ void CustomPropertyEditor::_modified(String p_string) {
vec.x = _parse_real_expression(value_editor[0]->get_text()); vec.x = _parse_real_expression(value_editor[0]->get_text());
vec.y = _parse_real_expression(value_editor[1]->get_text()); vec.y = _parse_real_expression(value_editor[1]->get_text());
v = vec; v = vec;
_emit_changed_whole_or_field(); if (v != prev_v) {
_emit_changed_whole_or_field();
}
} break; } break;
case Variant::RECT2: { case Variant::RECT2: {
@ -1490,7 +1498,9 @@ void CustomPropertyEditor::_modified(String p_string) {
r2.size.x = _parse_real_expression(value_editor[2]->get_text()); r2.size.x = _parse_real_expression(value_editor[2]->get_text());
r2.size.y = _parse_real_expression(value_editor[3]->get_text()); r2.size.y = _parse_real_expression(value_editor[3]->get_text());
v = r2; v = r2;
_emit_changed_whole_or_field(); if (v != prev_v) {
_emit_changed_whole_or_field();
}
} break; } break;
@ -1500,7 +1510,9 @@ void CustomPropertyEditor::_modified(String p_string) {
vec.y = _parse_real_expression(value_editor[1]->get_text()); vec.y = _parse_real_expression(value_editor[1]->get_text());
vec.z = _parse_real_expression(value_editor[2]->get_text()); vec.z = _parse_real_expression(value_editor[2]->get_text());
v = vec; v = vec;
_emit_changed_whole_or_field(); if (v != prev_v) {
_emit_changed_whole_or_field();
}
} break; } break;
case Variant::PLANE: { case Variant::PLANE: {
@ -1510,7 +1522,9 @@ void CustomPropertyEditor::_modified(String p_string) {
pl.normal.z = _parse_real_expression(value_editor[2]->get_text()); pl.normal.z = _parse_real_expression(value_editor[2]->get_text());
pl.d = _parse_real_expression(value_editor[3]->get_text()); pl.d = _parse_real_expression(value_editor[3]->get_text());
v = pl; v = pl;
_emit_changed_whole_or_field(); if (v != prev_v) {
_emit_changed_whole_or_field();
}
} break; } break;
case Variant::QUATERNION: { case Variant::QUATERNION: {
@ -1520,7 +1534,9 @@ void CustomPropertyEditor::_modified(String p_string) {
q.z = _parse_real_expression(value_editor[2]->get_text()); q.z = _parse_real_expression(value_editor[2]->get_text());
q.w = _parse_real_expression(value_editor[3]->get_text()); q.w = _parse_real_expression(value_editor[3]->get_text());
v = q; v = q;
_emit_changed_whole_or_field(); if (v != prev_v) {
_emit_changed_whole_or_field();
}
} break; } break;
case Variant::AABB: { case Variant::AABB: {
@ -1534,7 +1550,9 @@ void CustomPropertyEditor::_modified(String p_string) {
size.y = _parse_real_expression(value_editor[4]->get_text()); size.y = _parse_real_expression(value_editor[4]->get_text());
size.z = _parse_real_expression(value_editor[5]->get_text()); size.z = _parse_real_expression(value_editor[5]->get_text());
v = AABB(pos, size); v = AABB(pos, size);
_emit_changed_whole_or_field(); if (v != prev_v) {
_emit_changed_whole_or_field();
}
} break; } break;
case Variant::TRANSFORM2D: { case Variant::TRANSFORM2D: {
@ -1544,7 +1562,9 @@ void CustomPropertyEditor::_modified(String p_string) {
} }
v = m; v = m;
_emit_changed_whole_or_field(); if (v != prev_v) {
_emit_changed_whole_or_field();
}
} break; } break;
case Variant::BASIS: { case Variant::BASIS: {
@ -1554,7 +1574,9 @@ void CustomPropertyEditor::_modified(String p_string) {
} }
v = m; v = m;
_emit_changed_whole_or_field(); if (v != prev_v) {
_emit_changed_whole_or_field();
}
} break; } break;
case Variant::TRANSFORM3D: { case Variant::TRANSFORM3D: {
@ -1570,7 +1592,9 @@ void CustomPropertyEditor::_modified(String p_string) {
origin.z = _parse_real_expression(value_editor[11]->get_text()); origin.z = _parse_real_expression(value_editor[11]->get_text());
v = Transform3D(basis, origin); v = Transform3D(basis, origin);
_emit_changed_whole_or_field(); if (v != prev_v) {
_emit_changed_whole_or_field();
}
} break; } break;
case Variant::COLOR: { case Variant::COLOR: {
@ -1578,7 +1602,9 @@ void CustomPropertyEditor::_modified(String p_string) {
case Variant::NODE_PATH: { case Variant::NODE_PATH: {
v = NodePath(value_editor[0]->get_text()); v = NodePath(value_editor[0]->get_text());
emit_signal("variant_changed"); if (v != prev_v) {
emit_signal("variant_changed");
}
} break; } break;
case Variant::DICTIONARY: { case Variant::DICTIONARY: {
} break; } break;
@ -1654,25 +1680,7 @@ void CustomPropertyEditor::_focus_enter() {
} }
void CustomPropertyEditor::_focus_exit() { void CustomPropertyEditor::_focus_exit() {
switch (type) { _modified(String());
case Variant::FLOAT:
case Variant::STRING:
case Variant::VECTOR2:
case Variant::RECT2:
case Variant::VECTOR3:
case Variant::PLANE:
case Variant::QUATERNION:
case Variant::AABB:
case Variant::TRANSFORM2D:
case Variant::BASIS:
case Variant::TRANSFORM3D: {
for (int i = 0; i < MAX_VALUE_EDITORS; ++i) {
value_editor[i]->select(0, 0);
}
} break;
default: {
}
}
} }
void CustomPropertyEditor::config_action_buttons(const List<String> &p_strings) { void CustomPropertyEditor::config_action_buttons(const List<String> &p_strings) {