From 167c1027bea5b208e5878c96682eb2bec6f59633 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 3 Jan 2015 15:39:01 -0300 Subject: [PATCH] -fixed bug on focus capture, now respets line/text edit -when playing animations, property editor is now refreshed properly, fixes #1046 --- scene/gui/control.cpp | 4 +- tools/editor/editor_settings.cpp | 1 + .../animation_player_editor_plugin.cpp | 4 + tools/editor/property_editor.cpp | 73 +++++++++++++++++++ tools/editor/property_editor.h | 4 + 5 files changed, 84 insertions(+), 2 deletions(-) diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 068801d0bbc..ce268843b1a 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -2684,8 +2684,8 @@ bool Control::is_stopping_mouse() const { Control *Control::get_focus_owner() const { ERR_FAIL_COND_V(!is_inside_tree(),NULL); - ERR_FAIL_COND_V(!window,NULL); - return window->key_focus; + ERR_FAIL_COND_V(!data.window,NULL); + return data.window->window->key_focus; } void Control::_bind_methods() { diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index 3f44701b98f..bc800d7e9e0 100644 --- a/tools/editor/editor_settings.cpp +++ b/tools/editor/editor_settings.cpp @@ -446,6 +446,7 @@ void EditorSettings::_load_defaults() { set("animation/confirm_insert_track",true); set("property_editor/texture_preview_width",48); + set("property_editor/auto_refresh_interval",0.3); set("help/doc_path",""); set("import/ask_save_before_reimport",false); diff --git a/tools/editor/plugins/animation_player_editor_plugin.cpp b/tools/editor/plugins/animation_player_editor_plugin.cpp index 8bb37f1d715..f706d67f6d8 100644 --- a/tools/editor/plugins/animation_player_editor_plugin.cpp +++ b/tools/editor/plugins/animation_player_editor_plugin.cpp @@ -76,6 +76,8 @@ void AnimationPlayerEditor::_notification(int p_what) { seek->set_val(player->get_current_animation_pos()); if (edit_anim->is_pressed()) editor->get_animation_editor()->set_anim_pos(player->get_current_animation_pos()); + EditorNode::get_singleton()->get_property_editor()->refresh(); + } else if (last_active) { //need the last frame after it stopped @@ -854,6 +856,8 @@ void AnimationPlayerEditor::_animation_key_editor_seek(float p_pos) { return; seek->set_val(p_pos); + EditorNode::get_singleton()->get_property_editor()->refresh(); + //seekit diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 777694481b8..559d9b1db54 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -1876,6 +1876,14 @@ void PropertyEditor::_notification(int p_what) { if (p_what==NOTIFICATION_FIXED_PROCESS) { + if (refresh_countdown>0) { + refresh_countdown-=get_fixed_process_delta_time(); + if (refresh_countdown<=0) { + TreeItem *root = tree->get_root(); + _refresh_item(root); + } + } + changing=true; if (update_tree_pending) { @@ -1982,7 +1990,71 @@ TreeItem *PropertyEditor::get_parent_node(String p_path,HashMapget_metadata(1); + + if (name!=String()) { + + if (get_instanced_node()) { + + Dictionary d = get_instanced_node()->get_instance_state(); + if (d.has(name)) { + Variant v = obj->get(name); + Variant vorig = d[name]; + + int found=-1; + for(int i=0;iget_button_count(1);i++) { + + if (p_item->get_button_id(1,i)==3) { + found=i; + break; + } + } + + bool changed = ! (v==vorig); + + if ((found!=-1)!=changed) { + + if (changed) { + + p_item->add_button(1,get_icon("Reload","EditorIcons"),3); + } else { + + p_item->erase_button(1,found); + } + + } + + } + + } + + Dictionary d=p_item->get_metadata(0); + set_item_text(p_item,d["type"],d["name"],d["hint"],d["hint_text"]); + } + + TreeItem *c=p_item->get_children(); + + while (c) { + + _refresh_item(c); + + c=c->get_next(); + } + +} + +void PropertyEditor::refresh() { + + if (refresh_countdown>0) + return; + refresh_countdown=EditorSettings::get_singleton()->get("property_editor/auto_refresh_interval"); + +} void PropertyEditor::update_tree() { @@ -3021,6 +3093,7 @@ PropertyEditor::PropertyEditor() { keying=false; read_only=false; show_categories=false; + refresh_countdown=0; } diff --git a/tools/editor/property_editor.h b/tools/editor/property_editor.h index 08435ad75d4..c05e13b90e9 100644 --- a/tools/editor/property_editor.h +++ b/tools/editor/property_editor.h @@ -156,6 +156,7 @@ class PropertyEditor : public Control { bool keying; bool read_only; bool show_categories; + float refresh_countdown; HashMap pending; String selected_property; @@ -185,6 +186,7 @@ class PropertyEditor : public Control { void _draw_flags(Object *ti,const Rect2& p_rect); Node *get_instanced_node(); + void _refresh_item(TreeItem *p_item); UndoRedo *undo_redo; protected: @@ -203,6 +205,8 @@ public: void update_tree(); void update_property(const String& p_prop); + void refresh(); + void edit(Object* p_object); void set_keying(bool p_active);