Fix crash and Haiku preference window bugs
Some checks failed
Build / build-gentoo (push) Failing after 1m7s
Build / download-system-deps (push) Successful in 5m25s
Build / get-source-code (push) Successful in 11m27s
Build / build-deb (push) Successful in 11m17s
Build / build-appimage (push) Successful in 4m46s
Build / build-android (push) Failing after 3m22s
Build / build-windows (push) Failing after 9m41s

This commit is contained in:
Zachary Hall 2024-12-22 13:42:13 -08:00
parent 8e242d345b
commit b0bfa7945f
2 changed files with 15 additions and 4 deletions

View file

@ -165,6 +165,7 @@ HaikuLooperWindow::HaikuLooperWindow(Playback *playback) : BWindow(BRect(100, 10
delete msg; delete msg;
} }
void HaikuLooperWindow::UpdateCat(BBitmap *cat) { void HaikuLooperWindow::UpdateCat(BBitmap *cat) {
LockLooper();
if (cat != NULL) { if (cat != NULL) {
auto bounds = cat->Bounds(); auto bounds = cat->Bounds();
auto w = bounds.Width(), h = bounds.Height(); auto w = bounds.Width(), h = bounds.Height();
@ -183,10 +184,11 @@ void HaikuLooperWindow::UpdateCat(BBitmap *cat) {
} }
} }
BRect dst(sw - w, sh - h, w, h); BRect dst(sw - w, sh - h, w, h);
spacer->SetViewBitmap(cat, src, dst, B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM); spacer->SetViewOverlay(cat, src, dst, NULL, B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM);
} else { } else {
spacer->ClearViewBitmap(); spacer->ClearViewOverlay();
} }
UnlockLooper();
} }
HaikuLooperWindow::~HaikuLooperWindow() { HaikuLooperWindow::~HaikuLooperWindow() {
delete ref_handler; delete ref_handler;

View file

@ -73,6 +73,7 @@ HaikuPrefsWindow::HaikuPrefsWindow(BLooper *next_handler) : BWindow(BRect(100, 1
BBox *box = new BBox("prefs:label_settings_box"); BBox *box = new BBox("prefs:label_settings_box");
box->SetLabel("Labels and Icons"); box->SetLabel("Labels and Icons");
auto *label_settings_group = new BGroupView(B_VERTICAL); auto *label_settings_group = new BGroupView(B_VERTICAL);
box->AddChild(label_settings_group);
BGroupLayout *label_settings_layout = label_settings_group->GroupLayout(); BGroupLayout *label_settings_layout = label_settings_group->GroupLayout();
BMessage *labels_only_msg = new BMessage(CMD_SET_SETTING); BMessage *labels_only_msg = new BMessage(CMD_SET_SETTING);
labels_only_msg->AddString("pref_path", "ui.haiku.label_setting"); labels_only_msg->AddString("pref_path", "ui.haiku.label_setting");
@ -92,6 +93,8 @@ HaikuPrefsWindow::HaikuPrefsWindow(BLooper *next_handler) : BWindow(BRect(100, 1
BMessage *cat_enable_msg = new BMessage(CMD_SET_SETTING_CHECKBOX); BMessage *cat_enable_msg = new BMessage(CMD_SET_SETTING_CHECKBOX);
cat_enable_msg->AddString("pref_path", "ui.cat_enable"); cat_enable_msg->AddString("pref_path", "ui.cat_enable");
cat_enable = new BCheckBox("Enable Cat", cat_enable_msg); cat_enable = new BCheckBox("Enable Cat", cat_enable_msg);
BBox *cat_box = new BBox("prefs:cat_options");
cat_box->SetLabel("Cat Options");
BGroupView *cat_group = new BGroupView(B_VERTICAL); BGroupView *cat_group = new BGroupView(B_VERTICAL);
BGroupLayout *cat_layout = cat_group->GroupLayout(); BGroupLayout *cat_layout = cat_group->GroupLayout();
for (auto &kv : cats) { for (auto &kv : cats) {
@ -116,9 +119,15 @@ HaikuPrefsWindow::HaikuPrefsWindow(BLooper *next_handler) : BWindow(BRect(100, 1
} }
} }
BRect dst(rw - w, (rh - h) / 2, rw, rh); BRect dst(rw - w, (rh - h) / 2, rw, rh);
cat_radio->SetViewBitmap(cat_bmp, src, dst, B_FOLLOW_RIGHT|B_FOLLOW_TOP_BOTTOM); LockLooper();
cat_radio->SetViewOverlay(cat_bmp, src, dst, NULL, B_FOLLOW_RIGHT|B_FOLLOW_TOP_BOTTOM);
UnlockLooper();
cat_layout->AddView(cat_radio);
} }
root_layout->AddView(box, 3.0); root_layout->AddView(box, 3.0);
cat_box->AddChild(cat_group);
root_layout->AddView(cat_enable);
root_layout->AddView(cat_box, 3.0);
BGroupView *btn_view = new BGroupView(B_HORIZONTAL); BGroupView *btn_view = new BGroupView(B_HORIZONTAL);
BGroupLayout *btn_box = btn_view->GroupLayout(); BGroupLayout *btn_box = btn_view->GroupLayout();
revert_btn = new BButton("prefs:revert", "Revert", new BMessage(CMD_REVERT)); revert_btn = new BButton("prefs:revert", "Revert", new BMessage(CMD_REVERT));
@ -183,7 +192,7 @@ void HaikuPrefsWindow::MessageReceived(BMessage *msg) {
break; break;
} }
} }
cat_btns[cat_id]->SetValue(B_CONTROL_OFF); if (cat_btns.contains(cat_id)) cat_btns[cat_id]->SetValue(B_CONTROL_OFF);
cat_id = get_option<std::string>("ui.cat", cats.empty() ? "" : cats.begin()->first); cat_id = get_option<std::string>("ui.cat", cats.empty() ? "" : cats.begin()->first);
if (cat_btns.contains(cat_id)) cat_btns[cat_id]->SetValue(B_CONTROL_ON); if (cat_btns.contains(cat_id)) cat_btns[cat_id]->SetValue(B_CONTROL_ON);
enable_cat = get_option<bool>("ui.enable_cat", false); enable_cat = get_option<bool>("ui.enable_cat", false);