summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editor/editor_node.cpp4
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp40
-rw-r--r--editor/plugins/animation_player_editor_plugin.h2
-rw-r--r--main/performance.cpp1
-rw-r--r--tests/scene/test_node.h106
5 files changed, 134 insertions, 19 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index ae9261864f..b1b40eb52a 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -584,10 +584,11 @@ void EditorNode::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
Engine::get_singleton()->set_editor_hint(true);
- Window *window = static_cast<Window *>(get_tree()->get_root());
+ Window *window = get_window();
if (window) {
// Handle macOS fullscreen and extend-to-title changes.
window->connect("titlebar_changed", callable_mp(this, &EditorNode::_titlebar_resized));
+ window->set_theme(theme);
}
OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/low_processor_mode_sleep_usec")));
@@ -695,6 +696,7 @@ void EditorNode::_notification(int p_what) {
theme_base->set_theme(theme);
gui_base->set_theme(theme);
+ get_window()->set_theme(theme);
gui_base->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Background"), SNAME("EditorStyles")));
scene_root_parent->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Content"), SNAME("EditorStyles")));
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index 10f2ce25d9..ddd6ac728f 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -94,6 +94,7 @@ void AnimationPlayerEditor::_notification(int p_what) {
// Need the last frame after it stopped.
frame->set_value(player->get_current_animation_position());
track_editor->set_anim_pos(player->get_current_animation_position());
+ stop->set_icon(stop_icon);
}
last_active = player->is_playing();
@@ -119,8 +120,15 @@ void AnimationPlayerEditor::_notification(int p_what) {
case NOTIFICATION_TRANSLATION_CHANGED:
case NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
case NOTIFICATION_THEME_CHANGED: {
- autoplay->set_icon(get_theme_icon(SNAME("AutoPlay"), SNAME("EditorIcons")));
+ stop_icon = get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"));
+ pause_icon = get_theme_icon(SNAME("Pause"), SNAME("EditorIcons"));
+ if (player && player->is_playing()) {
+ stop->set_icon(pause_icon);
+ } else {
+ stop->set_icon(stop_icon);
+ }
+ autoplay->set_icon(get_theme_icon(SNAME("AutoPlay"), SNAME("EditorIcons")));
play->set_icon(get_theme_icon(SNAME("PlayStart"), SNAME("EditorIcons")));
play_from->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons")));
play_bw->set_icon(get_theme_icon(SNAME("PlayStartBackwards"), SNAME("EditorIcons")));
@@ -137,7 +145,6 @@ void AnimationPlayerEditor::_notification(int p_what) {
autoplay_reset_img->blit_rect(reset_img, Rect2i(Point2i(), icon_size), Point2i(icon_size.x, 0));
autoplay_reset_icon = ImageTexture::create_from_image(autoplay_reset_img);
}
- stop->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons")));
onion_toggle->set_icon(get_theme_icon(SNAME("Onion"), SNAME("EditorIcons")));
onion_skinning->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons")));
@@ -204,7 +211,7 @@ void AnimationPlayerEditor::_play_pressed() {
}
//unstop
- stop->set_pressed(false);
+ stop->set_icon(pause_icon);
}
void AnimationPlayerEditor::_play_from_pressed() {
@@ -221,7 +228,7 @@ void AnimationPlayerEditor::_play_from_pressed() {
}
//unstop
- stop->set_pressed(false);
+ stop->set_icon(pause_icon);
}
String AnimationPlayerEditor::_get_current() const {
@@ -242,7 +249,7 @@ void AnimationPlayerEditor::_play_bw_pressed() {
}
//unstop
- stop->set_pressed(false);
+ stop->set_icon(pause_icon);
}
void AnimationPlayerEditor::_play_bw_from_pressed() {
@@ -259,7 +266,7 @@ void AnimationPlayerEditor::_play_bw_from_pressed() {
}
//unstop
- stop->set_pressed(false);
+ stop->set_icon(pause_icon);
}
void AnimationPlayerEditor::_stop_pressed() {
@@ -267,9 +274,16 @@ void AnimationPlayerEditor::_stop_pressed() {
return;
}
- player->pause();
- play->set_pressed(false);
- stop->set_pressed(true);
+ if (player->is_playing()) {
+ player->pause();
+ } else {
+ String current = _get_current();
+ player->stop();
+ player->set_assigned_animation(current);
+ frame->set_value(0);
+ track_editor->set_anim_pos(0);
+ }
+ stop->set_icon(stop_icon);
}
void AnimationPlayerEditor::_animation_selected(int p_which) {
@@ -798,12 +812,9 @@ void AnimationPlayerEditor::_update_animation() {
updating = true;
if (player->is_playing()) {
- play->set_pressed(true);
- stop->set_pressed(false);
-
+ stop->set_icon(pause_icon);
} else {
- play->set_pressed(false);
- stop->set_pressed(true);
+ stop->set_icon(stop_icon);
}
scale->set_text(String::num(player->get_speed_scale(), 2));
@@ -1663,7 +1674,6 @@ AnimationPlayerEditor::AnimationPlayerEditor(AnimationPlayerEditorPlugin *p_plug
stop = memnew(Button);
stop->set_flat(true);
- stop->set_toggle_mode(true);
hb->add_child(stop);
stop->set_tooltip_text(TTR("Stop animation playback. (S)"));
diff --git a/editor/plugins/animation_player_editor_plugin.h b/editor/plugins/animation_player_editor_plugin.h
index 6c690c812c..327200506f 100644
--- a/editor/plugins/animation_player_editor_plugin.h
+++ b/editor/plugins/animation_player_editor_plugin.h
@@ -101,6 +101,8 @@ class AnimationPlayerEditor : public VBoxContainer {
OptionButton *library = nullptr;
Label *name_title = nullptr;
+ Ref<Texture2D> stop_icon;
+ Ref<Texture2D> pause_icon;
Ref<Texture2D> autoplay_icon;
Ref<Texture2D> reset_icon;
Ref<ImageTexture> autoplay_reset_icon;
diff --git a/main/performance.cpp b/main/performance.cpp
index 869a947b2a..e24a3673b9 100644
--- a/main/performance.cpp
+++ b/main/performance.cpp
@@ -316,6 +316,7 @@ uint64_t Performance::get_monitor_modification_time() {
Performance::Performance() {
_process_time = 0;
_physics_process_time = 0;
+ _navigation_process_time = 0;
_monitor_modification_time = 0;
singleton = this;
}
diff --git a/tests/scene/test_node.h b/tests/scene/test_node.h
index 20c42d9fc2..0ddf027970 100644
--- a/tests/scene/test_node.h
+++ b/tests/scene/test_node.h
@@ -37,7 +37,7 @@
namespace TestNode {
-TEST_CASE("[SceneTree][Node] Simple Add/Remove/Move/Find") {
+TEST_CASE("[SceneTree][Node] Testing node operations with a very simple scene tree") {
Node *node = memnew(Node);
// Check initial scene tree setup.
@@ -135,10 +135,30 @@ TEST_CASE("[SceneTree][Node] Simple Add/Remove/Move/Find") {
CHECK(node->is_inside_tree());
}
+ SUBCASE("Node should be possible to reparent") {
+ node->reparent(SceneTree::get_singleton()->get_root());
+
+ Node *child = SceneTree::get_singleton()->get_root()->get_child(0);
+ CHECK_EQ(child, node);
+ CHECK(node->is_inside_tree());
+ }
+
+ SUBCASE("Node should be possible to duplicate") {
+ node->set_name("MyName");
+
+ Node *duplicate = node->duplicate();
+
+ CHECK_FALSE(node == duplicate);
+ CHECK_FALSE(duplicate->is_inside_tree());
+ CHECK_EQ(duplicate->get_name(), node->get_name());
+
+ memdelete(duplicate);
+ }
+
memdelete(node);
}
-TEST_CASE("[SceneTree][Node] Nested Add/Remove/Move/Find") {
+TEST_CASE("[SceneTree][Node] Testing node operations with a more complex simple scene tree") {
Node *node1 = memnew(Node);
Node *node2 = memnew(Node);
Node *node1_1 = memnew(Node);
@@ -209,7 +229,7 @@ TEST_CASE("[SceneTree][Node] Nested Add/Remove/Move/Find") {
CHECK_EQ(child2, node1);
}
- SUBCASE("Nodes should be in the expected order when reparented") {
+ SUBCASE("Nodes should be in the expected order when reparented (remove/add)") {
CHECK_EQ(node2->get_child_count(), 0);
node1->remove_child(node1_1);
@@ -227,6 +247,22 @@ TEST_CASE("[SceneTree][Node] Nested Add/Remove/Move/Find") {
CHECK_EQ(SceneTree::get_singleton()->get_node_count(), 4);
}
+ SUBCASE("Nodes should be in the expected order when reparented") {
+ CHECK_EQ(node2->get_child_count(), 0);
+
+ node1_1->reparent(node2);
+
+ CHECK_EQ(node1->get_child_count(), 0);
+ CHECK_EQ(node2->get_child_count(), 1);
+ CHECK_EQ(node1_1->get_parent(), node2);
+
+ Node *child = node2->get_child(0);
+ CHECK_EQ(child, node1_1);
+
+ CHECK_EQ(SceneTree::get_singleton()->get_root()->get_child_count(), 2);
+ CHECK_EQ(SceneTree::get_singleton()->get_node_count(), 4);
+ }
+
SUBCASE("Nodes should be possible to find") {
Node *child = SceneTree::get_singleton()->get_root()->find_child("NestedNode", true, false);
CHECK_EQ(child, nullptr);
@@ -315,6 +351,70 @@ TEST_CASE("[SceneTree][Node] Nested Add/Remove/Move/Find") {
CHECK_EQ(E->get(), node1_1);
}
+ SUBCASE("Nodes added as siblings of another node should be right next to it") {
+ node1->remove_child(node1_1);
+
+ node1->add_sibling(node1_1);
+
+ CHECK_EQ(SceneTree::get_singleton()->get_root()->get_child_count(), 3);
+ CHECK_EQ(SceneTree::get_singleton()->get_node_count(), 4);
+
+ CHECK_EQ(SceneTree::get_singleton()->get_root()->get_child(0), node1);
+ CHECK_EQ(SceneTree::get_singleton()->get_root()->get_child(1), node1_1);
+ CHECK_EQ(SceneTree::get_singleton()->get_root()->get_child(2), node2);
+ }
+
+ SUBCASE("Replaced nodes should be be removed and the replacing node added") {
+ SceneTree::get_singleton()->get_root()->remove_child(node2);
+
+ node1->replace_by(node2);
+
+ CHECK_EQ(SceneTree::get_singleton()->get_root()->get_child_count(), 1);
+ CHECK_EQ(SceneTree::get_singleton()->get_node_count(), 3);
+
+ CHECK_FALSE(node1->is_inside_tree());
+ CHECK(node2->is_inside_tree());
+
+ CHECK_EQ(node1->get_parent(), nullptr);
+ CHECK_EQ(node2->get_parent(), SceneTree::get_singleton()->get_root());
+ CHECK_EQ(node2->get_child_count(), 1);
+ CHECK_EQ(node2->get_child(0), node1_1);
+ }
+
+ SUBCASE("Replacing nodes should keep the groups of the replaced nodes") {
+ SceneTree::get_singleton()->get_root()->remove_child(node2);
+
+ node1->add_to_group("nodes");
+ node1->replace_by(node2, true);
+
+ List<Node *> nodes;
+ SceneTree::get_singleton()->get_nodes_in_group("nodes", &nodes);
+ CHECK_EQ(nodes.size(), 1);
+
+ List<Node *>::Element *E = nodes.front();
+ CHECK_EQ(E->get(), node2);
+ }
+
+ SUBCASE("Duplicating a node should also duplicate the children") {
+ node1->set_name("MyName1");
+ node1_1->set_name("MyName1_1");
+ Node *duplicate1 = node1->duplicate();
+
+ CHECK_EQ(duplicate1->get_child_count(), node1->get_child_count());
+ Node *duplicate1_1 = duplicate1->get_child(0);
+
+ CHECK_EQ(duplicate1_1->get_child_count(), node1_1->get_child_count());
+
+ CHECK_EQ(duplicate1->get_name(), node1->get_name());
+ CHECK_EQ(duplicate1_1->get_name(), node1_1->get_name());
+
+ CHECK_FALSE(duplicate1->is_inside_tree());
+ CHECK_FALSE(duplicate1_1->is_inside_tree());
+
+ memdelete(duplicate1_1);
+ memdelete(duplicate1);
+ }
+
memdelete(node1_1);
memdelete(node1);
memdelete(node2);