Merge pull request #54836 from pycbouh/inspector-plugins-fixes-and-groups
This commit is contained in:
commit
68664c0239
13 changed files with 44 additions and 67 deletions
|
@ -25,8 +25,9 @@
|
|||
</method>
|
||||
<method name="_parse_begin" qualifiers="virtual">
|
||||
<return type="void" />
|
||||
<argument index="0" name="object" type="Object" />
|
||||
<description>
|
||||
Called to allow adding controls at the beginning of the list.
|
||||
Called to allow adding controls at the beginning of the property list for [code]object[/code].
|
||||
</description>
|
||||
</method>
|
||||
<method name="_parse_category" qualifiers="virtual">
|
||||
|
@ -34,12 +35,22 @@
|
|||
<argument index="0" name="object" type="Object" />
|
||||
<argument index="1" name="category" type="String" />
|
||||
<description>
|
||||
Called to allow adding controls at the beginning of a category in the property list for [code]object[/code].
|
||||
</description>
|
||||
</method>
|
||||
<method name="_parse_end" qualifiers="virtual">
|
||||
<return type="void" />
|
||||
<argument index="0" name="object" type="Object" />
|
||||
<description>
|
||||
Called to allow adding controls at the end of the list.
|
||||
Called to allow adding controls at the end of the property list for [code]object[/code].
|
||||
</description>
|
||||
</method>
|
||||
<method name="_parse_group" qualifiers="virtual">
|
||||
<return type="void" />
|
||||
<argument index="0" name="object" type="Object" />
|
||||
<argument index="1" name="group" type="String" />
|
||||
<description>
|
||||
Called to allow adding controls at the beginning of a group or a sub-group in the property list for [code]object[/code].
|
||||
</description>
|
||||
</method>
|
||||
<method name="_parse_property" qualifiers="virtual">
|
||||
|
@ -52,7 +63,7 @@
|
|||
<argument index="5" name="usage_flags" type="int" />
|
||||
<argument index="6" name="wide" type="bool" />
|
||||
<description>
|
||||
Called to allow adding property specific editors to the inspector. Usually these inherit [EditorProperty]. Returning [code]true[/code] removes the built-in editor for this property, otherwise allows to insert a custom editor before the built-in one.
|
||||
Called to allow adding property-specific editors to the property list for [code]object[/code]. The added editor control must extend [EditorProperty]. Returning [code]true[/code] removes the built-in editor for this property, otherwise allows to insert a custom editor before the built-in one.
|
||||
</description>
|
||||
</method>
|
||||
<method name="add_custom_control">
|
||||
|
|
|
@ -1014,11 +1014,15 @@ bool EditorInspectorPlugin::can_handle(Object *p_object) {
|
|||
}
|
||||
|
||||
void EditorInspectorPlugin::parse_begin(Object *p_object) {
|
||||
GDVIRTUAL_CALL(_parse_begin);
|
||||
GDVIRTUAL_CALL(_parse_begin, p_object);
|
||||
}
|
||||
|
||||
void EditorInspectorPlugin::parse_category(Object *p_object, const String &p_parse_category) {
|
||||
GDVIRTUAL_CALL(_parse_category, p_object, p_parse_category);
|
||||
void EditorInspectorPlugin::parse_category(Object *p_object, const String &p_category) {
|
||||
GDVIRTUAL_CALL(_parse_category, p_object, p_category);
|
||||
}
|
||||
|
||||
void EditorInspectorPlugin::parse_group(Object *p_object, const String &p_group) {
|
||||
GDVIRTUAL_CALL(_parse_group, p_object, p_group);
|
||||
}
|
||||
|
||||
bool EditorInspectorPlugin::parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide) {
|
||||
|
@ -1029,8 +1033,8 @@ bool EditorInspectorPlugin::parse_property(Object *p_object, const Variant::Type
|
|||
return false;
|
||||
}
|
||||
|
||||
void EditorInspectorPlugin::parse_end() {
|
||||
GDVIRTUAL_CALL(_parse_end);
|
||||
void EditorInspectorPlugin::parse_end(Object *p_object) {
|
||||
GDVIRTUAL_CALL(_parse_end, p_object);
|
||||
}
|
||||
|
||||
void EditorInspectorPlugin::_bind_methods() {
|
||||
|
@ -1039,10 +1043,11 @@ void EditorInspectorPlugin::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("add_property_editor_for_multiple_properties", "label", "properties", "editor"), &EditorInspectorPlugin::add_property_editor_for_multiple_properties);
|
||||
|
||||
GDVIRTUAL_BIND(_can_handle, "object")
|
||||
GDVIRTUAL_BIND(_parse_begin)
|
||||
GDVIRTUAL_BIND(_parse_begin, "object")
|
||||
GDVIRTUAL_BIND(_parse_category, "object", "category")
|
||||
GDVIRTUAL_BIND(_parse_group, "object", "group")
|
||||
GDVIRTUAL_BIND(_parse_property, "object", "type", "name", "hint_type", "hint_string", "usage_flags", "wide");
|
||||
GDVIRTUAL_BIND(_parse_end)
|
||||
GDVIRTUAL_BIND(_parse_end, "object")
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////
|
||||
|
@ -2628,6 +2633,12 @@ void EditorInspector::update_tree() {
|
|||
c.a /= level;
|
||||
section->setup(acc_path, component, object, c, use_folding);
|
||||
|
||||
// Add editors at the start of a group.
|
||||
for (Ref<EditorInspectorPlugin> &ped : valid_plugins) {
|
||||
ped->parse_group(object, path);
|
||||
_parse_added_editors(section->get_vbox(), ped);
|
||||
}
|
||||
|
||||
vbox_per_path[root_vbox][acc_path] = section->get_vbox();
|
||||
}
|
||||
|
||||
|
@ -2837,7 +2848,7 @@ void EditorInspector::update_tree() {
|
|||
|
||||
// Get the lists of to add at the end.
|
||||
for (Ref<EditorInspectorPlugin> &ped : valid_plugins) {
|
||||
ped->parse_end();
|
||||
ped->parse_end(object);
|
||||
_parse_added_editors(main_vbox, ped);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -215,10 +215,11 @@ protected:
|
|||
static void _bind_methods();
|
||||
|
||||
GDVIRTUAL1RC(bool, _can_handle, Variant)
|
||||
GDVIRTUAL0(_parse_begin)
|
||||
GDVIRTUAL1(_parse_begin, Object *)
|
||||
GDVIRTUAL2(_parse_category, Object *, String)
|
||||
GDVIRTUAL2(_parse_group, Object *, String)
|
||||
GDVIRTUAL7R(bool, _parse_property, Object *, int, String, int, String, int, bool)
|
||||
GDVIRTUAL0(_parse_end)
|
||||
GDVIRTUAL1(_parse_end, Object *)
|
||||
|
||||
public:
|
||||
void add_custom_control(Control *control);
|
||||
|
@ -227,9 +228,10 @@ public:
|
|||
|
||||
virtual bool can_handle(Object *p_object);
|
||||
virtual void parse_begin(Object *p_object);
|
||||
virtual void parse_category(Object *p_object, const String &p_parse_category);
|
||||
virtual void parse_category(Object *p_object, const String &p_category);
|
||||
virtual void parse_group(Object *p_object, const String &p_group);
|
||||
virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide = false);
|
||||
virtual void parse_end();
|
||||
virtual void parse_end(Object *p_object);
|
||||
};
|
||||
|
||||
class EditorInspectorCategory : public Control {
|
||||
|
|
|
@ -3170,11 +3170,7 @@ EditorPropertyResource::EditorPropertyResource() {
|
|||
////////////// DEFAULT PLUGIN //////////////////////
|
||||
|
||||
bool EditorInspectorDefaultPlugin::can_handle(Object *p_object) {
|
||||
return true; //can handle everything
|
||||
}
|
||||
|
||||
void EditorInspectorDefaultPlugin::parse_begin(Object *p_object) {
|
||||
//do none
|
||||
return true; // Can handle everything.
|
||||
}
|
||||
|
||||
bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide) {
|
||||
|
@ -3185,10 +3181,6 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, const Varian
|
|||
return false;
|
||||
}
|
||||
|
||||
void EditorInspectorDefaultPlugin::parse_end() {
|
||||
//do none
|
||||
}
|
||||
|
||||
struct EditorPropertyRangeHint {
|
||||
bool angle_in_degrees = false;
|
||||
bool greater = true;
|
||||
|
|
|
@ -696,9 +696,7 @@ class EditorInspectorDefaultPlugin : public EditorInspectorPlugin {
|
|||
|
||||
public:
|
||||
virtual bool can_handle(Object *p_object) override;
|
||||
virtual void parse_begin(Object *p_object) override;
|
||||
virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide = false) override;
|
||||
virtual void parse_end() override;
|
||||
|
||||
static EditorProperty *get_editor_for_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide = false);
|
||||
};
|
||||
|
|
|
@ -185,12 +185,6 @@ bool EditorInspectorPluginOpenTypeFeatures::can_handle(Object *p_object) {
|
|||
return (Object::cast_to<Control>(p_object) != nullptr);
|
||||
}
|
||||
|
||||
void EditorInspectorPluginOpenTypeFeatures::parse_begin(Object *p_object) {
|
||||
}
|
||||
|
||||
void EditorInspectorPluginOpenTypeFeatures::parse_category(Object *p_object, const String &p_parse_category) {
|
||||
}
|
||||
|
||||
bool EditorInspectorPluginOpenTypeFeatures::parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide) {
|
||||
if (p_path == "opentype_features/_new") {
|
||||
OpenTypeFeaturesAdd *editor = memnew(OpenTypeFeaturesAdd);
|
||||
|
|
|
@ -86,8 +86,6 @@ class EditorInspectorPluginOpenTypeFeatures : public EditorInspectorPlugin {
|
|||
|
||||
public:
|
||||
virtual bool can_handle(Object *p_object) override;
|
||||
virtual void parse_begin(Object *p_object) override;
|
||||
virtual void parse_category(Object *p_object, const String &p_parse_category) override;
|
||||
virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide = false) override;
|
||||
};
|
||||
|
||||
|
|
|
@ -271,11 +271,7 @@ EditorPropertyRootMotion::EditorPropertyRootMotion() {
|
|||
//////////////////////////
|
||||
|
||||
bool EditorInspectorRootMotionPlugin::can_handle(Object *p_object) {
|
||||
return true; //can handle everything
|
||||
}
|
||||
|
||||
void EditorInspectorRootMotionPlugin::parse_begin(Object *p_object) {
|
||||
//do none
|
||||
return true; // Can handle everything.
|
||||
}
|
||||
|
||||
bool EditorInspectorRootMotionPlugin::parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide) {
|
||||
|
@ -288,9 +284,5 @@ bool EditorInspectorRootMotionPlugin::parse_property(Object *p_object, const Var
|
|||
return true;
|
||||
}
|
||||
|
||||
return false; //can be overridden, although it will most likely be last anyway
|
||||
}
|
||||
|
||||
void EditorInspectorRootMotionPlugin::parse_end() {
|
||||
//do none
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -64,9 +64,7 @@ class EditorInspectorRootMotionPlugin : public EditorInspectorPlugin {
|
|||
|
||||
public:
|
||||
virtual bool can_handle(Object *p_object) override;
|
||||
virtual void parse_begin(Object *p_object) override;
|
||||
virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide = false) override;
|
||||
virtual void parse_end() override;
|
||||
};
|
||||
|
||||
#endif // ROOT_MOTION_EDITOR_PLUGIN_H
|
||||
|
|
|
@ -44,13 +44,6 @@ void EditorInspectorPluginStyleBox::parse_begin(Object *p_object) {
|
|||
add_custom_control(preview);
|
||||
}
|
||||
|
||||
bool EditorInspectorPluginStyleBox::parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, bool p_wide) {
|
||||
return false; //do not want
|
||||
}
|
||||
|
||||
void EditorInspectorPluginStyleBox::parse_end() {
|
||||
}
|
||||
|
||||
void StyleBoxPreview::edit(const Ref<StyleBox> &p_stylebox) {
|
||||
if (stylebox.is_valid()) {
|
||||
stylebox->disconnect("changed", callable_mp(this, &StyleBoxPreview::_sb_changed));
|
||||
|
|
|
@ -61,8 +61,6 @@ class EditorInspectorPluginStyleBox : public EditorInspectorPlugin {
|
|||
public:
|
||||
virtual bool can_handle(Object *p_object) override;
|
||||
virtual void parse_begin(Object *p_object) override;
|
||||
virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide = false) override;
|
||||
virtual void parse_end() override;
|
||||
};
|
||||
|
||||
class StyleBoxEditorPlugin : public EditorPlugin {
|
||||
|
|
|
@ -5187,11 +5187,7 @@ EditorPropertyShaderMode::EditorPropertyShaderMode() {
|
|||
}
|
||||
|
||||
bool EditorInspectorShaderModePlugin::can_handle(Object *p_object) {
|
||||
return true; //can handle everything
|
||||
}
|
||||
|
||||
void EditorInspectorShaderModePlugin::parse_begin(Object *p_object) {
|
||||
//do none
|
||||
return true; // Can handle everything.
|
||||
}
|
||||
|
||||
bool EditorInspectorShaderModePlugin::parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide) {
|
||||
|
@ -5204,11 +5200,7 @@ bool EditorInspectorShaderModePlugin::parse_property(Object *p_object, const Var
|
|||
return true;
|
||||
}
|
||||
|
||||
return false; //can be overridden, although it will most likely be last anyway
|
||||
}
|
||||
|
||||
void EditorInspectorShaderModePlugin::parse_end() {
|
||||
//do none
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
|
|
|
@ -523,9 +523,7 @@ class EditorInspectorShaderModePlugin : public EditorInspectorPlugin {
|
|||
|
||||
public:
|
||||
virtual bool can_handle(Object *p_object) override;
|
||||
virtual void parse_begin(Object *p_object) override;
|
||||
virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide = false) override;
|
||||
virtual void parse_end() override;
|
||||
};
|
||||
|
||||
class VisualShaderNodePortPreview : public Control {
|
||||
|
|
Loading…
Reference in a new issue