From 4ad74a5663d1e38f4e95159ec1caa53bae3b8799 Mon Sep 17 00:00:00 2001 From: kobewi Date: Tue, 30 Jan 2024 21:33:31 +0100 Subject: [PATCH] Some editor code cleanup --- editor/editor_dock_manager.cpp | 4 +--- editor/editor_node.cpp | 27 +++++++++------------------ editor/editor_node.h | 1 + editor/filesystem_dock.cpp | 7 +------ editor/filesystem_dock.h | 2 -- 5 files changed, 12 insertions(+), 29 deletions(-) diff --git a/editor/editor_dock_manager.cpp b/editor/editor_dock_manager.cpp index 0a133778577..dc4c8098604 100644 --- a/editor/editor_dock_manager.cpp +++ b/editor/editor_dock_manager.cpp @@ -510,9 +510,7 @@ void EditorDockManager::save_docks_to_config(Ref p_layout, const Str Array bottom_docks_dump; for (Control *bdock : bottom_docks) { - Control *dock = bdock; - String name = dock->get_name(); - bottom_docks_dump.push_back(name); + bottom_docks_dump.push_back(bdock->get_name()); } p_layout->set_value(p_section, "dock_bottom", bottom_docks_dump); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 3691172c180..6711be3d069 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -5158,27 +5158,11 @@ void EditorNode::_scene_tab_closed(int p_tab) { scene_tabs->update_scene_tabs(); } -class EditorBottomDockButton : public Button { - GDCLASS(EditorBottomDockButton, Button) - - static void _bind_methods() { - ADD_SIGNAL(MethodInfo("dropping")); - } - -public: - virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const override { - if (!is_pressed()) { - const_cast(this)->emit_signal("dropping"); - } - return false; - } -}; - Button *EditorNode::add_bottom_panel_item(String p_text, Control *p_item, bool p_at_front) { - Button *tb = memnew(EditorBottomDockButton); + Button *tb = memnew(Button); tb->set_flat(true); tb->connect("toggled", callable_mp(this, &EditorNode::_bottom_panel_switch_by_control).bind(p_item)); - tb->connect("dropping", callable_mp(this, &EditorNode::_bottom_panel_switch_by_control).bind(true, p_item)); + tb->set_drag_forwarding(Callable(), callable_mp(this, &EditorNode::_bottom_panel_drag_hover).bind(tb, p_item), Callable()); tb->set_text(p_text); tb->set_toggle_mode(true); tb->set_focus_mode(Control::FOCUS_NONE); @@ -6015,6 +5999,13 @@ void EditorNode::_bottom_panel_raise_toggled(bool p_pressed) { top_split->set_visible(!p_pressed); } +bool EditorNode::_bottom_panel_drag_hover(const Vector2 &, const Variant &, Button *p_button, Control *p_control) { + if (!p_button->is_pressed()) { + _bottom_panel_switch_by_control(true, p_control); + } + return false; +} + void EditorNode::_update_renderer_color() { String rendering_method = renderer->get_selected_metadata(); diff --git a/editor/editor_node.h b/editor/editor_node.h index 7d6123d04b1..e7011e921ee 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -657,6 +657,7 @@ private: void _bottom_panel_switch_by_control(bool p_enable, Control *p_control); void _bottom_panel_switch(bool p_enable, int p_idx); void _bottom_panel_raise_toggled(bool); + bool _bottom_panel_drag_hover(const Vector2 &, const Variant &, Button *p_button, Control *p_control); void _begin_first_scan(); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index facc3c3bb59..02ae15b80d9 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -495,12 +495,7 @@ void FileSystemDock::_update_display_mode(bool p_force) { void FileSystemDock::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - if (initialized) { - return; - } - initialized = true; - + case NOTIFICATION_READY: { EditorFeatureProfileManager::get_singleton()->connect("current_feature_profile_changed", callable_mp(this, &FileSystemDock::_feature_profile_changed)); EditorFileSystem::get_singleton()->connect("filesystem_changed", callable_mp(this, &FileSystemDock::_fs_changed)); EditorResourcePreview::get_singleton()->connect("preview_invalidated", callable_mp(this, &FileSystemDock::_preview_invalidated)); diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index d161a3bd15b..c9d2bc535ee 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -230,8 +230,6 @@ private: String current_path; String select_after_scan; - bool initialized = false; - bool updating_tree = false; int tree_update_id; FileSystemTree *tree = nullptr;