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.cpp95
1 files changed, 50 insertions, 45 deletions
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 1449edb58f..f534130735 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -96,11 +96,11 @@ Size2 EditorProperty::get_minimum_size() const {
if (checkable) {
Ref<Texture2D> check = get_theme_icon(SNAME("checked"), SNAME("CheckBox"));
- ms.width += check->get_width() + get_theme_constant(SNAME("hseparation"), SNAME("CheckBox")) + get_theme_constant(SNAME("hseparator"), SNAME("Tree"));
+ ms.width += check->get_width() + get_theme_constant(SNAME("h_separation"), SNAME("CheckBox")) + get_theme_constant(SNAME("hseparator"), SNAME("Tree"));
}
if (bottom_editor != nullptr && bottom_editor->is_visible()) {
- ms.height += get_theme_constant(SNAME("vseparation"));
+ ms.height += get_theme_constant(SNAME("v_separation"));
Size2 bems = bottom_editor->get_combined_minimum_size();
//bems.width += get_constant("item_margin", "Tree");
ms.height += bems.height;
@@ -169,7 +169,7 @@ void EditorProperty::_notification(int p_what) {
if (bottom_editor) {
int m = 0; //get_constant("item_margin", "Tree");
- bottom_rect = Rect2(m, rect.size.height + get_theme_constant(SNAME("vseparation")), size.width - m, bottom_editor->get_combined_minimum_size().height);
+ bottom_rect = Rect2(m, rect.size.height + get_theme_constant(SNAME("v_separation")), size.width - m, bottom_editor->get_combined_minimum_size().height);
}
if (keying) {
@@ -297,7 +297,7 @@ void EditorProperty::_notification(int p_what) {
} else {
draw_texture(checkbox, check_rect.position, color2);
}
- int check_ofs = get_theme_constant(SNAME("hseparator"), SNAME("Tree")) + checkbox->get_width() + get_theme_constant(SNAME("hseparation"), SNAME("CheckBox"));
+ int check_ofs = get_theme_constant(SNAME("hseparator"), SNAME("Tree")) + checkbox->get_width() + get_theme_constant(SNAME("h_separation"), SNAME("CheckBox"));
ofs += check_ofs;
text_limit -= check_ofs;
} else {
@@ -685,7 +685,7 @@ void EditorProperty::gui_input(const Ref<InputEvent> &p_event) {
}
}
-void EditorProperty::unhandled_key_input(const Ref<InputEvent> &p_event) {
+void EditorProperty::shortcut_input(const Ref<InputEvent> &p_event) {
if (!selected || !p_event->is_pressed()) {
return;
}
@@ -839,7 +839,7 @@ void EditorProperty::_update_pin_flags() {
}
pin_hidden = false;
{
- Set<StringName> storable_properties;
+ RBSet<StringName> storable_properties;
node->get_storable_properties(storable_properties);
if (storable_properties.has(node->get_property_store_alias(property))) {
can_pin = true;
@@ -971,7 +971,7 @@ EditorProperty::EditorProperty() {
label_reference = nullptr;
bottom_editor = nullptr;
menu = nullptr;
- set_process_unhandled_key_input(true);
+ set_process_shortcut_input(true);
}
void EditorProperty::_update_popup() {
@@ -1083,7 +1083,7 @@ void EditorInspectorCategory::_notification(int p_what) {
Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"));
- int hs = get_theme_constant(SNAME("hseparation"), SNAME("Tree"));
+ int hs = get_theme_constant(SNAME("h_separation"), SNAME("Tree"));
int w = font->get_string_size(label, font_size).width;
if (icon.is_valid()) {
@@ -1118,7 +1118,7 @@ Size2 EditorInspectorCategory::get_minimum_size() const {
if (icon.is_valid()) {
ms.height = MAX(icon->get_height(), ms.height);
}
- ms.height += get_theme_constant(SNAME("vseparation"), SNAME("Tree"));
+ ms.height += get_theme_constant(SNAME("v_separation"), SNAME("Tree"));
return ms;
}
@@ -1178,7 +1178,7 @@ void EditorInspectorSection::_notification(int p_what) {
if (arrow.is_valid()) {
header_height = MAX(header_height, arrow->get_height());
}
- header_height += get_theme_constant(SNAME("vseparation"), SNAME("Tree"));
+ header_height += get_theme_constant(SNAME("v_separation"), SNAME("Tree"));
int inspector_margin = get_theme_constant(SNAME("inspector_margin"), SNAME("Editor"));
int section_indent_size = get_theme_constant(SNAME("indent_size"), SNAME("EditorInspectorSection"));
@@ -1231,7 +1231,7 @@ void EditorInspectorSection::_notification(int p_what) {
if (arrow.is_valid()) {
header_height = MAX(header_height, arrow->get_height());
}
- header_height += get_theme_constant(SNAME("vseparation"), SNAME("Tree"));
+ header_height += get_theme_constant(SNAME("v_separation"), SNAME("Tree"));
int section_indent = 0;
int section_indent_size = get_theme_constant(SNAME("indent_size"), SNAME("EditorInspectorSection"));
@@ -1360,7 +1360,7 @@ Size2 EditorInspectorSection::get_minimum_size() const {
Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree"));
int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Tree"));
- ms.height += font->get_height(font_size) + get_theme_constant(SNAME("vseparation"), SNAME("Tree"));
+ ms.height += font->get_height(font_size) + get_theme_constant(SNAME("v_separation"), SNAME("Tree"));
ms.width += get_theme_constant(SNAME("inspector_margin"), SNAME("Editor"));
int section_indent_size = get_theme_constant(SNAME("indent_size"), SNAME("EditorInspectorSection"));
@@ -2445,8 +2445,8 @@ void EditorInspector::update_tree() {
object->get_property_list(&plist, true);
_update_script_class_properties(*object, plist);
- Map<VBoxContainer *, HashMap<String, VBoxContainer *>> vbox_per_path;
- Map<String, EditorInspectorArray *> editor_inspector_array_per_prefix;
+ HashMap<VBoxContainer *, HashMap<String, VBoxContainer *>> vbox_per_path;
+ HashMap<String, EditorInspectorArray *> editor_inspector_array_per_prefix;
Color sscolor = get_theme_color(SNAME("prop_subsection"), SNAME("Editor"));
@@ -2456,8 +2456,6 @@ void EditorInspector::update_tree() {
_parse_added_editors(main_vbox, ped);
}
- bool in_script_variables = false;
-
// Get the lists of editors for properties.
for (List<PropertyInfo>::Element *E_property = plist.front(); E_property; E_property = E_property->next()) {
PropertyInfo &p = E_property->get();
@@ -2549,9 +2547,6 @@ void EditorInspector::update_tree() {
if (category->icon.is_null() && has_theme_icon(base_type, SNAME("EditorIcons"))) {
category->icon = get_theme_icon(base_type, SNAME("EditorIcons"));
}
- in_script_variables = true;
- } else {
- in_script_variables = false;
}
if (category->icon.is_null()) {
if (!type.is_empty()) { // Can happen for built-in scripts.
@@ -2568,9 +2563,9 @@ void EditorInspector::update_tree() {
if (!class_descr_cache.has(type2)) {
String descr;
DocTools *dd = EditorHelp::get_doc_data();
- Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(type2);
+ HashMap<String, DocData::ClassDoc>::Iterator E = dd->class_list.find(type2);
if (E) {
- descr = DTR(E->get().brief_description);
+ descr = DTR(E->value.brief_description);
}
class_descr_cache[type2] = descr;
}
@@ -2612,9 +2607,9 @@ void EditorInspector::update_tree() {
// First check if we have an array that fits the prefix.
String array_prefix = "";
int array_index = -1;
- for (Map<String, EditorInspectorArray *>::Element *E = editor_inspector_array_per_prefix.front(); E; E = E->next()) {
- if (p.name.begins_with(E->key()) && E->key().length() > array_prefix.length()) {
- array_prefix = E->key();
+ for (KeyValue<String, EditorInspectorArray *> &E : editor_inspector_array_per_prefix) {
+ if (p.name.begins_with(E.key) && E.key.length() > array_prefix.length()) {
+ array_prefix = E.key;
}
}
@@ -2682,14 +2677,14 @@ void EditorInspector::update_tree() {
{
const int dot = name_override.find(".");
if (dot != -1) {
- feature_tag = name_override.right(dot);
+ feature_tag = name_override.substr(dot);
name_override = name_override.substr(0, dot);
}
}
- // Don't localize properties in Script Variables category.
+ // Don't localize script variables.
EditorPropertyNameProcessor::Style name_style = property_name_style;
- if (in_script_variables && name_style == EditorPropertyNameProcessor::STYLE_LOCALIZED) {
+ if ((p.usage & PROPERTY_USAGE_SCRIPT_VARIABLE) && name_style == EditorPropertyNameProcessor::STYLE_LOCALIZED) {
name_style = EditorPropertyNameProcessor::STYLE_CAPITALIZED;
}
const String property_label_string = EditorPropertyNameProcessor::get_singleton()->process_name(name_override, name_style) + feature_tag;
@@ -2745,9 +2740,15 @@ void EditorInspector::update_tree() {
String label;
String tooltip;
+ // Don't localize groups for script variables.
+ EditorPropertyNameProcessor::Style section_name_style = property_name_style;
+ if ((p.usage & PROPERTY_USAGE_SCRIPT_VARIABLE) && section_name_style == EditorPropertyNameProcessor::STYLE_LOCALIZED) {
+ section_name_style = EditorPropertyNameProcessor::STYLE_CAPITALIZED;
+ }
+
// Only process group label if this is not the group or subgroup.
if ((i == 0 && component == group) || (i == 1 && component == subgroup)) {
- if (property_name_style == EditorPropertyNameProcessor::STYLE_LOCALIZED) {
+ if (section_name_style == EditorPropertyNameProcessor::STYLE_LOCALIZED) {
label = TTRGET(component);
tooltip = component;
} else {
@@ -2755,8 +2756,8 @@ void EditorInspector::update_tree() {
tooltip = TTRGET(component);
}
} else {
- label = EditorPropertyNameProcessor::get_singleton()->process_name(component, property_name_style);
- tooltip = EditorPropertyNameProcessor::get_singleton()->process_name(component, EditorPropertyNameProcessor::get_tooltip_style(property_name_style));
+ label = EditorPropertyNameProcessor::get_singleton()->process_name(component, section_name_style);
+ tooltip = EditorPropertyNameProcessor::get_singleton()->process_name(component, EditorPropertyNameProcessor::get_tooltip_style(section_name_style));
}
Color c = sscolor;
@@ -2850,39 +2851,39 @@ void EditorInspector::update_tree() {
bool found = false;
// Search for the property description in the cache.
- Map<StringName, Map<StringName, String>>::Element *E = descr_cache.find(classname);
+ HashMap<StringName, HashMap<StringName, String>>::Iterator E = descr_cache.find(classname);
if (E) {
- Map<StringName, String>::Element *F = E->get().find(propname);
+ HashMap<StringName, String>::Iterator F = E->value.find(propname);
if (F) {
found = true;
- descr = F->get();
+ descr = F->value;
}
}
if (!found) {
// Build the property description String and add it to the cache.
DocTools *dd = EditorHelp::get_doc_data();
- Map<String, DocData::ClassDoc>::Element *F = dd->class_list.find(classname);
+ HashMap<String, DocData::ClassDoc>::Iterator F = dd->class_list.find(classname);
while (F && descr.is_empty()) {
- for (int i = 0; i < F->get().properties.size(); i++) {
- if (F->get().properties[i].name == propname.operator String()) {
- descr = DTR(F->get().properties[i].description);
+ for (int i = 0; i < F->value.properties.size(); i++) {
+ if (F->value.properties[i].name == propname.operator String()) {
+ descr = DTR(F->value.properties[i].description);
break;
}
}
Vector<String> slices = propname.operator String().split("/");
if (slices.size() == 2 && slices[0].begins_with("theme_override_")) {
- for (int i = 0; i < F->get().theme_properties.size(); i++) {
- if (F->get().theme_properties[i].name == slices[1]) {
- descr = DTR(F->get().theme_properties[i].description);
+ for (int i = 0; i < F->value.theme_properties.size(); i++) {
+ if (F->value.theme_properties[i].name == slices[1]) {
+ descr = DTR(F->value.theme_properties[i].description);
break;
}
}
}
- if (!F->get().inherits.is_empty()) {
- F = dd->class_list.find(F->get().inherits);
+ if (!F->value.inherits.is_empty()) {
+ F = dd->class_list.find(F->value.inherits);
} else {
break;
}
@@ -3471,7 +3472,7 @@ void EditorInspector::_object_id_selected(const String &p_path, ObjectID p_id) {
emit_signal(SNAME("object_id_selected"), p_id);
}
-void EditorInspector::_resource_selected(const String &p_path, RES p_resource) {
+void EditorInspector::_resource_selected(const String &p_path, Ref<Resource> p_resource) {
emit_signal(SNAME("resource_selected"), p_resource, p_path);
}
@@ -3515,7 +3516,9 @@ void EditorInspector::_notification(int p_what) {
get_v_scroll_bar()->call_deferred(SNAME("set_value"), update_scroll_request);
update_scroll_request = -1;
}
- if (refresh_countdown > 0) {
+ if (update_tree_pending) {
+ refresh_countdown = float(EditorSettings::get_singleton()->get("docks/property_editor/auto_refresh_interval"));
+ } else if (refresh_countdown > 0) {
refresh_countdown -= get_process_delta_time();
if (refresh_countdown <= 0) {
for (const KeyValue<StringName, List<EditorProperty *>> &F : editor_property_map) {
@@ -3635,7 +3638,7 @@ void EditorInspector::_update_script_class_properties(const Object &p_object, Li
break;
}
- Set<StringName> added;
+ RBSet<StringName> added;
for (const Ref<Script> &s : classes) {
String path = s->get_path();
String name = EditorNode::get_editor_data().script_class_get_name(path);
@@ -3720,6 +3723,8 @@ void EditorInspector::_check_meta_name(String name) {
error = TTR("Invalid metadata identifier.");
} else if (object->has_meta(name)) {
error = TTR("Metadata already exists.");
+ } else if (name[0] == '_') {
+ error = TTR("Names starting with _ are reserved for editor-only metadata.");
}
if (error != "") {