You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-12 13:20:55 +00:00
Allow EditorInspector to change its property name style when necessary
Previously, an EditorInspector's property name can only be set from outside. Inspectors used for settings needs to respond to changes in editor settings. So a few boilerplate code is almost always needed, including watching for a certain editor setting in `_notification()`. This commit adds a `set_use_settings_style()` function to tell the inspector to watch for editor settings changes on its own.
This commit is contained in:
@@ -3441,6 +3441,16 @@ void EditorInspector::set_property_name_style(EditorPropertyNameProcessor::Style
|
||||
update_tree();
|
||||
}
|
||||
|
||||
void EditorInspector::set_use_settings_name_style(bool p_enable) {
|
||||
if (use_settings_name_style == p_enable) {
|
||||
return;
|
||||
}
|
||||
use_settings_name_style = p_enable;
|
||||
if (use_settings_name_style) {
|
||||
set_property_name_style(EditorPropertyNameProcessor::get_singleton()->get_settings_style());
|
||||
}
|
||||
}
|
||||
|
||||
void EditorInspector::set_autoclear(bool p_enable) {
|
||||
autoclear = p_enable;
|
||||
}
|
||||
@@ -3973,7 +3983,20 @@ void EditorInspector::_notification(int p_what) {
|
||||
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
|
||||
_update_inspector_bg();
|
||||
|
||||
bool needs_update = false;
|
||||
|
||||
if (use_settings_name_style && EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/localize_settings")) {
|
||||
EditorPropertyNameProcessor::Style style = EditorPropertyNameProcessor::get_settings_style();
|
||||
if (property_name_style != style) {
|
||||
property_name_style = style;
|
||||
needs_update = true;
|
||||
}
|
||||
}
|
||||
if (EditorSettings::get_singleton()->check_changed_settings_in_group("interface/inspector")) {
|
||||
needs_update = true;
|
||||
}
|
||||
|
||||
if (needs_update) {
|
||||
update_tree();
|
||||
}
|
||||
} break;
|
||||
@@ -4158,4 +4181,7 @@ EditorInspector::EditorInspector() {
|
||||
ED_SHORTCUT("property_editor/copy_value", TTR("Copy Value"), KeyModifierMask::CMD_OR_CTRL | Key::C);
|
||||
ED_SHORTCUT("property_editor/paste_value", TTR("Paste Value"), KeyModifierMask::CMD_OR_CTRL | Key::V);
|
||||
ED_SHORTCUT("property_editor/copy_property_path", TTR("Copy Property Path"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::C);
|
||||
|
||||
// `use_settings_name_style` is true by default, set the name style accordingly.
|
||||
set_property_name_style(EditorPropertyNameProcessor::get_singleton()->get_settings_style());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user