summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/object/script_language.cpp10
-rw-r--r--doc/classes/RichTextLabel.xml14
-rw-r--r--editor/action_map_editor.cpp4
-rw-r--r--editor/animation_bezier_editor.cpp630
-rw-r--r--editor/animation_track_editor.cpp852
-rw-r--r--editor/audio_stream_preview.cpp34
-rw-r--r--editor/code_editor.cpp89
-rw-r--r--editor/code_editor.h2
-rw-r--r--editor/connections_dialog.cpp7
-rw-r--r--editor/create_dialog.cpp3
-rw-r--r--editor/debugger/debug_adapter/debug_adapter_server.cpp11
-rw-r--r--editor/debugger/editor_debugger_inspector.cpp11
-rw-r--r--editor/debugger/editor_debugger_node.cpp193
-rw-r--r--editor/debugger/editor_debugger_tree.cpp10
-rw-r--r--editor/debugger/editor_network_profiler.cpp21
-rw-r--r--editor/debugger/editor_profiler.cpp10
-rw-r--r--editor/debugger/editor_visual_profiler.cpp18
-rw-r--r--editor/debugger/script_editor_debugger.cpp3
-rw-r--r--editor/editor_audio_buses.cpp9
-rw-r--r--editor/editor_autoload_settings.cpp34
-rw-r--r--editor/editor_dir_dialog.cpp44
-rw-r--r--editor/editor_export.cpp1
-rw-r--r--editor/editor_feature_profile.cpp24
-rw-r--r--editor/editor_file_dialog.cpp86
-rw-r--r--editor/editor_file_system.cpp3
-rw-r--r--editor/editor_help.cpp9
-rw-r--r--editor/editor_help_search.cpp2
-rw-r--r--editor/editor_inspector.cpp614
-rw-r--r--editor/editor_log.cpp3
-rw-r--r--editor/editor_plugin.cpp13
-rw-r--r--editor/editor_plugin_settings.cpp14
-rw-r--r--editor/editor_properties.cpp195
-rw-r--r--editor/editor_properties_array_dict.cpp76
-rw-r--r--editor/editor_run_native.cpp96
-rw-r--r--editor/editor_settings_dialog.cpp3
-rw-r--r--editor/editor_spin_slider.cpp30
-rw-r--r--editor/editor_toaster.cpp4
-rw-r--r--editor/editor_zoom_widget.cpp6
-rw-r--r--editor/find_in_files.cpp60
-rw-r--r--editor/find_in_files.h2
-rw-r--r--editor/import/dynamic_font_import_settings.cpp19
-rw-r--r--editor/import/scene_import_settings.cpp6
-rw-r--r--editor/import_defaults_editor.cpp6
-rw-r--r--editor/localization_editor.cpp36
-rw-r--r--editor/node_dock.cpp9
-rw-r--r--editor/plugin_config_dialog.cpp1
-rw-r--r--editor/plugins/abstract_polygon_2d_editor.cpp1
-rw-r--r--editor/plugins/animation_blend_space_1d_editor.cpp63
-rw-r--r--editor/plugins/animation_blend_space_2d_editor.cpp83
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.cpp129
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.h3
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp3
-rw-r--r--editor/plugins/animation_state_machine_editor.cpp283
-rw-r--r--editor/plugins/animation_tree_editor_plugin.cpp24
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp17
-rw-r--r--editor/plugins/audio_stream_editor_plugin.cpp49
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp282
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h2
-rw-r--r--editor/plugins/cpu_particles_2d_editor_plugin.cpp10
-rw-r--r--editor/plugins/cpu_particles_3d_editor_plugin.cpp6
-rw-r--r--editor/plugins/curve_editor_plugin.cpp6
-rw-r--r--editor/plugins/debugger_editor_plugin.cpp6
-rw-r--r--editor/plugins/font_editor_plugin.cpp18
-rw-r--r--editor/plugins/gpu_particles_2d_editor_plugin.cpp12
-rw-r--r--editor/plugins/gpu_particles_3d_editor_plugin.cpp8
-rw-r--r--editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp58
-rw-r--r--editor/plugins/gradient_editor_plugin.cpp16
-rw-r--r--editor/plugins/material_editor_plugin.cpp40
-rw-r--r--editor/plugins/mesh_editor_plugin.cpp26
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp836
-rw-r--r--editor/plugins/ot_features_plugin.cpp26
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.cpp2
-rw-r--r--editor/plugins/polygon_3d_editor_plugin.cpp1
-rw-r--r--editor/plugins/replication_editor_plugin.cpp29
-rw-r--r--editor/plugins/resource_preloader_editor_plugin.cpp13
-rw-r--r--editor/plugins/root_motion_editor_plugin.cpp9
-rw-r--r--editor/plugins/script_editor_plugin.cpp4
-rw-r--r--editor/plugins/script_text_editor.cpp2
-rw-r--r--scene/gui/rich_text_label.cpp27
-rw-r--r--scene/gui/rich_text_label.h3
80 files changed, 2877 insertions, 2547 deletions
diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp
index 9fec7c397d..b14296b815 100644
--- a/core/object/script_language.cpp
+++ b/core/object/script_language.cpp
@@ -46,10 +46,12 @@ bool ScriptServer::languages_finished = false;
ScriptEditRequestFunction ScriptServer::edit_request_func = nullptr;
void Script::_notification(int p_what) {
- if (p_what == NOTIFICATION_POSTINITIALIZE) {
- if (EngineDebugger::is_active()) {
- EngineDebugger::get_script_debugger()->set_break_language(get_language());
- }
+ switch (p_what) {
+ case NOTIFICATION_POSTINITIALIZE: {
+ if (EngineDebugger::is_active()) {
+ EngineDebugger::get_script_debugger()->set_break_language(get_language());
+ }
+ } break;
}
}
diff --git a/doc/classes/RichTextLabel.xml b/doc/classes/RichTextLabel.xml
index 18d75889c3..f480071d32 100644
--- a/doc/classes/RichTextLabel.xml
+++ b/doc/classes/RichTextLabel.xml
@@ -81,12 +81,26 @@
Returns the total number of lines in the text. Wrapped text is counted as multiple lines.
</description>
</method>
+ <method name="get_line_offset">
+ <return type="float" />
+ <argument index="0" name="line" type="int" />
+ <description>
+ Returns the vertical offset of the line found at the provided index.
+ </description>
+ </method>
<method name="get_paragraph_count" qualifiers="const">
<return type="int" />
<description>
Returns the total number of paragraphs (newlines or [code]p[/code] tags in the tag stack's text tags). Considers wrapped text as one paragraph.
</description>
</method>
+ <method name="get_paragraph_offset">
+ <return type="float" />
+ <argument index="0" name="paragraph" type="int" />
+ <description>
+ Returns the vertical offset of the paragraph found at the provided index.
+ </description>
+ </method>
<method name="get_parsed_text" qualifiers="const">
<return type="String" />
<description>
diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp
index 6fd0132ab1..3eab494761 100644
--- a/editor/action_map_editor.cpp
+++ b/editor/action_map_editor.cpp
@@ -562,8 +562,6 @@ void InputEventConfigurationDialog::_notification(int p_what) {
_update_input_list();
} break;
- default:
- break;
}
}
@@ -1014,8 +1012,6 @@ void ActionMapEditor::_notification(int p_what) {
case NOTIFICATION_THEME_CHANGED: {
action_list_search->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
} break;
- default:
- break;
}
}
diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp
index cc9c6c26c5..c8c8c7d891 100644
--- a/editor/animation_bezier_editor.cpp
+++ b/editor/animation_bezier_editor.cpp
@@ -220,415 +220,423 @@ void AnimationBezierTrackEdit::_draw_line_clipped(const Vector2 &p_from, const V
}
void AnimationBezierTrackEdit::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
- panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/animation_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning")));
- }
- if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) {
- bezier_icon = get_theme_icon(SNAME("KeyBezierPoint"), SNAME("EditorIcons"));
- bezier_handle_icon = get_theme_icon(SNAME("KeyBezierHandle"), SNAME("EditorIcons"));
- selected_icon = get_theme_icon(SNAME("KeyBezierSelected"), SNAME("EditorIcons"));
- }
- if (p_what == NOTIFICATION_DRAW) {
- if (animation.is_null()) {
- return;
+ switch (p_what) {
+ case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
+ panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/animation_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning")));
+ } break;
+
+ case NOTIFICATION_ENTER_TREE: {
+ panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/animation_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning")));
+ [[fallthrough]];
}
+ case NOTIFICATION_THEME_CHANGED: {
+ bezier_icon = get_theme_icon(SNAME("KeyBezierPoint"), SNAME("EditorIcons"));
+ bezier_handle_icon = get_theme_icon(SNAME("KeyBezierHandle"), SNAME("EditorIcons"));
+ selected_icon = get_theme_icon(SNAME("KeyBezierSelected"), SNAME("EditorIcons"));
+ } break;
- int limit = timeline->get_name_limit();
+ case NOTIFICATION_DRAW: {
+ if (animation.is_null()) {
+ return;
+ }
- if (has_focus()) {
- Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
- accent.a *= 0.7;
- draw_rect(Rect2(Point2(), get_size()), accent, false, Math::round(EDSCALE));
- }
+ int limit = timeline->get_name_limit();
- Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
- int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label"));
- Color color = get_theme_color(SNAME("font_color"), SNAME("Label"));
- int hsep = get_theme_constant(SNAME("hseparation"), SNAME("ItemList"));
- int vsep = get_theme_constant(SNAME("vseparation"), SNAME("ItemList"));
- Color linecolor = color;
- linecolor.a = 0.2;
+ if (has_focus()) {
+ Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
+ accent.a *= 0.7;
+ draw_rect(Rect2(Point2(), get_size()), accent, false, Math::round(EDSCALE));
+ }
- draw_line(Point2(limit, 0), Point2(limit, get_size().height), linecolor, Math::round(EDSCALE));
+ Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
+ int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label"));
+ Color color = get_theme_color(SNAME("font_color"), SNAME("Label"));
+ int hsep = get_theme_constant(SNAME("hseparation"), SNAME("ItemList"));
+ int vsep = get_theme_constant(SNAME("vseparation"), SNAME("ItemList"));
+ Color linecolor = color;
+ linecolor.a = 0.2;
- int right_limit = get_size().width;
+ draw_line(Point2(limit, 0), Point2(limit, get_size().height), linecolor, Math::round(EDSCALE));
- int vofs = vsep;
- int margin = 0;
+ int right_limit = get_size().width;
- Map<int, Color> subtrack_colors;
- Color selected_track_color;
- subtracks.clear();
- subtrack_icons.clear();
+ int vofs = vsep;
+ int margin = 0;
- Map<String, Vector<int>> track_indices;
- int track_count = animation->get_track_count();
- for (int i = 0; i < track_count; ++i) {
- if (animation->track_get_type(i) != Animation::TrackType::TYPE_BEZIER) {
- continue;
- }
+ Map<int, Color> subtrack_colors;
+ Color selected_track_color;
+ subtracks.clear();
+ subtrack_icons.clear();
- String base_path = animation->track_get_path(i);
- if (is_filtered) {
- if (root && root->has_node(base_path)) {
- Node *node = root->get_node(base_path);
- if (!node) {
- continue; // No node, no filter.
- }
- if (!EditorNode::get_singleton()->get_editor_selection()->is_selected(node)) {
- continue; // Skip track due to not selected.
+ Map<String, Vector<int>> track_indices;
+ int track_count = animation->get_track_count();
+ for (int i = 0; i < track_count; ++i) {
+ if (animation->track_get_type(i) != Animation::TrackType::TYPE_BEZIER) {
+ continue;
+ }
+
+ String base_path = animation->track_get_path(i);
+ if (is_filtered) {
+ if (root && root->has_node(base_path)) {
+ Node *node = root->get_node(base_path);
+ if (!node) {
+ continue; // No node, no filter.
+ }
+ if (!EditorNode::get_singleton()->get_editor_selection()->is_selected(node)) {
+ continue; // Skip track due to not selected.
+ }
}
}
- }
- int end = base_path.find(":");
- if (end != -1) {
- base_path = base_path.substr(0, end + 1);
+ int end = base_path.find(":");
+ if (end != -1) {
+ base_path = base_path.substr(0, end + 1);
+ }
+ Vector<int> indices = track_indices.has(base_path) ? track_indices[base_path] : Vector<int>();
+ indices.push_back(i);
+ track_indices[base_path] = indices;
}
- Vector<int> indices = track_indices.has(base_path) ? track_indices[base_path] : Vector<int>();
- indices.push_back(i);
- track_indices[base_path] = indices;
- }
- for (const KeyValue<String, Vector<int>> &E : track_indices) {
- String base_path = E.key;
+ for (const KeyValue<String, Vector<int>> &E : track_indices) {
+ String base_path = E.key;
- Vector<int> tracks = E.value;
+ Vector<int> tracks = E.value;
- // NAMES AND ICON
- {
- NodePath path = animation->track_get_path(tracks[0]);
+ // NAMES AND ICON
+ {
+ NodePath path = animation->track_get_path(tracks[0]);
- Node *node = nullptr;
+ Node *node = nullptr;
- if (root && root->has_node(path)) {
- node = root->get_node(path);
- }
+ if (root && root->has_node(path)) {
+ node = root->get_node(path);
+ }
- String text;
+ String text;
- if (node) {
- int ofs = 0;
+ if (node) {
+ int ofs = 0;
- Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(node, "Node");
+ Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(node, "Node");
- text = node->get_name();
- ofs += hsep;
+ text = node->get_name();
+ ofs += hsep;
- TextLine text_buf = TextLine(text, font, font_size);
- text_buf.set_width(limit - ofs - icon->get_width() - hsep);
+ TextLine text_buf = TextLine(text, font, font_size);
+ text_buf.set_width(limit - ofs - icon->get_width() - hsep);
- int h = MAX(text_buf.get_size().y, icon->get_height());
+ int h = MAX(text_buf.get_size().y, icon->get_height());
- draw_texture(icon, Point2(ofs, vofs + int(h - icon->get_height()) / 2));
- ofs += icon->get_width();
+ draw_texture(icon, Point2(ofs, vofs + int(h - icon->get_height()) / 2));
+ ofs += icon->get_width();
- margin = icon->get_width();
+ margin = icon->get_width();
- Vector2 string_pos = Point2(ofs, vofs);
- string_pos = string_pos.floor();
- text_buf.draw(get_canvas_item(), string_pos, color);
+ Vector2 string_pos = Point2(ofs, vofs);
+ string_pos = string_pos.floor();
+ text_buf.draw(get_canvas_item(), string_pos, color);
- vofs += h + vsep;
+ vofs += h + vsep;
+ }
}
- }
- Ref<Texture2D> remove = get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"));
- float remove_hpos = limit - hsep - remove->get_width();
+ Ref<Texture2D> remove = get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"));
+ float remove_hpos = limit - hsep - remove->get_width();
- Ref<Texture2D> lock = get_theme_icon(SNAME("Lock"), SNAME("EditorIcons"));
- Ref<Texture2D> unlock = get_theme_icon(SNAME("Unlock"), SNAME("EditorIcons"));
- float lock_hpos = remove_hpos - hsep - lock->get_width();
+ Ref<Texture2D> lock = get_theme_icon(SNAME("Lock"), SNAME("EditorIcons"));
+ Ref<Texture2D> unlock = get_theme_icon(SNAME("Unlock"), SNAME("EditorIcons"));
+ float lock_hpos = remove_hpos - hsep - lock->get_width();
- Ref<Texture2D> visible = get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons"));
- Ref<Texture2D> hidden = get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons"));
- float visibility_hpos = lock_hpos - hsep - visible->get_width();
+ Ref<Texture2D> visible = get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons"));
+ Ref<Texture2D> hidden = get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons"));
+ float visibility_hpos = lock_hpos - hsep - visible->get_width();
- Ref<Texture2D> solo = get_theme_icon(SNAME("AudioBusSolo"), SNAME("EditorIcons"));
- float solo_hpos = visibility_hpos - hsep - solo->get_width();
+ Ref<Texture2D> solo = get_theme_icon(SNAME("AudioBusSolo"), SNAME("EditorIcons"));
+ float solo_hpos = visibility_hpos - hsep - solo->get_width();
- float buttons_width = remove->get_width() + lock->get_width() + visible->get_width() + solo->get_width() + hsep * 3;
+ float buttons_width = remove->get_width() + lock->get_width() + visible->get_width() + solo->get_width() + hsep * 3;
- for (int i = 0; i < tracks.size(); ++i) {
- // RELATED TRACKS TITLES
+ for (int i = 0; i < tracks.size(); ++i) {
+ // RELATED TRACKS TITLES
- int current_track = tracks[i];
+ int current_track = tracks[i];
- String path = animation->track_get_path(current_track);
- path = path.replace_first(base_path, "");
+ String path = animation->track_get_path(current_track);
+ path = path.replace_first(base_path, "");
- Color cc = color;
- TextLine text_buf = TextLine(path, font, font_size);
- text_buf.set_width(limit - margin - buttons_width);
+ Color cc = color;
+ TextLine text_buf = TextLine(path, font, font_size);
+ text_buf.set_width(limit - margin - buttons_width);
- Rect2 rect = Rect2(margin, vofs, solo_hpos - hsep - solo->get_width(), text_buf.get_size().y + vsep);
+ Rect2 rect = Rect2(margin, vofs, solo_hpos - hsep - solo->get_width(), text_buf.get_size().y + vsep);
- cc.a *= 0.7;
- float h;
- if (path.ends_with(":x")) {
- h = 0;
- } else if (path.ends_with(":y")) {
- h = 0.33f;
- } else if (path.ends_with(":z")) {
- h = 0.66f;
- } else {
- uint32_t hash = path.hash();
- hash = ((hash >> 16) ^ hash) * 0x45d9f3b;
- hash = ((hash >> 16) ^ hash) * 0x45d9f3b;
- hash = (hash >> 16) ^ hash;
- h = (hash % 65535) / 65536.0;
- }
-
- if (current_track != selected_track) {
- Color track_color;
- if (locked_tracks.has(current_track)) {
- track_color.set_hsv(h, 0, 0.4);
+ cc.a *= 0.7;
+ float h;
+ if (path.ends_with(":x")) {
+ h = 0;
+ } else if (path.ends_with(":y")) {
+ h = 0.33f;
+ } else if (path.ends_with(":z")) {
+ h = 0.66f;
} else {
- track_color.set_hsv(h, 0.2, 0.8);
+ uint32_t hash = path.hash();
+ hash = ((hash >> 16) ^ hash) * 0x45d9f3b;
+ hash = ((hash >> 16) ^ hash) * 0x45d9f3b;
+ hash = (hash >> 16) ^ hash;
+ h = (hash % 65535) / 65536.0;
}
- track_color.a = 0.5;
- draw_rect(Rect2(0, vofs, margin - hsep, text_buf.get_size().y * 0.8), track_color);
- subtrack_colors[current_track] = track_color;
-
- subtracks[current_track] = rect;
- } else {
- Color ac = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
- ac.a = 0.5;
- draw_rect(rect, ac);
- if (locked_tracks.has(selected_track)) {
- selected_track_color.set_hsv(h, 0.0, 0.4);
+
+ if (current_track != selected_track) {
+ Color track_color;
+ if (locked_tracks.has(current_track)) {
+ track_color.set_hsv(h, 0, 0.4);
+ } else {
+ track_color.set_hsv(h, 0.2, 0.8);
+ }
+ track_color.a = 0.5;
+ draw_rect(Rect2(0, vofs, margin - hsep, text_buf.get_size().y * 0.8), track_color);
+ subtrack_colors[current_track] = track_color;
+
+ subtracks[current_track] = rect;
} else {
- selected_track_color.set_hsv(h, 0.8, 0.8);
+ Color ac = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
+ ac.a = 0.5;
+ draw_rect(rect, ac);
+ if (locked_tracks.has(selected_track)) {
+ selected_track_color.set_hsv(h, 0.0, 0.4);
+ } else {
+ selected_track_color.set_hsv(h, 0.8, 0.8);
+ }
}
- }
- Vector2 string_pos = Point2(margin, vofs);
- text_buf.draw(get_canvas_item(), string_pos, cc);
+ Vector2 string_pos = Point2(margin, vofs);
+ text_buf.draw(get_canvas_item(), string_pos, cc);
- float icon_start_height = vofs + rect.size.y / 2;
- Rect2 remove_rect = Rect2(remove_hpos, icon_start_height - remove->get_height() / 2, remove->get_width(), remove->get_height());
- draw_texture(remove, remove_rect.position);
+ float icon_start_height = vofs + rect.size.y / 2;
+ Rect2 remove_rect = Rect2(remove_hpos, icon_start_height - remove->get_height() / 2, remove->get_width(), remove->get_height());
+ draw_texture(remove, remove_rect.position);
- Rect2 lock_rect = Rect2(lock_hpos, icon_start_height - lock->get_height() / 2, lock->get_width(), lock->get_height());
- if (locked_tracks.has(current_track)) {
- draw_texture(lock, lock_rect.position);
- } else {
- draw_texture(unlock, lock_rect.position);
- }
+ Rect2 lock_rect = Rect2(lock_hpos, icon_start_height - lock->get_height() / 2, lock->get_width(), lock->get_height());
+ if (locked_tracks.has(current_track)) {
+ draw_texture(lock, lock_rect.position);
+ } else {
+ draw_texture(unlock, lock_rect.position);
+ }
- Rect2 visible_rect = Rect2(visibility_hpos, icon_start_height - visible->get_height() / 2, visible->get_width(), visible->get_height());
- if (hidden_tracks.has(current_track)) {
- draw_texture(hidden, visible_rect.position);
- } else {
- draw_texture(visible, visible_rect.position);
- }
+ Rect2 visible_rect = Rect2(visibility_hpos, icon_start_height - visible->get_height() / 2, visible->get_width(), visible->get_height());
+ if (hidden_tracks.has(current_track)) {
+ draw_texture(hidden, visible_rect.position);
+ } else {
+ draw_texture(visible, visible_rect.position);
+ }
- Rect2 solo_rect = Rect2(solo_hpos, icon_start_height - solo->get_height() / 2, solo->get_width(), solo->get_height());
- draw_texture(solo, solo_rect.position);
+ Rect2 solo_rect = Rect2(solo_hpos, icon_start_height - solo->get_height() / 2, solo->get_width(), solo->get_height());
+ draw_texture(solo, solo_rect.position);
- Map<int, Rect2> track_icons;
- track_icons[REMOVE_ICON] = remove_rect;
- track_icons[LOCK_ICON] = lock_rect;
- track_icons[VISIBILITY_ICON] = visible_rect;
- track_icons[SOLO_ICON] = solo_rect;
+ Map<int, Rect2> track_icons;
+ track_icons[REMOVE_ICON] = remove_rect;
+ track_icons[LOCK_ICON] = lock_rect;
+ track_icons[VISIBILITY_ICON] = visible_rect;
+ track_icons[SOLO_ICON] = solo_rect;
- subtrack_icons[current_track] = track_icons;
+ subtrack_icons[current_track] = track_icons;
- vofs += text_buf.get_size().y + vsep;
+ vofs += text_buf.get_size().y + vsep;
+ }
}
- }
- Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
+ Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
- { //guides
- float min_left_scale = font->get_height(font_size) + vsep;
+ { //guides
+ float min_left_scale = font->get_height(font_size) + vsep;
- float scale = (min_left_scale * 2) * v_zoom;
- float step = Math::pow(10.0, Math::round(Math::log(scale / 5.0) / Math::log(10.0))) * 5.0;
- scale = Math::snapped(scale, step);
+ float scale = (min_left_scale * 2) * v_zoom;
+ float step = Math::pow(10.0, Math::round(Math::log(scale / 5.0) / Math::log(10.0))) * 5.0;
+ scale = Math::snapped(scale, step);
- while (scale / v_zoom < min_left_scale * 2) {
- scale += step;
- }
+ while (scale / v_zoom < min_left_scale * 2) {
+ scale += step;
+ }
- bool first = true;
- int prev_iv = 0;
- for (int i = font->get_height(font_size); i < get_size().height; i++) {
- float ofs = get_size().height / 2 - i;
- ofs *= v_zoom;
- ofs += v_scroll;
+ bool first = true;
+ int prev_iv = 0;
+ for (int i = font->get_height(font_size); i < get_size().height; i++) {
+ float ofs = get_size().height / 2 - i;
+ ofs *= v_zoom;
+ ofs += v_scroll;
- int iv = int(ofs / scale);
- if (ofs < 0) {
- iv -= 1;
- }
- if (!first && iv != prev_iv) {
- Color lc = linecolor;
- lc.a *= 0.5;
- draw_line(Point2(limit, i), Point2(right_limit, i), lc, Math::round(EDSCALE));
- Color c = color;
- c.a *= 0.5;
- draw_string(font, Point2(limit + 8, i - 2), TS->format_number(rtos(Math::snapped((iv + 1) * scale, step))), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, c);
- }
+ int iv = int(ofs / scale);
+ if (ofs < 0) {
+ iv -= 1;
+ }
+ if (!first && iv != prev_iv) {
+ Color lc = linecolor;
+ lc.a *= 0.5;
+ draw_line(Point2(limit, i), Point2(right_limit, i), lc, Math::round(EDSCALE));
+ Color c = color;
+ c.a *= 0.5;
+ draw_string(font, Point2(limit + 8, i - 2), TS->format_number(rtos(Math::snapped((iv + 1) * scale, step))), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, c);
+ }
- first = false;
- prev_iv = iv;
+ first = false;
+ prev_iv = iv;
+ }
}
- }
- { //draw OTHER curves
+ { //draw OTHER curves
- float scale = timeline->get_zoom_scale();
- Ref<Texture2D> point = get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons"));
- for (const KeyValue<int, Color> &E : subtrack_colors) {
- if (hidden_tracks.has(E.key)) {
- continue;
- }
- _draw_track(E.key, E.value);
+ float scale = timeline->get_zoom_scale();
+ Ref<Texture2D> point = get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons"));
+ for (const KeyValue<int, Color> &E : subtrack_colors) {
+ if (hidden_tracks.has(E.key)) {
+ continue;
+ }
+ _draw_track(E.key, E.value);
- for (int i = 0; i < animation->track_get_key_count(E.key); i++) {
- float offset = animation->track_get_key_time(E.key, i);
- float value = animation->bezier_track_get_key_value(E.key, i);
+ for (int i = 0; i < animation->track_get_key_count(E.key); i++) {
+ float offset = animation->track_get_key_time(E.key, i);
+ float value = animation->bezier_track_get_key_value(E.key, i);
- Vector2 pos((offset - timeline->get_value()) * scale + limit, _bezier_h_to_pixel(value));
+ Vector2 pos((offset - timeline->get_value()) * scale + limit, _bezier_h_to_pixel(value));
- if (pos.x >= limit && pos.x <= right_limit) {
- draw_texture(point, pos - point->get_size() / 2, E.value);
+ if (pos.x >= limit && pos.x <= right_limit) {
+ draw_texture(point, pos - point->get_size() / 2, E.value);
+ }
}
}
- }
- if (track_count > 0 && !hidden_tracks.has(selected_track)) {
- //draw edited curve
- _draw_track(selected_track, selected_track_color);
+ if (track_count > 0 && !hidden_tracks.has(selected_track)) {
+ //draw edited curve
+ _draw_track(selected_track, selected_track_color);
+ }
}
- }
- //draw editor handles
- {
- edit_points.clear();
- float scale = timeline->get_zoom_scale();
+ //draw editor handles
+ {
+ edit_points.clear();
+ float scale = timeline->get_zoom_scale();
- for (int i = 0; i < track_count; ++i) {
- if (animation->track_get_type(i) != Animation::TrackType::TYPE_BEZIER || hidden_tracks.has(i)) {
- continue;
- }
+ for (int i = 0; i < track_count; ++i) {
+ if (animation->track_get_type(i) != Animation::TrackType::TYPE_BEZIER || hidden_tracks.has(i)) {
+ continue;
+ }
- if (hidden_tracks.has(i) || locked_tracks.has(i)) {
- continue;
- }
+ if (hidden_tracks.has(i) || locked_tracks.has(i)) {
+ continue;
+ }
- int key_count = animation->track_get_key_count(i);
- String path = animation->track_get_path(i);
+ int key_count = animation->track_get_key_count(i);
+ String path = animation->track_get_path(i);
- if (is_filtered) {
- if (root && root->has_node(path)) {
- Node *node = root->get_node(path);
- if (!node) {
- continue; // No node, no filter.
- }
- if (!EditorNode::get_singleton()->get_editor_selection()->is_selected(node)) {
- continue; // Skip track due to not selected.
+ if (is_filtered) {
+ if (root && root->has_node(path)) {
+ Node *node = root->get_node(path);
+ if (!node) {
+ continue; // No node, no filter.
+ }
+ if (!EditorNode::get_singleton()->get_editor_selection()->is_selected(node)) {
+ continue; // Skip track due to not selected.
+ }
}
}
- }
- for (int j = 0; j < key_count; ++j) {
- float offset = animation->track_get_key_time(i, j);
- float value = animation->bezier_track_get_key_value(i, j);
+ for (int j = 0; j < key_count; ++j) {
+ float offset = animation->track_get_key_time(i, j);
+ float value = animation->bezier_track_get_key_value(i, j);
- if (moving_selection && selection.has(IntPair(i, j))) {
- offset += moving_selection_offset.x;
- value += moving_selection_offset.y;
- }
+ if (moving_selection && selection.has(IntPair(i, j))) {
+ offset += moving_selection_offset.x;
+ value += moving_selection_offset.y;
+ }
- Vector2 pos((offset - timeline->get_value()) * scale + limit, _bezier_h_to_pixel(value));
+ Vector2 pos((offset - timeline->get_value()) * scale + limit, _bezier_h_to_pixel(value));
- Vector2 in_vec = animation->bezier_track_get_key_in_handle(i, j);
- if (moving_handle != 0 && moving_handle_track == i && moving_handle_key == j) {
- in_vec = moving_handle_left;
- }
- Vector2 pos_in(((offset + in_vec.x) - timeline->get_value()) * scale + limit, _bezier_h_to_pixel(value + in_vec.y));
+ Vector2 in_vec = animation->bezier_track_get_key_in_handle(i, j);
+ if (moving_handle != 0 && moving_handle_track == i && moving_handle_key == j) {
+ in_vec = moving_handle_left;
+ }
+ Vector2 pos_in(((offset + in_vec.x) - timeline->get_value()) * scale + limit, _bezier_h_to_pixel(value + in_vec.y));
- Vector2 out_vec = animation->bezier_track_get_key_out_handle(i, j);
+ Vector2 out_vec = animation->bezier_track_get_key_out_handle(i, j);
- if (moving_handle != 0 && moving_handle_track == i && moving_handle_key == j) {
- out_vec = moving_handle_right;
- }
+ if (moving_handle != 0 && moving_handle_track == i && moving_handle_key == j) {
+ out_vec = moving_handle_right;
+ }
- Vector2 pos_out(((offset + out_vec.x) - timeline->get_value()) * scale + limit, _bezier_h_to_pixel(value + out_vec.y));
+ Vector2 pos_out(((offset + out_vec.x) - timeline->get_value()) * scale + limit, _bezier_h_to_pixel(value + out_vec.y));
- if (i == selected_track || selection.has(IntPair(i, j))) {
- _draw_line_clipped(pos, pos_in, accent, limit, right_limit);
- _draw_line_clipped(pos, pos_out, accent, limit, right_limit);
- }
+ if (i == selected_track || selection.has(IntPair(i, j))) {
+ _draw_line_clipped(pos, pos_in, accent, limit, right_limit);
+ _draw_line_clipped(pos, pos_out, accent, limit, right_limit);
+ }
- EditPoint ep;
- ep.track = i;
- ep.key = j;
- if (pos.x >= limit && pos.x <= right_limit) {
- ep.point_rect.position = (pos - bezier_icon->get_size() / 2).floor();
- ep.point_rect.size = bezier_icon->get_size();
- if (selection.has(IntPair(i, j))) {
- draw_texture(selected_icon, ep.point_rect.position);
- draw_string(font, ep.point_rect.position + Vector2(8, -font->get_height(font_size) - 8), TTR("Time:") + " " + TS->format_number(rtos(Math::snapped(offset, 0.001))), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, accent);
- draw_string(font, ep.point_rect.position + Vector2(8, -8), TTR("Value:") + " " + TS->format_number(rtos(Math::snapped(value, 0.001))), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, accent);
- } else {
- Color track_color = Color(1, 1, 1, 1);
- if (i != selected_track) {
- track_color = subtrack_colors[i];
+ EditPoint ep;
+ ep.track = i;
+ ep.key = j;
+ if (pos.x >= limit && pos.x <= right_limit) {
+ ep.point_rect.position = (pos - bezier_icon->get_size() / 2).floor();
+ ep.point_rect.size = bezier_icon->get_size();
+ if (selection.has(IntPair(i, j))) {
+ draw_texture(selected_icon, ep.point_rect.position);
+ draw_string(font, ep.point_rect.position + Vector2(8, -font->get_height(font_size) - 8), TTR("Time:") + " " + TS->format_number(rtos(Math::snapped(offset, 0.001))), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, accent);
+ draw_string(font, ep.point_rect.position + Vector2(8, -8), TTR("Value:") + " " + TS->format_number(rtos(Math::snapped(value, 0.001))), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, accent);
+ } else {
+ Color track_color = Color(1, 1, 1, 1);
+ if (i != selected_track) {
+ track_color = subtrack_colors[i];
+ }
+ draw_texture(bezier_icon, ep.point_rect.position, track_color);
}
- draw_texture(bezier_icon, ep.point_rect.position, track_color);
+ ep.point_rect = ep.point_rect.grow(ep.point_rect.size.width * 0.5);
}
- ep.point_rect = ep.point_rect.grow(ep.point_rect.size.width * 0.5);
- }
- if (i == selected_track || selection.has(IntPair(i, j))) {
- if (pos_in.x >= limit && pos_in.x <= right_limit) {
- ep.in_rect.position = (pos_in - bezier_handle_icon->get_size() / 2).floor();
- ep.in_rect.size = bezier_handle_icon->get_size();
- draw_texture(bezier_handle_icon, ep.in_rect.position);
- ep.in_rect = ep.in_rect.grow(ep.in_rect.size.width * 0.5);
+ if (i == selected_track || selection.has(IntPair(i, j))) {
+ if (pos_in.x >= limit && pos_in.x <= right_limit) {
+ ep.in_rect.position = (pos_in - bezier_handle_icon->get_size() / 2).floor();
+ ep.in_rect.size = bezier_handle_icon->get_size();
+ draw_texture(bezier_handle_icon, ep.in_rect.position);
+ ep.in_rect = ep.in_rect.grow(ep.in_rect.size.width * 0.5);
+ }
+ if (pos_out.x >= limit && pos_out.x <= right_limit) {
+ ep.out_rect.position = (pos_out - bezier_handle_icon->get_size() / 2).floor();
+ ep.out_rect.size = bezier_handle_icon->get_size();
+ draw_texture(bezier_handle_icon, ep.out_rect.position);
+ ep.out_rect = ep.out_rect.grow(ep.out_rect.size.width * 0.5);
+ }
}
- if (pos_out.x >= limit && pos_out.x <= right_limit) {
- ep.out_rect.position = (pos_out - bezier_handle_icon->get_size() / 2).floor();
- ep.out_rect.size = bezier_handle_icon->get_size();
- draw_texture(bezier_handle_icon, ep.out_rect.position);
- ep.out_rect = ep.out_rect.grow(ep.out_rect.size.width * 0.5);
+ if (!locked_tracks.has(i)) {
+ edit_points.push_back(ep);
}
}
- if (!locked_tracks.has(i)) {
- edit_points.push_back(ep);
- }
}
- }
- for (int i = 0; i < edit_points.size(); ++i) {
- if (edit_points[i].track == selected_track) {
- EditPoint ep = edit_points[i];
- edit_points.remove_at(i);
- edit_points.insert(0, ep);
+ for (int i = 0; i < edit_points.size(); ++i) {
+ if (edit_points[i].track == selected_track) {
+ EditPoint ep = edit_points[i];
+ edit_points.remove_at(i);
+ edit_points.insert(0, ep);
+ }
}
}
- }
- if (box_selecting) {
- Vector2 bs_from = box_selection_from;
- Vector2 bs_to = box_selection_to;
- if (bs_from.x > bs_to.x) {
- SWAP(bs_from.x, bs_to.x);
- }
- if (bs_from.y > bs_to.y) {
- SWAP(bs_from.y, bs_to.y);
+ if (box_selecting) {
+ Vector2 bs_from = box_selection_from;
+ Vector2 bs_to = box_selection_to;
+ if (bs_from.x > bs_to.x) {
+ SWAP(bs_from.x, bs_to.x);
+ }
+ if (bs_from.y > bs_to.y) {
+ SWAP(bs_from.y, bs_to.y);
+ }
+ draw_rect(
+ Rect2(bs_from, bs_to - bs_from),
+ get_theme_color(SNAME("box_selection_fill_color"), SNAME("Editor")));
+ draw_rect(
+ Rect2(bs_from, bs_to - bs_from),
+ get_theme_color(SNAME("box_selection_stroke_color"), SNAME("Editor")),
+ false,
+ Math::round(EDSCALE));
}
- draw_rect(
- Rect2(bs_from, bs_to - bs_from),
- get_theme_color(SNAME("box_selection_fill_color"), SNAME("Editor")));
- draw_rect(
- Rect2(bs_from, bs_to - bs_from),
- get_theme_color(SNAME("box_selection_stroke_color"), SNAME("Editor")),
- false,
- Math::round(EDSCALE));
- }
+ } break;
}
}
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index 113a2cb337..53f585d06b 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -1458,198 +1458,201 @@ int AnimationTimelineEdit::get_name_limit() const {
}
void AnimationTimelineEdit::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
- panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/animation_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning")));
- }
-
- if (p_what == NOTIFICATION_ENTER_TREE) {
- add_track->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
- loop->set_icon(get_theme_icon(SNAME("Loop"), SNAME("EditorIcons")));
- time_icon->set_texture(get_theme_icon(SNAME("Time"), SNAME("EditorIcons")));
-
- add_track->get_popup()->clear();
- add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")), TTR("Property Track"));
- add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyXPosition"), SNAME("EditorIcons")), TTR("3D Position Track"));
- add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyXRotation"), SNAME("EditorIcons")), TTR("3D Rotation Track"));
- add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyXScale"), SNAME("EditorIcons")), TTR("3D Scale Track"));
- add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyBlendShape"), SNAME("EditorIcons")), TTR("Blend Shape Track"));
- add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyCall"), SNAME("EditorIcons")), TTR("Call Method Track"));
- add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyBezier"), SNAME("EditorIcons")), TTR("Bezier Curve Track"));
- add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyAudio"), SNAME("EditorIcons")), TTR("Audio Playback Track"));
- add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyAnimation"), SNAME("EditorIcons")), TTR("Animation Playback Track"));
- }
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/animation_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning")));
+ add_track->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
+ loop->set_icon(get_theme_icon(SNAME("Loop"), SNAME("EditorIcons")));
+ time_icon->set_texture(get_theme_icon(SNAME("Time"), SNAME("EditorIcons")));
+
+ add_track->get_popup()->clear();
+ add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")), TTR("Property Track"));
+ add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyXPosition"), SNAME("EditorIcons")), TTR("3D Position Track"));
+ add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyXRotation"), SNAME("EditorIcons")), TTR("3D Rotation Track"));
+ add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyXScale"), SNAME("EditorIcons")), TTR("3D Scale Track"));
+ add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyBlendShape"), SNAME("EditorIcons")), TTR("Blend Shape Track"));
+ add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyCall"), SNAME("EditorIcons")), TTR("Call Method Track"));
+ add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyBezier"), SNAME("EditorIcons")), TTR("Bezier Curve Track"));
+ add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyAudio"), SNAME("EditorIcons")), TTR("Audio Playback Track"));
+ add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyAnimation"), SNAME("EditorIcons")), TTR("Animation Playback Track"));
+ } break;
- if (p_what == NOTIFICATION_RESIZED) {
- len_hb->set_position(Vector2(get_size().width - get_buttons_width(), 0));
- len_hb->set_size(Size2(get_buttons_width(), get_size().height));
- }
+ case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
+ panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/animation_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning")));
+ } break;
- if (p_what == NOTIFICATION_DRAW) {
- int key_range = get_size().width - get_buttons_width() - get_name_limit();
+ case NOTIFICATION_RESIZED: {
+ len_hb->set_position(Vector2(get_size().width - get_buttons_width(), 0));
+ len_hb->set_size(Size2(get_buttons_width(), get_size().height));
+ } break;
- if (!animation.is_valid()) {
- return;
- }
+ case NOTIFICATION_DRAW: {
+ int key_range = get_size().width - get_buttons_width() - get_name_limit();
- Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
- int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label"));
- Color color = get_theme_color(SNAME("font_color"), SNAME("Label"));
+ if (!animation.is_valid()) {
+ return;
+ }
- int zoomw = key_range;
- float scale = get_zoom_scale();
- int h = get_size().height;
+ Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
+ int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label"));
+ Color color = get_theme_color(SNAME("font_color"), SNAME("Label"));
- float l = animation->get_length();
- if (l <= 0) {
- l = 0.001; // Avoid crashor.
- }
+ int zoomw = key_range;
+ float scale = get_zoom_scale();
+ int h = get_size().height;
- Ref<Texture2D> hsize_icon = get_theme_icon(SNAME("Hsize"), SNAME("EditorIcons"));
- hsize_rect = Rect2(get_name_limit() - hsize_icon->get_width() - 2 * EDSCALE, (get_size().height - hsize_icon->get_height()) / 2, hsize_icon->get_width(), hsize_icon->get_height());
- draw_texture(hsize_icon, hsize_rect.position);
+ float l = animation->get_length();
+ if (l <= 0) {
+ l = 0.001; // Avoid crashor.
+ }
- {
- float time_min = 0;
- float time_max = animation->get_length();
- for (int i = 0; i < animation->get_track_count(); i++) {
- if (animation->track_get_key_count(i) > 0) {
- float beg = animation->track_get_key_time(i, 0);
+ Ref<Texture2D> hsize_icon = get_theme_icon(SNAME("Hsize"), SNAME("EditorIcons"));
+ hsize_rect = Rect2(get_name_limit() - hsize_icon->get_width() - 2 * EDSCALE, (get_size().height - hsize_icon->get_height()) / 2, hsize_icon->get_width(), hsize_icon->get_height());
+ draw_texture(hsize_icon, hsize_rect.position);
- if (beg < time_min) {
- time_min = beg;
- }
+ {
+ float time_min = 0;
+ float time_max = animation->get_length();
+ for (int i = 0; i < animation->get_track_count(); i++) {
+ if (animation->track_get_key_count(i) > 0) {
+ float beg = animation->track_get_key_time(i, 0);
+
+ if (beg < time_min) {
+ time_min = beg;
+ }
- float end = animation->track_get_key_time(i, animation->track_get_key_count(i) - 1);
+ float end = animation->track_get_key_time(i, animation->track_get_key_count(i) - 1);
- if (end > time_max) {
- time_max = end;
+ if (end > time_max) {
+ time_max = end;
+ }
}
}
- }
- float extra = (zoomw / scale) * 0.5;
+ float extra = (zoomw / scale) * 0.5;
- time_max += extra;
- set_min(time_min);
- set_max(time_max);
+ time_max += extra;
+ set_min(time_min);
+ set_max(time_max);
- if (zoomw / scale < (time_max - time_min)) {
- hscroll->show();
+ if (zoomw / scale < (time_max - time_min)) {
+ hscroll->show();
- } else {
- hscroll->hide();
+ } else {
+ hscroll->hide();
+ }
}
- }
- set_page(zoomw / scale);
+ set_page(zoomw / scale);
- int end_px = (l - get_value()) * scale;
- int begin_px = -get_value() * scale;
- Color notimecol = get_theme_color(SNAME("dark_color_2"), SNAME("Editor"));
- Color timecolor = color;
- timecolor.a = 0.2;
- Color linecolor = color;
- linecolor.a = 0.2;
+ int end_px = (l - get_value()) * scale;
+ int begin_px = -get_value() * scale;
+ Color notimecol = get_theme_color(SNAME("dark_color_2"), SNAME("Editor"));
+ Color timecolor = color;
+ timecolor.a = 0.2;
+ Color linecolor = color;
+ linecolor.a = 0.2;
- {
- draw_rect(Rect2(Point2(get_name_limit(), 0), Point2(zoomw - 1, h)), notimecol);
+ {
+ draw_rect(Rect2(Point2(get_name_limit(), 0), Point2(zoomw - 1, h)), notimecol);
- if (begin_px < zoomw && end_px > 0) {
- if (begin_px < 0) {
- begin_px = 0;
- }
- if (end_px > zoomw) {
- end_px = zoomw;
- }
+ if (begin_px < zoomw && end_px > 0) {
+ if (begin_px < 0) {
+ begin_px = 0;
+ }
+ if (end_px > zoomw) {
+ end_px = zoomw;
+ }
- draw_rect(Rect2(Point2(get_name_limit() + begin_px, 0), Point2(end_px - begin_px - 1, h)), timecolor);
+ draw_rect(Rect2(Point2(get_name_limit() + begin_px, 0), Point2(end_px - begin_px - 1, h)), timecolor);
+ }
}
- }
- Color color_time_sec = color;
- Color color_time_dec = color;
- color_time_dec.a *= 0.5;
+ Color color_time_sec = color;
+ Color color_time_dec = color;
+ color_time_dec.a *= 0.5;
#define SC_ADJ 100
- int min = 30;
- int dec = 1;
- int step = 1;
- int decimals = 2;
- bool step_found = false;
-
- const float period_width = font->get_char_size('.', 0, font_size).width;
- float max_digit_width = font->get_char_size('0', 0, font_size).width;
- for (int i = 1; i <= 9; i++) {
- const float digit_width = font->get_char_size('0' + i, 0, font_size).width;
- max_digit_width = MAX(digit_width, max_digit_width);
- }
- const int max_sc = int(Math::ceil(zoomw / scale));
- const int max_sc_width = String::num(max_sc).length() * max_digit_width;
-
- while (!step_found) {
- min = max_sc_width;
- if (decimals > 0) {
- min += period_width + max_digit_width * decimals;
+ int min = 30;
+ int dec = 1;
+ int step = 1;
+ int decimals = 2;
+ bool step_found = false;
+
+ const float period_width = font->get_char_size('.', 0, font_size).width;
+ float max_digit_width = font->get_char_size('0', 0, font_size).width;
+ for (int i = 1; i <= 9; i++) {
+ const float digit_width = font->get_char_size('0' + i, 0, font_size).width;
+ max_digit_width = MAX(digit_width, max_digit_width);
}
+ const int max_sc = int(Math::ceil(zoomw / scale));
+ const int max_sc_width = String::num(max_sc).length() * max_digit_width;
+
+ while (!step_found) {
+ min = max_sc_width;
+ if (decimals > 0) {
+ min += period_width + max_digit_width * decimals;
+ }
- static const int _multp[3] = { 1, 2, 5 };
- for (int i = 0; i < 3; i++) {
- step = (_multp[i] * dec);
- if (step * scale / SC_ADJ > min) {
- step_found = true;
+ static const int _multp[3] = { 1, 2, 5 };
+ for (int i = 0; i < 3; i++) {
+ step = (_multp[i] * dec);
+ if (step * scale / SC_ADJ > min) {
+ step_found = true;
+ break;
+ }
+ }
+ if (step_found) {
break;
}
+ dec *= 10;
+ decimals--;
+ if (decimals < 0) {
+ decimals = 0;
+ }
}
- if (step_found) {
- break;
- }
- dec *= 10;
- decimals--;
- if (decimals < 0) {
- decimals = 0;
- }
- }
- if (use_fps) {
- float step_size = animation->get_step();
- if (step_size > 0) {
- int prev_frame_ofs = -10000000;
+ if (use_fps) {
+ float step_size = animation->get_step();
+ if (step_size > 0) {
+ int prev_frame_ofs = -10000000;
- for (int i = 0; i < zoomw; i++) {
- float pos = get_value() + double(i) / scale;
- float prev = get_value() + (double(i) - 1.0) / scale;
+ for (int i = 0; i < zoomw; i++) {
+ float pos = get_value() + double(i) / scale;
+ float prev = get_value() + (double(i) - 1.0) / scale;
- int frame = pos / step_size;
- int prev_frame = prev / step_size;
+ int frame = pos / step_size;
+ int prev_frame = prev / step_size;
- bool sub = Math::floor(prev) == Math::floor(pos);
+ bool sub = Math::floor(prev) == Math::floor(pos);
- if (frame != prev_frame && i >= prev_frame_ofs) {
- draw_line(Point2(get_name_limit() + i, 0), Point2(get_name_limit() + i, h), linecolor, Math::round(EDSCALE));
+ if (frame != prev_frame && i >= prev_frame_ofs) {
+ draw_line(Point2(get_name_limit() + i, 0), Point2(get_name_limit() + i, h), linecolor, Math::round(EDSCALE));
- draw_string(font, Point2(get_name_limit() + i + 3 * EDSCALE, (h - font->get_height(font_size)) / 2 + font->get_ascent(font_size)).floor(), itos(frame), HORIZONTAL_ALIGNMENT_LEFT, zoomw - i, font_size, sub ? color_time_dec : color_time_sec);
- prev_frame_ofs = i + font->get_string_size(itos(frame), font_size).x + 5 * EDSCALE;
+ draw_string(font, Point2(get_name_limit() + i + 3 * EDSCALE, (h - font->get_height(font_size)) / 2 + font->get_ascent(font_size)).floor(), itos(frame), HORIZONTAL_ALIGNMENT_LEFT, zoomw - i, font_size, sub ? color_time_dec : color_time_sec);
+ prev_frame_ofs = i + font->get_string_size(itos(frame), font_size).x + 5 * EDSCALE;
+ }
}
}
- }
- } else {
- for (int i = 0; i < zoomw; i++) {
- float pos = get_value() + double(i) / scale;
- float prev = get_value() + (double(i) - 1.0) / scale;
-
- int sc = int(Math::floor(pos * SC_ADJ));
- int prev_sc = int(Math::floor(prev * SC_ADJ));
- bool sub = (sc % SC_ADJ);
-
- if ((sc / step) != (prev_sc / step) || (prev_sc < 0 && sc >= 0)) {
- int scd = sc < 0 ? prev_sc : sc;
- draw_line(Point2(get_name_limit() + i, 0), Point2(get_name_limit() + i, h), linecolor, Math::round(EDSCALE));
- draw_string(font, Point2(get_name_limit() + i + 3, (h - font->get_height(font_size)) / 2 + font->get_ascent(font_size)).floor(), String::num((scd - (scd % step)) / double(SC_ADJ), decimals), HORIZONTAL_ALIGNMENT_LEFT, zoomw - i, font_size, sub ? color_time_dec : color_time_sec);
+ } else {
+ for (int i = 0; i < zoomw; i++) {
+ float pos = get_value() + double(i) / scale;
+ float prev = get_value() + (double(i) - 1.0) / scale;
+
+ int sc = int(Math::floor(pos * SC_ADJ));
+ int prev_sc = int(Math::floor(prev * SC_ADJ));
+ bool sub = (sc % SC_ADJ);
+
+ if ((sc / step) != (prev_sc / step) || (prev_sc < 0 && sc >= 0)) {
+ int scd = sc < 0 ? prev_sc : sc;
+ draw_line(Point2(get_name_limit() + i, 0), Point2(get_name_limit() + i, h), linecolor, Math::round(EDSCALE));
+ draw_string(font, Point2(get_name_limit() + i + 3, (h - font->get_height(font_size)) / 2 + font->get_ascent(font_size)).floor(), String::num((scd - (scd % step)) / double(SC_ADJ), decimals), HORIZONTAL_ALIGNMENT_LEFT, zoomw - i, font_size, sub ? color_time_dec : color_time_sec);
+ }
}
}
- }
- draw_line(Vector2(0, get_size().height), get_size(), linecolor, Math::round(EDSCALE));
+ draw_line(Vector2(0, get_size().height), get_size(), linecolor, Math::round(EDSCALE));
+ } break;
}
}
@@ -1942,302 +1945,305 @@ AnimationTimelineEdit::AnimationTimelineEdit() {
////////////////////////////////////
void AnimationTrackEdit::_notification(int p_what) {
- if (p_what == NOTIFICATION_DRAW) {
- if (animation.is_null()) {
- return;
- }
- ERR_FAIL_INDEX(track, animation->get_track_count());
-
- int limit = timeline->get_name_limit();
+ switch (p_what) {
+ case NOTIFICATION_DRAW: {
+ if (animation.is_null()) {
+ return;
+ }
+ ERR_FAIL_INDEX(track, animation->get_track_count());
- if (has_focus()) {
- Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
- accent.a *= 0.7;
- // Offside so the horizontal sides aren't cutoff.
- draw_rect(Rect2(Point2(1 * EDSCALE, 0), get_size() - Size2(1 * EDSCALE, 0)), accent, false);
- }
+ int limit = timeline->get_name_limit();
- Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
- int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label"));
- Color color = get_theme_color(SNAME("font_color"), SNAME("Label"));
- Ref<Texture2D> type_icons[9] = {
- get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")),
- get_theme_icon(SNAME("KeyTrackPosition"), SNAME("EditorIcons")),
- get_theme_icon(SNAME("KeyTrackRotation"), SNAME("EditorIcons")),
- get_theme_icon(SNAME("KeyTrackScale"), SNAME("EditorIcons")),
- get_theme_icon(SNAME("KeyTrackBlendShape"), SNAME("EditorIcons")),
- get_theme_icon(SNAME("KeyCall"), SNAME("EditorIcons")),
- get_theme_icon(SNAME("KeyBezier"), SNAME("EditorIcons")),
- get_theme_icon(SNAME("KeyAudio"), SNAME("EditorIcons")),
- get_theme_icon(SNAME("KeyAnimation"), SNAME("EditorIcons"))
- };
- int hsep = get_theme_constant(SNAME("hseparation"), SNAME("ItemList"));
- Color linecolor = color;
- linecolor.a = 0.2;
+ if (has_focus()) {
+ Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
+ accent.a *= 0.7;
+ // Offside so the horizontal sides aren't cutoff.
+ draw_rect(Rect2(Point2(1 * EDSCALE, 0), get_size() - Size2(1 * EDSCALE, 0)), accent, false);
+ }
- // NAMES AND ICONS //
+ Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
+ int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label"));
+ Color color = get_theme_color(SNAME("font_color"), SNAME("Label"));
+ Ref<Texture2D> type_icons[9] = {
+ get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")),
+ get_theme_icon(SNAME("KeyTrackPosition"), SNAME("EditorIcons")),
+ get_theme_icon(SNAME("KeyTrackRotation"), SNAME("EditorIcons")),
+ get_theme_icon(SNAME("KeyTrackScale"), SNAME("EditorIcons")),
+ get_theme_icon(SNAME("KeyTrackBlendShape"), SNAME("EditorIcons")),
+ get_theme_icon(SNAME("KeyCall"), SNAME("EditorIcons")),
+ get_theme_icon(SNAME("KeyBezier"), SNAME("EditorIcons")),
+ get_theme_icon(SNAME("KeyAudio"), SNAME("EditorIcons")),
+ get_theme_icon(SNAME("KeyAnimation"), SNAME("EditorIcons"))
+ };
+ int hsep = get_theme_constant(SNAME("hseparation"), SNAME("ItemList"));
+ Color linecolor = color;
+ linecolor.a = 0.2;
- {
- Ref<Texture2D> check = animation->track_is_enabled(track) ? get_theme_icon(SNAME("checked"), SNAME("CheckBox")) : get_theme_icon(SNAME("unchecked"), SNAME("CheckBox"));
+ // NAMES AND ICONS //
- int ofs = in_group ? check->get_width() : 0; // Not the best reference for margin but..
+ {
+ Ref<Texture2D> check = animation->track_is_enabled(track) ? get_theme_icon(SNAME("checked"), SNAME("CheckBox")) : get_theme_icon(SNAME("unchecked"), SNAME("CheckBox"));
- check_rect = Rect2(Point2(ofs, int(get_size().height - check->get_height()) / 2), check->get_size());
- draw_texture(check, check_rect.position);
- ofs += check->get_width() + hsep;
+ int ofs = in_group ? check->get_width() : 0; // Not the best reference for margin but..
- Ref<Texture2D> type_icon = type_icons[animation->track_get_type(track)];
- draw_texture(type_icon, Point2(ofs, int(get_size().height - type_icon->get_height()) / 2));
- ofs += type_icon->get_width() + hsep;
+ check_rect = Rect2(Point2(ofs, int(get_size().height - check->get_height()) / 2), check->get_size());
+ draw_texture(check, check_rect.position);
+ ofs += check->get_width() + hsep;
- NodePath path = animation->track_get_path(track);
- Node *node = nullptr;
- if (root && root->has_node(path)) {
- node = root->get_node(path);
- }
+ Ref<Texture2D> type_icon = type_icons[animation->track_get_type(track)];
+ draw_texture(type_icon, Point2(ofs, int(get_size().height - type_icon->get_height()) / 2));
+ ofs += type_icon->get_width() + hsep;
- String text;
- Color text_color = color;
- if (node && EditorNode::get_singleton()->get_editor_selection()->is_selected(node)) {
- text_color = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
- }
+ NodePath path = animation->track_get_path(track);
+ Node *node = nullptr;
+ if (root && root->has_node(path)) {
+ node = root->get_node(path);
+ }
- if (in_group) {
- if (animation->track_get_type(track) == Animation::TYPE_METHOD) {
- text = TTR("Functions:");
- } else if (animation->track_get_type(track) == Animation::TYPE_AUDIO) {
- text = TTR("Audio Clips:");
- } else if (animation->track_get_type(track) == Animation::TYPE_ANIMATION) {
- text = TTR("Anim Clips:");
- } else {
- text += path.get_concatenated_subnames();
+ String text;
+ Color text_color = color;
+ if (node && EditorNode::get_singleton()->get_editor_selection()->is_selected(node)) {
+ text_color = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
}
- text_color.a *= 0.7;
- } else if (node) {
- Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(node, "Node");
- draw_texture(icon, Point2(ofs, int(get_size().height - icon->get_height()) / 2));
- icon_cache = icon;
+ if (in_group) {
+ if (animation->track_get_type(track) == Animation::TYPE_METHOD) {
+ text = TTR("Functions:");
+ } else if (animation->track_get_type(track) == Animation::TYPE_AUDIO) {
+ text = TTR("Audio Clips:");
+ } else if (animation->track_get_type(track) == Animation::TYPE_ANIMATION) {
+ text = TTR("Anim Clips:");
+ } else {
+ text += path.get_concatenated_subnames();
+ }
+ text_color.a *= 0.7;
+ } else if (node) {
+ Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(node, "Node");
- text = String() + node->get_name() + ":" + path.get_concatenated_subnames();
- ofs += hsep;
- ofs += icon->get_width();
+ draw_texture(icon, Point2(ofs, int(get_size().height - icon->get_height()) / 2));
+ icon_cache = icon;
- } else {
- icon_cache = type_icon;
+ text = String() + node->get_name() + ":" + path.get_concatenated_subnames();
+ ofs += hsep;
+ ofs += icon->get_width();
- text = path;
- }
+ } else {
+ icon_cache = type_icon;
- path_cache = text;
+ text = path;
+ }
- path_rect = Rect2(ofs, 0, limit - ofs - hsep, get_size().height);
+ path_cache = text;
- Vector2 string_pos = Point2(ofs, (get_size().height - font->get_height(font_size)) / 2 + font->get_ascent(font_size));
- string_pos = string_pos.floor();
- draw_string(font, string_pos, text, HORIZONTAL_ALIGNMENT_LEFT, limit - ofs - hsep, font_size, text_color);
+ path_rect = Rect2(ofs, 0, limit - ofs - hsep, get_size().height);
- draw_line(Point2(limit, 0), Point2(limit, get_size().height), linecolor, Math::round(EDSCALE));
- }
+ Vector2 string_pos = Point2(ofs, (get_size().height - font->get_height(font_size)) / 2 + font->get_ascent(font_size));
+ string_pos = string_pos.floor();
+ draw_string(font, string_pos, text, HORIZONTAL_ALIGNMENT_LEFT, limit - ofs - hsep, font_size, text_color);
- // KEYFRAMES //
+ draw_line(Point2(limit, 0), Point2(limit, get_size().height), linecolor, Math::round(EDSCALE));
+ }
- draw_bg(limit, get_size().width - timeline->get_buttons_width());
+ // KEYFRAMES //
- {
- float scale = timeline->get_zoom_scale();
- int limit_end = get_size().width - timeline->get_buttons_width();
+ draw_bg(limit, get_size().width - timeline->get_buttons_width());
- for (int i = 0; i < animation->track_get_key_count(track); i++) {
- float offset = animation->track_get_key_time(track, i) - timeline->get_value();
- if (editor->is_key_selected(track, i) && editor->is_moving_selection()) {
- offset = editor->snap_time(offset + editor->get_moving_selection_offset(), true);
- }
- offset = offset * scale + limit;
- if (i < animation->track_get_key_count(track) - 1) {
- float offset_n = animation->track_get_key_time(track, i + 1) - timeline->get_value();
- if (editor->is_key_selected(track, i + 1) && editor->is_moving_selection()) {
- offset_n = editor->snap_time(offset_n + editor->get_moving_selection_offset());
+ {
+ float scale = timeline->get_zoom_scale();
+ int limit_end = get_size().width - timeline->get_buttons_width();
+
+ for (int i = 0; i < animation->track_get_key_count(track); i++) {
+ float offset = animation->track_get_key_time(track, i) - timeline->get_value();
+ if (editor->is_key_selected(track, i) && editor->is_moving_selection()) {
+ offset = editor->snap_time(offset + editor->get_moving_selection_offset(), true);
}
- offset_n = offset_n * scale + limit;
+ offset = offset * scale + limit;
+ if (i < animation->track_get_key_count(track) - 1) {
+ float offset_n = animation->track_get_key_time(track, i + 1) - timeline->get_value();
+ if (editor->is_key_selected(track, i + 1) && editor->is_moving_selection()) {
+ offset_n = editor->snap_time(offset_n + editor->get_moving_selection_offset());
+ }
+ offset_n = offset_n * scale + limit;
- draw_key_link(i, scale, int(offset), int(offset_n), limit, limit_end);
- }
+ draw_key_link(i, scale, int(offset), int(offset_n), limit, limit_end);
+ }
- draw_key(i, scale, int(offset), editor->is_key_selected(track, i), limit, limit_end);
+ draw_key(i, scale, int(offset), editor->is_key_selected(track, i), limit, limit_end);
+ }
}
- }
- draw_fg(limit, get_size().width - timeline->get_buttons_width());
+ draw_fg(limit, get_size().width - timeline->get_buttons_width());
- // BUTTONS //
+ // BUTTONS //
- {
- Ref<Texture2D> wrap_icon[2] = {
- get_theme_icon(SNAME("InterpWrapClamp"), SNAME("EditorIcons")),
- get_theme_icon(SNAME("InterpWrapLoop"), SNAME("EditorIcons")),
- };
+ {
+ Ref<Texture2D> wrap_icon[2] = {
+ get_theme_icon(SNAME("InterpWrapClamp"), SNAME("EditorIcons")),
+ get_theme_icon(SNAME("InterpWrapLoop"), SNAME("EditorIcons")),
+ };
- Ref<Texture2D> interp_icon[3] = {
- get_theme_icon(SNAME("InterpRaw"), SNAME("EditorIcons")),
- get_theme_icon(SNAME("InterpLinear"), SNAME("EditorIcons")),
- get_theme_icon(SNAME("InterpCubic"), SNAME("EditorIcons"))
- };
- Ref<Texture2D> cont_icon[4] = {
- get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")),
- get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")),
- get_theme_icon(SNAME("TrackTrigger"), SNAME("EditorIcons")),
- get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons"))
- };
+ Ref<Texture2D> interp_icon[3] = {
+ get_theme_icon(SNAME("InterpRaw"), SNAME("EditorIcons")),
+ get_theme_icon(SNAME("InterpLinear"), SNAME("EditorIcons")),
+ get_theme_icon(SNAME("InterpCubic"), SNAME("EditorIcons"))
+ };
+ Ref<Texture2D> cont_icon[4] = {
+ get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")),
+ get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")),
+ get_theme_icon(SNAME("TrackTrigger"), SNAME("EditorIcons")),
+ get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons"))
+ };
- int ofs = get_size().width - timeline->get_buttons_width();
+ int ofs = get_size().width - timeline->get_buttons_width();
- Ref<Texture2D> down_icon = get_theme_icon(SNAME("select_arrow"), SNAME("Tree"));
+ Ref<Texture2D> down_icon = get_theme_icon(SNAME("select_arrow"), SNAME("Tree"));
- draw_line(Point2(ofs, 0), Point2(ofs, get_size().height), linecolor, Math::round(EDSCALE));
+ draw_line(Point2(ofs, 0), Point2(ofs, get_size().height), linecolor, Math::round(EDSCALE));
- ofs += hsep;
- {
- // Callmode.
+ ofs += hsep;
+ {
+ // Callmode.
- Animation::UpdateMode update_mode;
+ Animation::UpdateMode update_mode;
- if (animation->track_get_type(track) == Animation::TYPE_VALUE) {
- update_mode = animation->value_track_get_update_mode(track);
- } else {
- update_mode = Animation::UPDATE_CONTINUOUS;
- }
+ if (animation->track_get_type(track) == Animation::TYPE_VALUE) {
+ update_mode = animation->value_track_get_update_mode(track);
+ } else {
+ update_mode = Animation::UPDATE_CONTINUOUS;
+ }
- Ref<Texture2D> update_icon = cont_icon[update_mode];
+ Ref<Texture2D> update_icon = cont_icon[update_mode];
- update_mode_rect.position.x = ofs;
- update_mode_rect.position.y = int(get_size().height - update_icon->get_height()) / 2;
- update_mode_rect.size = update_icon->get_size();
+ update_mode_rect.position.x = ofs;
+ update_mode_rect.position.y = int(get_size().height - update_icon->get_height()) / 2;
+ update_mode_rect.size = update_icon->get_size();
- if (!animation->track_is_compressed(track) && animation->track_get_type(track) == Animation::TYPE_VALUE) {
- draw_texture(update_icon, update_mode_rect.position);
- }
- // Make it easier to click.
- update_mode_rect.position.y = 0;
- update_mode_rect.size.y = get_size().height;
+ if (!animation->track_is_compressed(track) && animation->track_get_type(track) == Animation::TYPE_VALUE) {
+ draw_texture(update_icon, update_mode_rect.position);
+ }
+ // Make it easier to click.
+ update_mode_rect.position.y = 0;
+ update_mode_rect.size.y = get_size().height;
- ofs += update_icon->get_width() + hsep / 2;
- update_mode_rect.size.x += hsep / 2;
+ ofs += update_icon->get_width() + hsep / 2;
+ update_mode_rect.size.x += hsep / 2;
- if (animation->track_get_type(track) == Animation::TYPE_VALUE) {
- draw_texture(down_icon, Vector2(ofs, int(get_size().height - down_icon->get_height()) / 2));
- update_mode_rect.size.x += down_icon->get_width();
- } else if (animation->track_get_type(track) == Animation::TYPE_BEZIER) {
- Ref<Texture2D> bezier_icon = get_theme_icon(SNAME("EditBezier"), SNAME("EditorIcons"));
- update_mode_rect.size.x += down_icon->get_width();
+ if (animation->track_get_type(track) == Animation::TYPE_VALUE) {
+ draw_texture(down_icon, Vector2(ofs, int(get_size().height - down_icon->get_height()) / 2));
+ update_mode_rect.size.x += down_icon->get_width();
+ } else if (animation->track_get_type(track) == Animation::TYPE_BEZIER) {
+ Ref<Texture2D> bezier_icon = get_theme_icon(SNAME("EditBezier"), SNAME("EditorIcons"));
+ update_mode_rect.size.x += down_icon->get_width();
- update_mode_rect = Rect2();
- } else {
- update_mode_rect = Rect2();
+ update_mode_rect = Rect2();
+ } else {
+ update_mode_rect = Rect2();
+ }
+
+ ofs += down_icon->get_width();
+ draw_line(Point2(ofs + hsep * 0.5, 0), Point2(ofs + hsep * 0.5, get_size().height), linecolor, Math::round(EDSCALE));
+ ofs += hsep;
}
- ofs += down_icon->get_width();
- draw_line(Point2(ofs + hsep * 0.5, 0), Point2(ofs + hsep * 0.5, get_size().height), linecolor, Math::round(EDSCALE));
- ofs += hsep;
- }
+ {
+ // Interp.
- {
- // Interp.
+ Animation::InterpolationType interp_mode = animation->track_get_interpolation_type(track);
- Animation::InterpolationType interp_mode = animation->track_get_interpolation_type(track);
+ Ref<Texture2D> icon = interp_icon[interp_mode];
- Ref<Texture2D> icon = interp_icon[interp_mode];
+ interp_mode_rect.position.x = ofs;
+ interp_mode_rect.position.y = int(get_size().height - icon->get_height()) / 2;
+ interp_mode_rect.size = icon->get_size();
- interp_mode_rect.position.x = ofs;
- interp_mode_rect.position.y = int(get_size().height - icon->get_height()) / 2;
- interp_mode_rect.size = icon->get_size();
+ if (!animation->track_is_compressed(track) && (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_BLEND_SHAPE || animation->track_get_type(track) == Animation::TYPE_POSITION_3D || animation->track_get_type(track) == Animation::TYPE_SCALE_3D || animation->track_get_type(track) == Animation::TYPE_ROTATION_3D)) {
+ draw_texture(icon, interp_mode_rect.position);
+ }
+ // Make it easier to click.
+ interp_mode_rect.position.y = 0;
+ interp_mode_rect.size.y = get_size().height;
- if (!animation->track_is_compressed(track) && (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_BLEND_SHAPE || animation->track_get_type(track) == Animation::TYPE_POSITION_3D || animation->track_get_type(track) == Animation::TYPE_SCALE_3D || animation->track_get_type(track) == Animation::TYPE_ROTATION_3D)) {
- draw_texture(icon, interp_mode_rect.position);
- }
- // Make it easier to click.
- interp_mode_rect.position.y = 0;
- interp_mode_rect.size.y = get_size().height;
+ ofs += icon->get_width() + hsep / 2;
+ interp_mode_rect.size.x += hsep / 2;
- ofs += icon->get_width() + hsep / 2;
- interp_mode_rect.size.x += hsep / 2;
+ if (!animation->track_is_compressed(track) && (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_BLEND_SHAPE || animation->track_get_type(track) == Animation::TYPE_POSITION_3D || animation->track_get_type(track) == Animation::TYPE_SCALE_3D || animation->track_get_type(track) == Animation::TYPE_ROTATION_3D)) {
+ draw_texture(down_icon, Vector2(ofs, int(get_size().height - down_icon->get_height()) / 2));
+ interp_mode_rect.size.x += down_icon->get_width();
+ } else {
+ interp_mode_rect = Rect2();
+ }
- if (!animation->track_is_compressed(track) && (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_BLEND_SHAPE || animation->track_get_type(track) == Animation::TYPE_POSITION_3D || animation->track_get_type(track) == Animation::TYPE_SCALE_3D || animation->track_get_type(track) == Animation::TYPE_ROTATION_3D)) {
- draw_texture(down_icon, Vector2(ofs, int(get_size().height - down_icon->get_height()) / 2));
- interp_mode_rect.size.x += down_icon->get_width();
- } else {
- interp_mode_rect = Rect2();
+ ofs += down_icon->get_width();
+ draw_line(Point2(ofs + hsep * 0.5, 0), Point2(ofs + hsep * 0.5, get_size().height), linecolor, Math::round(EDSCALE));
+ ofs += hsep;
}
- ofs += down_icon->get_width();
- draw_line(Point2(ofs + hsep * 0.5, 0), Point2(ofs + hsep * 0.5, get_size().height), linecolor, Math::round(EDSCALE));
- ofs += hsep;
- }
+ {
+ // Loop.
- {
- // Loop.
+ bool loop_wrap = animation->track_get_interpolation_loop_wrap(track);
- bool loop_wrap = animation->track_get_interpolation_loop_wrap(track);
+ Ref<Texture2D> icon = wrap_icon[loop_wrap ? 1 : 0];
- Ref<Texture2D> icon = wrap_icon[loop_wrap ? 1 : 0];
+ loop_wrap_rect.position.x = ofs;
+ loop_wrap_rect.position.y = int(get_size().height - icon->get_height()) / 2;
+ loop_wrap_rect.size = icon->get_size();
- loop_wrap_rect.position.x = ofs;
- loop_wrap_rect.position.y = int(get_size().height - icon->get_height()) / 2;
- loop_wrap_rect.size = icon->get_size();
+ if (!animation->track_is_compressed(track) && (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_BLEND_SHAPE || animation->track_get_type(track) == Animation::TYPE_POSITION_3D || animation->track_get_type(track) == Animation::TYPE_SCALE_3D || animation->track_get_type(track) == Animation::TYPE_ROTATION_3D)) {
+ draw_texture(icon, loop_wrap_rect.position);
+ }
- if (!animation->track_is_compressed(track) && (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_BLEND_SHAPE || animation->track_get_type(track) == Animation::TYPE_POSITION_3D || animation->track_get_type(track) == Animation::TYPE_SCALE_3D || animation->track_get_type(track) == Animation::TYPE_ROTATION_3D)) {
- draw_texture(icon, loop_wrap_rect.position);
- }
+ loop_wrap_rect.position.y = 0;
+ loop_wrap_rect.size.y = get_size().height;
- loop_wrap_rect.position.y = 0;
- loop_wrap_rect.size.y = get_size().height;
+ ofs += icon->get_width() + hsep / 2;
+ loop_wrap_rect.size.x += hsep / 2;
- ofs += icon->get_width() + hsep / 2;
- loop_wrap_rect.size.x += hsep / 2;
+ if (!animation->track_is_compressed(track) && (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_BLEND_SHAPE || animation->track_get_type(track) == Animation::TYPE_POSITION_3D || animation->track_get_type(track) == Animation::TYPE_SCALE_3D || animation->track_get_type(track) == Animation::TYPE_ROTATION_3D)) {
+ draw_texture(down_icon, Vector2(ofs, int(get_size().height - down_icon->get_height()) / 2));
+ loop_wrap_rect.size.x += down_icon->get_width();
+ } else {
+ loop_wrap_rect = Rect2();
+ }
- if (!animation->track_is_compressed(track) && (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_BLEND_SHAPE || animation->track_get_type(track) == Animation::TYPE_POSITION_3D || animation->track_get_type(track) == Animation::TYPE_SCALE_3D || animation->track_get_type(track) == Animation::TYPE_ROTATION_3D)) {
- draw_texture(down_icon, Vector2(ofs, int(get_size().height - down_icon->get_height()) / 2));
- loop_wrap_rect.size.x += down_icon->get_width();
- } else {
- loop_wrap_rect = Rect2();
+ ofs += down_icon->get_width();
+ draw_line(Point2(ofs + hsep * 0.5, 0), Point2(ofs + hsep * 0.5, get_size().height), linecolor, Math::round(EDSCALE));
+ ofs += hsep;
}
- ofs += down_icon->get_width();
- draw_line(Point2(ofs + hsep * 0.5, 0), Point2(ofs + hsep * 0.5, get_size().height), linecolor, Math::round(EDSCALE));
- ofs += hsep;
- }
-
- {
- // Erase.
+ {
+ // Erase.
- Ref<Texture2D> icon = get_theme_icon(animation->track_is_compressed(track) ? SNAME("Lock") : SNAME("Remove"), SNAME("EditorIcons"));
+ Ref<Texture2D> icon = get_theme_icon(animation->track_is_compressed(track) ? SNAME("Lock") : SNAME("Remove"), SNAME("EditorIcons"));
- remove_rect.position.x = ofs + ((get_size().width - ofs) - icon->get_width());
- remove_rect.position.y = int(get_size().height - icon->get_height()) / 2;
- remove_rect.size = icon->get_size();
+ remove_rect.position.x = ofs + ((get_size().width - ofs) - icon->get_width());
+ remove_rect.position.y = int(get_size().height - icon->get_height()) / 2;
+ remove_rect.size = icon->get_size();
- draw_texture(icon, remove_rect.position);
+ draw_texture(icon, remove_rect.position);
+ }
}
- }
-
- if (in_group) {
- draw_line(Vector2(timeline->get_name_limit(), get_size().height), get_size(), linecolor, Math::round(EDSCALE));
- } else {
- draw_line(Vector2(0, get_size().height), get_size(), linecolor, Math::round(EDSCALE));
- }
- if (dropping_at != 0) {
- Color drop_color = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
- if (dropping_at < 0) {
- draw_line(Vector2(0, 0), Vector2(get_size().width, 0), drop_color, Math::round(EDSCALE));
+ if (in_group) {
+ draw_line(Vector2(timeline->get_name_limit(), get_size().height), get_size(), linecolor, Math::round(EDSCALE));
} else {
- draw_line(Vector2(0, get_size().height), get_size(), drop_color, Math::round(EDSCALE));
+ draw_line(Vector2(0, get_size().height), get_size(), linecolor, Math::round(EDSCALE));
}
- }
- }
- if (p_what == NOTIFICATION_MOUSE_EXIT || p_what == NOTIFICATION_DRAG_END) {
- cancel_drop();
+ if (dropping_at != 0) {
+ Color drop_color = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
+ if (dropping_at < 0) {
+ draw_line(Vector2(0, 0), Vector2(get_size().width, 0), drop_color, Math::round(EDSCALE));
+ } else {
+ draw_line(Vector2(0, get_size().height), get_size(), drop_color, Math::round(EDSCALE));
+ }
+ }
+ } break;
+
+ case NOTIFICATION_MOUSE_EXIT:
+ case NOTIFICATION_DRAG_END: {
+ cancel_drop();
+ } break;
}
}
@@ -3205,40 +3211,42 @@ AnimationTrackEdit *AnimationTrackEditPlugin::create_animation_track_edit(Object
///////////////////////////////////////
void AnimationTrackEditGroup::_notification(int p_what) {
- if (p_what == NOTIFICATION_DRAW) {
- Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
- int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label"));
- int separation = get_theme_constant(SNAME("hseparation"), SNAME("ItemList"));
- Color color = get_theme_color(SNAME("font_color"), SNAME("Label"));
-
- if (root && root->has_node(node)) {
- Node *n = root->get_node(node);
- if (n && EditorNode::get_singleton()->get_editor_selection()->is_selected(n)) {
- color = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
+ switch (p_what) {
+ case NOTIFICATION_DRAW: {
+ Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
+ int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label"));
+ int separation = get_theme_constant(SNAME("hseparation"), SNAME("ItemList"));
+ Color color = get_theme_color(SNAME("font_color"), SNAME("Label"));
+
+ if (root && root->has_node(node)) {
+ Node *n = root->get_node(node);
+ if (n && EditorNode::get_singleton()->get_editor_selection()->is_selected(n)) {
+ color = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
+ }
}
- }
- Color bgcol = get_theme_color(SNAME("dark_color_2"), SNAME("Editor"));
- bgcol.a *= 0.6;
- draw_rect(Rect2(Point2(), get_size()), bgcol);
- Color linecolor = color;
- linecolor.a = 0.2;
+ Color bgcol = get_theme_color(SNAME("dark_color_2"), SNAME("Editor"));
+ bgcol.a *= 0.6;
+ draw_rect(Rect2(Point2(), get_size()), bgcol);
+ Color linecolor = color;
+ linecolor.a = 0.2;
- draw_line(Point2(), Point2(get_size().width, 0), linecolor, Math::round(EDSCALE));
- draw_line(Point2(timeline->get_name_limit(), 0), Point2(timeline->get_name_limit(), get_size().height), linecolor, Math::round(EDSCALE));
- draw_line(Point2(get_size().width - timeline->get_buttons_width(), 0), Point2(get_size().width - timeline->get_buttons_width(), get_size().height), linecolor, Math::round(EDSCALE));
+ draw_line(Point2(), Point2(get_size().width, 0), linecolor, Math::round(EDSCALE));
+ draw_line(Point2(timeline->get_name_limit(), 0), Point2(timeline->get_name_limit(), get_size().height), linecolor, Math::round(EDSCALE));
+ draw_line(Point2(get_size().width - timeline->get_buttons_width(), 0), Point2(get_size().width - timeline->get_buttons_width(), get_size().height), linecolor, Math::round(EDSCALE));
- int ofs = 0;
- draw_texture(icon, Point2(ofs, int(get_size().height - icon->get_height()) / 2));
- ofs += separation + icon->get_width();
- draw_string(font, Point2(ofs, int(get_size().height - font->get_height(font_size)) / 2 + font->get_ascent(font_size)), node_name, HORIZONTAL_ALIGNMENT_LEFT, timeline->get_name_limit() - ofs, font_size, color);
+ int ofs = 0;
+ draw_texture(icon, Point2(ofs, int(get_size().height - icon->get_height()) / 2));
+ ofs += separation + icon->get_width();
+ draw_string(font, Point2(ofs, int(get_size().height - font->get_height(font_size)) / 2 + font->get_ascent(font_size)), node_name, HORIZONTAL_ALIGNMENT_LEFT, timeline->get_name_limit() - ofs, font_size, color);
- int px = (-timeline->get_value() + timeline->get_play_position()) * timeline->get_zoom_scale() + timeline->get_name_limit();
+ int px = (-timeline->get_value() + timeline->get_play_position()) * timeline->get_zoom_scale() + timeline->get_name_limit();
- if (px >= timeline->get_name_limit() && px < (get_size().width - timeline->get_buttons_width())) {
- Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
- draw_line(Point2(px, 0), Point2(px, get_size().height), accent, Math::round(2 * EDSCALE));
- }
+ if (px >= timeline->get_name_limit() && px < (get_size().width - timeline->get_buttons_width())) {
+ Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
+ draw_line(Point2(px, 0), Point2(px, get_size().height), accent, Math::round(2 * EDSCALE));
+ }
+ } break;
}
}
@@ -4516,27 +4524,33 @@ MenuButton *AnimationTrackEditor::get_edit_menu() {
}
void AnimationTrackEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
- panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/animation_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning")));
- }
+ switch (p_what) {
+ case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
+ panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/animation_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning")));
+ } break;
- if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) {
- zoom_icon->set_texture(get_theme_icon(SNAME("Zoom"), SNAME("EditorIcons")));
- bezier_edit_icon->set_icon(get_theme_icon(SNAME("EditBezier"), SNAME("EditorIcons")));
- snap->set_icon(get_theme_icon(SNAME("Snap"), SNAME("EditorIcons")));
- view_group->set_icon(get_theme_icon(view_group->is_pressed() ? SNAME("AnimationTrackList") : SNAME("AnimationTrackGroup"), SNAME("EditorIcons")));
- selected_filter->set_icon(get_theme_icon(SNAME("AnimationFilter"), SNAME("EditorIcons")));
- imported_anim_warning->set_icon(get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons")));
- main_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
- edit->get_popup()->set_item_icon(edit->get_popup()->get_item_index(EDIT_APPLY_RESET), get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")));
- }
+ case NOTIFICATION_ENTER_TREE: {
+ panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/animation_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning")));
+ [[fallthrough]];
+ }
+ case NOTIFICATION_THEME_CHANGED: {
+ zoom_icon->set_texture(get_theme_icon(SNAME("Zoom"), SNAME("EditorIcons")));
+ bezier_edit_icon->set_icon(get_theme_icon(SNAME("EditBezier"), SNAME("EditorIcons")));
+ snap->set_icon(get_theme_icon(SNAME("Snap"), SNAME("EditorIcons")));
+ view_group->set_icon(get_theme_icon(view_group->is_pressed() ? SNAME("AnimationTrackList") : SNAME("AnimationTrackGroup"), SNAME("EditorIcons")));
+ selected_filter->set_icon(get_theme_icon(SNAME("AnimationFilter"), SNAME("EditorIcons")));
+ imported_anim_warning->set_icon(get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons")));
+ main_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
+ edit->get_popup()->set_item_icon(edit->get_popup()->get_item_index(EDIT_APPLY_RESET), get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")));
+ } break;
- if (p_what == NOTIFICATION_READY) {
- EditorNode::get_singleton()->get_editor_selection()->connect("selection_changed", callable_mp(this, &AnimationTrackEditor::_selection_changed));
- }
+ case NOTIFICATION_READY: {
+ EditorNode::get_singleton()->get_editor_selection()->connect("selection_changed", callable_mp(this, &AnimationTrackEditor::_selection_changed));
+ } break;
- if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- update_keying();
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ update_keying();
+ } break;
}
}
diff --git a/editor/audio_stream_preview.cpp b/editor/audio_stream_preview.cpp
index 81a6f78415..f8bf12227a 100644
--- a/editor/audio_stream_preview.cpp
+++ b/editor/audio_stream_preview.cpp
@@ -214,25 +214,27 @@ void AudioStreamPreviewGenerator::_bind_methods() {
AudioStreamPreviewGenerator *AudioStreamPreviewGenerator::singleton = nullptr;
void AudioStreamPreviewGenerator::_notification(int p_what) {
- if (p_what == NOTIFICATION_PROCESS) {
- List<ObjectID> to_erase;
- for (KeyValue<ObjectID, Preview> &E : previews) {
- if (!E.value.generating.is_set()) {
- if (E.value.thread) {
- E.value.thread->wait_to_finish();
- memdelete(E.value.thread);
- E.value.thread = nullptr;
- }
- if (!ObjectDB::get_instance(E.key)) { //no longer in use, get rid of preview
- to_erase.push_back(E.key);
+ switch (p_what) {
+ case NOTIFICATION_PROCESS: {
+ List<ObjectID> to_erase;
+ for (KeyValue<ObjectID, Preview> &E : previews) {
+ if (!E.value.generating.is_set()) {
+ if (E.value.thread) {
+ E.value.thread->wait_to_finish();
+ memdelete(E.value.thread);
+ E.value.thread = nullptr;
+ }
+ if (!ObjectDB::get_instance(E.key)) { //no longer in use, get rid of preview
+ to_erase.push_back(E.key);
+ }
}
}
- }
- while (to_erase.front()) {
- previews.erase(to_erase.front()->get());
- to_erase.pop_front();
- }
+ while (to_erase.front()) {
+ previews.erase(to_erase.front()->get());
+ to_erase.pop_front();
+ }
+ } break;
}
}
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 56dcd35c64..22d3155159 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -85,29 +85,31 @@ GotoLineDialog::GotoLineDialog() {
}
void FindReplaceBar::_notification(int p_what) {
- if (p_what == NOTIFICATION_READY) {
- find_prev->set_icon(get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons")));
- find_next->set_icon(get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons")));
- hide_button->set_normal_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons")));
- hide_button->set_hover_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons")));
- hide_button->set_pressed_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons")));
- hide_button->set_custom_minimum_size(hide_button->get_normal_texture()->get_size());
- } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- set_process_unhandled_input(is_visible_in_tree());
- } else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
- find_prev->set_icon(get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons")));
- find_next->set_icon(get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons")));
- hide_button->set_normal_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons")));
- hide_button->set_hover_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons")));
- hide_button->set_pressed_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons")));
- hide_button->set_custom_minimum_size(hide_button->get_normal_texture()->get_size());
- } else if (p_what == NOTIFICATION_THEME_CHANGED) {
- matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), SNAME("Editor")));
- } else if (p_what == NOTIFICATION_PREDELETE) {
- if (base_text_editor) {
- base_text_editor->remove_find_replace_bar();
- base_text_editor = nullptr;
- }
+ switch (p_what) {
+ case NOTIFICATION_READY:
+ case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
+ find_prev->set_icon(get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons")));
+ find_next->set_icon(get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons")));
+ hide_button->set_normal_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons")));
+ hide_button->set_hover_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons")));
+ hide_button->set_pressed_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons")));
+ hide_button->set_custom_minimum_size(hide_button->get_normal_texture()->get_size());
+ } break;
+
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ set_process_unhandled_input(is_visible_in_tree());
+ } break;
+
+ case NOTIFICATION_THEME_CHANGED: {
+ matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ } break;
+
+ case NOTIFICATION_PREDELETE: {
+ if (base_text_editor) {
+ base_text_editor->remove_find_replace_bar();
+ base_text_editor = nullptr;
+ }
+ } break;
}
}
@@ -1658,44 +1660,47 @@ void CodeTextEditor::_error_pressed(const Ref<InputEvent> &p_event) {
}
}
-void CodeTextEditor::_notification(int p_what) {
- switch (p_what) {
- case NOTIFICATION_ENTER_TREE:
- case NOTIFICATION_THEME_CHANGED: {
- error_button->set_icon(get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons")));
- error_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
- error_button->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts")));
- error_button->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts")));
+void CodeTextEditor::_update_status_bar_theme() {
+ error_button->set_icon(get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons")));
+ error_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ error_button->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts")));
+ error_button->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts")));
- warning_button->set_icon(get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons")));
- warning_button->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
- warning_button->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts")));
- warning_button->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts")));
+ warning_button->set_icon(get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons")));
+ warning_button->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
+ warning_button->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts")));
+ warning_button->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts")));
- line_and_col_txt->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts")));
- line_and_col_txt->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts")));
+ line_and_col_txt->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts")));
+ line_and_col_txt->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts")));
+}
- if (p_what == NOTIFICATION_ENTER_TREE) {
- break;
- }
+void CodeTextEditor::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ _update_status_bar_theme();
+ } break;
+
+ case NOTIFICATION_THEME_CHANGED: {
+ _update_status_bar_theme();
if (toggle_scripts_button->is_visible()) {
update_toggle_scripts_button();
}
_update_text_editor_theme();
} break;
+
case NOTIFICATION_VISIBILITY_CHANGED: {
if (toggle_scripts_button->is_visible()) {
update_toggle_scripts_button();
}
set_process_input(is_visible_in_tree());
} break;
+
case NOTIFICATION_PREDELETE: {
if (find_replace_bar) {
find_replace_bar->set_text_edit(nullptr);
}
} break;
- default:
- break;
}
}
diff --git a/editor/code_editor.h b/editor/code_editor.h
index aebdfe57c0..24316bf8b0 100644
--- a/editor/code_editor.h
+++ b/editor/code_editor.h
@@ -189,6 +189,8 @@ class CodeTextEditor : public VBoxContainer {
void _set_show_warnings_panel(bool p_show);
void _error_pressed(const Ref<InputEvent> &p_event);
+ void _update_status_bar_theme();
+
void _delete_line(int p_line);
void _toggle_scripts_pressed();
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp
index d4785afcf0..df2a66f182 100644
--- a/editor/connections_dialog.cpp
+++ b/editor/connections_dialog.cpp
@@ -277,8 +277,10 @@ void ConnectDialog::_update_ok_enabled() {
}
void ConnectDialog::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE) {
- bind_editor->edit(cdbinds);
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ bind_editor->edit(cdbinds);
+ } break;
}
}
@@ -938,6 +940,7 @@ void ConnectionsDock::_notification(int p_what) {
case NOTIFICATION_THEME_CHANGED: {
search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
} break;
+
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
update_tree();
} break;
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp
index c0c7b68686..081f0ac868 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -429,9 +429,11 @@ void CreateDialog::_notification(int p_what) {
connect("confirmed", callable_mp(this, &CreateDialog::_confirmed));
_update_theme();
} break;
+
case NOTIFICATION_EXIT_TREE: {
disconnect("confirmed", callable_mp(this, &CreateDialog::_confirmed));
} break;
+
case NOTIFICATION_VISIBILITY_CHANGED: {
if (is_visible()) {
search_box->call_deferred(SNAME("grab_focus")); // still not visible
@@ -440,6 +442,7 @@ void CreateDialog::_notification(int p_what) {
EditorSettings::get_singleton()->get_project_metadata("dialog_bounds", "create_new_node", Rect2(get_position(), get_size()));
}
} break;
+
case NOTIFICATION_THEME_CHANGED: {
_update_theme();
} break;
diff --git a/editor/debugger/debug_adapter/debug_adapter_server.cpp b/editor/debugger/debug_adapter/debug_adapter_server.cpp
index ffbbf66015..e9fc7ec913 100644
--- a/editor/debugger/debug_adapter/debug_adapter_server.cpp
+++ b/editor/debugger/debug_adapter/debug_adapter_server.cpp
@@ -42,12 +42,14 @@ DebugAdapterServer::DebugAdapterServer() {
void DebugAdapterServer::_notification(int p_what) {
switch (p_what) {
- case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_ENTER_TREE: {
start();
- break;
- case NOTIFICATION_EXIT_TREE:
+ } break;
+
+ case NOTIFICATION_EXIT_TREE: {
stop();
- break;
+ } break;
+
case NOTIFICATION_INTERNAL_PROCESS: {
// The main loop can be run again during request processing, which modifies internal state of the protocol.
// Thus, "polling" is needed to prevent it from parsing other requests while the current one isn't finished.
@@ -57,6 +59,7 @@ void DebugAdapterServer::_notification(int p_what) {
polling = false;
}
} break;
+
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
protocol._request_timeout = EditorSettings::get_singleton()->get("network/debug_adapter/request_timeout");
protocol._sync_breakpoints = EditorSettings::get_singleton()->get("network/debug_adapter/sync_breakpoints");
diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp
index ad782c87cb..c111190ca3 100644
--- a/editor/debugger/editor_debugger_inspector.cpp
+++ b/editor/debugger/editor_debugger_inspector.cpp
@@ -107,14 +107,13 @@ void EditorDebuggerInspector::_bind_methods() {
void EditorDebuggerInspector::_notification(int p_what) {
switch (p_what) {
- case NOTIFICATION_POSTINITIALIZE:
+ case NOTIFICATION_POSTINITIALIZE: {
connect("object_id_selected", callable_mp(this, &EditorDebuggerInspector::_object_selected));
- break;
- case NOTIFICATION_ENTER_TREE:
+ } break;
+
+ case NOTIFICATION_ENTER_TREE: {
edit(variables);
- break;
- default:
- break;
+ } break;
}
}
diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp
index 26032a9d32..7c9a984b6a 100644
--- a/editor/debugger/editor_debugger_node.cpp
+++ b/editor/debugger/editor_debugger_node.cpp
@@ -240,112 +240,113 @@ void EditorDebuggerNode::_notification(int p_what) {
tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles")));
}
} break;
+
case NOTIFICATION_READY: {
_update_debug_options();
} break;
- default:
- break;
- }
-
- if (p_what != NOTIFICATION_PROCESS || !server.is_valid()) {
- return;
- }
-
- if (!server.is_valid() || !server->is_active()) {
- stop();
- return;
- }
- server->poll();
-
- // Errors and warnings
- int error_count = 0;
- int warning_count = 0;
- _for_all(tabs, [&](ScriptEditorDebugger *dbg) {
- error_count += dbg->get_error_count();
- warning_count += dbg->get_warning_count();
- });
- if (error_count != last_error_count || warning_count != last_warning_count) {
- _for_all(tabs, [&](ScriptEditorDebugger *dbg) {
- dbg->update_tabs();
- });
-
- if (error_count == 0 && warning_count == 0) {
- debugger_button->set_text(TTR("Debugger"));
- debugger_button->remove_theme_color_override("font_color");
- debugger_button->set_icon(Ref<Texture2D>());
- } else {
- debugger_button->set_text(TTR("Debugger") + " (" + itos(error_count + warning_count) + ")");
- if (error_count >= 1 && warning_count >= 1) {
- debugger_button->set_icon(get_theme_icon(SNAME("ErrorWarning"), SNAME("EditorIcons")));
- // Use error color to represent the highest level of severity reported.
- debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
- } else if (error_count >= 1) {
- debugger_button->set_icon(get_theme_icon(SNAME("Error"), SNAME("EditorIcons")));
- debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
- } else {
- debugger_button->set_icon(get_theme_icon(SNAME("Warning"), SNAME("EditorIcons")));
- debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
+ case NOTIFICATION_PROCESS: {
+ if (!server.is_valid()) {
+ return;
}
- }
- last_error_count = error_count;
- last_warning_count = warning_count;
- }
- // Remote scene tree update
- remote_scene_tree_timeout -= get_process_delta_time();
- if (remote_scene_tree_timeout < 0) {
- remote_scene_tree_timeout = EditorSettings::get_singleton()->get("debugger/remote_scene_tree_refresh_interval");
- if (remote_scene_tree->is_visible_in_tree()) {
- get_current_debugger()->request_remote_tree();
- }
- }
-
- // Remote inspector update
- inspect_edited_object_timeout -= get_process_delta_time();
- if (inspect_edited_object_timeout < 0) {
- inspect_edited_object_timeout = EditorSettings::get_singleton()->get("debugger/remote_inspect_refresh_interval");
- if (EditorDebuggerRemoteObject *obj = get_inspected_remote_object()) {
- get_current_debugger()->request_remote_object(obj->remote_object_id);
- }
- }
-
- // Take connections.
- if (server->is_connection_available()) {
- ScriptEditorDebugger *debugger = nullptr;
- _for_all(tabs, [&](ScriptEditorDebugger *dbg) {
- if (debugger || dbg->is_session_active()) {
+ if (!server->is_active()) {
+ stop();
return;
}
- debugger = dbg;
- });
- if (debugger == nullptr) {
- if (tabs->get_tab_count() <= 4) { // Max 4 debugging sessions active.
- debugger = _add_debugger();
- } else {
- // We already have too many sessions, disconnecting new clients to prevent them from hanging.
- server->take_connection()->close();
- return; // Can't add, stop here.
+ server->poll();
+
+ // Errors and warnings
+ int error_count = 0;
+ int warning_count = 0;
+ _for_all(tabs, [&](ScriptEditorDebugger *dbg) {
+ error_count += dbg->get_error_count();
+ warning_count += dbg->get_warning_count();
+ });
+
+ if (error_count != last_error_count || warning_count != last_warning_count) {
+ _for_all(tabs, [&](ScriptEditorDebugger *dbg) {
+ dbg->update_tabs();
+ });
+
+ if (error_count == 0 && warning_count == 0) {
+ debugger_button->set_text(TTR("Debugger"));
+ debugger_button->remove_theme_color_override("font_color");
+ debugger_button->set_icon(Ref<Texture2D>());
+ } else {
+ debugger_button->set_text(TTR("Debugger") + " (" + itos(error_count + warning_count) + ")");
+ if (error_count >= 1 && warning_count >= 1) {
+ debugger_button->set_icon(get_theme_icon(SNAME("ErrorWarning"), SNAME("EditorIcons")));
+ // Use error color to represent the highest level of severity reported.
+ debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ } else if (error_count >= 1) {
+ debugger_button->set_icon(get_theme_icon(SNAME("Error"), SNAME("EditorIcons")));
+ debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ } else {
+ debugger_button->set_icon(get_theme_icon(SNAME("Warning"), SNAME("EditorIcons")));
+ debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
+ }
+ }
+ last_error_count = error_count;
+ last_warning_count = warning_count;
}
- }
- EditorNode::get_singleton()->get_pause_button()->set_disabled(false);
- // Switch to remote tree view if so desired.
- auto_switch_remote_scene_tree = (bool)EditorSettings::get_singleton()->get("debugger/auto_switch_to_remote_scene_tree");
- if (auto_switch_remote_scene_tree) {
- SceneTreeDock::get_singleton()->show_remote_tree();
- }
- // Good to go.
- SceneTreeDock::get_singleton()->show_tab_buttons();
- debugger->set_editor_remote_tree(remote_scene_tree);
- debugger->start(server->take_connection());
- // Send breakpoints.
- for (const KeyValue<Breakpoint, bool> &E : breakpoints) {
- const Breakpoint &bp = E.key;
- debugger->set_breakpoint(bp.source, bp.line, E.value);
- } // Will arrive too late, how does the regular run work?
-
- debugger->update_live_edit_root();
+ // Remote scene tree update
+ remote_scene_tree_timeout -= get_process_delta_time();
+ if (remote_scene_tree_timeout < 0) {
+ remote_scene_tree_timeout = EditorSettings::get_singleton()->get("debugger/remote_scene_tree_refresh_interval");
+ if (remote_scene_tree->is_visible_in_tree()) {
+ get_current_debugger()->request_remote_tree();
+ }
+ }
+
+ // Remote inspector update
+ inspect_edited_object_timeout -= get_process_delta_time();
+ if (inspect_edited_object_timeout < 0) {
+ inspect_edited_object_timeout = EditorSettings::get_singleton()->get("debugger/remote_inspect_refresh_interval");
+ if (EditorDebuggerRemoteObject *obj = get_inspected_remote_object()) {
+ get_current_debugger()->request_remote_object(obj->remote_object_id);
+ }
+ }
+
+ // Take connections.
+ if (server->is_connection_available()) {
+ ScriptEditorDebugger *debugger = nullptr;
+ _for_all(tabs, [&](ScriptEditorDebugger *dbg) {
+ if (debugger || dbg->is_session_active()) {
+ return;
+ }
+ debugger = dbg;
+ });
+ if (debugger == nullptr) {
+ if (tabs->get_tab_count() <= 4) { // Max 4 debugging sessions active.
+ debugger = _add_debugger();
+ } else {
+ // We already have too many sessions, disconnecting new clients to prevent them from hanging.
+ server->take_connection()->close();
+ return; // Can't add, stop here.
+ }
+ }
+
+ EditorNode::get_singleton()->get_pause_button()->set_disabled(false);
+ // Switch to remote tree view if so desired.
+ auto_switch_remote_scene_tree = (bool)EditorSettings::get_singleton()->get("debugger/auto_switch_to_remote_scene_tree");
+ if (auto_switch_remote_scene_tree) {
+ SceneTreeDock::get_singleton()->show_remote_tree();
+ }
+ // Good to go.
+ SceneTreeDock::get_singleton()->show_tab_buttons();
+ debugger->set_editor_remote_tree(remote_scene_tree);
+ debugger->start(server->take_connection());
+ // Send breakpoints.
+ for (const KeyValue<Breakpoint, bool> &E : breakpoints) {
+ const Breakpoint &bp = E.key;
+ debugger->set_breakpoint(bp.source, bp.line, E.value);
+ } // Will arrive too late, how does the regular run work?
+
+ debugger->update_live_edit_root();
+ }
+ } break;
}
}
diff --git a/editor/debugger/editor_debugger_tree.cpp b/editor/debugger/editor_debugger_tree.cpp
index c1fffae404..3a65d015d5 100644
--- a/editor/debugger/editor_debugger_tree.cpp
+++ b/editor/debugger/editor_debugger_tree.cpp
@@ -53,10 +53,12 @@ EditorDebuggerTree::EditorDebuggerTree() {
}
void EditorDebuggerTree::_notification(int p_what) {
- if (p_what == NOTIFICATION_POSTINITIALIZE) {
- connect("cell_selected", callable_mp(this, &EditorDebuggerTree::_scene_tree_selected));
- connect("item_collapsed", callable_mp(this, &EditorDebuggerTree::_scene_tree_folded));
- connect("item_rmb_selected", callable_mp(this, &EditorDebuggerTree::_scene_tree_rmb_selected));
+ switch (p_what) {
+ case NOTIFICATION_POSTINITIALIZE: {
+ connect("cell_selected", callable_mp(this, &EditorDebuggerTree::_scene_tree_selected));
+ connect("item_collapsed", callable_mp(this, &EditorDebuggerTree::_scene_tree_folded));
+ connect("item_rmb_selected", callable_mp(this, &EditorDebuggerTree::_scene_tree_rmb_selected));
+ } break;
}
}
diff --git a/editor/debugger/editor_network_profiler.cpp b/editor/debugger/editor_network_profiler.cpp
index b05134144e..8c18eba71d 100644
--- a/editor/debugger/editor_network_profiler.cpp
+++ b/editor/debugger/editor_network_profiler.cpp
@@ -39,15 +39,18 @@ void EditorNetworkProfiler::_bind_methods() {
}
void EditorNetworkProfiler::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons")));
- clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")));
- incoming_bandwidth_text->set_right_icon(get_theme_icon(SNAME("ArrowDown"), SNAME("EditorIcons")));
- outgoing_bandwidth_text->set_right_icon(get_theme_icon(SNAME("ArrowUp"), SNAME("EditorIcons")));
-
- // This needs to be done here to set the faded color when the profiler is first opened
- incoming_bandwidth_text->add_theme_color_override("font_uneditable_color", get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, 0.5));
- outgoing_bandwidth_text->add_theme_color_override("font_uneditable_color", get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, 0.5));
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons")));
+ clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")));
+ incoming_bandwidth_text->set_right_icon(get_theme_icon(SNAME("ArrowDown"), SNAME("EditorIcons")));
+ outgoing_bandwidth_text->set_right_icon(get_theme_icon(SNAME("ArrowUp"), SNAME("EditorIcons")));
+
+ // This needs to be done here to set the faded color when the profiler is first opened
+ incoming_bandwidth_text->add_theme_color_override("font_uneditable_color", get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, 0.5));
+ outgoing_bandwidth_text->add_theme_color_override("font_uneditable_color", get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, 0.5));
+ } break;
}
}
diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp
index da1d6a54f2..4b263e5152 100644
--- a/editor/debugger/editor_profiler.cpp
+++ b/editor/debugger/editor_profiler.cpp
@@ -393,9 +393,13 @@ void EditorProfiler::_clear_pressed() {
}
void EditorProfiler::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_LAYOUT_DIRECTION_CHANGED || p_what == NOTIFICATION_TRANSLATION_CHANGED) {
- activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons")));
- clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")));
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
+ case NOTIFICATION_TRANSLATION_CHANGED: {
+ activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons")));
+ clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")));
+ } break;
}
}
diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp
index 4b821f2a12..2a1b0029d4 100644
--- a/editor/debugger/editor_visual_profiler.cpp
+++ b/editor/debugger/editor_visual_profiler.cpp
@@ -422,13 +422,17 @@ void EditorVisualProfiler::_clear_pressed() {
}
void EditorVisualProfiler::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_LAYOUT_DIRECTION_CHANGED || p_what == NOTIFICATION_TRANSLATION_CHANGED) {
- if (is_layout_rtl()) {
- activate->set_icon(get_theme_icon(SNAME("PlayBackwards"), SNAME("EditorIcons")));
- } else {
- activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons")));
- }
- clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")));
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
+ case NOTIFICATION_TRANSLATION_CHANGED: {
+ if (is_layout_rtl()) {
+ activate->set_icon(get_theme_icon(SNAME("PlayBackwards"), SNAME("EditorIcons")));
+ } else {
+ activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons")));
+ }
+ clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")));
+ } break;
}
}
diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp
index e08ddff816..645d7608f3 100644
--- a/editor/debugger/script_editor_debugger.cpp
+++ b/editor/debugger/script_editor_debugger.cpp
@@ -796,8 +796,8 @@ void ScriptEditorDebugger::_notification(int p_what) {
search->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
reason->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
-
} break;
+
case NOTIFICATION_PROCESS: {
if (is_session_active()) {
peer->poll();
@@ -857,6 +857,7 @@ void ScriptEditorDebugger::_notification(int p_what) {
break;
};
} break;
+
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
if (tabs->has_theme_stylebox_override("panel")) {
tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles")));
diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp
index d091ca5056..9685ff4b70 100644
--- a/editor/editor_audio_buses.cpp
+++ b/editor/editor_audio_buses.cpp
@@ -98,6 +98,7 @@ void EditorAudioBus::_notification(int p_what) {
update_bus();
set_process(true);
} break;
+
case NOTIFICATION_DRAW: {
if (is_master) {
draw_style_box(get_theme_stylebox(SNAME("disabled"), SNAME("Button")), Rect2(Vector2(), get_size()));
@@ -113,6 +114,7 @@ void EditorAudioBus::_notification(int p_what) {
draw_rect(Rect2(Point2(), get_size()), accent, false);
}
} break;
+
case NOTIFICATION_PROCESS: {
if (cc != AudioServer::get_singleton()->get_bus_channels(get_index())) {
cc = AudioServer::get_singleton()->get_bus_channels(get_index());
@@ -157,6 +159,7 @@ void EditorAudioBus::_notification(int p_what) {
}
}
} break;
+
case NOTIFICATION_VISIBILITY_CHANGED: {
for (int i = 0; i < CHANNELS_MAX; i++) {
channel[i].peak_l = -100;
@@ -952,12 +955,14 @@ void EditorAudioBusDrop::_notification(int p_what) {
draw_rect(Rect2(Point2(), get_size()), accent, false);
}
} break;
+
case NOTIFICATION_MOUSE_ENTER: {
if (!hovering_drop) {
hovering_drop = true;
update();
}
} break;
+
case NOTIFICATION_MOUSE_EXIT:
case NOTIFICATION_DRAG_END: {
if (hovering_drop) {
@@ -1017,15 +1022,18 @@ void EditorAudioBuses::_notification(int p_what) {
case NOTIFICATION_THEME_CHANGED: {
bus_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
} break;
+
case NOTIFICATION_READY: {
_update_buses();
} break;
+
case NOTIFICATION_DRAG_END: {
if (drop_end) {
drop_end->queue_delete();
drop_end = nullptr;
}
} break;
+
case NOTIFICATION_PROCESS: {
// Check if anything was edited.
bool edited = AudioServer::get_singleton()->is_edited();
@@ -1401,6 +1409,7 @@ void EditorAudioMeterNotches::_notification(int p_what) {
case NOTIFICATION_THEME_CHANGED: {
notch_color = get_theme_color(SNAME("font_color"), SNAME("Editor"));
} break;
+
case NOTIFICATION_DRAW: {
_draw_audio_notches();
} break;
diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp
index a1250ef9f4..281d614ea9 100644
--- a/editor/editor_autoload_settings.cpp
+++ b/editor/editor_autoload_settings.cpp
@@ -42,23 +42,27 @@
#define PREVIEW_LIST_MAX_SIZE 10
void EditorAutoloadSettings::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE) {
- List<String> afn;
- ResourceLoader::get_recognized_extensions_for_type("Script", &afn);
- ResourceLoader::get_recognized_extensions_for_type("PackedScene", &afn);
-
- for (const String &E : afn) {
- file_dialog->add_filter("*." + E);
- }
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ List<String> afn;
+ ResourceLoader::get_recognized_extensions_for_type("Script", &afn);
+ ResourceLoader::get_recognized_extensions_for_type("PackedScene", &afn);
+
+ for (const String &E : afn) {
+ file_dialog->add_filter("*." + E);
+ }
- for (const AutoLoadInfo &info : autoload_cache) {
- if (info.node && info.in_editor) {
- get_tree()->get_root()->call_deferred(SNAME("add_child"), info.node);
+ for (const AutoLoadInfo &info : autoload_cache) {
+ if (info.node && info.in_editor) {
+ get_tree()->get_root()->call_deferred(SNAME("add_child"), info.node);
+ }
}
- }
- browse_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")));
- } else if (p_what == NOTIFICATION_THEME_CHANGED) {
- browse_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")));
+ browse_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")));
+ } break;
+
+ case NOTIFICATION_THEME_CHANGED: {
+ browse_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")));
+ } break;
}
}
diff --git a/editor/editor_dir_dialog.cpp b/editor/editor_dir_dialog.cpp
index 5f5e4f37fd..f181c04004 100644
--- a/editor/editor_dir_dialog.cpp
+++ b/editor/editor_dir_dialog.cpp
@@ -79,29 +79,31 @@ void EditorDirDialog::reload(const String &p_path) {
}
void EditorDirDialog::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE) {
- EditorFileSystem::get_singleton()->connect("filesystem_changed", callable_mp(this, &EditorDirDialog::reload), make_binds(""));
- reload();
-
- if (!tree->is_connected("item_collapsed", callable_mp(this, &EditorDirDialog::_item_collapsed))) {
- tree->connect("item_collapsed", callable_mp(this, &EditorDirDialog::_item_collapsed), varray(), CONNECT_DEFERRED);
- }
-
- if (!EditorFileSystem::get_singleton()->is_connected("filesystem_changed", callable_mp(this, &EditorDirDialog::reload))) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
EditorFileSystem::get_singleton()->connect("filesystem_changed", callable_mp(this, &EditorDirDialog::reload), make_binds(""));
- }
- }
-
- if (p_what == NOTIFICATION_EXIT_TREE) {
- if (EditorFileSystem::get_singleton()->is_connected("filesystem_changed", callable_mp(this, &EditorDirDialog::reload))) {
- EditorFileSystem::get_singleton()->disconnect("filesystem_changed", callable_mp(this, &EditorDirDialog::reload));
- }
- }
-
- if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- if (must_reload && is_visible()) {
reload();
- }
+
+ if (!tree->is_connected("item_collapsed", callable_mp(this, &EditorDirDialog::_item_collapsed))) {
+ tree->connect("item_collapsed", callable_mp(this, &EditorDirDialog::_item_collapsed), varray(), CONNECT_DEFERRED);
+ }
+
+ if (!EditorFileSystem::get_singleton()->is_connected("filesystem_changed", callable_mp(this, &EditorDirDialog::reload))) {
+ EditorFileSystem::get_singleton()->connect("filesystem_changed", callable_mp(this, &EditorDirDialog::reload), make_binds(""));
+ }
+ } break;
+
+ case NOTIFICATION_EXIT_TREE: {
+ if (EditorFileSystem::get_singleton()->is_connected("filesystem_changed", callable_mp(this, &EditorDirDialog::reload))) {
+ EditorFileSystem::get_singleton()->disconnect("filesystem_changed", callable_mp(this, &EditorDirDialog::reload));
+ }
+ } break;
+
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ if (must_reload && is_visible()) {
+ reload();
+ }
+ } break;
}
}
diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp
index 98ae459c76..295b477080 100644
--- a/editor/editor_export.cpp
+++ b/editor/editor_export.cpp
@@ -1544,6 +1544,7 @@ void EditorExport::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
load_config();
} break;
+
case NOTIFICATION_PROCESS: {
update_export_presets();
} break;
diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp
index 976c9043d2..008c42b3a7 100644
--- a/editor/editor_feature_profile.cpp
+++ b/editor/editor_feature_profile.cpp
@@ -309,18 +309,20 @@ EditorFeatureProfile::EditorFeatureProfile() {}
//////////////////////////
void EditorFeatureProfileManager::_notification(int p_what) {
- if (p_what == NOTIFICATION_READY) {
- current_profile = EDITOR_GET("_default_feature_profile");
- if (!current_profile.is_empty()) {
- current.instantiate();
- Error err = current->load_from_file(EditorSettings::get_singleton()->get_feature_profiles_dir().plus_file(current_profile + ".profile"));
- if (err != OK) {
- ERR_PRINT("Error loading default feature profile: " + current_profile);
- current_profile = String();
- current.unref();
+ switch (p_what) {
+ case NOTIFICATION_READY: {
+ current_profile = EDITOR_GET("_default_feature_profile");
+ if (!current_profile.is_empty()) {
+ current.instantiate();
+ Error err = current->load_from_file(EditorSettings::get_singleton()->get_feature_profiles_dir().plus_file(current_profile + ".profile"));
+ if (err != OK) {
+ ERR_PRINT("Error loading default feature profile: " + current_profile);
+ current_profile = String();
+ current.unref();
+ }
}
- }
- _update_profile_list(current_profile);
+ _update_profile_list(current_profile);
+ } break;
}
}
diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp
index bda026e16c..e6343100df 100644
--- a/editor/editor_file_dialog.cpp
+++ b/editor/editor_file_dialog.cpp
@@ -69,48 +69,60 @@ VBoxContainer *EditorFileDialog::get_vbox() {
}
void EditorFileDialog::_notification(int p_what) {
- if (p_what == NOTIFICATION_READY || p_what == NOTIFICATION_THEME_CHANGED || p_what == Control::NOTIFICATION_LAYOUT_DIRECTION_CHANGED || p_what == NOTIFICATION_TRANSLATION_CHANGED) {
- _update_icons();
- } else if (p_what == NOTIFICATION_PROCESS) {
- if (preview_waiting) {
- preview_wheel_timeout -= get_process_delta_time();
- if (preview_wheel_timeout <= 0) {
- preview_wheel_index++;
- if (preview_wheel_index >= 8) {
- preview_wheel_index = 0;
+ switch (p_what) {
+ case NOTIFICATION_READY:
+ case NOTIFICATION_THEME_CHANGED:
+ case Control::NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
+ case NOTIFICATION_TRANSLATION_CHANGED: {
+ _update_icons();
+ } break;
+
+ case NOTIFICATION_PROCESS: {
+ if (preview_waiting) {
+ preview_wheel_timeout -= get_process_delta_time();
+ if (preview_wheel_timeout <= 0) {
+ preview_wheel_index++;
+ if (preview_wheel_index >= 8) {
+ preview_wheel_index = 0;
+ }
+ Ref<Texture2D> frame = item_list->get_theme_icon("Progress" + itos(preview_wheel_index + 1), SNAME("EditorIcons"));
+ preview->set_texture(frame);
+ preview_wheel_timeout = 0.1;
}
- Ref<Texture2D> frame = item_list->get_theme_icon("Progress" + itos(preview_wheel_index + 1), SNAME("EditorIcons"));
- preview->set_texture(frame);
- preview_wheel_timeout = 0.1;
}
- }
+ } break;
- } else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
- bool is_showing_hidden = EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files");
- if (show_hidden_files != is_showing_hidden) {
- set_show_hidden_files(is_showing_hidden);
- }
- set_display_mode((DisplayMode)EditorSettings::get_singleton()->get("filesystem/file_dialog/display_mode").operator int());
+ case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
+ bool is_showing_hidden = EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files");
+ if (show_hidden_files != is_showing_hidden) {
+ set_show_hidden_files(is_showing_hidden);
+ }
+ set_display_mode((DisplayMode)EditorSettings::get_singleton()->get("filesystem/file_dialog/display_mode").operator int());
- _update_icons();
- // DO NOT CALL UPDATE FILE LIST HERE, ALL HUNDREDS OF HIDDEN DIALOGS WILL RESPOND, CALL INVALIDATE INSTEAD
- invalidate();
- } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- if (!is_visible()) {
- set_process_unhandled_input(false);
- }
- } else if (p_what == NOTIFICATION_WM_WINDOW_FOCUS_IN) {
- // Check if the current directory was removed externally (much less likely to happen while editor window is focused).
- String previous_dir = get_current_dir();
- while (!dir_access->dir_exists(get_current_dir())) {
- _go_up();
-
- // In case we can't go further up, use some fallback and break.
- if (get_current_dir() == previous_dir) {
- _dir_submitted(OS::get_singleton()->get_user_data_dir());
- break;
+ _update_icons();
+ // DO NOT CALL UPDATE FILE LIST HERE, ALL HUNDREDS OF HIDDEN DIALOGS WILL RESPOND, CALL INVALIDATE INSTEAD
+ invalidate();
+ } break;
+
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ if (!is_visible()) {
+ set_process_unhandled_input(false);
}
- }
+ } break;
+
+ case NOTIFICATION_WM_WINDOW_FOCUS_IN: {
+ // Check if the current directory was removed externally (much less likely to happen while editor window is focused).
+ String previous_dir = get_current_dir();
+ while (!dir_access->dir_exists(get_current_dir())) {
+ _go_up();
+
+ // In case we can't go further up, use some fallback and break.
+ if (get_current_dir() == previous_dir) {
+ _dir_submitted(OS::get_singleton()->get_user_data_dir());
+ break;
+ }
+ }
+ } break;
}
}
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index 34a21c90fe..0c46cebec0 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -1163,6 +1163,7 @@ void EditorFileSystem::_notification(int p_what) {
call_deferred(SNAME("scan")); //this should happen after every editor node entered the tree
} break;
+
case NOTIFICATION_EXIT_TREE: {
Thread &active_thread = thread.is_started() ? thread : thread_sources;
if (use_threads && active_thread.is_started()) {
@@ -1184,8 +1185,8 @@ void EditorFileSystem::_notification(int p_what) {
}
filesystem = nullptr;
new_filesystem = nullptr;
-
} break;
+
case NOTIFICATION_PROCESS: {
if (use_threads) {
if (scanning_changes) {
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 7d88b94a37..fe39f7acc9 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -1770,17 +1770,17 @@ void EditorHelp::_notification(int p_what) {
_wait_for_thread();
_update_doc();
} break;
+
case NOTIFICATION_THEME_CHANGED: {
if (is_inside_tree()) {
_class_desc_resized(true);
}
update_toggle_scripts_button();
} break;
- case NOTIFICATION_VISIBILITY_CHANGED:
+
+ case NOTIFICATION_VISIBILITY_CHANGED: {
update_toggle_scripts_button();
- break;
- default:
- break;
+ } break;
}
}
@@ -2041,6 +2041,7 @@ void FindBar::_notification(int p_what) {
hide_button->set_custom_minimum_size(hide_button->get_normal_texture()->get_size());
matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), SNAME("Editor")));
} break;
+
case NOTIFICATION_VISIBILITY_CHANGED: {
set_process_unhandled_input(is_visible_in_tree());
} break;
diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp
index aa4688452c..dd4969cdd2 100644
--- a/editor/editor_help_search.cpp
+++ b/editor/editor_help_search.cpp
@@ -111,9 +111,11 @@ void EditorHelpSearch::_notification(int p_what) {
EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "search_help", Rect2(get_position(), get_size()));
}
} break;
+
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
_update_icons();
} break;
+
case NOTIFICATION_ENTER_TREE: {
connect("confirmed", callable_mp(this, &EditorHelpSearch::_confirmed));
_update_icons();
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index c56ebaa499..675ef808e1 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -103,22 +103,96 @@ void EditorProperty::emit_changed(const StringName &p_property, const Variant &p
}
void EditorProperty::_notification(int p_what) {
- if (p_what == NOTIFICATION_SORT_CHILDREN) {
- Size2 size = get_size();
- Rect2 rect;
- Rect2 bottom_rect;
+ switch (p_what) {
+ case NOTIFICATION_SORT_CHILDREN: {
+ Size2 size = get_size();
+ Rect2 rect;
+ Rect2 bottom_rect;
+
+ right_child_rect = Rect2();
+ bottom_child_rect = Rect2();
+
+ {
+ int child_room = size.width * (1.0 - split_ratio);
+ Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree"));
+ int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Tree"));
+ int height = font->get_height(font_size);
+ bool no_children = true;
+
+ //compute room needed
+ for (int i = 0; i < get_child_count(); i++) {
+ Control *c = Object::cast_to<Control>(get_child(i));
+ if (!c) {
+ continue;
+ }
+ if (c->is_set_as_top_level()) {
+ continue;
+ }
+ if (c == bottom_editor) {
+ continue;
+ }
- right_child_rect = Rect2();
- bottom_child_rect = Rect2();
+ Size2 minsize = c->get_combined_minimum_size();
+ child_room = MAX(child_room, minsize.width);
+ height = MAX(height, minsize.height);
+ no_children = false;
+ }
- {
- int child_room = size.width * (1.0 - split_ratio);
- Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree"));
- int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Tree"));
- int height = font->get_height(font_size);
- bool no_children = true;
+ if (no_children) {
+ text_size = size.width;
+ rect = Rect2(size.width - 1, 0, 1, height);
+ } else {
+ text_size = MAX(0, size.width - (child_room + 4 * EDSCALE));
+ if (is_layout_rtl()) {
+ rect = Rect2(1, 0, child_room, height);
+ } else {
+ rect = Rect2(size.width - child_room, 0, child_room, height);
+ }
+ }
+
+ if (bottom_editor) {
+ int m = 0; //get_constant("item_margin", "Tree");
+
+ bottom_rect = Rect2(m, rect.size.height + get_theme_constant(SNAME("vseparation")), size.width - m, bottom_editor->get_combined_minimum_size().height);
+ }
+
+ if (keying) {
+ Ref<Texture2D> key;
+
+ if (use_keying_next()) {
+ key = get_theme_icon(SNAME("KeyNext"), SNAME("EditorIcons"));
+ } else {
+ key = get_theme_icon(SNAME("Key"), SNAME("EditorIcons"));
+ }
+
+ rect.size.x -= key->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree"));
+ if (is_layout_rtl()) {
+ rect.position.x += key->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree"));
+ }
+
+ if (no_children) {
+ text_size -= key->get_width() + 4 * EDSCALE;
+ }
+ }
+
+ if (deletable) {
+ Ref<Texture2D> close;
+
+ close = get_theme_icon(SNAME("Close"), SNAME("EditorIcons"));
+
+ rect.size.x -= close->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree"));
+
+ if (is_layout_rtl()) {
+ rect.position.x += close->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree"));
+ }
- //compute room needed
+ if (no_children) {
+ text_size -= close->get_width() + 4 * EDSCALE;
+ }
+ }
+ }
+
+ //set children
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
if (!c) {
@@ -131,253 +205,181 @@ void EditorProperty::_notification(int p_what) {
continue;
}
- Size2 minsize = c->get_combined_minimum_size();
- child_room = MAX(child_room, minsize.width);
- height = MAX(height, minsize.height);
- no_children = false;
- }
-
- if (no_children) {
- text_size = size.width;
- rect = Rect2(size.width - 1, 0, 1, height);
- } else {
- text_size = MAX(0, size.width - (child_room + 4 * EDSCALE));
- if (is_layout_rtl()) {
- rect = Rect2(1, 0, child_room, height);
- } else {
- rect = Rect2(size.width - child_room, 0, child_room, height);
- }
+ fit_child_in_rect(c, rect);
+ right_child_rect = rect;
}
if (bottom_editor) {
- int m = 0; //get_constant("item_margin", "Tree");
-
- bottom_rect = Rect2(m, rect.size.height + get_theme_constant(SNAME("vseparation")), size.width - m, bottom_editor->get_combined_minimum_size().height);
+ fit_child_in_rect(bottom_editor, bottom_rect);
+ bottom_child_rect = bottom_rect;
}
- if (keying) {
- Ref<Texture2D> key;
-
- if (use_keying_next()) {
- key = get_theme_icon(SNAME("KeyNext"), SNAME("EditorIcons"));
- } else {
- key = get_theme_icon(SNAME("Key"), SNAME("EditorIcons"));
- }
+ update(); //need to redraw text
+ } break;
- rect.size.x -= key->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree"));
- if (is_layout_rtl()) {
- rect.position.x += key->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree"));
- }
+ case NOTIFICATION_DRAW: {
+ Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree"));
+ int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Tree"));
+ Color dark_color = get_theme_color(SNAME("dark_color_2"), SNAME("Editor"));
+ bool rtl = is_layout_rtl();
- if (no_children) {
- text_size -= key->get_width() + 4 * EDSCALE;
- }
+ Size2 size = get_size();
+ if (bottom_editor) {
+ size.height = bottom_editor->get_offset(SIDE_TOP);
+ } else if (label_reference) {
+ size.height = label_reference->get_size().height;
}
- if (deletable) {
- Ref<Texture2D> close;
-
- close = get_theme_icon(SNAME("Close"), SNAME("EditorIcons"));
+ Ref<StyleBox> sb;
+ if (selected) {
+ sb = get_theme_stylebox(SNAME("bg_selected"));
+ } else {
+ sb = get_theme_stylebox(SNAME("bg"));
+ }
- rect.size.x -= close->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree"));
+ draw_style_box(sb, Rect2(Vector2(), size));
- if (is_layout_rtl()) {
- rect.position.x += close->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree"));
- }
-
- if (no_children) {
- text_size -= close->get_width() + 4 * EDSCALE;
- }
+ if (draw_top_bg && right_child_rect != Rect2()) {
+ draw_rect(right_child_rect, dark_color);
}
- }
-
- //set children
- for (int i = 0; i < get_child_count(); i++) {
- Control *c = Object::cast_to<Control>(get_child(i));
- if (!c) {
- continue;
+ if (bottom_child_rect != Rect2()) {
+ draw_rect(bottom_child_rect, dark_color);
}
- if (c->is_set_as_top_level()) {
- continue;
+
+ Color color;
+ if (draw_warning) {
+ color = get_theme_color(is_read_only() ? SNAME("readonly_warning_color") : SNAME("warning_color"));
+ } else {
+ color = get_theme_color(is_read_only() ? SNAME("readonly_color") : SNAME("property_color"));
}
- if (c == bottom_editor) {
- continue;
+ if (label.contains(".")) {
+ // FIXME: Move this to the project settings editor, as this is only used
+ // for project settings feature tag overrides.
+ color.a = 0.5;
}
- fit_child_in_rect(c, rect);
- right_child_rect = rect;
- }
-
- if (bottom_editor) {
- fit_child_in_rect(bottom_editor, bottom_rect);
- bottom_child_rect = bottom_rect;
- }
-
- update(); //need to redraw text
- }
-
- if (p_what == NOTIFICATION_DRAW) {
- Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree"));
- int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Tree"));
- Color dark_color = get_theme_color(SNAME("dark_color_2"), SNAME("Editor"));
- bool rtl = is_layout_rtl();
-
- Size2 size = get_size();
- if (bottom_editor) {
- size.height = bottom_editor->get_offset(SIDE_TOP);
- } else if (label_reference) {
- size.height = label_reference->get_size().height;
- }
-
- Ref<StyleBox> sb;
- if (selected) {
- sb = get_theme_stylebox(SNAME("bg_selected"));
- } else {
- sb = get_theme_stylebox(SNAME("bg"));
- }
-
- draw_style_box(sb, Rect2(Vector2(), size));
-
- if (draw_top_bg && right_child_rect != Rect2()) {
- draw_rect(right_child_rect, dark_color);
- }
- if (bottom_child_rect != Rect2()) {
- draw_rect(bottom_child_rect, dark_color);
- }
+ int ofs = get_theme_constant(SNAME("font_offset"));
+ int text_limit = text_size - ofs;
- Color color;
- if (draw_warning) {
- color = get_theme_color(is_read_only() ? SNAME("readonly_warning_color") : SNAME("warning_color"));
- } else {
- color = get_theme_color(is_read_only() ? SNAME("readonly_color") : SNAME("property_color"));
- }
- if (label.contains(".")) {
- // FIXME: Move this to the project settings editor, as this is only used
- // for project settings feature tag overrides.
- color.a = 0.5;
- }
-
- int ofs = get_theme_constant(SNAME("font_offset"));
- int text_limit = text_size - ofs;
+ if (checkable) {
+ Ref<Texture2D> checkbox;
+ if (checked) {
+ checkbox = get_theme_icon(SNAME("GuiChecked"), SNAME("EditorIcons"));
+ } else {
+ checkbox = get_theme_icon(SNAME("GuiUnchecked"), SNAME("EditorIcons"));
+ }
- if (checkable) {
- Ref<Texture2D> checkbox;
- if (checked) {
- checkbox = get_theme_icon(SNAME("GuiChecked"), SNAME("EditorIcons"));
+ Color color2(1, 1, 1);
+ if (check_hover) {
+ color2.r *= 1.2;
+ color2.g *= 1.2;
+ color2.b *= 1.2;
+ }
+ check_rect = Rect2(ofs, ((size.height - checkbox->get_height()) / 2), checkbox->get_width(), checkbox->get_height());
+ if (rtl) {
+ draw_texture(checkbox, Vector2(size.width - check_rect.position.x - checkbox->get_width(), check_rect.position.y), color2);
+ } else {
+ draw_texture(checkbox, check_rect.position, color2);
+ }
+ int check_ofs = get_theme_constant(SNAME("hseparator"), SNAME("Tree")) + checkbox->get_width() + get_theme_constant(SNAME("hseparation"), SNAME("CheckBox"));
+ ofs += check_ofs;
+ text_limit -= check_ofs;
} else {
- checkbox = get_theme_icon(SNAME("GuiUnchecked"), SNAME("EditorIcons"));
+ check_rect = Rect2();
}
- Color color2(1, 1, 1);
- if (check_hover) {
- color2.r *= 1.2;
- color2.g *= 1.2;
- color2.b *= 1.2;
- }
- check_rect = Rect2(ofs, ((size.height - checkbox->get_height()) / 2), checkbox->get_width(), checkbox->get_height());
- if (rtl) {
- draw_texture(checkbox, Vector2(size.width - check_rect.position.x - checkbox->get_width(), check_rect.position.y), color2);
+ if (can_revert && !is_read_only()) {
+ Ref<Texture2D> reload_icon = get_theme_icon(SNAME("ReloadSmall"), SNAME("EditorIcons"));
+ text_limit -= reload_icon->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")) * 2;
+ revert_rect = Rect2(ofs + text_limit, (size.height - reload_icon->get_height()) / 2, reload_icon->get_width(), reload_icon->get_height());
+
+ Color color2(1, 1, 1);
+ if (revert_hover) {
+ color2.r *= 1.2;
+ color2.g *= 1.2;
+ color2.b *= 1.2;
+ }
+ if (rtl) {
+ draw_texture(reload_icon, Vector2(size.width - revert_rect.position.x - reload_icon->get_width(), revert_rect.position.y), color2);
+ } else {
+ draw_texture(reload_icon, revert_rect.position, color2);
+ }
} else {
- draw_texture(checkbox, check_rect.position, color2);
+ revert_rect = Rect2();
}
- int check_ofs = get_theme_constant(SNAME("hseparator"), SNAME("Tree")) + checkbox->get_width() + get_theme_constant(SNAME("hseparation"), SNAME("CheckBox"));
- ofs += check_ofs;
- text_limit -= check_ofs;
- } else {
- check_rect = Rect2();
- }
-
- if (can_revert && !is_read_only()) {
- Ref<Texture2D> reload_icon = get_theme_icon(SNAME("ReloadSmall"), SNAME("EditorIcons"));
- text_limit -= reload_icon->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")) * 2;
- revert_rect = Rect2(ofs + text_limit, (size.height - reload_icon->get_height()) / 2, reload_icon->get_width(), reload_icon->get_height());
- Color color2(1, 1, 1);
- if (revert_hover) {
- color2.r *= 1.2;
- color2.g *= 1.2;
- color2.b *= 1.2;
- }
- if (rtl) {
- draw_texture(reload_icon, Vector2(size.width - revert_rect.position.x - reload_icon->get_width(), revert_rect.position.y), color2);
- } else {
- draw_texture(reload_icon, revert_rect.position, color2);
+ if (!pin_hidden && pinned) {
+ Ref<Texture2D> pinned_icon = get_theme_icon(SNAME("Pin"), SNAME("EditorIcons"));
+ int margin_w = get_theme_constant(SNAME("hseparator"), SNAME("Tree")) * 2;
+ int total_icon_w = margin_w + pinned_icon->get_width();
+ int text_w = font->get_string_size(label, font_size, rtl ? HORIZONTAL_ALIGNMENT_RIGHT : HORIZONTAL_ALIGNMENT_LEFT, text_limit - total_icon_w).x;
+ int y = (size.height - pinned_icon->get_height()) / 2;
+ if (rtl) {
+ draw_texture(pinned_icon, Vector2(size.width - ofs - text_w - total_icon_w, y), color);
+ } else {
+ draw_texture(pinned_icon, Vector2(ofs + text_w + margin_w, y), color);
+ }
+ text_limit -= total_icon_w;
}
- } else {
- revert_rect = Rect2();
- }
- if (!pin_hidden && pinned) {
- Ref<Texture2D> pinned_icon = get_theme_icon(SNAME("Pin"), SNAME("EditorIcons"));
- int margin_w = get_theme_constant(SNAME("hseparator"), SNAME("Tree")) * 2;
- int total_icon_w = margin_w + pinned_icon->get_width();
- int text_w = font->get_string_size(label, font_size, rtl ? HORIZONTAL_ALIGNMENT_RIGHT : HORIZONTAL_ALIGNMENT_LEFT, text_limit - total_icon_w).x;
- int y = (size.height - pinned_icon->get_height()) / 2;
+ int v_ofs = (size.height - font->get_height(font_size)) / 2;
if (rtl) {
- draw_texture(pinned_icon, Vector2(size.width - ofs - text_w - total_icon_w, y), color);
+ draw_string(font, Point2(size.width - ofs - text_limit, v_ofs + font->get_ascent(font_size)), label, HORIZONTAL_ALIGNMENT_RIGHT, text_limit, font_size, color);
} else {
- draw_texture(pinned_icon, Vector2(ofs + text_w + margin_w, y), color);
+ draw_string(font, Point2(ofs, v_ofs + font->get_ascent(font_size)), label, HORIZONTAL_ALIGNMENT_LEFT, text_limit, font_size, color);
}
- text_limit -= total_icon_w;
- }
- int v_ofs = (size.height - font->get_height(font_size)) / 2;
- if (rtl) {
- draw_string(font, Point2(size.width - ofs - text_limit, v_ofs + font->get_ascent(font_size)), label, HORIZONTAL_ALIGNMENT_RIGHT, text_limit, font_size, color);
- } else {
- draw_string(font, Point2(ofs, v_ofs + font->get_ascent(font_size)), label, HORIZONTAL_ALIGNMENT_LEFT, text_limit, font_size, color);
- }
+ if (keying) {
+ Ref<Texture2D> key;
- if (keying) {
- Ref<Texture2D> key;
+ if (use_keying_next()) {
+ key = get_theme_icon(SNAME("KeyNext"), SNAME("EditorIcons"));
+ } else {
+ key = get_theme_icon(SNAME("Key"), SNAME("EditorIcons"));
+ }
- if (use_keying_next()) {
- key = get_theme_icon(SNAME("KeyNext"), SNAME("EditorIcons"));
- } else {
- key = get_theme_icon(SNAME("Key"), SNAME("EditorIcons"));
- }
+ ofs = size.width - key->get_width() - get_theme_constant(SNAME("hseparator"), SNAME("Tree"));
- ofs = size.width - key->get_width() - get_theme_constant(SNAME("hseparator"), SNAME("Tree"));
+ Color color2(1, 1, 1);
+ if (keying_hover) {
+ color2.r *= 1.2;
+ color2.g *= 1.2;
+ color2.b *= 1.2;
+ }
+ keying_rect = Rect2(ofs, ((size.height - key->get_height()) / 2), key->get_width(), key->get_height());
+ if (rtl) {
+ draw_texture(key, Vector2(size.width - keying_rect.position.x - key->get_width(), keying_rect.position.y), color2);
+ } else {
+ draw_texture(key, keying_rect.position, color2);
+ }
- Color color2(1, 1, 1);
- if (keying_hover) {
- color2.r *= 1.2;
- color2.g *= 1.2;
- color2.b *= 1.2;
- }
- keying_rect = Rect2(ofs, ((size.height - key->get_height()) / 2), key->get_width(), key->get_height());
- if (rtl) {
- draw_texture(key, Vector2(size.width - keying_rect.position.x - key->get_width(), keying_rect.position.y), color2);
} else {
- draw_texture(key, keying_rect.position, color2);
+ keying_rect = Rect2();
}
- } else {
- keying_rect = Rect2();
- }
-
- if (deletable) {
- Ref<Texture2D> close;
+ if (deletable) {
+ Ref<Texture2D> close;
- close = get_theme_icon(SNAME("Close"), SNAME("EditorIcons"));
+ close = get_theme_icon(SNAME("Close"), SNAME("EditorIcons"));
- ofs = size.width - close->get_width() - get_theme_constant(SNAME("hseparator"), SNAME("Tree"));
+ ofs = size.width - close->get_width() - get_theme_constant(SNAME("hseparator"), SNAME("Tree"));
- Color color2(1, 1, 1);
- if (delete_hover) {
- color2.r *= 1.2;
- color2.g *= 1.2;
- color2.b *= 1.2;
- }
- delete_rect = Rect2(ofs, ((size.height - close->get_height()) / 2), close->get_width(), close->get_height());
- if (rtl) {
- draw_texture(close, Vector2(size.width - delete_rect.position.x - close->get_width(), delete_rect.position.y), color2);
+ Color color2(1, 1, 1);
+ if (delete_hover) {
+ color2.r *= 1.2;
+ color2.g *= 1.2;
+ color2.b *= 1.2;
+ }
+ delete_rect = Rect2(ofs, ((size.height - close->get_height()) / 2), close->get_width(), close->get_height());
+ if (rtl) {
+ draw_texture(close, Vector2(size.width - delete_rect.position.x - close->get_width(), delete_rect.position.y), color2);
+ } else {
+ draw_texture(close, delete_rect.position, color2);
+ }
} else {
- draw_texture(close, delete_rect.position, color2);
+ delete_rect = Rect2();
}
- } else {
- delete_rect = Rect2();
- }
+ } break;
}
}
@@ -1078,30 +1080,32 @@ void EditorInspectorPlugin::_bind_methods() {
////////////////////////////////////////////////
void EditorInspectorCategory::_notification(int p_what) {
- if (p_what == NOTIFICATION_DRAW) {
- Ref<StyleBox> sb = get_theme_stylebox(SNAME("prop_category_style"), SNAME("Editor"));
+ switch (p_what) {
+ case NOTIFICATION_DRAW: {
+ Ref<StyleBox> sb = get_theme_stylebox(SNAME("prop_category_style"), SNAME("Editor"));
- draw_style_box(sb, Rect2(Vector2(), get_size()));
+ draw_style_box(sb, Rect2(Vector2(), get_size()));
- Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
- int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"));
+ Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
+ int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"));
- int hs = get_theme_constant(SNAME("hseparation"), SNAME("Tree"));
+ int hs = get_theme_constant(SNAME("hseparation"), SNAME("Tree"));
- int w = font->get_string_size(label, font_size).width;
- if (icon.is_valid()) {
- w += hs + icon->get_width();
- }
+ int w = font->get_string_size(label, font_size).width;
+ if (icon.is_valid()) {
+ w += hs + icon->get_width();
+ }
- int ofs = (get_size().width - w) / 2;
+ int ofs = (get_size().width - w) / 2;
- if (icon.is_valid()) {
- draw_texture(icon, Point2(ofs, (get_size().height - icon->get_height()) / 2).floor());
- ofs += hs + icon->get_width();
- }
+ if (icon.is_valid()) {
+ draw_texture(icon, Point2(ofs, (get_size().height - icon->get_height()) / 2).floor());
+ ofs += hs + icon->get_width();
+ }
- Color color = get_theme_color(SNAME("font_color"), SNAME("Tree"));
- draw_string(font, Point2(ofs, font->get_ascent(font_size) + (get_size().height - font->get_height(font_size)) / 2).floor(), label, HORIZONTAL_ALIGNMENT_LEFT, get_size().width, font_size, color);
+ Color color = get_theme_color(SNAME("font_color"), SNAME("Tree"));
+ draw_string(font, Point2(ofs, font->get_ascent(font_size) + (get_size().height - font->get_height(font_size)) / 2).floor(), label, HORIZONTAL_ALIGNMENT_LEFT, get_size().width, font_size, color);
+ } break;
}
}
@@ -1152,6 +1156,7 @@ void EditorInspectorSection::_notification(int p_what) {
case NOTIFICATION_THEME_CHANGED: {
update_minimum_size();
} break;
+
case NOTIFICATION_SORT_CHILDREN: {
if (!vbox_added) {
return;
@@ -1205,6 +1210,7 @@ void EditorInspectorSection::_notification(int p_what) {
fit_child_in_rect(c, Rect2(offset, size));
}
} break;
+
case NOTIFICATION_DRAW: {
// Get the section header font.
Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
@@ -1299,6 +1305,7 @@ void EditorInspectorSection::_notification(int p_what) {
draw_style_box(section_indent_style, indent_rect);
}
} break;
+
case NOTIFICATION_DRAG_BEGIN: {
Dictionary dd = get_viewport()->gui_get_drag_data();
@@ -1317,10 +1324,12 @@ void EditorInspectorSection::_notification(int p_what) {
dropping = children_can_drop;
update();
} break;
+
case NOTIFICATION_DRAG_END: {
dropping = false;
update();
} break;
+
case NOTIFICATION_MOUSE_ENTER: {
if (dropping) {
dropping_unfold_timer->start();
@@ -2023,6 +2032,7 @@ void EditorInspectorArray::_notification(int p_what) {
add_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
update_minimum_size();
} break;
+
case NOTIFICATION_DRAG_BEGIN: {
Dictionary dict = get_viewport()->gui_get_drag_data();
if (dict.has("type") && dict["type"] == "property_array_element" && String(dict["property_array_prefix"]) == array_element_prefix) {
@@ -2030,6 +2040,7 @@ void EditorInspectorArray::_notification(int p_what) {
control_dropping->update();
}
} break;
+
case NOTIFICATION_DRAG_END: {
if (dropping) {
dropping = false;
@@ -2181,11 +2192,14 @@ void EditorPaginator::update(int p_page, int p_max_page) {
}
void EditorPaginator::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- first_page_button->set_icon(get_theme_icon(SNAME("PageFirst"), SNAME("EditorIcons")));
- prev_page_button->set_icon(get_theme_icon(SNAME("PagePrevious"), SNAME("EditorIcons")));
- next_page_button->set_icon(get_theme_icon(SNAME("PageNext"), SNAME("EditorIcons")));
- last_page_button->set_icon(get_theme_icon(SNAME("PageLast"), SNAME("EditorIcons")));
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ first_page_button->set_icon(get_theme_icon(SNAME("PageFirst"), SNAME("EditorIcons")));
+ prev_page_button->set_icon(get_theme_icon(SNAME("PagePrevious"), SNAME("EditorIcons")));
+ next_page_button->set_icon(get_theme_icon(SNAME("PageNext"), SNAME("EditorIcons")));
+ last_page_button->set_icon(get_theme_icon(SNAME("PageLast"), SNAME("EditorIcons")));
+ } break;
}
}
@@ -3424,80 +3438,84 @@ void EditorInspector::_node_removed(Node *p_node) {
}
void EditorInspector::_notification(int p_what) {
- if (p_what == NOTIFICATION_READY) {
- EditorFeatureProfileManager::get_singleton()->connect("current_feature_profile_changed", callable_mp(this, &EditorInspector::_feature_profile_changed));
- set_process(is_visible_in_tree());
- _update_inspector_bg();
- }
+ switch (p_what) {
+ case NOTIFICATION_READY: {
+ EditorFeatureProfileManager::get_singleton()->connect("current_feature_profile_changed", callable_mp(this, &EditorInspector::_feature_profile_changed));
+ set_process(is_visible_in_tree());
+ _update_inspector_bg();
+ } break;
- if (p_what == NOTIFICATION_ENTER_TREE) {
- if (!sub_inspector) {
- get_tree()->connect("node_removed", callable_mp(this, &EditorInspector::_node_removed));
- }
- }
- if (p_what == NOTIFICATION_PREDELETE) {
- edit(nullptr); //just in case
- }
- if (p_what == NOTIFICATION_EXIT_TREE) {
- if (!sub_inspector) {
- get_tree()->disconnect("node_removed", callable_mp(this, &EditorInspector::_node_removed));
- }
- edit(nullptr);
- }
+ case NOTIFICATION_ENTER_TREE: {
+ if (!sub_inspector) {
+ get_tree()->connect("node_removed", callable_mp(this, &EditorInspector::_node_removed));
+ }
+ } break;
- if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- set_process(is_visible_in_tree());
- }
+ case NOTIFICATION_PREDELETE: {
+ edit(nullptr); //just in case
+ } break;
- if (p_what == NOTIFICATION_PROCESS) {
- if (update_scroll_request >= 0) {
- get_v_scroll_bar()->call_deferred(SNAME("set_value"), update_scroll_request);
- update_scroll_request = -1;
- }
- if (refresh_countdown > 0) {
- refresh_countdown -= get_process_delta_time();
- if (refresh_countdown <= 0) {
- for (const KeyValue<StringName, List<EditorProperty *>> &F : editor_property_map) {
- for (EditorProperty *E : F.value) {
- if (!E->is_cache_valid()) {
- E->update_property();
- E->update_revert_and_pin_status();
- E->update_cache();
+ case NOTIFICATION_EXIT_TREE: {
+ if (!sub_inspector) {
+ get_tree()->disconnect("node_removed", callable_mp(this, &EditorInspector::_node_removed));
+ }
+ edit(nullptr);
+ } break;
+
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ set_process(is_visible_in_tree());
+ } break;
+
+ case NOTIFICATION_PROCESS: {
+ if (update_scroll_request >= 0) {
+ get_v_scroll_bar()->call_deferred(SNAME("set_value"), update_scroll_request);
+ update_scroll_request = -1;
+ }
+ if (refresh_countdown > 0) {
+ refresh_countdown -= get_process_delta_time();
+ if (refresh_countdown <= 0) {
+ for (const KeyValue<StringName, List<EditorProperty *>> &F : editor_property_map) {
+ for (EditorProperty *E : F.value) {
+ if (!E->is_cache_valid()) {
+ E->update_property();
+ E->update_revert_and_pin_status();
+ E->update_cache();
+ }
}
}
+ refresh_countdown = float(EditorSettings::get_singleton()->get("docks/property_editor/auto_refresh_interval"));
}
- refresh_countdown = float(EditorSettings::get_singleton()->get("docks/property_editor/auto_refresh_interval"));
}
- }
- changing++;
+ changing++;
- if (update_tree_pending) {
- update_tree();
- update_tree_pending = false;
- pending.clear();
+ if (update_tree_pending) {
+ update_tree();
+ update_tree_pending = false;
+ pending.clear();
- } else {
- while (pending.size()) {
- StringName prop = pending.front()->get();
- if (editor_property_map.has(prop)) {
- for (EditorProperty *E : editor_property_map[prop]) {
- E->update_property();
- E->update_revert_and_pin_status();
- E->update_cache();
+ } else {
+ while (pending.size()) {
+ StringName prop = pending.front()->get();
+ if (editor_property_map.has(prop)) {
+ for (EditorProperty *E : editor_property_map[prop]) {
+ E->update_property();
+ E->update_revert_and_pin_status();
+ E->update_cache();
+ }
}
+ pending.erase(pending.front());
}
- pending.erase(pending.front());
}
- }
- changing--;
- }
+ changing--;
+ } break;
- if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
- _update_inspector_bg();
+ case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
+ _update_inspector_bg();
- update_tree();
+ update_tree();
+ } break;
}
}
diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp
index 45d7f8d697..d9ba4139c2 100644
--- a/editor/editor_log.cpp
+++ b/editor/editor_log.cpp
@@ -93,12 +93,11 @@ void EditorLog::_notification(int p_what) {
_update_theme();
_load_state();
} break;
+
case NOTIFICATION_THEME_CHANGED: {
_update_theme();
_rebuild_log();
} break;
- default:
- break;
}
}
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp
index 10a2af0cb0..5166200ee3 100644
--- a/editor/editor_plugin.cpp
+++ b/editor/editor_plugin.cpp
@@ -849,11 +849,14 @@ void EditorPlugin::_editor_project_settings_changed() {
emit_signal(SNAME("project_settings_changed"));
}
void EditorPlugin::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE) {
- EditorNode::get_singleton()->connect("project_settings_changed", callable_mp(this, &EditorPlugin::_editor_project_settings_changed));
- }
- if (p_what == NOTIFICATION_EXIT_TREE) {
- EditorNode::get_singleton()->disconnect("project_settings_changed", callable_mp(this, &EditorPlugin::_editor_project_settings_changed));
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ EditorNode::get_singleton()->connect("project_settings_changed", callable_mp(this, &EditorPlugin::_editor_project_settings_changed));
+ } break;
+
+ case NOTIFICATION_EXIT_TREE: {
+ EditorNode::get_singleton()->disconnect("project_settings_changed", callable_mp(this, &EditorPlugin::_editor_project_settings_changed));
+ } break;
}
}
diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp
index aa59337ac0..401414ae50 100644
--- a/editor/editor_plugin_settings.cpp
+++ b/editor/editor_plugin_settings.cpp
@@ -39,11 +39,15 @@
#include "scene/gui/margin_container.h"
void EditorPluginSettings::_notification(int p_what) {
- if (p_what == NOTIFICATION_WM_WINDOW_FOCUS_IN) {
- update_plugins();
- } else if (p_what == Node::NOTIFICATION_READY) {
- plugin_config_dialog->connect("plugin_ready", Callable(EditorNode::get_singleton(), "_on_plugin_ready"));
- plugin_list->connect("button_pressed", callable_mp(this, &EditorPluginSettings::_cell_button_pressed));
+ switch (p_what) {
+ case NOTIFICATION_WM_WINDOW_FOCUS_IN: {
+ update_plugins();
+ } break;
+
+ case Node::NOTIFICATION_READY: {
+ plugin_config_dialog->connect("plugin_ready", Callable(EditorNode::get_singleton(), "_on_plugin_ready"));
+ plugin_list->connect("button_pressed", callable_mp(this, &EditorPluginSettings::_cell_button_pressed));
+ } break;
}
}
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 65c4ace468..68a3fabe1e 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -166,7 +166,6 @@ void EditorPropertyMultilineText::_notification(int p_what) {
Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label"));
text->set_custom_minimum_size(Vector2(0, font->get_height(font_size) * 6));
-
} break;
}
}
@@ -294,11 +293,11 @@ void EditorPropertyTextEnum::_bind_methods() {
void EditorPropertyTextEnum::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
- case NOTIFICATION_THEME_CHANGED:
+ case NOTIFICATION_THEME_CHANGED: {
edit_button->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")));
accept_button->set_icon(get_theme_icon(SNAME("ImportCheck"), SNAME("EditorIcons")));
cancel_button->set_icon(get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons")));
- break;
+ } break;
}
}
@@ -374,8 +373,11 @@ void EditorPropertyLocale::setup(const String &p_hint_text) {
}
void EditorPropertyLocale::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- locale_edit->set_icon(get_theme_icon(SNAME("Translation"), SNAME("EditorIcons")));
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ locale_edit->set_icon(get_theme_icon(SNAME("Translation"), SNAME("EditorIcons")));
+ } break;
}
}
@@ -467,8 +469,11 @@ void EditorPropertyPath::set_save_mode() {
}
void EditorPropertyPath::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- path_edit->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")));
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ path_edit->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")));
+ } break;
}
}
@@ -1065,9 +1070,6 @@ void EditorPropertyLayersGrid::_notification(int p_what) {
update();
}
} break;
-
- default:
- break;
}
}
@@ -1619,11 +1621,14 @@ void EditorPropertyVector2::update_property() {
}
void EditorPropertyVector2::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- const Color *colors = _get_property_colors();
- for (int i = 0; i < 2; i++) {
- spin[i]->set_custom_label_color(true, colors[i]);
- }
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ const Color *colors = _get_property_colors();
+ for (int i = 0; i < 2; i++) {
+ spin[i]->set_custom_label_color(true, colors[i]);
+ }
+ } break;
}
}
@@ -1710,11 +1715,14 @@ void EditorPropertyRect2::update_property() {
}
void EditorPropertyRect2::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- const Color *colors = _get_property_colors();
- for (int i = 0; i < 4; i++) {
- spin[i]->set_custom_label_color(true, colors[i % 2]);
- }
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ const Color *colors = _get_property_colors();
+ for (int i = 0; i < 4; i++) {
+ spin[i]->set_custom_label_color(true, colors[i % 2]);
+ }
+ } break;
}
}
@@ -1836,11 +1844,14 @@ Vector3 EditorPropertyVector3::get_vector() {
}
void EditorPropertyVector3::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- const Color *colors = _get_property_colors();
- for (int i = 0; i < 3; i++) {
- spin[i]->set_custom_label_color(true, colors[i]);
- }
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ const Color *colors = _get_property_colors();
+ for (int i = 0; i < 3; i++) {
+ spin[i]->set_custom_label_color(true, colors[i]);
+ }
+ } break;
}
}
@@ -1923,11 +1934,14 @@ void EditorPropertyVector2i::update_property() {
}
void EditorPropertyVector2i::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- const Color *colors = _get_property_colors();
- for (int i = 0; i < 2; i++) {
- spin[i]->set_custom_label_color(true, colors[i]);
- }
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ const Color *colors = _get_property_colors();
+ for (int i = 0; i < 2; i++) {
+ spin[i]->set_custom_label_color(true, colors[i]);
+ }
+ } break;
}
}
@@ -2014,11 +2028,14 @@ void EditorPropertyRect2i::update_property() {
}
void EditorPropertyRect2i::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- const Color *colors = _get_property_colors();
- for (int i = 0; i < 4; i++) {
- spin[i]->set_custom_label_color(true, colors[i % 2]);
- }
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ const Color *colors = _get_property_colors();
+ for (int i = 0; i < 4; i++) {
+ spin[i]->set_custom_label_color(true, colors[i % 2]);
+ }
+ } break;
}
}
@@ -2113,11 +2130,14 @@ void EditorPropertyVector3i::update_property() {
}
void EditorPropertyVector3i::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- const Color *colors = _get_property_colors();
- for (int i = 0; i < 3; i++) {
- spin[i]->set_custom_label_color(true, colors[i]);
- }
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ const Color *colors = _get_property_colors();
+ for (int i = 0; i < 3; i++) {
+ spin[i]->set_custom_label_color(true, colors[i]);
+ }
+ } break;
}
}
@@ -2203,11 +2223,14 @@ void EditorPropertyPlane::update_property() {
}
void EditorPropertyPlane::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- const Color *colors = _get_property_colors();
- for (int i = 0; i < 4; i++) {
- spin[i]->set_custom_label_color(true, colors[i]);
- }
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ const Color *colors = _get_property_colors();
+ for (int i = 0; i < 4; i++) {
+ spin[i]->set_custom_label_color(true, colors[i]);
+ }
+ } break;
}
}
@@ -2294,11 +2317,14 @@ void EditorPropertyQuaternion::update_property() {
}
void EditorPropertyQuaternion::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- const Color *colors = _get_property_colors();
- for (int i = 0; i < 4; i++) {
- spin[i]->set_custom_label_color(true, colors[i]);
- }
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ const Color *colors = _get_property_colors();
+ for (int i = 0; i < 4; i++) {
+ spin[i]->set_custom_label_color(true, colors[i]);
+ }
+ } break;
}
}
@@ -2388,11 +2414,14 @@ void EditorPropertyAABB::update_property() {
}
void EditorPropertyAABB::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- const Color *colors = _get_property_colors();
- for (int i = 0; i < 6; i++) {
- spin[i]->set_custom_label_color(true, colors[i % 3]);
- }
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ const Color *colors = _get_property_colors();
+ for (int i = 0; i < 6; i++) {
+ spin[i]->set_custom_label_color(true, colors[i % 3]);
+ }
+ } break;
}
}
@@ -2469,16 +2498,19 @@ void EditorPropertyTransform2D::update_property() {
}
void EditorPropertyTransform2D::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- const Color *colors = _get_property_colors();
- for (int i = 0; i < 6; i++) {
- // For Transform2D, use the 4th color (cyan) for the origin vector.
- if (i % 3 == 2) {
- spin[i]->set_custom_label_color(true, colors[3]);
- } else {
- spin[i]->set_custom_label_color(true, colors[i % 3]);
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ const Color *colors = _get_property_colors();
+ for (int i = 0; i < 6; i++) {
+ // For Transform2D, use the 4th color (cyan) for the origin vector.
+ if (i % 3 == 2) {
+ spin[i]->set_custom_label_color(true, colors[3]);
+ } else {
+ spin[i]->set_custom_label_color(true, colors[i % 3]);
+ }
}
- }
+ } break;
}
}
@@ -2562,11 +2594,14 @@ void EditorPropertyBasis::update_property() {
}
void EditorPropertyBasis::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- const Color *colors = _get_property_colors();
- for (int i = 0; i < 9; i++) {
- spin[i]->set_custom_label_color(true, colors[i % 3]);
- }
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ const Color *colors = _get_property_colors();
+ for (int i = 0; i < 9; i++) {
+ spin[i]->set_custom_label_color(true, colors[i % 3]);
+ }
+ } break;
}
}
@@ -2656,11 +2691,14 @@ void EditorPropertyTransform3D::update_using_transform(Transform3D p_transform)
}
void EditorPropertyTransform3D::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- const Color *colors = _get_property_colors();
- for (int i = 0; i < 12; i++) {
- spin[i]->set_custom_label_color(true, colors[i % 4]);
- }
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ const Color *colors = _get_property_colors();
+ for (int i = 0; i < 12; i++) {
+ spin[i]->set_custom_label_color(true, colors[i % 4]);
+ }
+ } break;
}
}
@@ -2902,9 +2940,12 @@ void EditorPropertyNodePath::setup(const NodePath &p_base_hint, Vector<StringNam
}
void EditorPropertyNodePath::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Ref<Texture2D> t = get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"));
- clear->set_icon(t);
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ Ref<Texture2D> t = get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"));
+ clear->set_icon(t);
+ } break;
}
}
diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp
index 3bd5abb296..61261af608 100644
--- a/editor/editor_properties_array_dict.cpp
+++ b/editor/editor_properties_array_dict.cpp
@@ -504,34 +504,37 @@ void EditorPropertyArray::drop_data_fw(const Point2 &p_point, const Variant &p_d
}
void EditorPropertyArray::_notification(int p_what) {
- if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) {
- change_type->clear();
- for (int i = 0; i < Variant::VARIANT_MAX; i++) {
- String type = Variant::get_type_name(Variant::Type(i));
- change_type->add_icon_item(get_theme_icon(type, SNAME("EditorIcons")), type, i);
- }
- change_type->add_separator();
- change_type->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Remove Item"), Variant::VARIANT_MAX);
+ switch (p_what) {
+ case NOTIFICATION_THEME_CHANGED:
+ case NOTIFICATION_ENTER_TREE: {
+ change_type->clear();
+ for (int i = 0; i < Variant::VARIANT_MAX; i++) {
+ String type = Variant::get_type_name(Variant::Type(i));
+ change_type->add_icon_item(get_theme_icon(type, SNAME("EditorIcons")), type, i);
+ }
+ change_type->add_separator();
+ change_type->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Remove Item"), Variant::VARIANT_MAX);
- if (Object::cast_to<Button>(button_add_item)) {
- button_add_item->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
- }
- }
+ if (Object::cast_to<Button>(button_add_item)) {
+ button_add_item->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
+ }
+ } break;
- if (p_what == NOTIFICATION_DRAG_BEGIN) {
- if (is_visible_in_tree()) {
- if (_is_drop_valid(get_viewport()->gui_get_drag_data())) {
- dropping = true;
- edit->update();
+ case NOTIFICATION_DRAG_BEGIN: {
+ if (is_visible_in_tree()) {
+ if (_is_drop_valid(get_viewport()->gui_get_drag_data())) {
+ dropping = true;
+ edit->update();
+ }
}
- }
- }
+ } break;
- if (p_what == NOTIFICATION_DRAG_END) {
- if (dropping) {
- dropping = false;
- edit->update();
- }
+ case NOTIFICATION_DRAG_END: {
+ if (dropping) {
+ dropping = false;
+ edit->update();
+ }
+ } break;
}
}
@@ -1151,18 +1154,21 @@ void EditorPropertyDictionary::_object_id_selected(const StringName &p_property,
}
void EditorPropertyDictionary::_notification(int p_what) {
- if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) {
- change_type->clear();
- for (int i = 0; i < Variant::VARIANT_MAX; i++) {
- String type = Variant::get_type_name(Variant::Type(i));
- change_type->add_icon_item(get_theme_icon(type, SNAME("EditorIcons")), type, i);
- }
- change_type->add_separator();
- change_type->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Remove Item"), Variant::VARIANT_MAX);
+ switch (p_what) {
+ case NOTIFICATION_THEME_CHANGED:
+ case NOTIFICATION_ENTER_TREE: {
+ change_type->clear();
+ for (int i = 0; i < Variant::VARIANT_MAX; i++) {
+ String type = Variant::get_type_name(Variant::Type(i));
+ change_type->add_icon_item(get_theme_icon(type, SNAME("EditorIcons")), type, i);
+ }
+ change_type->add_separator();
+ change_type->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Remove Item"), Variant::VARIANT_MAX);
- if (Object::cast_to<Button>(button_add_item)) {
- button_add_item->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
- }
+ if (Object::cast_to<Button>(button_add_item)) {
+ button_add_item->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
+ }
+ } break;
}
}
diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp
index 98f315f0db..85d304ec5d 100644
--- a/editor/editor_run_native.cpp
+++ b/editor/editor_run_native.cpp
@@ -35,61 +35,63 @@
#include "editor/editor_scale.h"
void EditorRunNative::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE) {
- for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) {
- Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(i);
- if (eep.is_null()) {
- continue;
- }
- Ref<ImageTexture> icon = eep->get_run_icon();
- if (!icon.is_null()) {
- Ref<Image> im = icon->get_image();
- im = im->duplicate();
- im->clear_mipmaps();
- if (!im->is_empty()) {
- im->resize(16 * EDSCALE, 16 * EDSCALE);
- Ref<ImageTexture> small_icon;
- small_icon.instantiate();
- small_icon->create_from_image(im);
- MenuButton *mb = memnew(MenuButton);
- mb->get_popup()->connect("id_pressed", callable_mp(this, &EditorRunNative::run_native), varray(i));
- mb->connect("pressed", callable_mp(this, &EditorRunNative::run_native), varray(-1, i));
- mb->set_icon(small_icon);
- add_child(mb);
- menus[i] = mb;
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) {
+ Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(i);
+ if (eep.is_null()) {
+ continue;
+ }
+ Ref<ImageTexture> icon = eep->get_run_icon();
+ if (!icon.is_null()) {
+ Ref<Image> im = icon->get_image();
+ im = im->duplicate();
+ im->clear_mipmaps();
+ if (!im->is_empty()) {
+ im->resize(16 * EDSCALE, 16 * EDSCALE);
+ Ref<ImageTexture> small_icon;
+ small_icon.instantiate();
+ small_icon->create_from_image(im);
+ MenuButton *mb = memnew(MenuButton);
+ mb->get_popup()->connect("id_pressed", callable_mp(this, &EditorRunNative::run_native), varray(i));
+ mb->connect("pressed", callable_mp(this, &EditorRunNative::run_native), varray(-1, i));
+ mb->set_icon(small_icon);
+ add_child(mb);
+ menus[i] = mb;
+ }
}
}
- }
- }
+ } break;
- if (p_what == NOTIFICATION_PROCESS) {
- bool changed = EditorExport::get_singleton()->poll_export_platforms() || first;
-
- if (changed) {
- for (KeyValue<int, MenuButton *> &E : menus) {
- Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(E.key);
- MenuButton *mb = E.value;
- int dc = eep->get_options_count();
-
- if (dc == 0) {
- mb->hide();
- } else {
- mb->get_popup()->clear();
- mb->show();
- if (dc == 1) {
- mb->set_tooltip(eep->get_option_tooltip(0));
+ case NOTIFICATION_PROCESS: {
+ bool changed = EditorExport::get_singleton()->poll_export_platforms() || first;
+
+ if (changed) {
+ for (KeyValue<int, MenuButton *> &E : menus) {
+ Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(E.key);
+ MenuButton *mb = E.value;
+ int dc = eep->get_options_count();
+
+ if (dc == 0) {
+ mb->hide();
} else {
- mb->set_tooltip(eep->get_options_tooltip());
- for (int i = 0; i < dc; i++) {
- mb->get_popup()->add_icon_item(eep->get_option_icon(i), eep->get_option_label(i));
- mb->get_popup()->set_item_tooltip(mb->get_popup()->get_item_count() - 1, eep->get_option_tooltip(i));
+ mb->get_popup()->clear();
+ mb->show();
+ if (dc == 1) {
+ mb->set_tooltip(eep->get_option_tooltip(0));
+ } else {
+ mb->set_tooltip(eep->get_options_tooltip());
+ for (int i = 0; i < dc; i++) {
+ mb->get_popup()->add_icon_item(eep->get_option_icon(i), eep->get_option_label(i));
+ mb->get_popup()->set_item_tooltip(mb->get_popup()->get_item_count() - 1, eep->get_option_tooltip(i));
+ }
}
}
}
- }
- first = false;
- }
+ first = false;
+ }
+ } break;
}
}
diff --git a/editor/editor_settings_dialog.cpp b/editor/editor_settings_dialog.cpp
index e4ad62c470..6a5ab91ba0 100644
--- a/editor/editor_settings_dialog.cpp
+++ b/editor/editor_settings_dialog.cpp
@@ -121,14 +121,17 @@ void EditorSettingsDialog::_notification(int p_what) {
set_process_unhandled_input(false);
}
} break;
+
case NOTIFICATION_READY: {
undo_redo->set_method_notify_callback(EditorDebuggerNode::_method_changeds, nullptr);
undo_redo->set_property_notify_callback(EditorDebuggerNode::_property_changeds, nullptr);
undo_redo->set_commit_notify_callback(_undo_redo_callback, this);
} break;
+
case NOTIFICATION_ENTER_TREE: {
_update_icons();
} break;
+
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
_update_icons();
// Update theme colors.
diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp
index ccebca4cc9..a4a9e691a0 100644
--- a/editor/editor_spin_slider.cpp
+++ b/editor/editor_spin_slider.cpp
@@ -430,47 +430,49 @@ void EditorSpinSlider::_draw_spin_slider() {
void EditorSpinSlider::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
- case NOTIFICATION_THEME_CHANGED:
+ case NOTIFICATION_THEME_CHANGED: {
_update_value_input_stylebox();
- break;
+ } break;
- case NOTIFICATION_INTERNAL_PROCESS:
+ case NOTIFICATION_INTERNAL_PROCESS: {
if (value_input_dirty) {
value_input_dirty = false;
value_input->set_text(get_text_value());
}
set_process_internal(false);
- break;
+ } break;
- case NOTIFICATION_DRAW:
+ case NOTIFICATION_DRAW: {
_draw_spin_slider();
- break;
+ } break;
case NOTIFICATION_WM_WINDOW_FOCUS_IN:
case NOTIFICATION_WM_WINDOW_FOCUS_OUT:
- case NOTIFICATION_EXIT_TREE:
+ case NOTIFICATION_EXIT_TREE: {
if (grabbing_spinner) {
grabber->hide();
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
grabbing_spinner = false;
grabbing_spinner_attempt = false;
}
- break;
+ } break;
- case NOTIFICATION_MOUSE_ENTER:
+ case NOTIFICATION_MOUSE_ENTER: {
mouse_over_spin = true;
update();
- break;
- case NOTIFICATION_MOUSE_EXIT:
+ } break;
+
+ case NOTIFICATION_MOUSE_EXIT: {
mouse_over_spin = false;
update();
- break;
- case NOTIFICATION_FOCUS_ENTER:
+ } break;
+
+ case NOTIFICATION_FOCUS_ENTER: {
if ((Input::get_singleton()->is_action_pressed("ui_focus_next") || Input::get_singleton()->is_action_pressed("ui_focus_prev")) && !value_input_just_closed) {
_focus_entered();
}
value_input_just_closed = false;
- break;
+ } break;
}
}
diff --git a/editor/editor_toaster.cpp b/editor/editor_toaster.cpp
index f96df86682..319b4709fe 100644
--- a/editor/editor_toaster.cpp
+++ b/editor/editor_toaster.cpp
@@ -104,6 +104,7 @@ void EditorToaster::_notification(int p_what) {
main_button->update();
}
} break;
+
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
if (vbox_container->is_visible()) {
@@ -134,12 +135,11 @@ void EditorToaster::_notification(int p_what) {
main_button->update();
disable_notifications_button->update();
} break;
+
case NOTIFICATION_TRANSFORM_CHANGED: {
_update_vbox_position();
_update_disable_notifications_button();
} break;
- default:
- break;
}
}
diff --git a/editor/editor_zoom_widget.cpp b/editor/editor_zoom_widget.cpp
index abfa383297..c8099c9a0b 100644
--- a/editor/editor_zoom_widget.cpp
+++ b/editor/editor_zoom_widget.cpp
@@ -144,12 +144,10 @@ void EditorZoomWidget::set_zoom_by_increments(int p_increment_count, bool p_inte
void EditorZoomWidget::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
- case NOTIFICATION_THEME_CHANGED:
+ case NOTIFICATION_THEME_CHANGED: {
zoom_minus->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons")));
zoom_plus->set_icon(get_theme_icon(SNAME("ZoomMore"), SNAME("EditorIcons")));
- break;
- default:
- break;
+ } break;
}
}
diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp
index 929f8b8d2c..eff9185c71 100644
--- a/editor/find_in_files.cpp
+++ b/editor/find_in_files.cpp
@@ -103,9 +103,11 @@ void FindInFiles::set_filter(const Set<String> &exts) {
_extension_filter = exts;
}
-void FindInFiles::_notification(int p_notification) {
- if (p_notification == NOTIFICATION_PROCESS) {
- _process();
+void FindInFiles::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_PROCESS: {
+ _process();
+ } break;
}
}
@@ -456,26 +458,28 @@ Set<String> FindInFilesDialog::get_filter() const {
}
void FindInFilesDialog::_notification(int p_what) {
- if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- if (is_visible()) {
- // Doesn't work more than once if not deferred...
- _search_text_line_edit->call_deferred(SNAME("grab_focus"));
- _search_text_line_edit->select_all();
- // Extensions might have changed in the meantime, we clean them and instance them again.
- for (int i = 0; i < _filters_container->get_child_count(); i++) {
- _filters_container->get_child(i)->queue_delete();
- }
- Array exts = ProjectSettings::get_singleton()->get("editor/script/search_in_file_extensions");
- for (int i = 0; i < exts.size(); ++i) {
- CheckBox *cb = memnew(CheckBox);
- cb->set_text(exts[i]);
- if (!_filters_preferences.has(exts[i])) {
- _filters_preferences[exts[i]] = true;
+ switch (p_what) {
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ if (is_visible()) {
+ // Doesn't work more than once if not deferred...
+ _search_text_line_edit->call_deferred(SNAME("grab_focus"));
+ _search_text_line_edit->select_all();
+ // Extensions might have changed in the meantime, we clean them and instance them again.
+ for (int i = 0; i < _filters_container->get_child_count(); i++) {
+ _filters_container->get_child(i)->queue_delete();
+ }
+ Array exts = ProjectSettings::get_singleton()->get("editor/script/search_in_file_extensions");
+ for (int i = 0; i < exts.size(); ++i) {
+ CheckBox *cb = memnew(CheckBox);
+ cb->set_text(exts[i]);
+ if (!_filters_preferences.has(exts[i])) {
+ _filters_preferences[exts[i]] = true;
+ }
+ cb->set_pressed(_filters_preferences[exts[i]]);
+ _filters_container->add_child(cb);
}
- cb->set_pressed(_filters_preferences[exts[i]]);
- _filters_container->add_child(cb);
}
- }
+ } break;
}
}
@@ -687,11 +691,15 @@ void FindInFilesPanel::stop_search() {
}
void FindInFilesPanel::_notification(int p_what) {
- if (p_what == NOTIFICATION_PROCESS) {
- _progress_bar->set_as_ratio(_finder->get_progress());
- } else if (p_what == NOTIFICATION_THEME_CHANGED) {
- _search_text_label->add_theme_font_override("font", get_theme_font(SNAME("source"), SNAME("EditorFonts")));
- _results_display->add_theme_font_override("font", get_theme_font(SNAME("source"), SNAME("EditorFonts")));
+ switch (p_what) {
+ case NOTIFICATION_PROCESS: {
+ _progress_bar->set_as_ratio(_finder->get_progress());
+ } break;
+
+ case NOTIFICATION_THEME_CHANGED: {
+ _search_text_label->add_theme_font_override("font", get_theme_font(SNAME("source"), SNAME("EditorFonts")));
+ _results_display->add_theme_font_override("font", get_theme_font(SNAME("source"), SNAME("EditorFonts")));
+ } break;
}
}
diff --git a/editor/find_in_files.h b/editor/find_in_files.h
index fca6910f1c..1b6666b554 100644
--- a/editor/find_in_files.h
+++ b/editor/find_in_files.h
@@ -60,7 +60,7 @@ public:
float get_progress() const;
protected:
- void _notification(int p_notification);
+ void _notification(int p_what);
static void _bind_methods();
diff --git a/editor/import/dynamic_font_import_settings.cpp b/editor/import/dynamic_font_import_settings.cpp
index 864e69a16e..8486d170a7 100644
--- a/editor/import/dynamic_font_import_settings.cpp
+++ b/editor/import/dynamic_font_import_settings.cpp
@@ -900,13 +900,18 @@ String DynamicFontImportSettings::_pad_zeros(const String &p_hex) const {
}
void DynamicFontImportSettings::_notification(int p_what) {
- if (p_what == NOTIFICATION_READY) {
- connect("confirmed", callable_mp(this, &DynamicFontImportSettings::_re_import));
- } else if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- add_lang->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
- add_script->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
- add_var->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
- add_ot->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
+ switch (p_what) {
+ case NOTIFICATION_READY: {
+ connect("confirmed", callable_mp(this, &DynamicFontImportSettings::_re_import));
+ } break;
+
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ add_lang->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
+ add_script->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
+ add_var->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
+ add_ot->set_icon(add_var->get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
+ } break;
}
}
diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp
index a3fb753d7f..488bd02de4 100644
--- a/editor/import/scene_import_settings.cpp
+++ b/editor/import/scene_import_settings.cpp
@@ -837,8 +837,10 @@ void SceneImportSettings::_re_import() {
}
void SceneImportSettings::_notification(int p_what) {
- if (p_what == NOTIFICATION_READY) {
- connect("confirmed", callable_mp(this, &SceneImportSettings::_re_import));
+ switch (p_what) {
+ case NOTIFICATION_READY: {
+ connect("confirmed", callable_mp(this, &SceneImportSettings::_re_import));
+ } break;
}
}
diff --git a/editor/import_defaults_editor.cpp b/editor/import_defaults_editor.cpp
index 767e2a7fad..ca979c094f 100644
--- a/editor/import_defaults_editor.cpp
+++ b/editor/import_defaults_editor.cpp
@@ -80,8 +80,10 @@ protected:
};
void ImportDefaultsEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_PREDELETE) {
- inspector->edit(nullptr);
+ switch (p_what) {
+ case NOTIFICATION_PREDELETE: {
+ inspector->edit(nullptr);
+ } break;
}
}
diff --git a/editor/localization_editor.cpp b/editor/localization_editor.cpp
index 401ba02099..cd9986d527 100644
--- a/editor/localization_editor.cpp
+++ b/editor/localization_editor.cpp
@@ -40,25 +40,27 @@
#include "scene/gui/control.h"
void LocalizationEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE) {
- translation_list->connect("button_pressed", callable_mp(this, &LocalizationEditor::_translation_delete));
- translation_pot_list->connect("button_pressed", callable_mp(this, &LocalizationEditor::_pot_delete));
-
- List<String> tfn;
- ResourceLoader::get_recognized_extensions_for_type("Translation", &tfn);
- for (const String &E : tfn) {
- translation_file_open->add_filter("*." + E);
- }
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ translation_list->connect("button_pressed", callable_mp(this, &LocalizationEditor::_translation_delete));
+ translation_pot_list->connect("button_pressed", callable_mp(this, &LocalizationEditor::_pot_delete));
+
+ List<String> tfn;
+ ResourceLoader::get_recognized_extensions_for_type("Translation", &tfn);
+ for (const String &E : tfn) {
+ translation_file_open->add_filter("*." + E);
+ }
- List<String> rfn;
- ResourceLoader::get_recognized_extensions_for_type("Resource", &rfn);
- for (const String &E : rfn) {
- translation_res_file_open_dialog->add_filter("*." + E);
- translation_res_option_file_open_dialog->add_filter("*." + E);
- }
+ List<String> rfn;
+ ResourceLoader::get_recognized_extensions_for_type("Resource", &rfn);
+ for (const String &E : rfn) {
+ translation_res_file_open_dialog->add_filter("*." + E);
+ translation_res_option_file_open_dialog->add_filter("*." + E);
+ }
- _update_pot_file_extensions();
- pot_generate_dialog->add_filter("*.pot");
+ _update_pot_file_extensions();
+ pot_generate_dialog->add_filter("*.pot");
+ } break;
}
}
diff --git a/editor/node_dock.cpp b/editor/node_dock.cpp
index 9b06435648..18545d3c9a 100644
--- a/editor/node_dock.cpp
+++ b/editor/node_dock.cpp
@@ -52,9 +52,12 @@ void NodeDock::_bind_methods() {
}
void NodeDock::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- connections_button->set_icon(get_theme_icon(SNAME("Signals"), SNAME("EditorIcons")));
- groups_button->set_icon(get_theme_icon(SNAME("Groups"), SNAME("EditorIcons")));
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ connections_button->set_icon(get_theme_icon(SNAME("Signals"), SNAME("EditorIcons")));
+ groups_button->set_icon(get_theme_icon(SNAME("Groups"), SNAME("EditorIcons")));
+ } break;
}
}
diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp
index 5786d24d23..48ea3013f7 100644
--- a/editor/plugin_config_dialog.cpp
+++ b/editor/plugin_config_dialog.cpp
@@ -160,6 +160,7 @@ void PluginConfigDialog::_notification(int p_what) {
name_edit->grab_focus();
}
} break;
+
case NOTIFICATION_READY: {
connect("confirmed", callable_mp(this, &PluginConfigDialog::_on_confirmed));
get_cancel_button()->connect("pressed", callable_mp(this, &PluginConfigDialog::_on_cancelled));
diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp
index 8f6ac149aa..5a2696fff1 100644
--- a/editor/plugins/abstract_polygon_2d_editor.cpp
+++ b/editor/plugins/abstract_polygon_2d_editor.cpp
@@ -154,6 +154,7 @@ void AbstractPolygon2DEditor::_notification(int p_what) {
button_edit->set_icon(get_theme_icon(SNAME("CurveEdit"), SNAME("EditorIcons")));
button_delete->set_icon(get_theme_icon(SNAME("CurveDelete"), SNAME("EditorIcons")));
} break;
+
case NOTIFICATION_READY: {
disable_polygon_editing(false, String());
diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp
index 4156c14a7e..fe8b462084 100644
--- a/editor/plugins/animation_blend_space_1d_editor.cpp
+++ b/editor/plugins/animation_blend_space_1d_editor.cpp
@@ -531,39 +531,42 @@ void AnimationNodeBlendSpace1DEditor::_open_editor() {
}
void AnimationNodeBlendSpace1DEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
- error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
- panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
- tool_blend->set_icon(get_theme_icon(SNAME("EditPivot"), SNAME("EditorIcons")));
- tool_select->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons")));
- tool_create->set_icon(get_theme_icon(SNAME("EditKey"), SNAME("EditorIcons")));
- tool_erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
- snap->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons")));
- open_editor->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")));
- }
-
- if (p_what == NOTIFICATION_PROCESS) {
- String error;
-
- if (!AnimationTreeEditor::get_singleton()->get_tree()->is_active()) {
- error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails.");
- } else if (AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) {
- error = AnimationTreeEditor::get_singleton()->get_tree()->get_invalid_state_reason();
- }
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
+ error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
+ tool_blend->set_icon(get_theme_icon(SNAME("EditPivot"), SNAME("EditorIcons")));
+ tool_select->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons")));
+ tool_create->set_icon(get_theme_icon(SNAME("EditKey"), SNAME("EditorIcons")));
+ tool_erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
+ snap->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons")));
+ open_editor->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")));
+ } break;
+
+ case NOTIFICATION_PROCESS: {
+ String error;
+
+ if (!AnimationTreeEditor::get_singleton()->get_tree()->is_active()) {
+ error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails.");
+ } else if (AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) {
+ error = AnimationTreeEditor::get_singleton()->get_tree()->get_invalid_state_reason();
+ }
- if (error != error_label->get_text()) {
- error_label->set_text(error);
- if (!error.is_empty()) {
- error_panel->show();
- } else {
- error_panel->hide();
+ if (error != error_label->get_text()) {
+ error_label->set_text(error);
+ if (!error.is_empty()) {
+ error_panel->show();
+ } else {
+ error_panel->hide();
+ }
}
- }
- }
+ } break;
- if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- set_process(is_visible_in_tree());
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ set_process(is_visible_in_tree());
+ } break;
}
}
diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp
index 6d876aba44..506a709728 100644
--- a/editor/plugins/animation_blend_space_2d_editor.cpp
+++ b/editor/plugins/animation_blend_space_2d_editor.cpp
@@ -731,49 +731,52 @@ void AnimationNodeBlendSpace2DEditor::_edit_point_pos(double) {
}
void AnimationNodeBlendSpace2DEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
- error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
- panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
- tool_blend->set_icon(get_theme_icon(SNAME("EditPivot"), SNAME("EditorIcons")));
- tool_select->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons")));
- tool_create->set_icon(get_theme_icon(SNAME("EditKey"), SNAME("EditorIcons")));
- tool_triangle->set_icon(get_theme_icon(SNAME("ToolTriangle"), SNAME("EditorIcons")));
- tool_erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
- snap->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons")));
- open_editor->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")));
- auto_triangles->set_icon(get_theme_icon(SNAME("AutoTriangle"), SNAME("EditorIcons")));
- interpolation->clear();
- interpolation->add_icon_item(get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")), "", 0);
- interpolation->add_icon_item(get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")), "", 1);
- interpolation->add_icon_item(get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons")), "", 2);
- }
-
- if (p_what == NOTIFICATION_PROCESS) {
- String error;
-
- if (!AnimationTreeEditor::get_singleton()->get_tree()) {
- error = TTR("BlendSpace2D does not belong to an AnimationTree node.");
- } else if (!AnimationTreeEditor::get_singleton()->get_tree()->is_active()) {
- error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails.");
- } else if (AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) {
- error = AnimationTreeEditor::get_singleton()->get_tree()->get_invalid_state_reason();
- } else if (blend_space->get_triangle_count() == 0) {
- error = TTR("No triangles exist, so no blending can take place.");
- }
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
+ error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
+ tool_blend->set_icon(get_theme_icon(SNAME("EditPivot"), SNAME("EditorIcons")));
+ tool_select->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons")));
+ tool_create->set_icon(get_theme_icon(SNAME("EditKey"), SNAME("EditorIcons")));
+ tool_triangle->set_icon(get_theme_icon(SNAME("ToolTriangle"), SNAME("EditorIcons")));
+ tool_erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
+ snap->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons")));
+ open_editor->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")));
+ auto_triangles->set_icon(get_theme_icon(SNAME("AutoTriangle"), SNAME("EditorIcons")));
+ interpolation->clear();
+ interpolation->add_icon_item(get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")), "", 0);
+ interpolation->add_icon_item(get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")), "", 1);
+ interpolation->add_icon_item(get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons")), "", 2);
+ } break;
+
+ case NOTIFICATION_PROCESS: {
+ String error;
+
+ if (!AnimationTreeEditor::get_singleton()->get_tree()) {
+ error = TTR("BlendSpace2D does not belong to an AnimationTree node.");
+ } else if (!AnimationTreeEditor::get_singleton()->get_tree()->is_active()) {
+ error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails.");
+ } else if (AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) {
+ error = AnimationTreeEditor::get_singleton()->get_tree()->get_invalid_state_reason();
+ } else if (blend_space->get_triangle_count() == 0) {
+ error = TTR("No triangles exist, so no blending can take place.");
+ }
- if (error != error_label->get_text()) {
- error_label->set_text(error);
- if (!error.is_empty()) {
- error_panel->show();
- } else {
- error_panel->hide();
+ if (error != error_label->get_text()) {
+ error_label->set_text(error);
+ if (!error.is_empty()) {
+ error_panel->show();
+ } else {
+ error_panel->hide();
+ }
}
- }
- }
+ } break;
- if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- set_process(is_visible_in_tree());
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ set_process(is_visible_in_tree());
+ } break;
}
}
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp
index 14dd782b73..0b3164aada 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp
@@ -734,80 +734,95 @@ void AnimationNodeBlendTreeEditor::_removed_from_graph() {
}
}
+void AnimationNodeBlendTreeEditor::_update_editor_settings() {
+ graph->get_panner()->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/sub_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning")));
+ graph->set_warped_panning(bool(EditorSettings::get_singleton()->get("editors/panning/warped_mouse_panning")));
+}
+
+void AnimationNodeBlendTreeEditor::_update_theme() {
+ error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
+ error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
+}
+
void AnimationNodeBlendTreeEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
- graph->get_panner()->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/sub_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning")));
- graph->set_warped_panning(bool(EditorSettings::get_singleton()->get("editors/panning/warped_mouse_panning")));
- }
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ _update_editor_settings();
+ _update_theme();
+ } break;
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
- error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
+ _update_editor_settings();
+ } break;
- if (p_what == NOTIFICATION_THEME_CHANGED && is_visible_in_tree()) {
- _update_graph();
- }
- }
+ case NOTIFICATION_THEME_CHANGED: {
+ _update_theme();
- if (p_what == NOTIFICATION_PROCESS) {
- String error;
+ if (is_visible_in_tree()) {
+ _update_graph();
+ }
+ } break;
- if (!AnimationTreeEditor::get_singleton()->get_tree()->is_active()) {
- error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails.");
- } else if (AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) {
- error = AnimationTreeEditor::get_singleton()->get_tree()->get_invalid_state_reason();
- }
+ case NOTIFICATION_PROCESS: {
+ String error;
- if (error != error_label->get_text()) {
- error_label->set_text(error);
- if (!error.is_empty()) {
- error_panel->show();
- } else {
- error_panel->hide();
+ if (!AnimationTreeEditor::get_singleton()->get_tree()->is_active()) {
+ error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails.");
+ } else if (AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) {
+ error = AnimationTreeEditor::get_singleton()->get_tree()->get_invalid_state_reason();
}
- }
- List<AnimationNodeBlendTree::NodeConnection> conns;
- blend_tree->get_node_connections(&conns);
- for (const AnimationNodeBlendTree::NodeConnection &E : conns) {
- float activity = 0;
- StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E.input_node;
- if (AnimationTreeEditor::get_singleton()->get_tree() && !AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) {
- activity = AnimationTreeEditor::get_singleton()->get_tree()->get_connection_activity(path, E.input_index);
+ if (error != error_label->get_text()) {
+ error_label->set_text(error);
+ if (!error.is_empty()) {
+ error_panel->show();
+ } else {
+ error_panel->hide();
+ }
}
- graph->set_connection_activity(E.output_node, 0, E.input_node, E.input_index, activity);
- }
- AnimationTree *graph_player = AnimationTreeEditor::get_singleton()->get_tree();
- AnimationPlayer *player = nullptr;
- if (graph_player->has_node(graph_player->get_animation_player())) {
- player = Object::cast_to<AnimationPlayer>(graph_player->get_node(graph_player->get_animation_player()));
- }
+ List<AnimationNodeBlendTree::NodeConnection> conns;
+ blend_tree->get_node_connections(&conns);
+ for (const AnimationNodeBlendTree::NodeConnection &E : conns) {
+ float activity = 0;
+ StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E.input_node;
+ if (AnimationTreeEditor::get_singleton()->get_tree() && !AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) {
+ activity = AnimationTreeEditor::get_singleton()->get_tree()->get_connection_activity(path, E.input_index);
+ }
+ graph->set_connection_activity(E.output_node, 0, E.input_node, E.input_index, activity);
+ }
- if (player) {
- for (const KeyValue<StringName, ProgressBar *> &E : animations) {
- Ref<AnimationNodeAnimation> an = blend_tree->get_node(E.key);
- if (an.is_valid()) {
- if (player->has_animation(an->get_animation())) {
- Ref<Animation> anim = player->get_animation(an->get_animation());
- if (anim.is_valid()) {
- E.value->set_max(anim->get_length());
- //StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E.input_node;
- StringName time_path = AnimationTreeEditor::get_singleton()->get_base_path() + String(E.key) + "/time";
- E.value->set_value(AnimationTreeEditor::get_singleton()->get_tree()->get(time_path));
+ AnimationTree *graph_player = AnimationTreeEditor::get_singleton()->get_tree();
+ AnimationPlayer *player = nullptr;
+ if (graph_player->has_node(graph_player->get_animation_player())) {
+ player = Object::cast_to<AnimationPlayer>(graph_player->get_node(graph_player->get_animation_player()));
+ }
+
+ if (player) {
+ for (const KeyValue<StringName, ProgressBar *> &E : animations) {
+ Ref<AnimationNodeAnimation> an = blend_tree->get_node(E.key);
+ if (an.is_valid()) {
+ if (player->has_animation(an->get_animation())) {
+ Ref<Animation> anim = player->get_animation(an->get_animation());
+ if (anim.is_valid()) {
+ E.value->set_max(anim->get_length());
+ //StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E.input_node;
+ StringName time_path = AnimationTreeEditor::get_singleton()->get_base_path() + String(E.key) + "/time";
+ E.value->set_value(AnimationTreeEditor::get_singleton()->get_tree()->get(time_path));
+ }
}
}
}
}
- }
- for (int i = 0; i < visible_properties.size(); i++) {
- visible_properties[i]->update_property();
- }
- }
+ for (int i = 0; i < visible_properties.size(); i++) {
+ visible_properties[i]->update_property();
+ }
+ } break;
- if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- set_process(is_visible_in_tree());
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ set_process(is_visible_in_tree());
+ } break;
}
}
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.h b/editor/plugins/animation_blend_tree_editor_plugin.h
index b1b905a3f5..c111f9245e 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.h
+++ b/editor/plugins/animation_blend_tree_editor_plugin.h
@@ -119,6 +119,9 @@ class AnimationNodeBlendTreeEditor : public AnimationTreeNodeEditorPlugin {
void _property_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing);
void _removed_from_graph();
+ void _update_editor_settings();
+ void _update_theme();
+
EditorFileDialog *open_file;
Ref<AnimationNode> file_loaded;
void _file_opened(const String &p_file);
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index 28b1126102..ad126d28f6 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) {
last_active = player->is_playing();
updating = false;
} break;
+
case NOTIFICATION_ENTER_TREE: {
tool_anim->get_popup()->connect("id_pressed", callable_mp(this, &AnimationPlayerEditor::_animation_tool_menu));
@@ -105,9 +106,11 @@ void AnimationPlayerEditor::_notification(int p_what) {
add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("panel"), SNAME("Panel")));
} break;
+
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("panel"), SNAME("Panel")));
} break;
+
case NOTIFICATION_TRANSLATION_CHANGED:
case NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
case NOTIFICATION_THEME_CHANGED: {
diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp
index 5e32c77511..6c284f2268 100644
--- a/editor/plugins/animation_state_machine_editor.cpp
+++ b/editor/plugins/animation_state_machine_editor.cpp
@@ -884,169 +884,174 @@ void AnimationNodeStateMachineEditor::_update_graph() {
}
void AnimationNodeStateMachineEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_LAYOUT_DIRECTION_CHANGED || p_what == NOTIFICATION_TRANSLATION_CHANGED) {
- error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
- error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
- panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
-
- tool_select->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons")));
- tool_create->set_icon(get_theme_icon(SNAME("ToolAddNode"), SNAME("EditorIcons")));
- tool_connect->set_icon(get_theme_icon(SNAME("ToolConnect"), SNAME("EditorIcons")));
-
- transition_mode->clear();
- transition_mode->add_icon_item(get_theme_icon(SNAME("TransitionImmediate"), SNAME("EditorIcons")), TTR("Immediate"));
- transition_mode->add_icon_item(get_theme_icon(SNAME("TransitionSync"), SNAME("EditorIcons")), TTR("Sync"));
- transition_mode->add_icon_item(get_theme_icon(SNAME("TransitionEnd"), SNAME("EditorIcons")), TTR("At End"));
-
- tool_erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
- tool_autoplay->set_icon(get_theme_icon(SNAME("AutoPlay"), SNAME("EditorIcons")));
- tool_end->set_icon(get_theme_icon(SNAME("AutoEnd"), SNAME("EditorIcons")));
-
- play_mode->clear();
- play_mode->add_icon_item(get_theme_icon(SNAME("PlayTravel"), SNAME("EditorIcons")), TTR("Travel"));
- play_mode->add_icon_item(get_theme_icon(SNAME("Play"), SNAME("EditorIcons")), TTR("Immediate"));
- }
-
- if (p_what == NOTIFICATION_PROCESS) {
- String error;
-
- Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback");
-
- if (error_time > 0) {
- error = error_text;
- error_time -= get_process_delta_time();
- } else if (!AnimationTreeEditor::get_singleton()->get_tree()->is_active()) {
- error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails.");
- } else if (AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) {
- error = AnimationTreeEditor::get_singleton()->get_tree()->get_invalid_state_reason();
- /*} else if (state_machine->get_parent().is_valid() && state_machine->get_parent()->is_class("AnimationNodeStateMachine")) {
- if (state_machine->get_start_node() == StringName() || state_machine->get_end_node() == StringName()) {
- error = TTR("Start and end nodes are needed for a sub-transition.");
- }*/
- } else if (playback.is_null()) {
- error = vformat(TTR("No playback resource set at path: %s."), AnimationTreeEditor::get_singleton()->get_base_path() + "playback");
- }
-
- if (error != error_label->get_text()) {
- error_label->set_text(error);
- if (!error.is_empty()) {
- error_panel->show();
- } else {
- error_panel->hide();
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED:
+ case NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
+ case NOTIFICATION_TRANSLATION_CHANGED: {
+ error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
+ error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
+
+ tool_select->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons")));
+ tool_create->set_icon(get_theme_icon(SNAME("ToolAddNode"), SNAME("EditorIcons")));
+ tool_connect->set_icon(get_theme_icon(SNAME("ToolConnect"), SNAME("EditorIcons")));
+
+ transition_mode->clear();
+ transition_mode->add_icon_item(get_theme_icon(SNAME("TransitionImmediate"), SNAME("EditorIcons")), TTR("Immediate"));
+ transition_mode->add_icon_item(get_theme_icon(SNAME("TransitionSync"), SNAME("EditorIcons")), TTR("Sync"));
+ transition_mode->add_icon_item(get_theme_icon(SNAME("TransitionEnd"), SNAME("EditorIcons")), TTR("At End"));
+
+ tool_erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
+ tool_autoplay->set_icon(get_theme_icon(SNAME("AutoPlay"), SNAME("EditorIcons")));
+ tool_end->set_icon(get_theme_icon(SNAME("AutoEnd"), SNAME("EditorIcons")));
+
+ play_mode->clear();
+ play_mode->add_icon_item(get_theme_icon(SNAME("PlayTravel"), SNAME("EditorIcons")), TTR("Travel"));
+ play_mode->add_icon_item(get_theme_icon(SNAME("Play"), SNAME("EditorIcons")), TTR("Immediate"));
+ } break;
+
+ case NOTIFICATION_PROCESS: {
+ String error;
+
+ Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback");
+
+ if (error_time > 0) {
+ error = error_text;
+ error_time -= get_process_delta_time();
+ } else if (!AnimationTreeEditor::get_singleton()->get_tree()->is_active()) {
+ error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails.");
+ } else if (AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) {
+ error = AnimationTreeEditor::get_singleton()->get_tree()->get_invalid_state_reason();
+ /*} else if (state_machine->get_parent().is_valid() && state_machine->get_parent()->is_class("AnimationNodeStateMachine")) {
+ if (state_machine->get_start_node() == StringName() || state_machine->get_end_node() == StringName()) {
+ error = TTR("Start and end nodes are needed for a sub-transition.");
+ }*/
+ } else if (playback.is_null()) {
+ error = vformat(TTR("No playback resource set at path: %s."), AnimationTreeEditor::get_singleton()->get_base_path() + "playback");
}
- }
- for (int i = 0; i < transition_lines.size(); i++) {
- int tidx = -1;
- for (int j = 0; j < state_machine->get_transition_count(); j++) {
- if (transition_lines[i].from_node == state_machine->get_transition_from(j) && transition_lines[i].to_node == state_machine->get_transition_to(j)) {
- tidx = j;
- break;
+ if (error != error_label->get_text()) {
+ error_label->set_text(error);
+ if (!error.is_empty()) {
+ error_panel->show();
+ } else {
+ error_panel->hide();
}
}
- if (tidx == -1) { //missing transition, should redraw
- state_machine_draw->update();
- break;
- }
+ for (int i = 0; i < transition_lines.size(); i++) {
+ int tidx = -1;
+ for (int j = 0; j < state_machine->get_transition_count(); j++) {
+ if (transition_lines[i].from_node == state_machine->get_transition_from(j) && transition_lines[i].to_node == state_machine->get_transition_to(j)) {
+ tidx = j;
+ break;
+ }
+ }
- if (transition_lines[i].disabled != state_machine->get_transition(tidx)->is_disabled()) {
- state_machine_draw->update();
- break;
- }
+ if (tidx == -1) { //missing transition, should redraw
+ state_machine_draw->update();
+ break;
+ }
- if (transition_lines[i].auto_advance != state_machine->get_transition(tidx)->has_auto_advance()) {
- state_machine_draw->update();
- break;
- }
+ if (transition_lines[i].disabled != state_machine->get_transition(tidx)->is_disabled()) {
+ state_machine_draw->update();
+ break;
+ }
- if (transition_lines[i].advance_condition_name != state_machine->get_transition(tidx)->get_advance_condition_name()) {
- state_machine_draw->update();
- break;
- }
+ if (transition_lines[i].auto_advance != state_machine->get_transition(tidx)->has_auto_advance()) {
+ state_machine_draw->update();
+ break;
+ }
- if (transition_lines[i].mode != state_machine->get_transition(tidx)->get_switch_mode()) {
- state_machine_draw->update();
- break;
- }
+ if (transition_lines[i].advance_condition_name != state_machine->get_transition(tidx)->get_advance_condition_name()) {
+ state_machine_draw->update();
+ break;
+ }
- bool acstate = transition_lines[i].advance_condition_name != StringName() && bool(AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + String(transition_lines[i].advance_condition_name)));
+ if (transition_lines[i].mode != state_machine->get_transition(tidx)->get_switch_mode()) {
+ state_machine_draw->update();
+ break;
+ }
- if (transition_lines[i].advance_condition_state != acstate) {
- state_machine_draw->update();
- break;
+ bool acstate = transition_lines[i].advance_condition_name != StringName() && bool(AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + String(transition_lines[i].advance_condition_name)));
+
+ if (transition_lines[i].advance_condition_state != acstate) {
+ state_machine_draw->update();
+ break;
+ }
}
- }
- bool same_travel_path = true;
- Vector<StringName> tp;
- bool is_playing = false;
- StringName current_node;
- StringName blend_from_node;
- play_pos = 0;
- current_length = 0;
-
- if (playback.is_valid()) {
- tp = playback->get_travel_path();
- is_playing = playback->is_playing();
- current_node = playback->get_current_node();
- blend_from_node = playback->get_blend_from_node();
- play_pos = playback->get_current_play_pos();
- current_length = playback->get_current_length();
- }
+ bool same_travel_path = true;
+ Vector<StringName> tp;
+ bool is_playing = false;
+ StringName current_node;
+ StringName blend_from_node;
+ play_pos = 0;
+ current_length = 0;
+
+ if (playback.is_valid()) {
+ tp = playback->get_travel_path();
+ is_playing = playback->is_playing();
+ current_node = playback->get_current_node();
+ blend_from_node = playback->get_blend_from_node();
+ play_pos = playback->get_current_play_pos();
+ current_length = playback->get_current_length();
+ }
- {
- if (last_travel_path.size() != tp.size()) {
- same_travel_path = false;
- } else {
- for (int i = 0; i < last_travel_path.size(); i++) {
- if (last_travel_path[i] != tp[i]) {
- same_travel_path = false;
- break;
+ {
+ if (last_travel_path.size() != tp.size()) {
+ same_travel_path = false;
+ } else {
+ for (int i = 0; i < last_travel_path.size(); i++) {
+ if (last_travel_path[i] != tp[i]) {
+ same_travel_path = false;
+ break;
+ }
}
}
}
- }
- //update if travel state changed
- if (!same_travel_path || last_active != is_playing || last_current_node != current_node || last_blend_from_node != blend_from_node) {
- state_machine_draw->update();
- last_travel_path = tp;
- last_current_node = current_node;
- last_active = is_playing;
- last_blend_from_node = blend_from_node;
- state_machine_play_pos->update();
- }
+ //update if travel state changed
+ if (!same_travel_path || last_active != is_playing || last_current_node != current_node || last_blend_from_node != blend_from_node) {
+ state_machine_draw->update();
+ last_travel_path = tp;
+ last_current_node = current_node;
+ last_active = is_playing;
+ last_blend_from_node = blend_from_node;
+ state_machine_play_pos->update();
+ }
- {
- if (current_node != StringName() && state_machine->has_node(current_node)) {
- String next = current_node;
- Ref<AnimationNodeStateMachine> anodesm = state_machine->get_node(next);
- Ref<AnimationNodeStateMachinePlayback> current_node_playback;
-
- while (anodesm.is_valid()) {
- current_node_playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + next + "/playback");
- next += "/" + current_node_playback->get_current_node();
- anodesm = anodesm->get_node(current_node_playback->get_current_node());
- }
+ {
+ if (current_node != StringName() && state_machine->has_node(current_node)) {
+ String next = current_node;
+ Ref<AnimationNodeStateMachine> anodesm = state_machine->get_node(next);
+ Ref<AnimationNodeStateMachinePlayback> current_node_playback;
- // when current_node is a state machine, use playback of current_node to set play_pos
- if (current_node_playback.is_valid()) {
- play_pos = current_node_playback->get_current_play_pos();
- current_length = current_node_playback->get_current_length();
+ while (anodesm.is_valid()) {
+ current_node_playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + next + "/playback");
+ next += "/" + current_node_playback->get_current_node();
+ anodesm = anodesm->get_node(current_node_playback->get_current_node());
+ }
+
+ // when current_node is a state machine, use playback of current_node to set play_pos
+ if (current_node_playback.is_valid()) {
+ play_pos = current_node_playback->get_current_play_pos();
+ current_length = current_node_playback->get_current_length();
+ }
}
}
- }
- if (last_play_pos != play_pos) {
- last_play_pos = play_pos;
- state_machine_play_pos->update();
- }
- }
+ if (last_play_pos != play_pos) {
+ last_play_pos = play_pos;
+ state_machine_play_pos->update();
+ }
+ } break;
- if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- over_node = StringName();
- set_process(is_visible_in_tree());
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ over_node = StringName();
+ set_process(is_visible_in_tree());
+ } break;
}
}
diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp
index f7057f375e..7ea6906d72 100644
--- a/editor/plugins/animation_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_tree_editor_plugin.cpp
@@ -145,19 +145,21 @@ void AnimationTreeEditor::enter_editor(const String &p_path) {
}
void AnimationTreeEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_PROCESS) {
- ObjectID root;
- if (tree && tree->get_tree_root().is_valid()) {
- root = tree->get_tree_root()->get_instance_id();
- }
+ switch (p_what) {
+ case NOTIFICATION_PROCESS: {
+ ObjectID root;
+ if (tree && tree->get_tree_root().is_valid()) {
+ root = tree->get_tree_root()->get_instance_id();
+ }
- if (root != current_root) {
- edit_path(Vector<String>());
- }
+ if (root != current_root) {
+ edit_path(Vector<String>());
+ }
- if (button_path.size() != edited_path.size()) {
- edit_path(edited_path);
- }
+ if (button_path.size() != edited_path.size()) {
+ edit_path(edited_path);
+ }
+ } break;
}
}
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index 7ab9fa05f7..9e9915cfa4 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -68,11 +68,13 @@ void EditorAssetLibraryItem::set_image(int p_type, int p_index, const Ref<Textur
}
void EditorAssetLibraryItem::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE) {
- icon->set_normal_texture(get_theme_icon(SNAME("ProjectIconLoading"), SNAME("EditorIcons")));
- category->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5));
- author->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5));
- price->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5));
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ icon->set_normal_texture(get_theme_icon(SNAME("ProjectIconLoading"), SNAME("EditorIcons")));
+ category->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5));
+ author->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5));
+ price->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5));
+ } break;
}
}
@@ -406,6 +408,7 @@ void EditorAssetLibraryItemDownload::_notification(int p_what) {
status->add_theme_color_override("font_color", get_theme_color(SNAME("status_color"), SNAME("AssetLib")));
dismiss_button->set_normal_texture(get_theme_icon(SNAME("dismiss"), SNAME("AssetLib")));
} break;
+
case NOTIFICATION_PROCESS: {
// Make the progress bar visible again when retrying the download.
progress->set_modulate(Color(1, 1, 1, 1));
@@ -576,6 +579,7 @@ void EditorAssetLibrary::_notification(int p_what) {
case NOTIFICATION_READY: {
error_label->raise();
} break;
+
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
error_tr->set_texture(get_theme_icon(SNAME("Error"), SNAME("EditorIcons")));
@@ -584,6 +588,7 @@ void EditorAssetLibrary::_notification(int p_what) {
downloads_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
error_label->add_theme_color_override("color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
} break;
+
case NOTIFICATION_VISIBILITY_CHANGED: {
if (is_visible()) {
// Focus the search box automatically when switching to the Templates tab (in the Project Manager)
@@ -596,6 +601,7 @@ void EditorAssetLibrary::_notification(int p_what) {
}
}
} break;
+
case NOTIFICATION_PROCESS: {
HTTPClient::Status s = request->get_http_client_status();
const bool loading = s != HTTPClient::STATUS_DISCONNECTED;
@@ -612,6 +618,7 @@ void EditorAssetLibrary::_notification(int p_what) {
}
} break;
+
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
_update_repository_options();
setup_http_request(request);
diff --git a/editor/plugins/audio_stream_editor_plugin.cpp b/editor/plugins/audio_stream_editor_plugin.cpp
index c77ff5778a..a60e49ca9d 100644
--- a/editor/plugins/audio_stream_editor_plugin.cpp
+++ b/editor/plugins/audio_stream_editor_plugin.cpp
@@ -39,29 +39,32 @@
#include "editor/editor_settings.h"
void AudioStreamEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_READY) {
- AudioStreamPreviewGenerator::get_singleton()->connect("preview_updated", callable_mp(this, &AudioStreamEditor::_preview_changed));
- }
-
- if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) {
- _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons")));
- _stop_button->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons")));
- _preview->set_color(get_theme_color(SNAME("dark_color_2"), SNAME("Editor")));
- set_color(get_theme_color(SNAME("dark_color_1"), SNAME("Editor")));
-
- _indicator->update();
- _preview->update();
- }
-
- if (p_what == NOTIFICATION_PROCESS) {
- _current = _player->get_playback_position();
- _indicator->update();
- }
-
- if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- if (!is_visible_in_tree()) {
- _stop();
- }
+ switch (p_what) {
+ case NOTIFICATION_READY: {
+ AudioStreamPreviewGenerator::get_singleton()->connect("preview_updated", callable_mp(this, &AudioStreamEditor::_preview_changed));
+ } break;
+
+ case NOTIFICATION_THEME_CHANGED:
+ case NOTIFICATION_ENTER_TREE: {
+ _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons")));
+ _stop_button->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons")));
+ _preview->set_color(get_theme_color(SNAME("dark_color_2"), SNAME("Editor")));
+ set_color(get_theme_color(SNAME("dark_color_1"), SNAME("Editor")));
+
+ _indicator->update();
+ _preview->update();
+ } break;
+
+ case NOTIFICATION_PROCESS: {
+ _current = _player->get_playback_position();
+ _indicator->update();
+ } break;
+
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ if (!is_visible_in_tree()) {
+ _stop();
+ }
+ } break;
}
}
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 06ca89da51..76558eb946 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -3694,149 +3694,154 @@ void CanvasItemEditor::set_current_tool(Tool p_tool) {
_button_tool_select(p_tool);
}
+void CanvasItemEditor::_update_editor_settings() {
+ select_button->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons")));
+ list_select_button->set_icon(get_theme_icon(SNAME("ListSelect"), SNAME("EditorIcons")));
+ move_button->set_icon(get_theme_icon(SNAME("ToolMove"), SNAME("EditorIcons")));
+ scale_button->set_icon(get_theme_icon(SNAME("ToolScale"), SNAME("EditorIcons")));
+ rotate_button->set_icon(get_theme_icon(SNAME("ToolRotate"), SNAME("EditorIcons")));
+ smart_snap_button->set_icon(get_theme_icon(SNAME("Snap"), SNAME("EditorIcons")));
+ grid_snap_button->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons")));
+ snap_config_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons")));
+ skeleton_menu->set_icon(get_theme_icon(SNAME("Bone"), SNAME("EditorIcons")));
+ override_camera_button->set_icon(get_theme_icon(SNAME("Camera2D"), SNAME("EditorIcons")));
+ pan_button->set_icon(get_theme_icon(SNAME("ToolPan"), SNAME("EditorIcons")));
+ ruler_button->set_icon(get_theme_icon(SNAME("Ruler"), SNAME("EditorIcons")));
+ pivot_button->set_icon(get_theme_icon(SNAME("EditPivot"), SNAME("EditorIcons")));
+ select_handle = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons"));
+ anchor_handle = get_theme_icon(SNAME("EditorControlAnchor"), SNAME("EditorIcons"));
+ lock_button->set_icon(get_theme_icon(SNAME("Lock"), SNAME("EditorIcons")));
+ unlock_button->set_icon(get_theme_icon(SNAME("Unlock"), SNAME("EditorIcons")));
+ group_button->set_icon(get_theme_icon(SNAME("Group"), SNAME("EditorIcons")));
+ ungroup_button->set_icon(get_theme_icon(SNAME("Ungroup"), SNAME("EditorIcons")));
+ key_loc_button->set_icon(get_theme_icon(SNAME("KeyPosition"), SNAME("EditorIcons")));
+ key_rot_button->set_icon(get_theme_icon(SNAME("KeyRotation"), SNAME("EditorIcons")));
+ key_scale_button->set_icon(get_theme_icon(SNAME("KeyScale"), SNAME("EditorIcons")));
+ key_insert_button->set_icon(get_theme_icon(SNAME("Key"), SNAME("EditorIcons")));
+ key_auto_insert_button->set_icon(get_theme_icon(SNAME("AutoKey"), SNAME("EditorIcons")));
+ // Use a different color for the active autokey icon to make them easier
+ // to distinguish from the other key icons at the top. On a light theme,
+ // the icon will be dark, so we need to lighten it before blending it
+ // with the red color.
+ const Color key_auto_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25);
+ key_auto_insert_button->add_theme_color_override("icon_pressed_color", key_auto_color.lerp(Color(1, 0, 0), 0.55));
+ animation_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons")));
+
+ _update_context_menu_stylebox();
+
+ panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/2d_editor_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning")));
+ pan_speed = int(EditorSettings::get_singleton()->get("editors/panning/2d_editor_pan_speed"));
+ warped_panning = bool(EditorSettings::get_singleton()->get("editors/panning/warped_mouse_panning"));
+}
+
void CanvasItemEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_PHYSICS_PROCESS) {
- EditorNode::get_singleton()->get_scene_root()->set_snap_controls_to_pixels(GLOBAL_GET("gui/common/snap_controls_to_pixels"));
+ switch (p_what) {
+ case NOTIFICATION_PHYSICS_PROCESS: {
+ EditorNode::get_singleton()->get_scene_root()->set_snap_controls_to_pixels(GLOBAL_GET("gui/common/snap_controls_to_pixels"));
- int nb_having_pivot = 0;
+ int nb_having_pivot = 0;
- // Update the viewport if the canvas_item changes
- List<CanvasItem *> selection = _get_edited_canvas_items(true);
- for (CanvasItem *canvas_item : selection) {
- CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
+ // Update the viewport if the canvas_item changes
+ List<CanvasItem *> selection = _get_edited_canvas_items(true);
+ for (CanvasItem *canvas_item : selection) {
+ CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
- Rect2 rect;
- if (canvas_item->_edit_use_rect()) {
- rect = canvas_item->_edit_get_rect();
- } else {
- rect = Rect2();
- }
- Transform2D xform = canvas_item->get_transform();
+ Rect2 rect;
+ if (canvas_item->_edit_use_rect()) {
+ rect = canvas_item->_edit_get_rect();
+ } else {
+ rect = Rect2();
+ }
+ Transform2D xform = canvas_item->get_transform();
- if (rect != se->prev_rect || xform != se->prev_xform) {
- viewport->update();
- se->prev_rect = rect;
- se->prev_xform = xform;
+ if (rect != se->prev_rect || xform != se->prev_xform) {
+ viewport->update();
+ se->prev_rect = rect;
+ se->prev_xform = xform;
+ }
+
+ Control *control = Object::cast_to<Control>(canvas_item);
+ if (control) {
+ real_t anchors[4];
+ Vector2 pivot;
+
+ pivot = control->get_pivot_offset();
+ anchors[SIDE_LEFT] = control->get_anchor(SIDE_LEFT);
+ anchors[SIDE_RIGHT] = control->get_anchor(SIDE_RIGHT);
+ anchors[SIDE_TOP] = control->get_anchor(SIDE_TOP);
+ anchors[SIDE_BOTTOM] = control->get_anchor(SIDE_BOTTOM);
+
+ if (pivot != se->prev_pivot || anchors[SIDE_LEFT] != se->prev_anchors[SIDE_LEFT] || anchors[SIDE_RIGHT] != se->prev_anchors[SIDE_RIGHT] || anchors[SIDE_TOP] != se->prev_anchors[SIDE_TOP] || anchors[SIDE_BOTTOM] != se->prev_anchors[SIDE_BOTTOM]) {
+ se->prev_pivot = pivot;
+ se->prev_anchors[SIDE_LEFT] = anchors[SIDE_LEFT];
+ se->prev_anchors[SIDE_RIGHT] = anchors[SIDE_RIGHT];
+ se->prev_anchors[SIDE_TOP] = anchors[SIDE_TOP];
+ se->prev_anchors[SIDE_BOTTOM] = anchors[SIDE_BOTTOM];
+ viewport->update();
+ }
+ }
+
+ if (canvas_item->_edit_use_pivot()) {
+ nb_having_pivot++;
+ }
}
- Control *control = Object::cast_to<Control>(canvas_item);
- if (control) {
- real_t anchors[4];
- Vector2 pivot;
-
- pivot = control->get_pivot_offset();
- anchors[SIDE_LEFT] = control->get_anchor(SIDE_LEFT);
- anchors[SIDE_RIGHT] = control->get_anchor(SIDE_RIGHT);
- anchors[SIDE_TOP] = control->get_anchor(SIDE_TOP);
- anchors[SIDE_BOTTOM] = control->get_anchor(SIDE_BOTTOM);
-
- if (pivot != se->prev_pivot || anchors[SIDE_LEFT] != se->prev_anchors[SIDE_LEFT] || anchors[SIDE_RIGHT] != se->prev_anchors[SIDE_RIGHT] || anchors[SIDE_TOP] != se->prev_anchors[SIDE_TOP] || anchors[SIDE_BOTTOM] != se->prev_anchors[SIDE_BOTTOM]) {
- se->prev_pivot = pivot;
- se->prev_anchors[SIDE_LEFT] = anchors[SIDE_LEFT];
- se->prev_anchors[SIDE_RIGHT] = anchors[SIDE_RIGHT];
- se->prev_anchors[SIDE_TOP] = anchors[SIDE_TOP];
- se->prev_anchors[SIDE_BOTTOM] = anchors[SIDE_BOTTOM];
+ // Activate / Deactivate the pivot tool
+ pivot_button->set_disabled(nb_having_pivot == 0);
+
+ // Update the viewport if bones changes
+ for (KeyValue<BoneKey, BoneList> &E : bone_list) {
+ Object *b = ObjectDB::get_instance(E.key.from);
+ if (!b) {
viewport->update();
+ break;
}
- }
- if (canvas_item->_edit_use_pivot()) {
- nb_having_pivot++;
- }
- }
+ Node2D *b2 = Object::cast_to<Node2D>(b);
+ if (!b2 || !b2->is_inside_tree()) {
+ continue;
+ }
- // Activate / Deactivate the pivot tool
- pivot_button->set_disabled(nb_having_pivot == 0);
+ Transform2D global_xform = b2->get_global_transform();
- // Update the viewport if bones changes
- for (KeyValue<BoneKey, BoneList> &E : bone_list) {
- Object *b = ObjectDB::get_instance(E.key.from);
- if (!b) {
- viewport->update();
- break;
+ if (global_xform != E.value.xform) {
+ E.value.xform = global_xform;
+ viewport->update();
+ }
+
+ Bone2D *bone = Object::cast_to<Bone2D>(b);
+ if (bone && bone->get_length() != E.value.length) {
+ E.value.length = bone->get_length();
+ viewport->update();
+ }
}
+ } break;
- Node2D *b2 = Object::cast_to<Node2D>(b);
- if (!b2 || !b2->is_inside_tree()) {
- continue;
+ case NOTIFICATION_ENTER_TREE: {
+ select_sb->set_texture(get_theme_icon(SNAME("EditorRect2D"), SNAME("EditorIcons")));
+ for (int i = 0; i < 4; i++) {
+ select_sb->set_margin_size(Side(i), 4);
+ select_sb->set_default_margin(Side(i), 4);
}
- Transform2D global_xform = b2->get_global_transform();
+ AnimationPlayerEditor::get_singleton()->get_track_editor()->connect("visibility_changed", callable_mp(this, &CanvasItemEditor::_keying_changed));
+ _keying_changed();
+ _update_editor_settings();
+ } break;
- if (global_xform != E.value.xform) {
- E.value.xform = global_xform;
- viewport->update();
- }
+ case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
+ select_sb->set_texture(get_theme_icon(SNAME("EditorRect2D"), SNAME("EditorIcons")));
+ _update_editor_settings();
+ } break;
- Bone2D *bone = Object::cast_to<Bone2D>(b);
- if (bone && bone->get_length() != E.value.length) {
- E.value.length = bone->get_length();
- viewport->update();
- }
- }
- }
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ if (!is_visible() && override_camera_button->is_pressed()) {
+ EditorDebuggerNode *debugger = EditorDebuggerNode::get_singleton();
- if (p_what == NOTIFICATION_ENTER_TREE) {
- select_sb->set_texture(get_theme_icon(SNAME("EditorRect2D"), SNAME("EditorIcons")));
- for (int i = 0; i < 4; i++) {
- select_sb->set_margin_size(Side(i), 4);
- select_sb->set_default_margin(Side(i), 4);
- }
-
- AnimationPlayerEditor::get_singleton()->get_track_editor()->connect("visibility_changed", callable_mp(this, &CanvasItemEditor::_keying_changed));
- _keying_changed();
-
- } else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
- select_sb->set_texture(get_theme_icon(SNAME("EditorRect2D"), SNAME("EditorIcons")));
- }
-
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
- select_button->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons")));
- list_select_button->set_icon(get_theme_icon(SNAME("ListSelect"), SNAME("EditorIcons")));
- move_button->set_icon(get_theme_icon(SNAME("ToolMove"), SNAME("EditorIcons")));
- scale_button->set_icon(get_theme_icon(SNAME("ToolScale"), SNAME("EditorIcons")));
- rotate_button->set_icon(get_theme_icon(SNAME("ToolRotate"), SNAME("EditorIcons")));
- smart_snap_button->set_icon(get_theme_icon(SNAME("Snap"), SNAME("EditorIcons")));
- grid_snap_button->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons")));
- snap_config_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons")));
- skeleton_menu->set_icon(get_theme_icon(SNAME("Bone"), SNAME("EditorIcons")));
- override_camera_button->set_icon(get_theme_icon(SNAME("Camera2D"), SNAME("EditorIcons")));
- pan_button->set_icon(get_theme_icon(SNAME("ToolPan"), SNAME("EditorIcons")));
- ruler_button->set_icon(get_theme_icon(SNAME("Ruler"), SNAME("EditorIcons")));
- pivot_button->set_icon(get_theme_icon(SNAME("EditPivot"), SNAME("EditorIcons")));
- select_handle = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons"));
- anchor_handle = get_theme_icon(SNAME("EditorControlAnchor"), SNAME("EditorIcons"));
- lock_button->set_icon(get_theme_icon(SNAME("Lock"), SNAME("EditorIcons")));
- unlock_button->set_icon(get_theme_icon(SNAME("Unlock"), SNAME("EditorIcons")));
- group_button->set_icon(get_theme_icon(SNAME("Group"), SNAME("EditorIcons")));
- ungroup_button->set_icon(get_theme_icon(SNAME("Ungroup"), SNAME("EditorIcons")));
- key_loc_button->set_icon(get_theme_icon(SNAME("KeyPosition"), SNAME("EditorIcons")));
- key_rot_button->set_icon(get_theme_icon(SNAME("KeyRotation"), SNAME("EditorIcons")));
- key_scale_button->set_icon(get_theme_icon(SNAME("KeyScale"), SNAME("EditorIcons")));
- key_insert_button->set_icon(get_theme_icon(SNAME("Key"), SNAME("EditorIcons")));
- key_auto_insert_button->set_icon(get_theme_icon(SNAME("AutoKey"), SNAME("EditorIcons")));
- // Use a different color for the active autokey icon to make them easier
- // to distinguish from the other key icons at the top. On a light theme,
- // the icon will be dark, so we need to lighten it before blending it
- // with the red color.
- const Color key_auto_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25);
- key_auto_insert_button->add_theme_color_override("icon_pressed_color", key_auto_color.lerp(Color(1, 0, 0), 0.55));
- animation_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons")));
-
- _update_context_menu_stylebox();
-
- panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/2d_editor_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning")));
- pan_speed = int(EditorSettings::get_singleton()->get("editors/panning/2d_editor_pan_speed"));
- warped_panning = bool(EditorSettings::get_singleton()->get("editors/panning/warped_mouse_panning"));
- }
-
- if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- if (!is_visible() && override_camera_button->is_pressed()) {
- EditorDebuggerNode *debugger = EditorDebuggerNode::get_singleton();
-
- debugger->set_camera_override(EditorDebuggerNode::OVERRIDE_NONE);
- override_camera_button->set_pressed(false);
- }
+ debugger->set_camera_override(EditorDebuggerNode::OVERRIDE_NONE);
+ override_camera_button->set_pressed(false);
+ }
+ } break;
}
}
@@ -5702,29 +5707,32 @@ Node *CanvasItemEditorViewport::_make_texture_node_type(String texture_node_type
return node;
}
-void CanvasItemEditorViewport::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- List<BaseButton *> btn_list;
- button_group->get_buttons(&btn_list);
-
- for (int i = 0; i < btn_list.size(); i++) {
- CheckBox *check = Object::cast_to<CheckBox>(btn_list[i]);
- check->set_icon(get_theme_icon(check->get_text(), SNAME("EditorIcons")));
- }
+void CanvasItemEditorViewport::_update_theme() {
+ List<BaseButton *> btn_list;
+ button_group->get_buttons(&btn_list);
- label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
+ for (int i = 0; i < btn_list.size(); i++) {
+ CheckBox *check = Object::cast_to<CheckBox>(btn_list[i]);
+ check->set_icon(get_theme_icon(check->get_text(), SNAME("EditorIcons")));
}
+ label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
+}
+
+void CanvasItemEditorViewport::_notification(int p_what) {
switch (p_what) {
+ case NOTIFICATION_THEME_CHANGED: {
+ _update_theme();
+ } break;
+
case NOTIFICATION_ENTER_TREE: {
+ _update_theme();
connect("mouse_exited", callable_mp(this, &CanvasItemEditorViewport::_on_mouse_exit));
} break;
+
case NOTIFICATION_EXIT_TREE: {
disconnect("mouse_exited", callable_mp(this, &CanvasItemEditorViewport::_on_mouse_exit));
} break;
-
- default:
- break;
}
}
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index 6c1b18acf4..57760475a1 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -389,6 +389,7 @@ private:
void _add_node_pressed(int p_result);
void _node_created(Node *p_node);
void _reset_create_position();
+ void _update_editor_settings();
UndoRedo *undo_redo;
@@ -607,6 +608,7 @@ class CanvasItemEditorViewport : public Control {
bool _create_instance(Node *parent, String &path, const Point2 &p_point);
void _perform_drop_data();
void _show_resource_type_selector();
+ void _update_theme();
static void _bind_methods();
diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.cpp b/editor/plugins/cpu_particles_2d_editor_plugin.cpp
index 786c0e002d..79025041d3 100644
--- a/editor/plugins/cpu_particles_2d_editor_plugin.cpp
+++ b/editor/plugins/cpu_particles_2d_editor_plugin.cpp
@@ -224,10 +224,12 @@ void CPUParticles2DEditorPlugin::_generate_emission_mask() {
}
void CPUParticles2DEditorPlugin::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE) {
- menu->get_popup()->connect("id_pressed", callable_mp(this, &CPUParticles2DEditorPlugin::_menu_callback));
- menu->set_icon(epoints->get_theme_icon(SNAME("CPUParticles2D"), SNAME("EditorIcons")));
- file->connect("file_selected", callable_mp(this, &CPUParticles2DEditorPlugin::_file_selected));
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ menu->get_popup()->connect("id_pressed", callable_mp(this, &CPUParticles2DEditorPlugin::_menu_callback));
+ menu->set_icon(epoints->get_theme_icon(SNAME("CPUParticles2D"), SNAME("EditorIcons")));
+ file->connect("file_selected", callable_mp(this, &CPUParticles2DEditorPlugin::_file_selected));
+ } break;
}
}
diff --git a/editor/plugins/cpu_particles_3d_editor_plugin.cpp b/editor/plugins/cpu_particles_3d_editor_plugin.cpp
index 046a48337a..775c2dbb2a 100644
--- a/editor/plugins/cpu_particles_3d_editor_plugin.cpp
+++ b/editor/plugins/cpu_particles_3d_editor_plugin.cpp
@@ -43,8 +43,10 @@ void CPUParticles3DEditor::_node_removed(Node *p_node) {
}
void CPUParticles3DEditor::_notification(int p_notification) {
- if (p_notification == NOTIFICATION_ENTER_TREE) {
- options->set_icon(get_theme_icon(SNAME("CPUParticles3D"), SNAME("EditorIcons")));
+ switch (p_notification) {
+ case NOTIFICATION_ENTER_TREE: {
+ options->set_icon(get_theme_icon(SNAME("CPUParticles3D"), SNAME("EditorIcons")));
+ } break;
}
}
diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp
index d221d8aeaf..6d1a86765a 100644
--- a/editor/plugins/curve_editor_plugin.cpp
+++ b/editor/plugins/curve_editor_plugin.cpp
@@ -97,8 +97,10 @@ Size2 CurveEditor::get_minimum_size() const {
}
void CurveEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_DRAW) {
- _draw();
+ switch (p_what) {
+ case NOTIFICATION_DRAW: {
+ _draw();
+ } break;
}
}
diff --git a/editor/plugins/debugger_editor_plugin.cpp b/editor/plugins/debugger_editor_plugin.cpp
index 32f58c6931..501becac57 100644
--- a/editor/plugins/debugger_editor_plugin.cpp
+++ b/editor/plugins/debugger_editor_plugin.cpp
@@ -177,8 +177,10 @@ void DebuggerEditorPlugin::_menu_option(int p_option) {
}
void DebuggerEditorPlugin::_notification(int p_what) {
- if (p_what == NOTIFICATION_READY) {
- _update_debug_options();
+ switch (p_what) {
+ case NOTIFICATION_READY: {
+ _update_debug_options();
+ } break;
}
}
diff --git a/editor/plugins/font_editor_plugin.cpp b/editor/plugins/font_editor_plugin.cpp
index e14304a2c8..b9de621bcb 100644
--- a/editor/plugins/font_editor_plugin.cpp
+++ b/editor/plugins/font_editor_plugin.cpp
@@ -33,14 +33,16 @@
#include "editor/editor_scale.h"
void FontDataPreview::_notification(int p_what) {
- if (p_what == NOTIFICATION_DRAW) {
- Color text_color = get_theme_color(SNAME("font_color"), SNAME("Label"));
- Color line_color = text_color;
- line_color.a *= 0.6;
- Vector2 pos = (get_size() - line->get_size()) / 2;
- line->draw(get_canvas_item(), pos, text_color);
- draw_line(Vector2(0, pos.y + line->get_line_ascent()), Vector2(pos.x - 5, pos.y + line->get_line_ascent()), line_color);
- draw_line(Vector2(pos.x + line->get_size().x + 5, pos.y + line->get_line_ascent()), Vector2(get_size().x, pos.y + line->get_line_ascent()), line_color);
+ switch (p_what) {
+ case NOTIFICATION_DRAW: {
+ Color text_color = get_theme_color(SNAME("font_color"), SNAME("Label"));
+ Color line_color = text_color;
+ line_color.a *= 0.6;
+ Vector2 pos = (get_size() - line->get_size()) / 2;
+ line->draw(get_canvas_item(), pos, text_color);
+ draw_line(Vector2(0, pos.y + line->get_line_ascent()), Vector2(pos.x - 5, pos.y + line->get_line_ascent()), line_color);
+ draw_line(Vector2(pos.x + line->get_size().x + 5, pos.y + line->get_line_ascent()), Vector2(get_size().x, pos.y + line->get_line_ascent()), line_color);
+ } break;
}
}
diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.cpp b/editor/plugins/gpu_particles_2d_editor_plugin.cpp
index fdfd4b5832..b15aec87d9 100644
--- a/editor/plugins/gpu_particles_2d_editor_plugin.cpp
+++ b/editor/plugins/gpu_particles_2d_editor_plugin.cpp
@@ -354,11 +354,13 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() {
}
void GPUParticles2DEditorPlugin::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE) {
- menu->get_popup()->connect("id_pressed", callable_mp(this, &GPUParticles2DEditorPlugin::_menu_callback));
- menu->set_icon(menu->get_theme_icon(SNAME("GPUParticles2D"), SNAME("EditorIcons")));
- file->connect("file_selected", callable_mp(this, &GPUParticles2DEditorPlugin::_file_selected));
- EditorNode::get_singleton()->get_editor_selection()->connect("selection_changed", callable_mp(this, &GPUParticles2DEditorPlugin::_selection_changed));
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ menu->get_popup()->connect("id_pressed", callable_mp(this, &GPUParticles2DEditorPlugin::_menu_callback));
+ menu->set_icon(menu->get_theme_icon(SNAME("GPUParticles2D"), SNAME("EditorIcons")));
+ file->connect("file_selected", callable_mp(this, &GPUParticles2DEditorPlugin::_file_selected));
+ EditorNode::get_singleton()->get_editor_selection()->connect("selection_changed", callable_mp(this, &GPUParticles2DEditorPlugin::_selection_changed));
+ } break;
}
}
diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.cpp b/editor/plugins/gpu_particles_3d_editor_plugin.cpp
index ec61c01705..293d1c3913 100644
--- a/editor/plugins/gpu_particles_3d_editor_plugin.cpp
+++ b/editor/plugins/gpu_particles_3d_editor_plugin.cpp
@@ -231,9 +231,11 @@ void GPUParticles3DEditor::_node_removed(Node *p_node) {
}
void GPUParticles3DEditor::_notification(int p_notification) {
- if (p_notification == NOTIFICATION_ENTER_TREE) {
- options->set_icon(options->get_popup()->get_theme_icon(SNAME("GPUParticles3D"), SNAME("EditorIcons")));
- get_tree()->connect("node_removed", callable_mp(this, &GPUParticles3DEditor::_node_removed));
+ switch (p_notification) {
+ case NOTIFICATION_ENTER_TREE: {
+ options->set_icon(options->get_popup()->get_theme_icon(SNAME("GPUParticles3D"), SNAME("EditorIcons")));
+ get_tree()->connect("node_removed", callable_mp(this, &GPUParticles3DEditor::_node_removed));
+ } break;
}
}
diff --git a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp
index f63a31e869..affe10a01d 100644
--- a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp
+++ b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp
@@ -66,41 +66,43 @@ bool GPUParticlesCollisionSDF3DEditorPlugin::handles(Object *p_object) const {
}
void GPUParticlesCollisionSDF3DEditorPlugin::_notification(int p_what) {
- if (p_what == NOTIFICATION_PROCESS) {
- if (!col_sdf) {
- return;
- }
+ switch (p_what) {
+ case NOTIFICATION_PROCESS: {
+ if (!col_sdf) {
+ return;
+ }
- // Set information tooltip on the Bake button. This information is useful
- // to optimize performance (video RAM size) and reduce collision tunneling (individual cell size).
+ // Set information tooltip on the Bake button. This information is useful
+ // to optimize performance (video RAM size) and reduce collision tunneling (individual cell size).
- const Vector3i size = col_sdf->get_estimated_cell_size();
+ const Vector3i size = col_sdf->get_estimated_cell_size();
- const Vector3 extents = col_sdf->get_extents();
+ const Vector3 extents = col_sdf->get_extents();
- int data_size = 2;
- const double size_mb = size.x * size.y * size.z * data_size / (1024.0 * 1024.0);
- // Add a qualitative measurement to help the user assess whether a GPUParticlesCollisionSDF3D node is using a lot of VRAM.
- String size_quality;
- if (size_mb < 8.0) {
- size_quality = TTR("Low");
- } else if (size_mb < 32.0) {
- size_quality = TTR("Moderate");
- } else {
- size_quality = TTR("High");
- }
+ int data_size = 2;
+ const double size_mb = size.x * size.y * size.z * data_size / (1024.0 * 1024.0);
+ // Add a qualitative measurement to help the user assess whether a GPUParticlesCollisionSDF3D node is using a lot of VRAM.
+ String size_quality;
+ if (size_mb < 8.0) {
+ size_quality = TTR("Low");
+ } else if (size_mb < 32.0) {
+ size_quality = TTR("Moderate");
+ } else {
+ size_quality = TTR("High");
+ }
- String text;
- text += vformat(TTR("Subdivisions: %s"), vformat(String::utf8("%d × %d × %d"), size.x, size.y, size.z)) + "\n";
- text += vformat(TTR("Cell size: %s"), vformat(String::utf8("%.3f × %.3f × %.3f"), extents.x / size.x, extents.y / size.y, extents.z / size.z)) + "\n";
- text += vformat(TTR("Video RAM size: %s MB (%s)"), String::num(size_mb, 2), size_quality);
+ String text;
+ text += vformat(TTR("Subdivisions: %s"), vformat(String::utf8("%d × %d × %d"), size.x, size.y, size.z)) + "\n";
+ text += vformat(TTR("Cell size: %s"), vformat(String::utf8("%.3f × %.3f × %.3f"), extents.x / size.x, extents.y / size.y, extents.z / size.z)) + "\n";
+ text += vformat(TTR("Video RAM size: %s MB (%s)"), String::num(size_mb, 2), size_quality);
- // Only update the tooltip when needed to avoid constant redrawing.
- if (bake->get_tooltip(Point2()) == text) {
- return;
- }
+ // Only update the tooltip when needed to avoid constant redrawing.
+ if (bake->get_tooltip(Point2()) == text) {
+ return;
+ }
- bake->set_tooltip(text);
+ bake->set_tooltip(text);
+ } break;
}
}
diff --git a/editor/plugins/gradient_editor_plugin.cpp b/editor/plugins/gradient_editor_plugin.cpp
index 3f5b687430..e9d7808684 100644
--- a/editor/plugins/gradient_editor_plugin.cpp
+++ b/editor/plugins/gradient_editor_plugin.cpp
@@ -91,13 +91,15 @@ GradientEditor::GradientEditor() {
///////////////////////
void GradientReverseButton::_notification(int p_what) {
- if (p_what == NOTIFICATION_DRAW) {
- Ref<Texture2D> icon = get_theme_icon(SNAME("ReverseGradient"), SNAME("EditorIcons"));
- if (is_pressed()) {
- draw_texture_rect(icon, Rect2(margin, margin, icon->get_width(), icon->get_height()), false, get_theme_color(SNAME("icon_pressed_color"), SNAME("Button")));
- } else {
- draw_texture_rect(icon, Rect2(margin, margin, icon->get_width(), icon->get_height()));
- }
+ switch (p_what) {
+ case NOTIFICATION_DRAW: {
+ Ref<Texture2D> icon = get_theme_icon(SNAME("ReverseGradient"), SNAME("EditorIcons"));
+ if (is_pressed()) {
+ draw_texture_rect(icon, Rect2(margin, margin, icon->get_width(), icon->get_height()), false, get_theme_color(SNAME("icon_pressed_color"), SNAME("Button")));
+ } else {
+ draw_texture_rect(icon, Rect2(margin, margin, icon->get_width(), icon->get_height()));
+ }
+ } break;
}
}
diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp
index f3759da47f..daa864cfa1 100644
--- a/editor/plugins/material_editor_plugin.cpp
+++ b/editor/plugins/material_editor_plugin.cpp
@@ -38,31 +38,33 @@
#include "scene/resources/sky_material.h"
void MaterialEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_READY) {
- //get_scene()->connect("node_removed",this,"_node_removed");
+ switch (p_what) {
+ case NOTIFICATION_READY: {
+ //get_scene()->connect("node_removed",this,"_node_removed");
- if (first_enter) {
- //it's in propertyeditor so.. could be moved around
+ if (first_enter) {
+ //it's in propertyeditor so.. could be moved around
- light_1_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight1"), SNAME("EditorIcons")));
- light_1_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight1Off"), SNAME("EditorIcons")));
- light_2_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight2"), SNAME("EditorIcons")));
- light_2_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight2Off"), SNAME("EditorIcons")));
+ light_1_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight1"), SNAME("EditorIcons")));
+ light_1_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight1Off"), SNAME("EditorIcons")));
+ light_2_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight2"), SNAME("EditorIcons")));
+ light_2_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight2Off"), SNAME("EditorIcons")));
- sphere_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewSphereOff"), SNAME("EditorIcons")));
- sphere_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewSphere"), SNAME("EditorIcons")));
- box_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewCubeOff"), SNAME("EditorIcons")));
- box_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewCube"), SNAME("EditorIcons")));
+ sphere_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewSphereOff"), SNAME("EditorIcons")));
+ sphere_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewSphere"), SNAME("EditorIcons")));
+ box_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewCubeOff"), SNAME("EditorIcons")));
+ box_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewCube"), SNAME("EditorIcons")));
- first_enter = false;
- }
- }
+ first_enter = false;
+ }
+ } break;
- if (p_what == NOTIFICATION_DRAW) {
- Ref<Texture2D> checkerboard = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons"));
- Size2 size = get_size();
+ case NOTIFICATION_DRAW: {
+ Ref<Texture2D> checkerboard = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons"));
+ Size2 size = get_size();
- draw_texture_rect(checkerboard, Rect2(Point2(), size), true);
+ draw_texture_rect(checkerboard, Rect2(Point2(), size), true);
+ } break;
}
}
diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp
index 8711559dbf..4760b61dc8 100644
--- a/editor/plugins/mesh_editor_plugin.cpp
+++ b/editor/plugins/mesh_editor_plugin.cpp
@@ -49,18 +49,20 @@ void MeshEditor::gui_input(const Ref<InputEvent> &p_event) {
}
void MeshEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_READY) {
- //get_scene()->connect("node_removed",this,"_node_removed");
-
- if (first_enter) {
- //it's in propertyeditor so. could be moved around
-
- light_1_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight1"), SNAME("EditorIcons")));
- light_1_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight1Off"), SNAME("EditorIcons")));
- light_2_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight2"), SNAME("EditorIcons")));
- light_2_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight2Off"), SNAME("EditorIcons")));
- first_enter = false;
- }
+ switch (p_what) {
+ case NOTIFICATION_READY: {
+ //get_scene()->connect("node_removed",this,"_node_removed");
+
+ if (first_enter) {
+ //it's in propertyeditor so. could be moved around
+
+ light_1_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight1"), SNAME("EditorIcons")));
+ light_1_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight1Off"), SNAME("EditorIcons")));
+ light_2_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight2"), SNAME("EditorIcons")));
+ light_2_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight2Off"), SNAME("EditorIcons")));
+ first_enter = false;
+ }
+ } break;
}
}
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 52671f224e..3d3738ad47 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -82,28 +82,32 @@
#define MAX_FOV 179
void ViewportRotationControl::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE) {
- axis_menu_options.clear();
- axis_menu_options.push_back(Node3DEditorViewport::VIEW_RIGHT);
- axis_menu_options.push_back(Node3DEditorViewport::VIEW_TOP);
- axis_menu_options.push_back(Node3DEditorViewport::VIEW_REAR);
- axis_menu_options.push_back(Node3DEditorViewport::VIEW_LEFT);
- axis_menu_options.push_back(Node3DEditorViewport::VIEW_BOTTOM);
- axis_menu_options.push_back(Node3DEditorViewport::VIEW_FRONT);
-
- axis_colors.clear();
- axis_colors.push_back(get_theme_color(SNAME("axis_x_color"), SNAME("Editor")));
- axis_colors.push_back(get_theme_color(SNAME("axis_y_color"), SNAME("Editor")));
- axis_colors.push_back(get_theme_color(SNAME("axis_z_color"), SNAME("Editor")));
- update();
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ axis_menu_options.clear();
+ axis_menu_options.push_back(Node3DEditorViewport::VIEW_RIGHT);
+ axis_menu_options.push_back(Node3DEditorViewport::VIEW_TOP);
+ axis_menu_options.push_back(Node3DEditorViewport::VIEW_REAR);
+ axis_menu_options.push_back(Node3DEditorViewport::VIEW_LEFT);
+ axis_menu_options.push_back(Node3DEditorViewport::VIEW_BOTTOM);
+ axis_menu_options.push_back(Node3DEditorViewport::VIEW_FRONT);
+
+ axis_colors.clear();
+ axis_colors.push_back(get_theme_color(SNAME("axis_x_color"), SNAME("Editor")));
+ axis_colors.push_back(get_theme_color(SNAME("axis_y_color"), SNAME("Editor")));
+ axis_colors.push_back(get_theme_color(SNAME("axis_z_color"), SNAME("Editor")));
+ update();
- if (!is_connected("mouse_exited", callable_mp(this, &ViewportRotationControl::_on_mouse_exited))) {
- connect("mouse_exited", callable_mp(this, &ViewportRotationControl::_on_mouse_exited));
- }
- }
+ if (!is_connected("mouse_exited", callable_mp(this, &ViewportRotationControl::_on_mouse_exited))) {
+ connect("mouse_exited", callable_mp(this, &ViewportRotationControl::_on_mouse_exited));
+ }
+ } break;
- if (p_what == NOTIFICATION_DRAW && viewport != nullptr) {
- _draw();
+ case NOTIFICATION_DRAW: {
+ if (viewport != nullptr) {
+ _draw();
+ }
+ } break;
}
}
@@ -2422,279 +2426,281 @@ void Node3DEditorViewport::_project_settings_changed() {
}
void Node3DEditorViewport::_notification(int p_what) {
- if (p_what == NOTIFICATION_READY) {
- EditorNode::get_singleton()->connect("project_settings_changed", callable_mp(this, &Node3DEditorViewport::_project_settings_changed));
- }
+ switch (p_what) {
+ case NOTIFICATION_READY: {
+ EditorNode::get_singleton()->connect("project_settings_changed", callable_mp(this, &Node3DEditorViewport::_project_settings_changed));
+ } break;
- if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- bool visible = is_visible_in_tree();
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ bool visible = is_visible_in_tree();
- set_process(visible);
+ set_process(visible);
- if (visible) {
- orthogonal = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_ORTHOGONAL));
- _update_name();
- _update_camera(0);
- } else {
- set_freelook_active(false);
- }
- call_deferred(SNAME("update_transform_gizmo_view"));
- rotation_control->set_visible(EditorSettings::get_singleton()->get("editors/3d/navigation/show_viewport_rotation_gizmo"));
- }
+ if (visible) {
+ orthogonal = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_ORTHOGONAL));
+ _update_name();
+ _update_camera(0);
+ } else {
+ set_freelook_active(false);
+ }
+ call_deferred(SNAME("update_transform_gizmo_view"));
+ rotation_control->set_visible(EditorSettings::get_singleton()->get("editors/3d/navigation/show_viewport_rotation_gizmo"));
+ } break;
- if (p_what == NOTIFICATION_RESIZED) {
- call_deferred(SNAME("update_transform_gizmo_view"));
- }
+ case NOTIFICATION_RESIZED: {
+ call_deferred(SNAME("update_transform_gizmo_view"));
+ } break;
- if (p_what == NOTIFICATION_PROCESS) {
- real_t delta = get_process_delta_time();
+ case NOTIFICATION_PROCESS: {
+ real_t delta = get_process_delta_time();
- if (zoom_indicator_delay > 0) {
- zoom_indicator_delay -= delta;
- if (zoom_indicator_delay <= 0) {
- surface->update();
- zoom_limit_label->hide();
+ if (zoom_indicator_delay > 0) {
+ zoom_indicator_delay -= delta;
+ if (zoom_indicator_delay <= 0) {
+ surface->update();
+ zoom_limit_label->hide();
+ }
}
- }
- _update_freelook(delta);
+ _update_freelook(delta);
- Node *scene_root = SceneTreeDock::get_singleton()->get_editor_data()->get_edited_scene_root();
- if (previewing_cinema && scene_root != nullptr) {
- Camera3D *cam = scene_root->get_viewport()->get_camera_3d();
- if (cam != nullptr && cam != previewing) {
- //then switch the viewport's camera to the scene's viewport camera
- if (previewing != nullptr) {
- previewing->disconnect("tree_exited", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene));
+ Node *scene_root = SceneTreeDock::get_singleton()->get_editor_data()->get_edited_scene_root();
+ if (previewing_cinema && scene_root != nullptr) {
+ Camera3D *cam = scene_root->get_viewport()->get_camera_3d();
+ if (cam != nullptr && cam != previewing) {
+ //then switch the viewport's camera to the scene's viewport camera
+ if (previewing != nullptr) {
+ previewing->disconnect("tree_exited", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene));
+ }
+ previewing = cam;
+ previewing->connect("tree_exited", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene));
+ RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), cam->get_camera());
+ surface->update();
}
- previewing = cam;
- previewing->connect("tree_exited", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene));
- RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), cam->get_camera());
- surface->update();
}
- }
- _update_camera(delta);
+ _update_camera(delta);
- Map<Node *, Object *> &selection = editor_selection->get_selection();
+ Map<Node *, Object *> &selection = editor_selection->get_selection();
- bool changed = false;
- bool exist = false;
+ bool changed = false;
+ bool exist = false;
- for (const KeyValue<Node *, Object *> &E : selection) {
- Node3D *sp = Object::cast_to<Node3D>(E.key);
- if (!sp) {
- continue;
- }
+ for (const KeyValue<Node *, Object *> &E : selection) {
+ Node3D *sp = Object::cast_to<Node3D>(E.key);
+ if (!sp) {
+ continue;
+ }
- Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
- if (!se) {
- continue;
- }
+ Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
+ if (!se) {
+ continue;
+ }
- Transform3D t = sp->get_global_gizmo_transform();
- VisualInstance3D *vi = Object::cast_to<VisualInstance3D>(sp);
- AABB new_aabb = vi ? vi->get_aabb() : _calculate_spatial_bounds(sp);
+ Transform3D t = sp->get_global_gizmo_transform();
+ VisualInstance3D *vi = Object::cast_to<VisualInstance3D>(sp);
+ AABB new_aabb = vi ? vi->get_aabb() : _calculate_spatial_bounds(sp);
- exist = true;
- if (se->last_xform == t && se->aabb == new_aabb && !se->last_xform_dirty) {
- continue;
- }
- changed = true;
- se->last_xform_dirty = false;
- se->last_xform = t;
+ exist = true;
+ if (se->last_xform == t && se->aabb == new_aabb && !se->last_xform_dirty) {
+ continue;
+ }
+ changed = true;
+ se->last_xform_dirty = false;
+ se->last_xform = t;
- se->aabb = new_aabb;
+ se->aabb = new_aabb;
- Transform3D t_offset = t;
+ Transform3D t_offset = t;
- // apply AABB scaling before item's global transform
- {
- const Vector3 offset(0.005, 0.005, 0.005);
- Basis aabb_s;
- aabb_s.scale(se->aabb.size + offset);
- t.translate(se->aabb.position - offset / 2);
- t.basis = t.basis * aabb_s;
- }
- {
- const Vector3 offset(0.01, 0.01, 0.01);
- Basis aabb_s;
- aabb_s.scale(se->aabb.size + offset);
- t_offset.translate(se->aabb.position - offset / 2);
- t_offset.basis = t_offset.basis * aabb_s;
+ // apply AABB scaling before item's global transform
+ {
+ const Vector3 offset(0.005, 0.005, 0.005);
+ Basis aabb_s;
+ aabb_s.scale(se->aabb.size + offset);
+ t.translate(se->aabb.position - offset / 2);
+ t.basis = t.basis * aabb_s;
+ }
+ {
+ const Vector3 offset(0.01, 0.01, 0.01);
+ Basis aabb_s;
+ aabb_s.scale(se->aabb.size + offset);
+ t_offset.translate(se->aabb.position - offset / 2);
+ t_offset.basis = t_offset.basis * aabb_s;
+ }
+
+ RenderingServer::get_singleton()->instance_set_transform(se->sbox_instance, t);
+ RenderingServer::get_singleton()->instance_set_transform(se->sbox_instance_offset, t_offset);
+ RenderingServer::get_singleton()->instance_set_transform(se->sbox_instance_xray, t);
+ RenderingServer::get_singleton()->instance_set_transform(se->sbox_instance_xray_offset, t_offset);
}
- RenderingServer::get_singleton()->instance_set_transform(se->sbox_instance, t);
- RenderingServer::get_singleton()->instance_set_transform(se->sbox_instance_offset, t_offset);
- RenderingServer::get_singleton()->instance_set_transform(se->sbox_instance_xray, t);
- RenderingServer::get_singleton()->instance_set_transform(se->sbox_instance_xray_offset, t_offset);
- }
+ if (changed || (spatial_editor->is_gizmo_visible() && !exist)) {
+ spatial_editor->update_transform_gizmo();
+ }
- if (changed || (spatial_editor->is_gizmo_visible() && !exist)) {
- spatial_editor->update_transform_gizmo();
- }
+ if (message_time > 0) {
+ if (message != last_message) {
+ surface->update();
+ last_message = message;
+ }
- if (message_time > 0) {
- if (message != last_message) {
- surface->update();
- last_message = message;
+ message_time -= get_physics_process_delta_time();
+ if (message_time < 0) {
+ surface->update();
+ }
}
- message_time -= get_physics_process_delta_time();
- if (message_time < 0) {
- surface->update();
+ bool show_info = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_INFORMATION));
+ if (show_info != info_label->is_visible()) {
+ info_label->set_visible(show_info);
}
- }
- bool show_info = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_INFORMATION));
- if (show_info != info_label->is_visible()) {
- info_label->set_visible(show_info);
- }
+ Camera3D *current_camera;
- Camera3D *current_camera;
+ if (previewing) {
+ current_camera = previewing;
+ } else {
+ current_camera = camera;
+ }
+
+ if (show_info) {
+ const String viewport_size = vformat(String::utf8("%d × %d"), viewport->get_size().x, viewport->get_size().y);
+ String text;
+ text += vformat(TTR("X: %s\n"), rtos(current_camera->get_position().x).pad_decimals(1));
+ text += vformat(TTR("Y: %s\n"), rtos(current_camera->get_position().y).pad_decimals(1));
+ text += vformat(TTR("Z: %s\n"), rtos(current_camera->get_position().z).pad_decimals(1));
+ text += "\n";
+ text += vformat(
+ TTR("Size: %s (%.1fMP)\n"),
+ viewport_size,
+ viewport->get_size().x * viewport->get_size().y * 0.000001);
+
+ text += "\n";
+ text += vformat(TTR("Objects: %d\n"), viewport->get_render_info(Viewport::RENDER_INFO_TYPE_VISIBLE, Viewport::RENDER_INFO_OBJECTS_IN_FRAME));
+ text += vformat(TTR("Primitives: %d\n"), viewport->get_render_info(Viewport::RENDER_INFO_TYPE_VISIBLE, Viewport::RENDER_INFO_PRIMITIVES_IN_FRAME));
+ text += vformat(TTR("Draw Calls: %d"), viewport->get_render_info(Viewport::RENDER_INFO_TYPE_VISIBLE, Viewport::RENDER_INFO_DRAW_CALLS_IN_FRAME));
+
+ info_label->set_text(text);
+ }
+
+ // FPS Counter.
+ bool show_fps = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_FRAME_TIME));
+
+ if (show_fps != fps_label->is_visible()) {
+ cpu_time_label->set_visible(show_fps);
+ gpu_time_label->set_visible(show_fps);
+ fps_label->set_visible(show_fps);
+ RS::get_singleton()->viewport_set_measure_render_time(viewport->get_viewport_rid(), show_fps);
+ for (int i = 0; i < FRAME_TIME_HISTORY; i++) {
+ cpu_time_history[i] = 0;
+ gpu_time_history[i] = 0;
+ }
+ cpu_time_history_index = 0;
+ gpu_time_history_index = 0;
+ }
+ if (show_fps) {
+ cpu_time_history[cpu_time_history_index] = RS::get_singleton()->viewport_get_measured_render_time_cpu(viewport->get_viewport_rid());
+ cpu_time_history_index = (cpu_time_history_index + 1) % FRAME_TIME_HISTORY;
+ double cpu_time = 0.0;
+ for (int i = 0; i < FRAME_TIME_HISTORY; i++) {
+ cpu_time += cpu_time_history[i];
+ }
+ cpu_time /= FRAME_TIME_HISTORY;
+ // Prevent unrealistically low values.
+ cpu_time = MAX(0.01, cpu_time);
+
+ gpu_time_history[gpu_time_history_index] = RS::get_singleton()->viewport_get_measured_render_time_gpu(viewport->get_viewport_rid());
+ gpu_time_history_index = (gpu_time_history_index + 1) % FRAME_TIME_HISTORY;
+ double gpu_time = 0.0;
+ for (int i = 0; i < FRAME_TIME_HISTORY; i++) {
+ gpu_time += gpu_time_history[i];
+ }
+ gpu_time /= FRAME_TIME_HISTORY;
+ // Prevent division by zero for the FPS counter (and unrealistically low values).
+ // This limits the reported FPS to 100000.
+ gpu_time = MAX(0.01, gpu_time);
+
+ // Color labels depending on performance level ("good" = green, "OK" = yellow, "bad" = red).
+ // Middle point is at 15 ms.
+ cpu_time_label->set_text(vformat(TTR("CPU Time: %s ms"), rtos(cpu_time).pad_decimals(2)));
+ cpu_time_label->add_theme_color_override(
+ "font_color",
+ frame_time_gradient->get_color_at_offset(
+ Math::range_lerp(cpu_time, 0, 30, 0, 1)));
+
+ gpu_time_label->set_text(vformat(TTR("GPU Time: %s ms"), rtos(gpu_time).pad_decimals(2)));
+ // Middle point is at 15 ms.
+ gpu_time_label->add_theme_color_override(
+ "font_color",
+ frame_time_gradient->get_color_at_offset(
+ Math::range_lerp(gpu_time, 0, 30, 0, 1)));
+
+ const double fps = 1000.0 / gpu_time;
+ fps_label->set_text(vformat(TTR("FPS: %d"), fps));
+ // Middle point is at 60 FPS.
+ fps_label->add_theme_color_override(
+ "font_color",
+ frame_time_gradient->get_color_at_offset(
+ Math::range_lerp(fps, 110, 10, 0, 1)));
+ }
+
+ bool show_cinema = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_CINEMATIC_PREVIEW));
+ cinema_label->set_visible(show_cinema);
+ if (show_cinema) {
+ float cinema_half_width = cinema_label->get_size().width / 2.0f;
+ cinema_label->set_anchor_and_offset(SIDE_LEFT, 0.5f, -cinema_half_width);
+ }
- if (previewing) {
- current_camera = previewing;
- } else {
- current_camera = camera;
- }
-
- if (show_info) {
- const String viewport_size = vformat(String::utf8("%d × %d"), viewport->get_size().x, viewport->get_size().y);
- String text;
- text += vformat(TTR("X: %s\n"), rtos(current_camera->get_position().x).pad_decimals(1));
- text += vformat(TTR("Y: %s\n"), rtos(current_camera->get_position().y).pad_decimals(1));
- text += vformat(TTR("Z: %s\n"), rtos(current_camera->get_position().z).pad_decimals(1));
- text += "\n";
- text += vformat(
- TTR("Size: %s (%.1fMP)\n"),
- viewport_size,
- viewport->get_size().x * viewport->get_size().y * 0.000001);
-
- text += "\n";
- text += vformat(TTR("Objects: %d\n"), viewport->get_render_info(Viewport::RENDER_INFO_TYPE_VISIBLE, Viewport::RENDER_INFO_OBJECTS_IN_FRAME));
- text += vformat(TTR("Primitives: %d\n"), viewport->get_render_info(Viewport::RENDER_INFO_TYPE_VISIBLE, Viewport::RENDER_INFO_PRIMITIVES_IN_FRAME));
- text += vformat(TTR("Draw Calls: %d"), viewport->get_render_info(Viewport::RENDER_INFO_TYPE_VISIBLE, Viewport::RENDER_INFO_DRAW_CALLS_IN_FRAME));
-
- info_label->set_text(text);
- }
-
- // FPS Counter.
- bool show_fps = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_FRAME_TIME));
-
- if (show_fps != fps_label->is_visible()) {
- cpu_time_label->set_visible(show_fps);
- gpu_time_label->set_visible(show_fps);
- fps_label->set_visible(show_fps);
- RS::get_singleton()->viewport_set_measure_render_time(viewport->get_viewport_rid(), show_fps);
- for (int i = 0; i < FRAME_TIME_HISTORY; i++) {
- cpu_time_history[i] = 0;
- gpu_time_history[i] = 0;
- }
- cpu_time_history_index = 0;
- gpu_time_history_index = 0;
- }
- if (show_fps) {
- cpu_time_history[cpu_time_history_index] = RS::get_singleton()->viewport_get_measured_render_time_cpu(viewport->get_viewport_rid());
- cpu_time_history_index = (cpu_time_history_index + 1) % FRAME_TIME_HISTORY;
- double cpu_time = 0.0;
- for (int i = 0; i < FRAME_TIME_HISTORY; i++) {
- cpu_time += cpu_time_history[i];
- }
- cpu_time /= FRAME_TIME_HISTORY;
- // Prevent unrealistically low values.
- cpu_time = MAX(0.01, cpu_time);
-
- gpu_time_history[gpu_time_history_index] = RS::get_singleton()->viewport_get_measured_render_time_gpu(viewport->get_viewport_rid());
- gpu_time_history_index = (gpu_time_history_index + 1) % FRAME_TIME_HISTORY;
- double gpu_time = 0.0;
- for (int i = 0; i < FRAME_TIME_HISTORY; i++) {
- gpu_time += gpu_time_history[i];
- }
- gpu_time /= FRAME_TIME_HISTORY;
- // Prevent division by zero for the FPS counter (and unrealistically low values).
- // This limits the reported FPS to 100000.
- gpu_time = MAX(0.01, gpu_time);
-
- // Color labels depending on performance level ("good" = green, "OK" = yellow, "bad" = red).
- // Middle point is at 15 ms.
- cpu_time_label->set_text(vformat(TTR("CPU Time: %s ms"), rtos(cpu_time).pad_decimals(2)));
- cpu_time_label->add_theme_color_override(
- "font_color",
- frame_time_gradient->get_color_at_offset(
- Math::range_lerp(cpu_time, 0, 30, 0, 1)));
-
- gpu_time_label->set_text(vformat(TTR("GPU Time: %s ms"), rtos(gpu_time).pad_decimals(2)));
- // Middle point is at 15 ms.
- gpu_time_label->add_theme_color_override(
- "font_color",
- frame_time_gradient->get_color_at_offset(
- Math::range_lerp(gpu_time, 0, 30, 0, 1)));
-
- const double fps = 1000.0 / gpu_time;
- fps_label->set_text(vformat(TTR("FPS: %d"), fps));
- // Middle point is at 60 FPS.
- fps_label->add_theme_color_override(
- "font_color",
- frame_time_gradient->get_color_at_offset(
- Math::range_lerp(fps, 110, 10, 0, 1)));
- }
-
- bool show_cinema = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_CINEMATIC_PREVIEW));
- cinema_label->set_visible(show_cinema);
- if (show_cinema) {
- float cinema_half_width = cinema_label->get_size().width / 2.0f;
- cinema_label->set_anchor_and_offset(SIDE_LEFT, 0.5f, -cinema_half_width);
- }
-
- if (lock_rotation) {
- float locked_half_width = locked_label->get_size().width / 2.0f;
- locked_label->set_anchor_and_offset(SIDE_LEFT, 0.5f, -locked_half_width);
- }
- }
-
- if (p_what == NOTIFICATION_ENTER_TREE) {
- surface->connect("draw", callable_mp(this, &Node3DEditorViewport::_draw));
- surface->connect("gui_input", callable_mp(this, &Node3DEditorViewport::_sinput));
- surface->connect("mouse_entered", callable_mp(this, &Node3DEditorViewport::_surface_mouse_enter));
- surface->connect("mouse_exited", callable_mp(this, &Node3DEditorViewport::_surface_mouse_exit));
- surface->connect("focus_entered", callable_mp(this, &Node3DEditorViewport::_surface_focus_enter));
- surface->connect("focus_exited", callable_mp(this, &Node3DEditorViewport::_surface_focus_exit));
-
- _init_gizmo_instance(index);
- }
-
- if (p_what == NOTIFICATION_EXIT_TREE) {
- _finish_gizmo_instances();
- }
+ if (lock_rotation) {
+ float locked_half_width = locked_label->get_size().width / 2.0f;
+ locked_label->set_anchor_and_offset(SIDE_LEFT, 0.5f, -locked_half_width);
+ }
+ } break;
- if (p_what == NOTIFICATION_THEME_CHANGED) {
- view_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons")));
- preview_camera->set_icon(get_theme_icon(SNAME("Camera3D"), SNAME("EditorIcons")));
- Control *gui_base = EditorNode::get_singleton()->get_gui_base();
+ case NOTIFICATION_ENTER_TREE: {
+ surface->connect("draw", callable_mp(this, &Node3DEditorViewport::_draw));
+ surface->connect("gui_input", callable_mp(this, &Node3DEditorViewport::_sinput));
+ surface->connect("mouse_entered", callable_mp(this, &Node3DEditorViewport::_surface_mouse_enter));
+ surface->connect("mouse_exited", callable_mp(this, &Node3DEditorViewport::_surface_mouse_exit));
+ surface->connect("focus_entered", callable_mp(this, &Node3DEditorViewport::_surface_focus_enter));
+ surface->connect("focus_exited", callable_mp(this, &Node3DEditorViewport::_surface_focus_exit));
+
+ _init_gizmo_instance(index);
+ } break;
- view_menu->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- view_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- view_menu->add_theme_style_override("pressed", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- view_menu->add_theme_style_override("focus", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- view_menu->add_theme_style_override("disabled", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
-
- preview_camera->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- preview_camera->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- preview_camera->add_theme_style_override("pressed", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- preview_camera->add_theme_style_override("focus", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- preview_camera->add_theme_style_override("disabled", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
-
- frame_time_gradient->set_color(0, get_theme_color(SNAME("success_color"), SNAME("Editor")));
- frame_time_gradient->set_color(1, get_theme_color(SNAME("warning_color"), SNAME("Editor")));
- frame_time_gradient->set_color(2, get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ case NOTIFICATION_EXIT_TREE: {
+ _finish_gizmo_instances();
+ } break;
- info_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- cpu_time_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- gpu_time_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- fps_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- cinema_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- locked_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
+ case NOTIFICATION_THEME_CHANGED: {
+ view_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons")));
+ preview_camera->set_icon(get_theme_icon(SNAME("Camera3D"), SNAME("EditorIcons")));
+ Control *gui_base = EditorNode::get_singleton()->get_gui_base();
+
+ view_menu->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
+ view_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
+ view_menu->add_theme_style_override("pressed", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
+ view_menu->add_theme_style_override("focus", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
+ view_menu->add_theme_style_override("disabled", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
+
+ preview_camera->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
+ preview_camera->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
+ preview_camera->add_theme_style_override("pressed", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
+ preview_camera->add_theme_style_override("focus", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
+ preview_camera->add_theme_style_override("disabled", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
+
+ frame_time_gradient->set_color(0, get_theme_color(SNAME("success_color"), SNAME("Editor")));
+ frame_time_gradient->set_color(1, get_theme_color(SNAME("warning_color"), SNAME("Editor")));
+ frame_time_gradient->set_color(2, get_theme_color(SNAME("error_color"), SNAME("Editor")));
+
+ info_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
+ cpu_time_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
+ gpu_time_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
+ fps_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
+ cinema_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
+ locked_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
+ } break;
}
}
@@ -4799,197 +4805,202 @@ void Node3DEditorViewportContainer::gui_input(const Ref<InputEvent> &p_event) {
}
void Node3DEditorViewportContainer::_notification(int p_what) {
- if (p_what == NOTIFICATION_MOUSE_ENTER || p_what == NOTIFICATION_MOUSE_EXIT) {
- mouseover = (p_what == NOTIFICATION_MOUSE_ENTER);
- update();
- }
+ switch (p_what) {
+ case NOTIFICATION_MOUSE_ENTER:
+ case NOTIFICATION_MOUSE_EXIT: {
+ mouseover = (p_what == NOTIFICATION_MOUSE_ENTER);
+ update();
+ } break;
- if (p_what == NOTIFICATION_DRAW && mouseover) {
- Ref<Texture2D> h_grabber = get_theme_icon(SNAME("grabber"), SNAME("HSplitContainer"));
- Ref<Texture2D> v_grabber = get_theme_icon(SNAME("grabber"), SNAME("VSplitContainer"));
+ case NOTIFICATION_DRAW: {
+ if (mouseover) {
+ Ref<Texture2D> h_grabber = get_theme_icon(SNAME("grabber"), SNAME("HSplitContainer"));
+ Ref<Texture2D> v_grabber = get_theme_icon(SNAME("grabber"), SNAME("VSplitContainer"));
- Ref<Texture2D> hdiag_grabber = get_theme_icon(SNAME("GuiViewportHdiagsplitter"), SNAME("EditorIcons"));
- Ref<Texture2D> vdiag_grabber = get_theme_icon(SNAME("GuiViewportVdiagsplitter"), SNAME("EditorIcons"));
- Ref<Texture2D> vh_grabber = get_theme_icon(SNAME("GuiViewportVhsplitter"), SNAME("EditorIcons"));
+ Ref<Texture2D> hdiag_grabber = get_theme_icon(SNAME("GuiViewportHdiagsplitter"), SNAME("EditorIcons"));
+ Ref<Texture2D> vdiag_grabber = get_theme_icon(SNAME("GuiViewportVdiagsplitter"), SNAME("EditorIcons"));
+ Ref<Texture2D> vh_grabber = get_theme_icon(SNAME("GuiViewportVhsplitter"), SNAME("EditorIcons"));
- Vector2 size = get_size();
+ Vector2 size = get_size();
- int h_sep = get_theme_constant(SNAME("separation"), SNAME("HSplitContainer"));
+ int h_sep = get_theme_constant(SNAME("separation"), SNAME("HSplitContainer"));
- int v_sep = get_theme_constant(SNAME("separation"), SNAME("VSplitContainer"));
+ int v_sep = get_theme_constant(SNAME("separation"), SNAME("VSplitContainer"));
- int mid_w = size.width * ratio_h;
- int mid_h = size.height * ratio_v;
+ int mid_w = size.width * ratio_h;
+ int mid_h = size.height * ratio_v;
- int size_left = mid_w - h_sep / 2;
- int size_bottom = size.height - mid_h - v_sep / 2;
+ int size_left = mid_w - h_sep / 2;
+ int size_bottom = size.height - mid_h - v_sep / 2;
- switch (view) {
- case VIEW_USE_1_VIEWPORT: {
- // Nothing to show.
+ switch (view) {
+ case VIEW_USE_1_VIEWPORT: {
+ // Nothing to show.
- } break;
- case VIEW_USE_2_VIEWPORTS: {
- draw_texture(v_grabber, Vector2((size.width - v_grabber->get_width()) / 2, mid_h - v_grabber->get_height() / 2));
- set_default_cursor_shape(CURSOR_VSPLIT);
+ } break;
+ case VIEW_USE_2_VIEWPORTS: {
+ draw_texture(v_grabber, Vector2((size.width - v_grabber->get_width()) / 2, mid_h - v_grabber->get_height() / 2));
+ set_default_cursor_shape(CURSOR_VSPLIT);
- } break;
- case VIEW_USE_2_VIEWPORTS_ALT: {
- draw_texture(h_grabber, Vector2(mid_w - h_grabber->get_width() / 2, (size.height - h_grabber->get_height()) / 2));
- set_default_cursor_shape(CURSOR_HSPLIT);
+ } break;
+ case VIEW_USE_2_VIEWPORTS_ALT: {
+ draw_texture(h_grabber, Vector2(mid_w - h_grabber->get_width() / 2, (size.height - h_grabber->get_height()) / 2));
+ set_default_cursor_shape(CURSOR_HSPLIT);
- } break;
- case VIEW_USE_3_VIEWPORTS: {
- if ((hovering_v && hovering_h && !dragging_v && !dragging_h) || (dragging_v && dragging_h)) {
- draw_texture(hdiag_grabber, Vector2(mid_w - hdiag_grabber->get_width() / 2, mid_h - v_grabber->get_height() / 4));
- set_default_cursor_shape(CURSOR_DRAG);
- } else if ((hovering_v && !dragging_h) || dragging_v) {
- draw_texture(v_grabber, Vector2((size.width - v_grabber->get_width()) / 2, mid_h - v_grabber->get_height() / 2));
- set_default_cursor_shape(CURSOR_VSPLIT);
- } else if (hovering_h || dragging_h) {
- draw_texture(h_grabber, Vector2(mid_w - h_grabber->get_width() / 2, mid_h + v_grabber->get_height() / 2 + (size_bottom - h_grabber->get_height()) / 2));
- set_default_cursor_shape(CURSOR_HSPLIT);
- }
+ } break;
+ case VIEW_USE_3_VIEWPORTS: {
+ if ((hovering_v && hovering_h && !dragging_v && !dragging_h) || (dragging_v && dragging_h)) {
+ draw_texture(hdiag_grabber, Vector2(mid_w - hdiag_grabber->get_width() / 2, mid_h - v_grabber->get_height() / 4));
+ set_default_cursor_shape(CURSOR_DRAG);
+ } else if ((hovering_v && !dragging_h) || dragging_v) {
+ draw_texture(v_grabber, Vector2((size.width - v_grabber->get_width()) / 2, mid_h - v_grabber->get_height() / 2));
+ set_default_cursor_shape(CURSOR_VSPLIT);
+ } else if (hovering_h || dragging_h) {
+ draw_texture(h_grabber, Vector2(mid_w - h_grabber->get_width() / 2, mid_h + v_grabber->get_height() / 2 + (size_bottom - h_grabber->get_height()) / 2));
+ set_default_cursor_shape(CURSOR_HSPLIT);
+ }
- } break;
- case VIEW_USE_3_VIEWPORTS_ALT: {
- if ((hovering_v && hovering_h && !dragging_v && !dragging_h) || (dragging_v && dragging_h)) {
- draw_texture(vdiag_grabber, Vector2(mid_w - vdiag_grabber->get_width() + v_grabber->get_height() / 4, mid_h - vdiag_grabber->get_height() / 2));
- set_default_cursor_shape(CURSOR_DRAG);
- } else if ((hovering_v && !dragging_h) || dragging_v) {
- draw_texture(v_grabber, Vector2((size_left - v_grabber->get_width()) / 2, mid_h - v_grabber->get_height() / 2));
- set_default_cursor_shape(CURSOR_VSPLIT);
- } else if (hovering_h || dragging_h) {
- draw_texture(h_grabber, Vector2(mid_w - h_grabber->get_width() / 2, (size.height - h_grabber->get_height()) / 2));
- set_default_cursor_shape(CURSOR_HSPLIT);
- }
+ } break;
+ case VIEW_USE_3_VIEWPORTS_ALT: {
+ if ((hovering_v && hovering_h && !dragging_v && !dragging_h) || (dragging_v && dragging_h)) {
+ draw_texture(vdiag_grabber, Vector2(mid_w - vdiag_grabber->get_width() + v_grabber->get_height() / 4, mid_h - vdiag_grabber->get_height() / 2));
+ set_default_cursor_shape(CURSOR_DRAG);
+ } else if ((hovering_v && !dragging_h) || dragging_v) {
+ draw_texture(v_grabber, Vector2((size_left - v_grabber->get_width()) / 2, mid_h - v_grabber->get_height() / 2));
+ set_default_cursor_shape(CURSOR_VSPLIT);
+ } else if (hovering_h || dragging_h) {
+ draw_texture(h_grabber, Vector2(mid_w - h_grabber->get_width() / 2, (size.height - h_grabber->get_height()) / 2));
+ set_default_cursor_shape(CURSOR_HSPLIT);
+ }
- } break;
- case VIEW_USE_4_VIEWPORTS: {
- Vector2 half(mid_w, mid_h);
- if ((hovering_v && hovering_h && !dragging_v && !dragging_h) || (dragging_v && dragging_h)) {
- draw_texture(vh_grabber, half - vh_grabber->get_size() / 2.0);
- set_default_cursor_shape(CURSOR_DRAG);
- } else if ((hovering_v && !dragging_h) || dragging_v) {
- draw_texture(v_grabber, half - v_grabber->get_size() / 2.0);
- set_default_cursor_shape(CURSOR_VSPLIT);
- } else if (hovering_h || dragging_h) {
- draw_texture(h_grabber, half - h_grabber->get_size() / 2.0);
- set_default_cursor_shape(CURSOR_HSPLIT);
- }
+ } break;
+ case VIEW_USE_4_VIEWPORTS: {
+ Vector2 half(mid_w, mid_h);
+ if ((hovering_v && hovering_h && !dragging_v && !dragging_h) || (dragging_v && dragging_h)) {
+ draw_texture(vh_grabber, half - vh_grabber->get_size() / 2.0);
+ set_default_cursor_shape(CURSOR_DRAG);
+ } else if ((hovering_v && !dragging_h) || dragging_v) {
+ draw_texture(v_grabber, half - v_grabber->get_size() / 2.0);
+ set_default_cursor_shape(CURSOR_VSPLIT);
+ } else if (hovering_h || dragging_h) {
+ draw_texture(h_grabber, half - h_grabber->get_size() / 2.0);
+ set_default_cursor_shape(CURSOR_HSPLIT);
+ }
- } break;
- }
- }
+ } break;
+ }
+ }
+ } break;
- if (p_what == NOTIFICATION_SORT_CHILDREN) {
- Node3DEditorViewport *viewports[4];
- int vc = 0;
- for (int i = 0; i < get_child_count(); i++) {
- viewports[vc] = Object::cast_to<Node3DEditorViewport>(get_child(i));
- if (viewports[vc]) {
- vc++;
+ case NOTIFICATION_SORT_CHILDREN: {
+ Node3DEditorViewport *viewports[4];
+ int vc = 0;
+ for (int i = 0; i < get_child_count(); i++) {
+ viewports[vc] = Object::cast_to<Node3DEditorViewport>(get_child(i));
+ if (viewports[vc]) {
+ vc++;
+ }
}
- }
- ERR_FAIL_COND(vc != 4);
+ ERR_FAIL_COND(vc != 4);
- Size2 size = get_size();
+ Size2 size = get_size();
- if (size.x < 10 || size.y < 10) {
- for (int i = 0; i < 4; i++) {
- viewports[i]->hide();
+ if (size.x < 10 || size.y < 10) {
+ for (int i = 0; i < 4; i++) {
+ viewports[i]->hide();
+ }
+ return;
}
- return;
- }
- int h_sep = get_theme_constant(SNAME("separation"), SNAME("HSplitContainer"));
+ int h_sep = get_theme_constant(SNAME("separation"), SNAME("HSplitContainer"));
- int v_sep = get_theme_constant(SNAME("separation"), SNAME("VSplitContainer"));
+ int v_sep = get_theme_constant(SNAME("separation"), SNAME("VSplitContainer"));
- int mid_w = size.width * ratio_h;
- int mid_h = size.height * ratio_v;
+ int mid_w = size.width * ratio_h;
+ int mid_h = size.height * ratio_v;
- int size_left = mid_w - h_sep / 2;
- int size_right = size.width - mid_w - h_sep / 2;
+ int size_left = mid_w - h_sep / 2;
+ int size_right = size.width - mid_w - h_sep / 2;
- int size_top = mid_h - v_sep / 2;
- int size_bottom = size.height - mid_h - v_sep / 2;
+ int size_top = mid_h - v_sep / 2;
+ int size_bottom = size.height - mid_h - v_sep / 2;
- switch (view) {
- case VIEW_USE_1_VIEWPORT: {
- viewports[0]->show();
- for (int i = 1; i < 4; i++) {
- viewports[i]->hide();
- }
+ switch (view) {
+ case VIEW_USE_1_VIEWPORT: {
+ viewports[0]->show();
+ for (int i = 1; i < 4; i++) {
+ viewports[i]->hide();
+ }
- fit_child_in_rect(viewports[0], Rect2(Vector2(), size));
+ fit_child_in_rect(viewports[0], Rect2(Vector2(), size));
- } break;
- case VIEW_USE_2_VIEWPORTS: {
- for (int i = 0; i < 4; i++) {
- if (i == 1 || i == 3) {
- viewports[i]->hide();
- } else {
- viewports[i]->show();
+ } break;
+ case VIEW_USE_2_VIEWPORTS: {
+ for (int i = 0; i < 4; i++) {
+ if (i == 1 || i == 3) {
+ viewports[i]->hide();
+ } else {
+ viewports[i]->show();
+ }
}
- }
- fit_child_in_rect(viewports[0], Rect2(Vector2(), Vector2(size.width, size_top)));
- fit_child_in_rect(viewports[2], Rect2(Vector2(0, mid_h + v_sep / 2), Vector2(size.width, size_bottom)));
+ fit_child_in_rect(viewports[0], Rect2(Vector2(), Vector2(size.width, size_top)));
+ fit_child_in_rect(viewports[2], Rect2(Vector2(0, mid_h + v_sep / 2), Vector2(size.width, size_bottom)));
- } break;
- case VIEW_USE_2_VIEWPORTS_ALT: {
- for (int i = 0; i < 4; i++) {
- if (i == 1 || i == 3) {
- viewports[i]->hide();
- } else {
- viewports[i]->show();
+ } break;
+ case VIEW_USE_2_VIEWPORTS_ALT: {
+ for (int i = 0; i < 4; i++) {
+ if (i == 1 || i == 3) {
+ viewports[i]->hide();
+ } else {
+ viewports[i]->show();
+ }
}
- }
- fit_child_in_rect(viewports[0], Rect2(Vector2(), Vector2(size_left, size.height)));
- fit_child_in_rect(viewports[2], Rect2(Vector2(mid_w + h_sep / 2, 0), Vector2(size_right, size.height)));
+ fit_child_in_rect(viewports[0], Rect2(Vector2(), Vector2(size_left, size.height)));
+ fit_child_in_rect(viewports[2], Rect2(Vector2(mid_w + h_sep / 2, 0), Vector2(size_right, size.height)));
- } break;
- case VIEW_USE_3_VIEWPORTS: {
- for (int i = 0; i < 4; i++) {
- if (i == 1) {
- viewports[i]->hide();
- } else {
- viewports[i]->show();
+ } break;
+ case VIEW_USE_3_VIEWPORTS: {
+ for (int i = 0; i < 4; i++) {
+ if (i == 1) {
+ viewports[i]->hide();
+ } else {
+ viewports[i]->show();
+ }
}
- }
- fit_child_in_rect(viewports[0], Rect2(Vector2(), Vector2(size.width, size_top)));
- fit_child_in_rect(viewports[2], Rect2(Vector2(0, mid_h + v_sep / 2), Vector2(size_left, size_bottom)));
- fit_child_in_rect(viewports[3], Rect2(Vector2(mid_w + h_sep / 2, mid_h + v_sep / 2), Vector2(size_right, size_bottom)));
+ fit_child_in_rect(viewports[0], Rect2(Vector2(), Vector2(size.width, size_top)));
+ fit_child_in_rect(viewports[2], Rect2(Vector2(0, mid_h + v_sep / 2), Vector2(size_left, size_bottom)));
+ fit_child_in_rect(viewports[3], Rect2(Vector2(mid_w + h_sep / 2, mid_h + v_sep / 2), Vector2(size_right, size_bottom)));
- } break;
- case VIEW_USE_3_VIEWPORTS_ALT: {
- for (int i = 0; i < 4; i++) {
- if (i == 1) {
- viewports[i]->hide();
- } else {
- viewports[i]->show();
+ } break;
+ case VIEW_USE_3_VIEWPORTS_ALT: {
+ for (int i = 0; i < 4; i++) {
+ if (i == 1) {
+ viewports[i]->hide();
+ } else {
+ viewports[i]->show();
+ }
}
- }
- fit_child_in_rect(viewports[0], Rect2(Vector2(), Vector2(size_left, size_top)));
- fit_child_in_rect(viewports[2], Rect2(Vector2(0, mid_h + v_sep / 2), Vector2(size_left, size_bottom)));
- fit_child_in_rect(viewports[3], Rect2(Vector2(mid_w + h_sep / 2, 0), Vector2(size_right, size.height)));
+ fit_child_in_rect(viewports[0], Rect2(Vector2(), Vector2(size_left, size_top)));
+ fit_child_in_rect(viewports[2], Rect2(Vector2(0, mid_h + v_sep / 2), Vector2(size_left, size_bottom)));
+ fit_child_in_rect(viewports[3], Rect2(Vector2(mid_w + h_sep / 2, 0), Vector2(size_right, size.height)));
- } break;
- case VIEW_USE_4_VIEWPORTS: {
- for (int i = 0; i < 4; i++) {
- viewports[i]->show();
- }
+ } break;
+ case VIEW_USE_4_VIEWPORTS: {
+ for (int i = 0; i < 4; i++) {
+ viewports[i]->show();
+ }
- fit_child_in_rect(viewports[0], Rect2(Vector2(), Vector2(size_left, size_top)));
- fit_child_in_rect(viewports[1], Rect2(Vector2(mid_w + h_sep / 2, 0), Vector2(size_right, size_top)));
- fit_child_in_rect(viewports[2], Rect2(Vector2(0, mid_h + v_sep / 2), Vector2(size_left, size_bottom)));
- fit_child_in_rect(viewports[3], Rect2(Vector2(mid_w + h_sep / 2, mid_h + v_sep / 2), Vector2(size_right, size_bottom)));
+ fit_child_in_rect(viewports[0], Rect2(Vector2(), Vector2(size_left, size_top)));
+ fit_child_in_rect(viewports[1], Rect2(Vector2(mid_w + h_sep / 2, 0), Vector2(size_right, size_top)));
+ fit_child_in_rect(viewports[2], Rect2(Vector2(0, mid_h + v_sep / 2), Vector2(size_left, size_bottom)));
+ fit_child_in_rect(viewports[3], Rect2(Vector2(mid_w + h_sep / 2, mid_h + v_sep / 2), Vector2(size_right, size_bottom)));
- } break;
- }
+ } break;
+ }
+ } break;
}
}
@@ -6951,6 +6962,7 @@ void Node3DEditor::_notification(int p_what) {
sun_state->set_custom_minimum_size(sun_vb->get_combined_minimum_size());
environ_state->set_custom_minimum_size(environ_vb->get_combined_minimum_size());
} break;
+
case NOTIFICATION_ENTER_TREE: {
_update_theme();
_register_all_gizmos();
@@ -6958,9 +6970,11 @@ void Node3DEditor::_notification(int p_what) {
_init_indicators();
update_all_gizmos();
} break;
+
case NOTIFICATION_EXIT_TREE: {
_finish_indicators();
} break;
+
case NOTIFICATION_THEME_CHANGED: {
_update_theme();
_update_gizmos_menu_theme();
@@ -6968,11 +6982,13 @@ void Node3DEditor::_notification(int p_what) {
sun_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window")));
environ_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window")));
} break;
+
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
// Update grid color by rebuilding grid.
_finish_grid();
_init_grid();
} break;
+
case NOTIFICATION_VISIBILITY_CHANGED: {
if (!is_visible() && tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->is_pressed()) {
EditorDebuggerNode *debugger = EditorDebuggerNode::get_singleton();
diff --git a/editor/plugins/ot_features_plugin.cpp b/editor/plugins/ot_features_plugin.cpp
index 719b9ecc7c..f8e6054848 100644
--- a/editor/plugins/ot_features_plugin.cpp
+++ b/editor/plugins/ot_features_plugin.cpp
@@ -46,12 +46,15 @@ void OpenTypeFeaturesEditor::update_property() {
}
void OpenTypeFeaturesEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
-
- button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
- button->set_size(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))->get_size());
- spin->set_custom_label_color(true, base);
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
+
+ button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
+ button->set_size(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))->get_size());
+ spin->set_custom_label_color(true, base);
+ } break;
}
}
@@ -139,10 +142,13 @@ void OpenTypeFeaturesAdd::_features_menu() {
}
void OpenTypeFeaturesAdd::_notification(int p_what) {
- if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) {
- set_label("");
- button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
- button->set_size(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))->get_size());
+ switch (p_what) {
+ case NOTIFICATION_THEME_CHANGED:
+ case NOTIFICATION_ENTER_TREE: {
+ set_label("");
+ button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
+ button->set_size(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))->get_size());
+ } break;
}
}
diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp
index 910af24743..f096b2abb1 100644
--- a/editor/plugins/polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/polygon_2d_editor_plugin.cpp
@@ -69,6 +69,7 @@ void Polygon2DEditor::_notification(int p_what) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
uv_panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/sub_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning")));
} break;
+
case NOTIFICATION_READY: {
button_uv->set_icon(get_theme_icon(SNAME("Uv"), SNAME("EditorIcons")));
@@ -96,6 +97,7 @@ void Polygon2DEditor::_notification(int p_what) {
uv_edit_draw->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
bone_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
} break;
+
case NOTIFICATION_VISIBILITY_CHANGED: {
if (!is_visible()) {
uv_edit->hide();
diff --git a/editor/plugins/polygon_3d_editor_plugin.cpp b/editor/plugins/polygon_3d_editor_plugin.cpp
index 6cba3e2861..2d4812c55b 100644
--- a/editor/plugins/polygon_3d_editor_plugin.cpp
+++ b/editor/plugins/polygon_3d_editor_plugin.cpp
@@ -50,6 +50,7 @@ void Polygon3DEditor::_notification(int p_what) {
get_tree()->connect("node_removed", callable_mp(this, &Polygon3DEditor::_node_removed));
} break;
+
case NOTIFICATION_PROCESS: {
if (!node) {
return;
diff --git a/editor/plugins/replication_editor_plugin.cpp b/editor/plugins/replication_editor_plugin.cpp
index 604cbcd103..e4c1c69804 100644
--- a/editor/plugins/replication_editor_plugin.cpp
+++ b/editor/plugins/replication_editor_plugin.cpp
@@ -94,10 +94,15 @@ void ReplicationEditor::_bind_methods() {
}
void ReplicationEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
- add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("panel"), SNAME("Panel")));
- } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- update_keying();
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
+ add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("panel"), SNAME("Panel")));
+ } break;
+
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ update_keying();
+ } break;
}
}
@@ -355,13 +360,15 @@ void ReplicationEditorPlugin::_property_keyed(const String &p_keyed, const Varia
}
void ReplicationEditorPlugin::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE) {
- //Node3DEditor::get_singleton()->connect("transform_key_request", callable_mp(this, &AnimationPlayerEditorPlugin::_transform_key_request));
- InspectorDock::get_inspector_singleton()->connect("property_keyed", callable_mp(this, &ReplicationEditorPlugin::_property_keyed));
- repl_editor->connect("keying_changed", callable_mp(this, &ReplicationEditorPlugin::_keying_changed));
- // TODO make lock usable.
- //InspectorDock::get_inspector_singleton()->connect("object_inspected", callable_mp(repl_editor, &ReplicationEditor::update_keying));
- get_tree()->connect("node_removed", callable_mp(this, &ReplicationEditorPlugin::_node_removed));
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ //Node3DEditor::get_singleton()->connect("transform_key_request", callable_mp(this, &AnimationPlayerEditorPlugin::_transform_key_request));
+ InspectorDock::get_inspector_singleton()->connect("property_keyed", callable_mp(this, &ReplicationEditorPlugin::_property_keyed));
+ repl_editor->connect("keying_changed", callable_mp(this, &ReplicationEditorPlugin::_keying_changed));
+ // TODO make lock usable.
+ //InspectorDock::get_inspector_singleton()->connect("object_inspected", callable_mp(repl_editor, &ReplicationEditor::update_keying));
+ get_tree()->connect("node_removed", callable_mp(this, &ReplicationEditorPlugin::_node_removed));
+ } break;
}
}
diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp
index e04e3c146f..b7aef7f1bb 100644
--- a/editor/plugins/resource_preloader_editor_plugin.cpp
+++ b/editor/plugins/resource_preloader_editor_plugin.cpp
@@ -38,15 +38,10 @@
#include "editor/editor_settings.h"
void ResourcePreloaderEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE) {
- load->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")));
- }
-
- if (p_what == NOTIFICATION_READY) {
- //NodePath("/root")->connect("node_removed", this,"_node_removed",Vector<Variant>(),true);
- }
-
- if (p_what == NOTIFICATION_DRAW) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ load->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")));
+ } break;
}
}
diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp
index 34b39d2a17..bfb672d694 100644
--- a/editor/plugins/root_motion_editor_plugin.cpp
+++ b/editor/plugins/root_motion_editor_plugin.cpp
@@ -233,9 +233,12 @@ void EditorPropertyRootMotion::setup(const NodePath &p_base_hint) {
}
void EditorPropertyRootMotion::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Ref<Texture2D> t = get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"));
- clear->set_icon(t);
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ Ref<Texture2D> t = get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"));
+ clear->set_icon(t);
+ } break;
}
}
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 315879d4ac..205464daee 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -356,6 +356,7 @@ void ScriptEditorQuickOpen::_notification(int p_what) {
case NOTIFICATION_VISIBILITY_CHANGED: {
search_box->set_right_icon(search_options->get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
} break;
+
case NOTIFICATION_EXIT_TREE: {
disconnect("confirmed", callable_mp(this, &ScriptEditorQuickOpen::_confirmed));
} break;
@@ -1667,9 +1668,6 @@ void ScriptEditor::_notification(int p_what) {
}
} break;
-
- default:
- break;
}
}
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 4a47766fc0..b87f2995ed 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -1343,8 +1343,6 @@ void ScriptTextEditor::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
code_editor->get_text_editor()->set_gutter_width(connection_gutter, code_editor->get_text_editor()->get_line_height());
} break;
- default:
- break;
}
}
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index cfd0e664be..dd07831b83 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -3725,7 +3725,7 @@ void RichTextLabel::scroll_to_line(int p_line) {
if ((line_count <= p_line) && (line_count + main->lines[i].text_buf->get_line_count() >= p_line)) {
float line_offset = 0.f;
for (int j = 0; j < p_line - line_count; j++) {
- line_offset += main->lines[i].text_buf->get_line_size(j).y;
+ line_offset += main->lines[i].text_buf->get_line_size(j).y + get_theme_constant(SNAME("line_separation"));
}
vscroll->set_value(main->lines[i].offset.y + line_offset);
return;
@@ -3734,6 +3734,28 @@ void RichTextLabel::scroll_to_line(int p_line) {
}
}
+float RichTextLabel::get_line_offset(int p_line) {
+ int line_count = 0;
+ for (int i = 0; i < main->lines.size(); i++) {
+ if ((line_count <= p_line) && (p_line <= line_count + main->lines[i].text_buf->get_line_count())) {
+ float line_offset = 0.f;
+ for (int j = 0; j < p_line - line_count; j++) {
+ line_offset += main->lines[i].text_buf->get_line_size(j).y + get_theme_constant(SNAME("line_separation"));
+ }
+ return main->lines[i].offset.y + line_offset;
+ }
+ line_count += main->lines[i].text_buf->get_line_count();
+ }
+ return 0;
+}
+
+float RichTextLabel::get_paragraph_offset(int p_paragraph) {
+ if (0 <= p_paragraph && p_paragraph < main->lines.size()) {
+ return main->lines[p_paragraph].offset.y;
+ }
+ return 0;
+}
+
int RichTextLabel::get_line_count() const {
int line_count = 0;
for (int i = 0; i < main->lines.size(); i++) {
@@ -4350,6 +4372,9 @@ void RichTextLabel::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_content_height"), &RichTextLabel::get_content_height);
ClassDB::bind_method(D_METHOD("get_content_width"), &RichTextLabel::get_content_width);
+ ClassDB::bind_method(D_METHOD("get_line_offset", "line"), &RichTextLabel::get_line_offset);
+ ClassDB::bind_method(D_METHOD("get_paragraph_offset", "paragraph"), &RichTextLabel::get_paragraph_offset);
+
ClassDB::bind_method(D_METHOD("parse_expressions_for_values", "expressions"), &RichTextLabel::parse_expressions_for_values);
ClassDB::bind_method(D_METHOD("set_effects", "effects"), &RichTextLabel::set_effects);
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index ddc8cc75b8..53c2046c8f 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -551,6 +551,9 @@ public:
int get_paragraph_count() const;
int get_visible_paragraph_count() const;
+ float get_line_offset(int p_line);
+ float get_paragraph_offset(int p_paragraph);
+
void scroll_to_line(int p_line);
int get_line_count() const;
int get_visible_line_count() const;