summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main')
-rw-r--r--scene/main/canvas_item.cpp7
-rw-r--r--scene/main/canvas_layer.cpp5
-rw-r--r--scene/main/http_request.cpp28
-rw-r--r--scene/main/node.cpp10
-rw-r--r--scene/main/scene_tree.cpp11
-rw-r--r--scene/main/shader_globals_override.cpp35
-rw-r--r--scene/main/timer.cpp4
-rw-r--r--scene/main/viewport.cpp20
-rw-r--r--scene/main/window.cpp21
9 files changed, 78 insertions, 63 deletions
diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp
index b794bbbc57..9ad711c596 100644
--- a/scene/main/canvas_item.cpp
+++ b/scene/main/canvas_item.cpp
@@ -305,6 +305,7 @@ void CanvasItem::_notification(int p_what) {
get_tree()->xform_change_list.add(&xform_change);
}
} break;
+
case NOTIFICATION_MOVED_IN_PARENT: {
if (!is_inside_tree()) {
break;
@@ -317,8 +318,8 @@ void CanvasItem::_notification(int p_what) {
ERR_FAIL_COND(!p);
RenderingServer::get_singleton()->canvas_item_set_draw_index(canvas_item, get_index());
}
-
} break;
+
case NOTIFICATION_EXIT_TREE: {
if (xform_change.in_list()) {
get_tree()->xform_change_list.remove(&xform_change);
@@ -334,9 +335,7 @@ void CanvasItem::_notification(int p_what) {
global_invalid = true;
visible_in_tree = false;
} break;
- case NOTIFICATION_DRAW:
- case NOTIFICATION_TRANSFORM_CHANGED: {
- } break;
+
case NOTIFICATION_VISIBILITY_CHANGED: {
emit_signal(SceneStringNames::get_singleton()->visibility_changed);
} break;
diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp
index 2f7b18a80e..6c627857fa 100644
--- a/scene/main/canvas_layer.cpp
+++ b/scene/main/canvas_layer.cpp
@@ -174,8 +174,8 @@ void CanvasLayer::_notification(int p_what) {
RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_index());
RenderingServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform);
_update_follow_viewport();
-
} break;
+
case NOTIFICATION_EXIT_TREE: {
ERR_FAIL_NULL_MSG(vp, "Viewport is not initialized.");
@@ -183,13 +183,12 @@ void CanvasLayer::_notification(int p_what) {
RenderingServer::get_singleton()->viewport_remove_canvas(viewport, canvas);
viewport = RID();
_update_follow_viewport(false);
-
} break;
+
case NOTIFICATION_MOVED_IN_PARENT: {
if (is_inside_tree()) {
RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_index());
}
-
} break;
}
}
diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp
index 4e91548d14..700ba761f6 100644
--- a/scene/main/http_request.cpp
+++ b/scene/main/http_request.cpp
@@ -464,20 +464,22 @@ void HTTPRequest::_request_done(int p_status, int p_code, const PackedStringArra
}
void HTTPRequest::_notification(int p_what) {
- if (p_what == NOTIFICATION_INTERNAL_PROCESS) {
- if (use_threads.is_set()) {
- return;
- }
- bool done = _update_connection();
- if (done) {
- set_process_internal(false);
- }
- }
+ switch (p_what) {
+ case NOTIFICATION_INTERNAL_PROCESS: {
+ if (use_threads.is_set()) {
+ return;
+ }
+ bool done = _update_connection();
+ if (done) {
+ set_process_internal(false);
+ }
+ } break;
- if (p_what == NOTIFICATION_EXIT_TREE) {
- if (requesting) {
- cancel_request();
- }
+ case NOTIFICATION_EXIT_TREE: {
+ if (requesting) {
+ cancel_request();
+ }
+ } break;
}
}
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 05086541a5..42a2e41a08 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -54,12 +54,12 @@ void Node::_notification(int p_notification) {
switch (p_notification) {
case NOTIFICATION_PROCESS: {
GDVIRTUAL_CALL(_process, get_process_delta_time());
-
} break;
+
case NOTIFICATION_PHYSICS_PROCESS: {
GDVIRTUAL_CALL(_physics_process, get_physics_process_delta_time());
-
} break;
+
case NOTIFICATION_ENTER_TREE: {
ERR_FAIL_COND(!get_viewport());
ERR_FAIL_COND(!get_tree());
@@ -88,8 +88,8 @@ void Node::_notification(int p_notification) {
get_tree()->node_count++;
orphan_node_count--;
-
} break;
+
case NOTIFICATION_EXIT_TREE: {
ERR_FAIL_COND(!get_viewport());
ERR_FAIL_COND(!get_tree());
@@ -113,12 +113,14 @@ void Node::_notification(int p_notification) {
data.path_cache = nullptr;
}
} break;
+
case NOTIFICATION_PATH_RENAMED: {
if (data.path_cache) {
memdelete(data.path_cache);
data.path_cache = nullptr;
}
} break;
+
case NOTIFICATION_READY: {
if (GDVIRTUAL_IS_OVERRIDDEN(_input)) {
set_process_input(true);
@@ -141,9 +143,11 @@ void Node::_notification(int p_notification) {
GDVIRTUAL_CALL(_ready);
} break;
+
case NOTIFICATION_POSTINITIALIZE: {
data.in_constructor = false;
} break;
+
case NOTIFICATION_PREDELETE: {
if (data.parent) {
data.parent->remove_child(this);
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index f02032a6c9..2b4d7d8331 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -616,6 +616,7 @@ void SceneTree::_notification(int p_notification) {
get_root()->propagate_notification(p_notification);
}
} break;
+
case NOTIFICATION_OS_MEMORY_WARNING:
case NOTIFICATION_OS_IME_UPDATE:
case NOTIFICATION_WM_ABOUT:
@@ -624,13 +625,11 @@ void SceneTree::_notification(int p_notification) {
case NOTIFICATION_APPLICATION_PAUSED:
case NOTIFICATION_APPLICATION_FOCUS_IN:
case NOTIFICATION_APPLICATION_FOCUS_OUT: {
- get_root()->propagate_notification(p_notification); //pass these to nodes, since they are mirrored
+ // Pass these to nodes, since they are mirrored.
+ get_root()->propagate_notification(p_notification);
} break;
-
- default:
- break;
- };
-};
+ }
+}
void SceneTree::set_auto_accept_quit(bool p_enable) {
accept_quit = p_enable;
diff --git a/scene/main/shader_globals_override.cpp b/scene/main/shader_globals_override.cpp
index 09dfc50066..5387dc01e2 100644
--- a/scene/main/shader_globals_override.cpp
+++ b/scene/main/shader_globals_override.cpp
@@ -247,26 +247,29 @@ void ShaderGlobalsOverride::_activate() {
}
void ShaderGlobalsOverride::_notification(int p_what) {
- if (p_what == Node3D::NOTIFICATION_ENTER_TREE) {
- add_to_group(SceneStringNames::get_singleton()->shader_overrides_group);
- _activate();
+ switch (p_what) {
+ case Node3D::NOTIFICATION_ENTER_TREE: {
+ add_to_group(SceneStringNames::get_singleton()->shader_overrides_group);
+ _activate();
+ } break;
- } else if (p_what == Node3D::NOTIFICATION_EXIT_TREE) {
- if (active) {
- //remove overrides
- const StringName *K = nullptr;
- while ((K = overrides.next(K))) {
- Override *o = overrides.getptr(*K);
- if (o->in_use) {
- RS::get_singleton()->global_variable_set_override(*K, Variant());
+ case Node3D::NOTIFICATION_EXIT_TREE: {
+ if (active) {
+ //remove overrides
+ const StringName *K = nullptr;
+ while ((K = overrides.next(K))) {
+ Override *o = overrides.getptr(*K);
+ if (o->in_use) {
+ RS::get_singleton()->global_variable_set_override(*K, Variant());
+ }
}
}
- }
- remove_from_group(SceneStringNames::get_singleton()->shader_overrides_group_active);
- remove_from_group(SceneStringNames::get_singleton()->shader_overrides_group);
- get_tree()->call_group(SceneStringNames::get_singleton()->shader_overrides_group, "_activate"); //another may want to activate when this is removed
- active = false;
+ remove_from_group(SceneStringNames::get_singleton()->shader_overrides_group_active);
+ remove_from_group(SceneStringNames::get_singleton()->shader_overrides_group);
+ get_tree()->call_group(SceneStringNames::get_singleton()->shader_overrides_group, "_activate"); //another may want to activate when this is removed
+ active = false;
+ } break;
}
}
diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp
index babe62f453..120b537e4f 100644
--- a/scene/main/timer.cpp
+++ b/scene/main/timer.cpp
@@ -43,6 +43,7 @@ void Timer::_notification(int p_what) {
autostart = false;
}
} break;
+
case NOTIFICATION_INTERNAL_PROCESS: {
if (!processing || timer_process_callback == TIMER_PROCESS_PHYSICS || !is_processing_internal()) {
return;
@@ -58,8 +59,8 @@ void Timer::_notification(int p_what) {
emit_signal(SNAME("timeout"));
}
-
} break;
+
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
if (!processing || timer_process_callback == TIMER_PROCESS_IDLE || !is_physics_processing_internal()) {
return;
@@ -74,7 +75,6 @@ void Timer::_notification(int p_what) {
}
emit_signal(SNAME("timeout"));
}
-
} break;
}
}
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 0a46614fd3..2831e76fba 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -406,8 +406,8 @@ void Viewport::_notification(int p_what) {
#endif // _3D_DISABLED
set_physics_process_internal(true);
}
-
} break;
+
case NOTIFICATION_READY: {
#ifndef _3D_DISABLED
if (audio_listener_3d_set.size() && !audio_listener_3d) {
@@ -438,6 +438,7 @@ void Viewport::_notification(int p_what) {
}
#endif // _3D_DISABLED
} break;
+
case NOTIFICATION_EXIT_TREE: {
_gui_cancel_tooltip();
@@ -461,6 +462,7 @@ void Viewport::_notification(int p_what) {
RS::get_singleton()->viewport_set_active(viewport, false);
RenderingServer::get_singleton()->viewport_set_parent_viewport(viewport, RID());
} break;
+
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
if (!get_tree()) {
return;
@@ -493,9 +495,11 @@ void Viewport::_notification(int p_what) {
}
#endif // _3D_DISABLED
} break;
+
case NOTIFICATION_WM_MOUSE_ENTER: {
gui.mouse_in_window = true;
} break;
+
case NOTIFICATION_WM_MOUSE_EXIT: {
gui.mouse_in_window = false;
_drop_physics_mouseover();
@@ -504,6 +508,7 @@ void Viewport::_notification(int p_what) {
// not mouse_focus, because, for example, we want to continue
// dragging a scrollbar even if the mouse has left the window.
} break;
+
case NOTIFICATION_WM_WINDOW_FOCUS_OUT: {
_drop_physics_mouseover();
if (gui.mouse_focus && !gui.forced_mouse_focus) {
@@ -3939,11 +3944,14 @@ Transform2D SubViewport::_stretch_transform() {
}
void SubViewport::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE) {
- RS::get_singleton()->viewport_set_active(get_viewport_rid(), true);
- }
- if (p_what == NOTIFICATION_EXIT_TREE) {
- RS::get_singleton()->viewport_set_active(get_viewport_rid(), false);
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ RS::get_singleton()->viewport_set_active(get_viewport_rid(), true);
+ } break;
+
+ case NOTIFICATION_EXIT_TREE: {
+ RS::get_singleton()->viewport_set_active(get_viewport_rid(), false);
+ } break;
}
}
diff --git a/scene/main/window.cpp b/scene/main/window.cpp
index 77c0fa2a48..e7a575f40a 100644
--- a/scene/main/window.cpp
+++ b/scene/main/window.cpp
@@ -738,18 +738,16 @@ void Window::_notification(int p_what) {
bool embedded = false;
{
embedder = _get_embedder();
-
if (embedder) {
embedded = true;
-
if (!visible) {
- embedder = nullptr; //not yet since not visible
+ embedder = nullptr; // Not yet since not visible.
}
}
}
if (embedded) {
- //create as embedded
+ // Create as embedded.
if (embedder) {
embedder->_sub_window_register(this);
RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE);
@@ -757,22 +755,22 @@ void Window::_notification(int p_what) {
}
} else {
- if (get_parent() == nullptr) {
- //it's the root window!
- visible = true; //always visible
+ if (!get_parent()) {
+ // It's the root window!
+ visible = true; // Always visible.
window_id = DisplayServer::MAIN_WINDOW_ID;
DisplayServer::get_singleton()->window_attach_instance_id(get_instance_id(), window_id);
_update_from_window();
- //since this window already exists (created on start), we must update pos and size from it
+ // Since this window already exists (created on start), we must update pos and size from it.
{
position = DisplayServer::get_singleton()->window_get_position(window_id);
size = DisplayServer::get_singleton()->window_get_size(window_id);
}
- _update_viewport_size(); //then feed back to the viewport
+ _update_viewport_size(); // Then feed back to the viewport.
_update_window_callbacks();
RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_WHEN_VISIBLE);
} else {
- //create
+ // Create.
if (visible) {
_make_window();
}
@@ -788,11 +786,13 @@ void Window::_notification(int p_what) {
RS::get_singleton()->viewport_set_active(get_viewport_rid(), true);
}
} break;
+
case NOTIFICATION_READY: {
if (wrap_controls) {
_update_child_controls();
}
} break;
+
case NOTIFICATION_TRANSLATION_CHANGED: {
if (embedder) {
embedder->_sub_window_update(this);
@@ -811,6 +811,7 @@ void Window::_notification(int p_what) {
child_controls_changed();
} break;
+
case NOTIFICATION_EXIT_TREE: {
if (transient) {
_clear_transient();