1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-18 14:21:41 +00:00

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

View File

@@ -356,12 +356,13 @@ void EditorNode::_update_scene_tabs() {
scene_tabs->set_current_tab(editor_data.get_edited_scene()); 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()) { if (scene_tabs->get_offset_buttons_visible()) {
// Move the add button to a fixed position. // Move the add button to a fixed position.
if (scene_tab_add->get_parent() == scene_tabs) { if (scene_tab_add->get_parent() == scene_tabs) {
scene_tabs->remove_child(scene_tab_add); scene_tabs->remove_child(scene_tab_add);
scene_tab_add_ph->add_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 { } else {
// Move the add button to be after the last tab. // 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) { if (scene_tabs->get_tab_count() == 0) {
scene_tab_add->set_position(Point2()); scene_tab_add->set_rect(Rect2(Point2(), add_button_size));
return; return;
} }
Rect2 last_tab = scene_tabs->get_tab_rect(scene_tabs->get_tab_count() - 1); Rect2 last_tab = scene_tabs->get_tab_rect(scene_tabs->get_tab_count() - 1);
int hsep = scene_tabs->get_theme_constant(SNAME("h_separation")); int hsep = scene_tabs->get_theme_constant(SNAME("h_separation"));
if (scene_tabs->is_layout_rtl()) { 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 { } 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));
} }
} }