diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-06-25 17:30:28 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-06-25 17:31:22 -0300 |
commit | 760cdbe1a31837bcb142de6912718fd80f57346b (patch) | |
tree | 2b11c560a4e20999d54a391cc4c803504cd46907 /core | |
parent | 826784d965a5200670f13709d69e3135bf1f4d9e (diff) |
-Added folding to property editor, persistent on objects it edits
-Some changes to tree to support this properly
Diffstat (limited to 'core')
-rw-r--r-- | core/core_string_names.cpp | 3 | ||||
-rw-r--r-- | core/core_string_names.h | 3 | ||||
-rw-r--r-- | core/object.cpp | 42 | ||||
-rw-r--r-- | core/object.h | 6 |
4 files changed, 54 insertions, 0 deletions
diff --git a/core/core_string_names.cpp b/core/core_string_names.cpp index e35ac2b72c..0ed44b0cb7 100644 --- a/core/core_string_names.cpp +++ b/core/core_string_names.cpp @@ -44,4 +44,7 @@ CoreStringNames::CoreStringNames() { _iter_next = StaticCString::create("_iter_next"); _iter_get = StaticCString::create("_iter_get"); get_rid = StaticCString::create("get_rid"); +#ifdef TOOLS_ENABLED + _sections_unfolded = StaticCString::create("_sections_unfolded"); +#endif } diff --git a/core/core_string_names.h b/core/core_string_names.h index 6672772432..4b4f87a8f0 100644 --- a/core/core_string_names.h +++ b/core/core_string_names.h @@ -61,6 +61,9 @@ public: StringName _iter_next; StringName _iter_get; StringName get_rid; +#ifdef TOOLS_ENABLED + StringName _sections_unfolded; +#endif }; #endif // SCENE_STRING_NAMES_H diff --git a/core/object.cpp b/core/object.cpp index f20e93f9d7..d83b2d0c6e 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -419,6 +419,16 @@ void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid if (r_valid) *r_valid = true; return; +#ifdef TOOLS_ENABLED + } else if (p_name == CoreStringNames::get_singleton()->_sections_unfolded) { + Array arr = p_value; + for (int i = 0; i < arr.size(); i++) { + editor_section_folding.insert(arr[i]); + } + if (r_valid) + *r_valid = true; + return; +#endif } else { //something inside the object... :| bool success = _setv(p_name, p_value); @@ -464,6 +474,16 @@ Variant Object::get(const StringName &p_name, bool *r_valid) const { if (r_valid) *r_valid = true; return ret; +#ifdef TOOLS_ENABLED + } else if (p_name == CoreStringNames::get_singleton()->_sections_unfolded) { + Array array; + for (Set<String>::Element *E = editor_section_folding.front(); E; E = E->next()) { + array.push_back(E->get()); + } + if (r_valid) + *r_valid = true; + return array; +#endif } else { //something inside the object... :| bool success = _getv(p_name, ret); @@ -516,6 +536,11 @@ void Object::get_property_list(List<PropertyInfo> *p_list, bool p_reversed) cons if (!is_class("Script")) // can still be set, but this is for userfriendlyness p_list->push_back(PropertyInfo(Variant::OBJECT, "script", PROPERTY_HINT_RESOURCE_TYPE, "Script", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NONZERO)); +#ifdef TOOLS_ENABLED + if (editor_section_folding.size()) { + p_list->push_back(PropertyInfo(Variant::ARRAY, CoreStringNames::get_singleton()->_sections_unfolded, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); + } +#endif if (!metadata.empty()) p_list->push_back(PropertyInfo(Variant::DICTIONARY, "__meta__", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_STORE_IF_NONZERO)); if (script_instance && !p_reversed) { @@ -1571,6 +1596,23 @@ void Object::_clear_internal_resource_paths(const Variant &p_var) { } } +#ifdef TOOLS_ENABLED +void Object::editor_set_section_unfold(const String &p_section, bool p_unfolded) { + + set_edited(true); + if (p_unfolded) + editor_section_folding.insert(p_section); + else + editor_section_folding.erase(p_section); +} + +bool Object::editor_is_section_unfolded(const String &p_section) { + + return editor_section_folding.has(p_section); +} + +#endif + void Object::clear_internal_resource_paths() { List<PropertyInfo> pinfo; diff --git a/core/object.h b/core/object.h index 83b03b9239..fabd10fa1f 100644 --- a/core/object.h +++ b/core/object.h @@ -430,6 +430,7 @@ private: #ifdef TOOLS_ENABLED bool _edited; uint32_t _edited_version; + Set<String> editor_section_folding; #endif ScriptInstance *script_instance; RefPtr script; @@ -666,6 +667,11 @@ public: _FORCE_INLINE_ void set_message_translation(bool p_enable) { _can_translate = p_enable; } _FORCE_INLINE_ bool can_translate_messages() const { return _can_translate; } +#ifdef TOOLS_ENABLED + void editor_set_section_unfold(const String &p_section, bool p_unfolded); + bool editor_is_section_unfolded(const String &p_section); +#endif + void clear_internal_resource_paths(); Object(); |