浏览代码

Some editor code cleanup

kobewi 1 年之前
父节点
当前提交
4ad74a5663
共有 5 个文件被更改,包括 12 次插入29 次删除
  1. 1 3
      editor/editor_dock_manager.cpp
  2. 9 18
      editor/editor_node.cpp
  3. 1 0
      editor/editor_node.h
  4. 1 6
      editor/filesystem_dock.cpp
  5. 0 2
      editor/filesystem_dock.h

+ 1 - 3
editor/editor_dock_manager.cpp

@@ -510,9 +510,7 @@ void EditorDockManager::save_docks_to_config(Ref<ConfigFile> 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);

+ 9 - 18
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<EditorBottomDockButton *>(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();
 

+ 1 - 0
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();
 

+ 1 - 6
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));

+ 0 - 2
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;