1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-04 17:04:49 +00:00

Use new dock system for Debugger

This commit is contained in:
Logan Detrick
2025-11-24 15:59:05 -08:00
parent 9dd6c4dbac
commit 45f4aebe24
6 changed files with 37 additions and 38 deletions

View File

@@ -35,7 +35,6 @@
#include "editor/debugger/editor_debugger_server.h" #include "editor/debugger/editor_debugger_server.h"
#include "editor/debugger/editor_file_server.h" #include "editor/debugger/editor_file_server.h"
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/gui/editor_bottom_panel.h"
#include "editor/run/run_instances_dialog.h" #include "editor/run/run_instances_dialog.h"
#include "editor/script/script_editor_plugin.h" #include "editor/script/script_editor_plugin.h"
#include "editor/settings/editor_command_palette.h" #include "editor/settings/editor_command_palette.h"
@@ -56,7 +55,7 @@ DebuggerEditorPlugin::DebuggerEditorPlugin(PopupMenu *p_debug_menu) {
file_server = memnew(EditorFileServer); file_server = memnew(EditorFileServer);
EditorDebuggerNode *debugger = memnew(EditorDebuggerNode); EditorDebuggerNode *debugger = memnew(EditorDebuggerNode);
EditorNode::get_bottom_panel()->add_item(TTRC("Debugger"), debugger, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_debugger_bottom_panel", TTRC("Toggle Debugger Bottom Panel"), KeyModifierMask::ALT | Key::D)); EditorDockManager::get_singleton()->add_dock(debugger);
// Main editor debug menu. // Main editor debug menu.
debug_menu = p_debug_menu; debug_menu = p_debug_menu;

View File

@@ -40,9 +40,9 @@
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/editor_string_names.h" #include "editor/editor_string_names.h"
#include "editor/editor_undo_redo_manager.h" #include "editor/editor_undo_redo_manager.h"
#include "editor/gui/editor_bottom_panel.h"
#include "editor/run/editor_run_bar.h" #include "editor/run/editor_run_bar.h"
#include "editor/script/script_editor_plugin.h" #include "editor/script/script_editor_plugin.h"
#include "editor/settings/editor_command_palette.h"
#include "editor/settings/editor_settings.h" #include "editor/settings/editor_settings.h"
#include "editor/themes/editor_theme_manager.h" #include "editor/themes/editor_theme_manager.h"
#include "scene/gui/menu_button.h" #include "scene/gui/menu_button.h"
@@ -61,6 +61,17 @@ void _for_all(TabContainer *p_node, const Func &p_func) {
EditorDebuggerNode *EditorDebuggerNode::singleton = nullptr; EditorDebuggerNode *EditorDebuggerNode::singleton = nullptr;
EditorDebuggerNode::EditorDebuggerNode() { EditorDebuggerNode::EditorDebuggerNode() {
set_name(TTRC("Debugger"));
set_icon_name("Debug");
set_dock_shortcut(ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_debugger_bottom_panel", TTRC("Toggle Debugger Dock"), KeyModifierMask::ALT | Key::D));
set_default_slot(DockConstants::DOCK_SLOT_BOTTOM);
set_available_layouts(EditorDock::DOCK_LAYOUT_HORIZONTAL);
set_global(false);
set_transient(true);
set_clip_contents(false);
_update_margins();
if (!singleton) { if (!singleton) {
singleton = this; singleton = this;
} }
@@ -332,13 +343,6 @@ void EditorDebuggerNode::_notification(int p_what) {
} break; } break;
case NOTIFICATION_READY: { case NOTIFICATION_READY: {
// TODO: Replace this hack once EditorDebuggerNode is converted to a dock. It should be in the constructor.
EditorDock *parent = Object::cast_to<EditorDock>(get_parent());
if (parent) {
parent->set_clip_contents(false);
_update_margins();
}
_update_debug_options(); _update_debug_options();
initializing = false; initializing = false;
} break; } break;
@@ -440,29 +444,25 @@ void EditorDebuggerNode::_update_errors() {
last_error_count = error_count; last_error_count = error_count;
last_warning_count = warning_count; last_warning_count = warning_count;
// TODO: Replace this hack once EditorDebuggerNode is converted to a dock.
EditorDock *parent = Object::cast_to<EditorDock>(get_parent());
if (!parent) {
return;
}
if (error_count == 0 && warning_count == 0) { if (error_count == 0 && warning_count == 0) {
set_name(TTR("Debugger")); set_title("");
parent->set_dock_icon(Ref<Texture2D>()); set_dock_icon(Ref<Texture2D>());
parent->set_title_color(Color(0, 0, 0, 0)); set_title_color(Color(0, 0, 0, 0));
set_force_show_icon(false);
} else { } else {
set_name(TTR("Debugger") + " (" + itos(error_count + warning_count) + ")"); set_title(TTR("Debugger") + " (" + itos(error_count + warning_count) + ")");
if (error_count >= 1 && warning_count >= 1) { if (error_count >= 1 && warning_count >= 1) {
parent->set_dock_icon(get_editor_theme_icon(SNAME("ErrorWarning"))); set_dock_icon(get_editor_theme_icon(SNAME("ErrorWarning")));
// Use error color to represent the highest level of severity reported. // Use error color to represent the highest level of severity reported.
parent->set_title_color(get_theme_color(SNAME("error_color"), EditorStringName(Editor))); set_title_color(get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
} else if (error_count >= 1) { } else if (error_count >= 1) {
parent->set_dock_icon(get_editor_theme_icon(SNAME("Error"))); set_dock_icon(get_editor_theme_icon(SNAME("Error")));
parent->set_title_color(get_theme_color(SNAME("error_color"), EditorStringName(Editor))); set_title_color(get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
} else { } else {
parent->set_dock_icon(get_editor_theme_icon(SNAME("Warning"))); set_dock_icon(get_editor_theme_icon(SNAME("Warning")));
parent->set_title_color(get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); set_title_color(get_theme_color(SNAME("warning_color"), EditorStringName(Editor)));
} }
set_force_show_icon(true);
} }
} }
} }
@@ -564,7 +564,7 @@ void EditorDebuggerNode::_break_state_changed() {
const bool breaked = get_current_debugger()->is_breaked(); const bool breaked = get_current_debugger()->is_breaked();
const bool can_debug = get_current_debugger()->is_debuggable(); const bool can_debug = get_current_debugger()->is_debuggable();
if (breaked) { // Show debugger. if (breaked) { // Show debugger.
EditorNode::get_bottom_panel()->make_item_visible(this); EditorDockManager::get_singleton()->focus_dock(this);
} }
// Update script menu. // Update script menu.

View File

@@ -32,7 +32,7 @@
#include "core/object/script_language.h" #include "core/object/script_language.h"
#include "editor/debugger/editor_debugger_server.h" #include "editor/debugger/editor_debugger_server.h"
#include "scene/gui/margin_container.h" #include "editor/docks/editor_dock.h"
class Button; class Button;
class DebugAdapterParser; class DebugAdapterParser;
@@ -44,8 +44,8 @@ class ScriptEditorDebugger;
class TabContainer; class TabContainer;
class UndoRedo; class UndoRedo;
class EditorDebuggerNode : public MarginContainer { class EditorDebuggerNode : public EditorDock {
GDCLASS(EditorDebuggerNode, MarginContainer); GDCLASS(EditorDebuggerNode, EditorDock);
public: public:
enum CameraOverride { enum CameraOverride {

View File

@@ -73,7 +73,7 @@ void EditorDebuggerTree::_notification(int p_what) {
connect("item_mouse_selected", callable_mp(this, &EditorDebuggerTree::_scene_tree_rmb_selected)); connect("item_mouse_selected", callable_mp(this, &EditorDebuggerTree::_scene_tree_rmb_selected));
} break; } break;
case NOTIFICATION_ENTER_TREE: { case NOTIFICATION_READY: {
update_icon_max_width(); update_icon_max_width();
} break; } break;
} }

View File

@@ -1070,12 +1070,7 @@ void ScriptEditorDebugger::_update_reason_content_height() {
void ScriptEditorDebugger::_notification(int p_what) { void ScriptEditorDebugger::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_ENTER_TREE: { case NOTIFICATION_POSTINITIALIZE: {
le_set->connect(SceneStringName(pressed), callable_mp(this, &ScriptEditorDebugger::_live_edit_set));
le_clear->connect(SceneStringName(pressed), callable_mp(this, &ScriptEditorDebugger::_live_edit_clear));
error_tree->connect(SceneStringName(item_selected), callable_mp(this, &ScriptEditorDebugger::_error_selected));
error_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_error_activated));
breakpoints_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_breakpoint_tree_clicked));
connect("started", callable_mp(expression_evaluator, &EditorExpressionEvaluator::on_start)); connect("started", callable_mp(expression_evaluator, &EditorExpressionEvaluator::on_start));
} break; } break;
@@ -2206,6 +2201,7 @@ ScriptEditorDebugger::ScriptEditorDebugger() {
breakpoints_tree->set_hide_root(true); breakpoints_tree->set_hide_root(true);
breakpoints_tree->set_theme_type_variation("TreeSecondary"); breakpoints_tree->set_theme_type_variation("TreeSecondary");
breakpoints_tree->connect("item_mouse_selected", callable_mp(this, &ScriptEditorDebugger::_breakpoints_item_rmb_selected)); breakpoints_tree->connect("item_mouse_selected", callable_mp(this, &ScriptEditorDebugger::_breakpoints_item_rmb_selected));
breakpoints_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_breakpoint_tree_clicked));
breakpoints_tree->create_item(); breakpoints_tree->create_item();
parent_sc->add_child(breakpoints_tree); parent_sc->add_child(breakpoints_tree);
@@ -2262,6 +2258,8 @@ ScriptEditorDebugger::ScriptEditorDebugger() {
error_tree->set_allow_rmb_select(true); error_tree->set_allow_rmb_select(true);
error_tree->set_allow_reselect(true); error_tree->set_allow_reselect(true);
error_tree->set_theme_type_variation("TreeSecondary"); error_tree->set_theme_type_variation("TreeSecondary");
error_tree->connect(SceneStringName(item_selected), callable_mp(this, &ScriptEditorDebugger::_error_selected));
error_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_error_activated));
error_tree->connect("item_mouse_selected", callable_mp(this, &ScriptEditorDebugger::_error_tree_item_rmb_selected)); error_tree->connect("item_mouse_selected", callable_mp(this, &ScriptEditorDebugger::_error_tree_item_rmb_selected));
errors_tab->add_child(error_tree); errors_tab->add_child(error_tree);
@@ -2412,8 +2410,10 @@ Instead, use the monitors tab to obtain more precise VRAM usage.
info_left->add_child(l); info_left->add_child(l);
lehb->add_child(live_edit_root); lehb->add_child(live_edit_root);
le_set = memnew(Button(TTRC("Set From Tree"))); le_set = memnew(Button(TTRC("Set From Tree")));
le_set->connect(SceneStringName(pressed), callable_mp(this, &ScriptEditorDebugger::_live_edit_set));
lehb->add_child(le_set); lehb->add_child(le_set);
le_clear = memnew(Button(TTRC("Clear"))); le_clear = memnew(Button(TTRC("Clear")));
le_clear->connect(SceneStringName(pressed), callable_mp(this, &ScriptEditorDebugger::_live_edit_clear));
lehb->add_child(le_clear); lehb->add_child(le_clear);
info_left->add_child(lehb); info_left->add_child(lehb);
} }

View File

@@ -5321,7 +5321,7 @@ void EditorNode::_project_run_started() {
if (action_on_play == ACTION_ON_PLAY_OPEN_OUTPUT) { if (action_on_play == ACTION_ON_PLAY_OPEN_OUTPUT) {
editor_dock_manager->focus_dock(log); editor_dock_manager->focus_dock(log);
} else if (action_on_play == ACTION_ON_PLAY_OPEN_DEBUGGER) { } else if (action_on_play == ACTION_ON_PLAY_OPEN_DEBUGGER) {
bottom_panel->make_item_visible(EditorDebuggerNode::get_singleton()); editor_dock_manager->focus_dock(EditorDebuggerNode::get_singleton());
} }
} }