Merge pull request #12855 from Hinsbart/remove_preview

Remove preview when closing "change default type" dialog.
This commit is contained in:
Rémi Verschelde 2017-11-12 21:03:42 +01:00 committed by GitHub
commit b0f10c6643
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View file

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

View file

@ -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<String> &files) const;
void _remove_preview();