You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-04 17:04:49 +00:00
Fix tab bar offset
This commit is contained in:
@@ -1829,26 +1829,33 @@ void TabBar::_ensure_no_over_offset() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int limit_minus_buttons = get_size().width - theme_cache.increment_icon->get_width() - theme_cache.decrement_icon->get_width();
|
int limit_with_buttons = get_size().width - theme_cache.increment_icon->get_width() - theme_cache.decrement_icon->get_width();
|
||||||
|
int limit_with_no_button = get_size().width;
|
||||||
int prev_offset = offset;
|
int offset_with_buttons = offset;
|
||||||
|
int offset_with_no_button = offset;
|
||||||
|
|
||||||
int total_w = tabs[max_drawn_tab].ofs_cache + tabs[max_drawn_tab].size_cache - tabs[offset].ofs_cache;
|
int total_w = tabs[max_drawn_tab].ofs_cache + tabs[max_drawn_tab].size_cache - tabs[offset].ofs_cache;
|
||||||
for (int i = offset; i > 0; i--) {
|
for (int i = offset - 1; i >= 0; i--) {
|
||||||
if (tabs[i - 1].hidden) {
|
if (tabs[i].hidden) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
total_w += tabs[i - 1].size_cache;
|
total_w += tabs[i].size_cache;
|
||||||
|
|
||||||
if (total_w < limit_minus_buttons) {
|
if (total_w < limit_with_buttons) {
|
||||||
offset--;
|
offset_with_buttons--;
|
||||||
|
offset_with_no_button--;
|
||||||
|
} else if (total_w < limit_with_no_button) {
|
||||||
|
offset_with_no_button--;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prev_offset != offset) {
|
int new_offset = (offset_with_no_button == 0) ? 0 : offset_with_buttons;
|
||||||
|
|
||||||
|
if (new_offset != offset) {
|
||||||
|
offset = new_offset;
|
||||||
_update_cache();
|
_update_cache();
|
||||||
queue_redraw();
|
queue_redraw();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user