A bunch of tab fixes (#6551)

* Make sure the speed tab is properly hidden when toggle off advance mode

* Clear each page before clearing the parent, otherwise the child pages will be destroyed twice

* Fix crash if current selected tab is positioned after the removed tab

* Fix issue that sometimes the printer config first page is not displayed

* Fix issue that the wrong tab item get bold if the number of tabs changed
This commit is contained in:
Noisyfox
2024-08-26 20:21:59 +08:00
committed by GitHub
parent 2bf54878f7
commit 3757295b95
4 changed files with 23 additions and 17 deletions

View File

@@ -120,6 +120,11 @@ bool TabCtrl::DeleteItem(int item)
if (item < 0 || item >= btns.size()) {
return false;
}
const bool selection_changed = sel >= item;
if (selection_changed) {
sendTabCtrlEvent(true);
}
Button* btn = btns[item];
btn->Destroy();
@@ -127,9 +132,12 @@ bool TabCtrl::DeleteItem(int item)
sizer->Remove(item * 2);
if (btns.size() > 1)
sizer->GetItem(sizer->GetItemCount() - 1)->SetMinSize({0, 0});
if (selection_changed) {
sel--; // `relayout()` uses `sel` so we need to update this before calling `relayout()`
}
relayout();
if (sel >= item) {
sel--;
if (selection_changed) {
sendTabCtrlEvent();
}