Merge pull request #75381 from timothyqiu/add-height

Make Add Scene button the same height as scene tabs
This commit is contained in:
Yuri Sizov 2023-03-27 11:22:20 +02:00 committed by GitHub
commit ee68e4e29a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -356,12 +356,13 @@ void EditorNode::_update_scene_tabs() {
scene_tabs->set_current_tab(editor_data.get_edited_scene());
}
const Size2 add_button_size = Size2(0, scene_tabs->get_size().y);
if (scene_tabs->get_offset_buttons_visible()) {
// Move the add button to a fixed position.
if (scene_tab_add->get_parent() == scene_tabs) {
scene_tabs->remove_child(scene_tab_add);
scene_tab_add_ph->add_child(scene_tab_add);
scene_tab_add->set_position(Point2());
scene_tab_add->set_rect(Rect2(Point2(), add_button_size));
}
} else {
// Move the add button to be after the last tab.
@ -371,16 +372,16 @@ void EditorNode::_update_scene_tabs() {
}
if (scene_tabs->get_tab_count() == 0) {
scene_tab_add->set_position(Point2());
scene_tab_add->set_rect(Rect2(Point2(), add_button_size));
return;
}
Rect2 last_tab = scene_tabs->get_tab_rect(scene_tabs->get_tab_count() - 1);
int hsep = scene_tabs->get_theme_constant(SNAME("h_separation"));
if (scene_tabs->is_layout_rtl()) {
scene_tab_add->set_position(Point2(last_tab.position.x - scene_tab_add->get_size().x - hsep, last_tab.position.y));
scene_tab_add->set_rect(Rect2(Point2(last_tab.position.x - scene_tab_add->get_size().x - hsep, last_tab.position.y), add_button_size));
} else {
scene_tab_add->set_position(Point2(last_tab.position.x + last_tab.size.width + hsep, last_tab.position.y));
scene_tab_add->set_rect(Rect2(Point2(last_tab.position.x + last_tab.size.width + hsep, last_tab.position.y), add_button_size));
}
}