Skip to content

Commit 30f1ab1

Browse files
committed
Merge pull request #113133 from lodetrick/debugger-dock
Use new dock system for Debugger
2 parents e0e1a0c + 45f4aeb commit 30f1ab1

File tree

6 files changed

+37
-38
lines changed

6 files changed

+37
-38
lines changed

editor/debugger/debugger_editor_plugin.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include "editor/debugger/editor_debugger_server.h"
3636
#include "editor/debugger/editor_file_server.h"
3737
#include "editor/editor_node.h"
38-
#include "editor/gui/editor_bottom_panel.h"
3938
#include "editor/run/run_instances_dialog.h"
4039
#include "editor/script/script_editor_plugin.h"
4140
#include "editor/settings/editor_command_palette.h"
@@ -56,7 +55,7 @@ DebuggerEditorPlugin::DebuggerEditorPlugin(PopupMenu *p_debug_menu) {
5655
file_server = memnew(EditorFileServer);
5756

5857
EditorDebuggerNode *debugger = memnew(EditorDebuggerNode);
59-
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));
58+
EditorDockManager::get_singleton()->add_dock(debugger);
6059

6160
// Main editor debug menu.
6261
debug_menu = p_debug_menu;

editor/debugger/editor_debugger_node.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@
4040
#include "editor/editor_node.h"
4141
#include "editor/editor_string_names.h"
4242
#include "editor/editor_undo_redo_manager.h"
43-
#include "editor/gui/editor_bottom_panel.h"
4443
#include "editor/run/editor_run_bar.h"
4544
#include "editor/script/script_editor_plugin.h"
45+
#include "editor/settings/editor_command_palette.h"
4646
#include "editor/settings/editor_settings.h"
4747
#include "editor/themes/editor_theme_manager.h"
4848
#include "scene/gui/menu_button.h"
@@ -61,6 +61,17 @@ void _for_all(TabContainer *p_node, const Func &p_func) {
6161
EditorDebuggerNode *EditorDebuggerNode::singleton = nullptr;
6262

6363
EditorDebuggerNode::EditorDebuggerNode() {
64+
set_name(TTRC("Debugger"));
65+
set_icon_name("Debug");
66+
set_dock_shortcut(ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_debugger_bottom_panel", TTRC("Toggle Debugger Dock"), KeyModifierMask::ALT | Key::D));
67+
set_default_slot(DockConstants::DOCK_SLOT_BOTTOM);
68+
set_available_layouts(EditorDock::DOCK_LAYOUT_HORIZONTAL);
69+
set_global(false);
70+
set_transient(true);
71+
72+
set_clip_contents(false);
73+
_update_margins();
74+
6475
if (!singleton) {
6576
singleton = this;
6677
}
@@ -332,13 +343,6 @@ void EditorDebuggerNode::_notification(int p_what) {
332343
} break;
333344

334345
case NOTIFICATION_READY: {
335-
// TODO: Replace this hack once EditorDebuggerNode is converted to a dock. It should be in the constructor.
336-
EditorDock *parent = Object::cast_to<EditorDock>(get_parent());
337-
if (parent) {
338-
parent->set_clip_contents(false);
339-
_update_margins();
340-
}
341-
342346
_update_debug_options();
343347
initializing = false;
344348
} break;
@@ -440,29 +444,25 @@ void EditorDebuggerNode::_update_errors() {
440444
last_error_count = error_count;
441445
last_warning_count = warning_count;
442446

443-
// TODO: Replace this hack once EditorDebuggerNode is converted to a dock.
444-
EditorDock *parent = Object::cast_to<EditorDock>(get_parent());
445-
if (!parent) {
446-
return;
447-
}
448-
449447
if (error_count == 0 && warning_count == 0) {
450-
set_name(TTR("Debugger"));
451-
parent->set_dock_icon(Ref<Texture2D>());
452-
parent->set_title_color(Color(0, 0, 0, 0));
448+
set_title("");
449+
set_dock_icon(Ref<Texture2D>());
450+
set_title_color(Color(0, 0, 0, 0));
451+
set_force_show_icon(false);
453452
} else {
454-
set_name(TTR("Debugger") + " (" + itos(error_count + warning_count) + ")");
453+
set_title(TTR("Debugger") + " (" + itos(error_count + warning_count) + ")");
455454
if (error_count >= 1 && warning_count >= 1) {
456-
parent->set_dock_icon(get_editor_theme_icon(SNAME("ErrorWarning")));
455+
set_dock_icon(get_editor_theme_icon(SNAME("ErrorWarning")));
457456
// Use error color to represent the highest level of severity reported.
458-
parent->set_title_color(get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
457+
set_title_color(get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
459458
} else if (error_count >= 1) {
460-
parent->set_dock_icon(get_editor_theme_icon(SNAME("Error")));
461-
parent->set_title_color(get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
459+
set_dock_icon(get_editor_theme_icon(SNAME("Error")));
460+
set_title_color(get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
462461
} else {
463-
parent->set_dock_icon(get_editor_theme_icon(SNAME("Warning")));
464-
parent->set_title_color(get_theme_color(SNAME("warning_color"), EditorStringName(Editor)));
462+
set_dock_icon(get_editor_theme_icon(SNAME("Warning")));
463+
set_title_color(get_theme_color(SNAME("warning_color"), EditorStringName(Editor)));
465464
}
465+
set_force_show_icon(true);
466466
}
467467
}
468468
}
@@ -564,7 +564,7 @@ void EditorDebuggerNode::_break_state_changed() {
564564
const bool breaked = get_current_debugger()->is_breaked();
565565
const bool can_debug = get_current_debugger()->is_debuggable();
566566
if (breaked) { // Show debugger.
567-
EditorNode::get_bottom_panel()->make_item_visible(this);
567+
EditorDockManager::get_singleton()->focus_dock(this);
568568
}
569569

570570
// Update script menu.

editor/debugger/editor_debugger_node.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
#include "core/object/script_language.h"
3434
#include "editor/debugger/editor_debugger_server.h"
35-
#include "scene/gui/margin_container.h"
35+
#include "editor/docks/editor_dock.h"
3636

3737
class Button;
3838
class DebugAdapterParser;
@@ -44,8 +44,8 @@ class ScriptEditorDebugger;
4444
class TabContainer;
4545
class UndoRedo;
4646

47-
class EditorDebuggerNode : public MarginContainer {
48-
GDCLASS(EditorDebuggerNode, MarginContainer);
47+
class EditorDebuggerNode : public EditorDock {
48+
GDCLASS(EditorDebuggerNode, EditorDock);
4949

5050
public:
5151
enum CameraOverride {

editor/debugger/editor_debugger_tree.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void EditorDebuggerTree::_notification(int p_what) {
7373
connect("item_mouse_selected", callable_mp(this, &EditorDebuggerTree::_scene_tree_rmb_selected));
7474
} break;
7575

76-
case NOTIFICATION_ENTER_TREE: {
76+
case NOTIFICATION_READY: {
7777
update_icon_max_width();
7878
} break;
7979
}

editor/debugger/script_editor_debugger.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,12 +1070,7 @@ void ScriptEditorDebugger::_update_reason_content_height() {
10701070

10711071
void ScriptEditorDebugger::_notification(int p_what) {
10721072
switch (p_what) {
1073-
case NOTIFICATION_ENTER_TREE: {
1074-
le_set->connect(SceneStringName(pressed), callable_mp(this, &ScriptEditorDebugger::_live_edit_set));
1075-
le_clear->connect(SceneStringName(pressed), callable_mp(this, &ScriptEditorDebugger::_live_edit_clear));
1076-
error_tree->connect(SceneStringName(item_selected), callable_mp(this, &ScriptEditorDebugger::_error_selected));
1077-
error_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_error_activated));
1078-
breakpoints_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_breakpoint_tree_clicked));
1073+
case NOTIFICATION_POSTINITIALIZE: {
10791074
connect("started", callable_mp(expression_evaluator, &EditorExpressionEvaluator::on_start));
10801075
} break;
10811076

@@ -2206,6 +2201,7 @@ ScriptEditorDebugger::ScriptEditorDebugger() {
22062201
breakpoints_tree->set_hide_root(true);
22072202
breakpoints_tree->set_theme_type_variation("TreeSecondary");
22082203
breakpoints_tree->connect("item_mouse_selected", callable_mp(this, &ScriptEditorDebugger::_breakpoints_item_rmb_selected));
2204+
breakpoints_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_breakpoint_tree_clicked));
22092205
breakpoints_tree->create_item();
22102206

22112207
parent_sc->add_child(breakpoints_tree);
@@ -2262,6 +2258,8 @@ ScriptEditorDebugger::ScriptEditorDebugger() {
22622258
error_tree->set_allow_rmb_select(true);
22632259
error_tree->set_allow_reselect(true);
22642260
error_tree->set_theme_type_variation("TreeSecondary");
2261+
error_tree->connect(SceneStringName(item_selected), callable_mp(this, &ScriptEditorDebugger::_error_selected));
2262+
error_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_error_activated));
22652263
error_tree->connect("item_mouse_selected", callable_mp(this, &ScriptEditorDebugger::_error_tree_item_rmb_selected));
22662264
errors_tab->add_child(error_tree);
22672265

@@ -2412,8 +2410,10 @@ Instead, use the monitors tab to obtain more precise VRAM usage.
24122410
info_left->add_child(l);
24132411
lehb->add_child(live_edit_root);
24142412
le_set = memnew(Button(TTRC("Set From Tree")));
2413+
le_set->connect(SceneStringName(pressed), callable_mp(this, &ScriptEditorDebugger::_live_edit_set));
24152414
lehb->add_child(le_set);
24162415
le_clear = memnew(Button(TTRC("Clear")));
2416+
le_clear->connect(SceneStringName(pressed), callable_mp(this, &ScriptEditorDebugger::_live_edit_clear));
24172417
lehb->add_child(le_clear);
24182418
info_left->add_child(lehb);
24192419
}

editor/editor_node.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5322,7 +5322,7 @@ void EditorNode::_project_run_started() {
53225322
if (action_on_play == ACTION_ON_PLAY_OPEN_OUTPUT) {
53235323
editor_dock_manager->focus_dock(log);
53245324
} else if (action_on_play == ACTION_ON_PLAY_OPEN_DEBUGGER) {
5325-
bottom_panel->make_item_visible(EditorDebuggerNode::get_singleton());
5325+
editor_dock_manager->focus_dock(EditorDebuggerNode::get_singleton());
53265326
}
53275327
}
53285328

0 commit comments

Comments
 (0)