summaryrefslogtreecommitdiff
path: root/editor/progress_dialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/progress_dialog.cpp')
-rw-r--r--editor/progress_dialog.cpp90
1 files changed, 54 insertions, 36 deletions
diff --git a/editor/progress_dialog.cpp b/editor/progress_dialog.cpp
index 4cc60c4c3c..37f941c7b2 100644
--- a/editor/progress_dialog.cpp
+++ b/editor/progress_dialog.cpp
@@ -1,37 +1,38 @@
-/*************************************************************************/
-/* progress_dialog.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
+/**************************************************************************/
+/* progress_dialog.cpp */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
#include "progress_dialog.h"
#include "core/object/message_queue.h"
#include "core/os/os.h"
+#include "editor/editor_node.h"
#include "editor/editor_scale.h"
#include "main/main.h"
#include "servers/display_server.h"
@@ -133,6 +134,14 @@ void BackgroundProgress::end_task(const String &p_task) {
ProgressDialog *ProgressDialog::singleton = nullptr;
void ProgressDialog::_notification(int p_what) {
+ if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
+ if (!is_visible()) {
+ Node *p = get_parent();
+ if (p) {
+ p->remove_child(this);
+ }
+ }
+ }
}
void ProgressDialog::_popup() {
@@ -146,8 +155,17 @@ void ProgressDialog::_popup() {
main->set_offset(SIDE_TOP, style->get_margin(SIDE_TOP));
main->set_offset(SIDE_BOTTOM, -style->get_margin(SIDE_BOTTOM));
- //raise();
- popup_centered(ms);
+ EditorNode *ed = EditorNode::get_singleton();
+ if (ed && !is_inside_tree()) {
+ Window *w = ed->get_window();
+ while (w && w->get_exclusive_child()) {
+ w = w->get_exclusive_child();
+ }
+ if (w && w != this) {
+ w->add_child(this);
+ popup_centered(ms);
+ }
+ }
}
void ProgressDialog::add_task(const String &p_task, const String &p_label, int p_steps, bool p_can_cancel) {
@@ -177,7 +195,7 @@ void ProgressDialog::add_task(const String &p_task, const String &p_label, int p
cancel_hb->hide();
}
cancel_hb->move_to_front();
- cancelled = false;
+ canceled = false;
_popup();
if (p_can_cancel) {
cancel->grab_focus();
@@ -185,12 +203,12 @@ void ProgressDialog::add_task(const String &p_task, const String &p_label, int p
}
bool ProgressDialog::task_step(const String &p_task, const String &p_state, int p_step, bool p_force_redraw) {
- ERR_FAIL_COND_V(!tasks.has(p_task), cancelled);
+ ERR_FAIL_COND_V(!tasks.has(p_task), canceled);
if (!p_force_redraw) {
uint64_t tus = OS::get_singleton()->get_ticks_usec();
if (tus - last_progress_tick < 200000) { //200ms
- return cancelled;
+ return canceled;
}
}
@@ -210,7 +228,7 @@ bool ProgressDialog::task_step(const String &p_task, const String &p_state, int
#ifndef ANDROID_ENABLED
Main::iteration(); // this will not work on a lot of platforms, so it's only meant for the editor
#endif
- return cancelled;
+ return canceled;
}
void ProgressDialog::end_task(const String &p_task) {
@@ -228,7 +246,7 @@ void ProgressDialog::end_task(const String &p_task) {
}
void ProgressDialog::_cancel_pressed() {
- cancelled = true;
+ canceled = true;
}
void ProgressDialog::_bind_methods() {