diff --git a/core/core_constants.cpp b/core/core_constants.cpp index 68af5abf66a3..25da49fa5c3e 100644 --- a/core/core_constants.cpp +++ b/core/core_constants.cpp @@ -677,6 +677,7 @@ void register_global_constants() { BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_NODE_TYPE); BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_HIDE_QUATERNION_EDIT); BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_PASSWORD); + BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_TOOL_BUTTON); BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_MAX); BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_NONE); diff --git a/core/object/object.h b/core/object/object.h index 1274247d716b..bbdcefcbac19 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -87,6 +87,7 @@ enum PropertyHint { PROPERTY_HINT_PASSWORD, PROPERTY_HINT_LAYERS_AVOIDANCE, PROPERTY_HINT_DICTIONARY_TYPE, + PROPERTY_HINT_TOOL_BUTTON, PROPERTY_HINT_MAX, }; @@ -135,6 +136,7 @@ enum PropertyUsageFlags { #define ADD_SUBGROUP(m_name, m_prefix) ::ClassDB::add_property_subgroup(get_class_static(), m_name, m_prefix) #define ADD_SUBGROUP_INDENT(m_name, m_prefix, m_depth) ::ClassDB::add_property_subgroup(get_class_static(), m_name, m_prefix, m_depth) #define ADD_LINKED_PROPERTY(m_property, m_linked_property) ::ClassDB::add_linked_property(get_class_static(), m_property, m_linked_property) +#define ADD_TOOL_BUTTON(m_method, m_label, m_icon) ::ClassDB::add_property(get_class_static(), PropertyInfo(Variant::NIL, "@tool_button_" + String(m_method), PROPERTY_HINT_TOOL_BUTTON, String(m_method) + "," + String(m_label) + "," + String(m_icon), PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_INTERNAL), StringName(), StringName()) #define ADD_ARRAY_COUNT(m_label, m_count_property, m_count_property_setter, m_count_property_getter, m_prefix) ClassDB::add_property_array_count(get_class_static(), m_label, m_count_property, _scs_create(m_count_property_setter), _scs_create(m_count_property_getter), m_prefix) #define ADD_ARRAY_COUNT_WITH_USAGE_FLAGS(m_label, m_count_property, m_count_property_setter, m_count_property_getter, m_prefix, m_property_usage_flags) ClassDB::add_property_array_count(get_class_static(), m_label, m_count_property, _scs_create(m_count_property_setter), _scs_create(m_count_property_getter), m_prefix, m_property_usage_flags) diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index f222cbc96953..31efab40aad2 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -2933,7 +2933,9 @@ Hints that a string property is a password, and every character is replaced with the secret character. - + + + Represents the size of the [enum PropertyHint] enum. diff --git a/editor/plugins/tool_button_editor_plugin.cpp b/editor/plugins/tool_button_editor_plugin.cpp index e091e518eddf..ce0860a2f18c 100644 --- a/editor/plugins/tool_button_editor_plugin.cpp +++ b/editor/plugins/tool_button_editor_plugin.cpp @@ -34,16 +34,16 @@ #include "editor/editor_undo_redo_manager.h" #include "scene/gui/button.h" -bool ToolButtonInspectorPlugin::can_handle(Object *p_object) { +bool EditorInspectorToolButtonPlugin::can_handle(Object *p_object) { Ref