Some editor code cleanup

This commit is contained in:
kobewi 2024-01-30 21:33:31 +01:00
parent 313f623b9d
commit 4ad74a5663
5 changed files with 12 additions and 29 deletions

View file

@ -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);

View file

@ -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();

View file

@ -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();

View file

@ -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));

View file

@ -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;