-fixed bug on focus capture, now respets line/text edit

-when playing animations, property editor is now refreshed properly, fixes #1046
This commit is contained in:
Juan Linietsky 2015-01-03 15:39:01 -03:00
parent ffd4b22e09
commit 167c1027be
5 changed files with 84 additions and 2 deletions

View File

@ -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() {

View File

@ -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);

View File

@ -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

View File

@ -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,HashMap<String,TreeItem*
}
void PropertyEditor::_refresh_item(TreeItem *p_item) {
if (!p_item)
return;
String name = p_item->get_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;i<p_item->get_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;
}

View File

@ -156,6 +156,7 @@ class PropertyEditor : public Control {
bool keying;
bool read_only;
bool show_categories;
float refresh_countdown;
HashMap<String,String> 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);