From 58fafea485bc7223ff4cffe9b9eef8ce9cda0c4c Mon Sep 17 00:00:00 2001 From: Andreas Haas Date: Sun, 12 Nov 2017 10:50:06 +0100 Subject: Remove preview when closing "change default type" dialog. --- editor/plugins/canvas_item_editor_plugin.cpp | 13 ++++++++++--- editor/plugins/canvas_item_editor_plugin.h | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'editor') diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 16564ce45f..21f0afde81 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -4377,7 +4377,7 @@ void CanvasItemEditorViewport::_on_select_type(Object *selected) { label->set_text(vformat(TTR("Adding %s..."), type)); } -void CanvasItemEditorViewport::_on_change_type() { +void CanvasItemEditorViewport::_on_change_type_confirmed() { if (!button_group->get_pressed_button()) return; @@ -4387,6 +4387,11 @@ void CanvasItemEditorViewport::_on_change_type() { selector->hide(); } +void CanvasItemEditorViewport::_on_change_type_closed() { + + _remove_preview(); +} + void CanvasItemEditorViewport::_create_preview(const Vector &files) const { label->set_position(get_global_position() + Point2(14, 14) * EDSCALE); label_desc->set_position(label->get_position() + Point2(0, label->get_size().height)); @@ -4721,7 +4726,8 @@ void CanvasItemEditorViewport::_notification(int p_what) { void CanvasItemEditorViewport::_bind_methods() { ClassDB::bind_method(D_METHOD("_on_select_type"), &CanvasItemEditorViewport::_on_select_type); - ClassDB::bind_method(D_METHOD("_on_change_type"), &CanvasItemEditorViewport::_on_change_type); + ClassDB::bind_method(D_METHOD("_on_change_type_confirmed"), &CanvasItemEditorViewport::_on_change_type_confirmed); + ClassDB::bind_method(D_METHOD("_on_change_type_closed"), &CanvasItemEditorViewport::_on_change_type_closed); ClassDB::bind_method(D_METHOD("_on_mouse_exit"), &CanvasItemEditorViewport::_on_mouse_exit); } @@ -4749,7 +4755,8 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte selector = memnew(AcceptDialog); editor->get_gui_base()->add_child(selector); selector->set_title(TTR("Change default type")); - selector->connect("confirmed", this, "_on_change_type"); + selector->connect("confirmed", this, "_on_change_type_confirmed"); + selector->connect("popup_hide", this, "_on_change_type_closed"); VBoxContainer *vbc = memnew(VBoxContainer); selector->add_child(vbc); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 97e3b03569..457833e1a7 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -568,7 +568,8 @@ class CanvasItemEditorViewport : public Control { void _on_mouse_exit(); void _on_select_type(Object *selected); - void _on_change_type(); + void _on_change_type_confirmed(); + void _on_change_type_closed(); void _create_preview(const Vector &files) const; void _remove_preview(); -- cgit v1.2.3