Change method of storing folding, solves problems with inheritance, closes #3395

This commit is contained in:
Juan Linietsky 2016-06-28 13:10:15 -03:00
parent 519fce94e9
commit 5065e46381
4 changed files with 31 additions and 6 deletions

View File

@ -144,6 +144,7 @@ opts.Add('unix_global_settings_path', 'unix-specific path to system-wide setting
opts.Add('disable_3d', 'Disable 3D nodes for smaller executable (yes/no)', "no")
opts.Add('disable_advanced_gui', 'Disable advance 3D gui nodes and behaviors (yes/no)', "no")
opts.Add('colored', 'Enable colored output for the compilation (yes/no)', 'no')
opts.Add('deprecated','Enable deprecated features (yes/no)','yes')
opts.Add('extra_suffix', 'Custom extra suffix added to the base filename of all generated binary files.', '')
opts.Add('vsproj', 'Generate Visual Studio Project. (yes/no)', 'no')
@ -179,6 +180,9 @@ if (env_base['target']=='debug'):
env_base.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']);
env_base.Append(CPPFLAGS=['-DSCI_NAMESPACE'])
if (env_base['deprecated']!='no'):
env_base.Append(CPPFLAGS=['-DENABLE_DEPRECATED']);
env_base.platforms = {}

View File

@ -2085,6 +2085,15 @@ bool Node::is_owned_by_parent() const {
return data.parent_owned;
}
void Node::set_display_folded(bool p_folded) {
data.display_folded=p_folded;
}
bool Node::is_displayed_folded() const {
return data.display_folded;
}
void Node::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_add_child_below_node","node:Node","child_node:Node","legible_unique_name"),&Node::add_child_below_node,DEFVAL(false));
@ -2140,6 +2149,8 @@ void Node::_bind_methods() {
ObjectTypeDB::bind_method(_MD("can_process"),&Node::can_process);
ObjectTypeDB::bind_method(_MD("print_stray_nodes"),&Node::_print_stray_nodes);
ObjectTypeDB::bind_method(_MD("get_position_in_parent"),&Node::get_position_in_parent);
ObjectTypeDB::bind_method(_MD("set_display_folded","fold"),&Node::set_display_folded);
ObjectTypeDB::bind_method(_MD("is_displayed_folded"),&Node::is_displayed_folded);
ObjectTypeDB::bind_method(_MD("get_tree:SceneTree"),&Node::get_tree);
@ -2194,6 +2205,7 @@ void Node::_bind_methods() {
//ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/input" ), _SCS("set_process_input"),_SCS("is_processing_input" ) );
//ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/unhandled_input" ), _SCS("set_process_unhandled_input"),_SCS("is_processing_unhandled_input" ) );
ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "process/pause_mode",PROPERTY_HINT_ENUM,"Inherit,Stop,Process" ), _SCS("set_pause_mode"),_SCS("get_pause_mode" ) );
ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "editor/display_folded",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR ), _SCS("set_display_folded"),_SCS("is_displayed_folded" ) );
BIND_VMETHOD( MethodInfo("_process",PropertyInfo(Variant::REAL,"delta")) );
BIND_VMETHOD( MethodInfo("_fixed_process",PropertyInfo(Variant::REAL,"delta")) );
@ -2231,6 +2243,7 @@ Node::Node() {
data.in_constructor=true;
data.viewport=NULL;
data.use_placeholder=false;
data.display_folded=false;
}
Node::~Node() {
@ -2240,6 +2253,7 @@ Node::~Node() {
data.owned.clear();
data.children.clear();
ERR_FAIL_COND(data.parent);
ERR_FAIL_COND(data.children.size());

View File

@ -111,6 +111,7 @@ private:
bool in_constructor;
bool use_placeholder;
bool display_folded;
} data;
@ -325,6 +326,8 @@ public:
void update_configuration_warning();
void set_display_folded(bool p_folded);
bool is_displayed_folded() const;
/* CANVAS */
Node();

View File

@ -302,8 +302,15 @@ bool SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) {
item->set_selectable(0,true);
if (can_rename) {
bool collapsed = p_node->has_meta("_editor_collapsed") ? (bool)p_node->get_meta("_editor_collapsed") : false;
#ifdef ENABLE_DEPRECATED
if (p_node->has_meta("_editor_collapsed")) {
//remove previous way of storing folding, which did not get along with scene inheritance and instancing
if ((bool)p_node->get_meta("_editor_collapsed"))
p_node->set_display_folded(true);
p_node->set_meta("_editor_collapsed",Variant());
}
#endif
bool collapsed = p_node->is_displayed_folded();
if (collapsed)
item->set_collapsed(true);
}
@ -896,10 +903,7 @@ void SceneTreeEditor::_cell_collapsed(Object *p_obj) {
Node *n=get_node(np);
ERR_FAIL_COND(!n);
if (collapsed)
n->set_meta("_editor_collapsed",true);
else
n->set_meta("_editor_collapsed",Variant());
n->set_display_folded(collapsed);
}