From 8e242d345b53aff17f98345dd292021fe03f404d Mon Sep 17 00:00:00 2001 From: Zachary Hall Date: Sun, 22 Dec 2024 13:12:01 -0800 Subject: [PATCH] Fix some more compiler errors --- backends/ui/haiku/main_window.cpp | 23 ++++------------------- backends/ui/haiku/prefs.cpp | 28 +++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/backends/ui/haiku/main_window.cpp b/backends/ui/haiku/main_window.cpp index 861b8e1..2a20b31 100644 --- a/backends/ui/haiku/main_window.cpp +++ b/backends/ui/haiku/main_window.cpp @@ -63,22 +63,7 @@ void HaikuLooperWindow::UpdateViewFlags(BLayout *layout) { } UpdateViewFlags(owner); } -void HaikuLooperWindow::AddCat(std::string name, BBitmap *bitmap) { - if (bitmap == NULL) return; - if (cats.contains(name)) { - delete cats[name]; - } - cats[name] = bitmap; -} -void HaikuLooperWindow::LoadCat(const char *path) { - return BTranslationUtils::LoadBitmap(path); -} -void HaikuLooperWindow::LoadCat(const void *ptr, size_t len, const char *name) { - BMemoryIO *io = new BMemoryIO(ptr, len); - BBitmap *output = BTranslationUtils::LoadBitmap(io); - delete io; - return output; -} + HaikuLooperWindow::HaikuLooperWindow(Playback *playback) : BWindow(BRect(100, 100, 500, 100), "Looper", B_TITLED_WINDOW, 0) { pause_bitmap = load_icon(ICON_PAUSE); resume_bitmap = load_icon(ICON_PLAY); @@ -198,9 +183,9 @@ void HaikuLooperWindow::UpdateCat(BBitmap *cat) { } } BRect dst(sw - w, sh - h, w, h); - spacer->SetOverlayBitmap(cat, src, dst, NULL, B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM); + spacer->SetViewBitmap(cat, src, dst, B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM); } else { - spacer->ClearOverlayBitmap(); + spacer->ClearViewBitmap(); } } HaikuLooperWindow::~HaikuLooperWindow() { @@ -289,7 +274,7 @@ void HaikuLooperWindow::MessageReceived(BMessage *msg) { } break; case CMD_SET_CAT: { BBitmap *cat = NULL; - if (msg->FindPointer("cat", &cat) != B_OK) { + if (msg->FindPointer("cat", (void**)&cat) != B_OK) { cat = NULL; } UpdateCat(cat); diff --git a/backends/ui/haiku/prefs.cpp b/backends/ui/haiku/prefs.cpp index 77d2db1..48e2f7a 100644 --- a/backends/ui/haiku/prefs.cpp +++ b/backends/ui/haiku/prefs.cpp @@ -7,6 +7,8 @@ #include #include #include "main_window.h" +#include +#include using namespace Looper::Options; #define CMD_UPDATE_LABEL_SETTING 0x1000 #define CMD_FRONTEND 0x1001 @@ -15,6 +17,22 @@ using namespace Looper::Options; #define CMD_APPLY 0x1004 #define CMD_SET_SETTING_CHECKBOX 0x1005 bool show_icons, show_labels; +void HaikuPrefsWindow::AddCat(std::string name, BBitmap *bitmap) { + if (bitmap == NULL) return; + if (cats.contains(name)) { + delete cats[name]; + } + cats[name] = bitmap; +} +BBitmap *HaikuPrefsWindow::LoadCat(const char *path) { + return BTranslationUtils::GetBitmap(path); +} +BBitmap *HaikuPrefsWindow::LoadCat(const void *ptr, size_t len, const char *name) { + BMemoryIO *io = new BMemoryIO(ptr, len); + BBitmap *output = BTranslationUtils::GetBitmap(io); + delete io; + return output; +} HaikuPrefsWindow::HaikuPrefsWindow(BLooper *next_handler) : BWindow(BRect(100, 100, 0, 0), "Preferences", B_TITLED_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS) { this->next_handler = next_handler; @@ -83,7 +101,7 @@ HaikuPrefsWindow::HaikuPrefsWindow(BLooper *next_handler) : BWindow(BRect(100, 1 BRadioButton *cat_radio = new BRadioButton(fmt::format("prefs:cat:{}", kv.first).c_str(), msg); cat_btns[kv.first] = cat_radio; BBitmap *cat_bmp = kv.second; - BRect src = cat_bmp->bounds(); + BRect src = cat_bmp->Bounds(); float w = src.Width(), h = src.Height(); float rw = cat_radio->Bounds().Width(), rh = cat_radio->Bounds().Height(); if (w > rw || h > rh) { @@ -98,7 +116,7 @@ HaikuPrefsWindow::HaikuPrefsWindow(BLooper *next_handler) : BWindow(BRect(100, 1 } } BRect dst(rw - w, (rh - h) / 2, rw, rh); - cat_radio->SetOverlayBitmap(cat_bmp, src, dst, B_FOLLOW_RIGHT|B_FOLLOW_TOP_BOTTOM); + cat_radio->SetViewBitmap(cat_bmp, src, dst, B_FOLLOW_RIGHT|B_FOLLOW_TOP_BOTTOM); } root_layout->AddView(box, 3.0); BGroupView *btn_view = new BGroupView(B_HORIZONTAL); @@ -149,7 +167,7 @@ void HaikuPrefsWindow::MessageReceived(BMessage *msg) { set_option("ui.enable_cat", enable_cat); next_handler->PostMessage(CMD_UPDATE_LABEL_SETTING); BMessage *cat_msg = new BMessage(CMD_SET_CAT); - if (enable_cat) cat_msg->AddPointer("cat", cats[cat_id]) + if (enable_cat) cat_msg->AddPointer("cat", cats[cat_id]); next_handler->PostMessage(cat_msg); } break; case CMD_REVERT: { @@ -165,7 +183,7 @@ void HaikuPrefsWindow::MessageReceived(BMessage *msg) { break; } } - cat_btns[cat_id].SetValue(B_CONTROL_OFF); + cat_btns[cat_id]->SetValue(B_CONTROL_OFF); cat_id = get_option("ui.cat", cats.empty() ? "" : cats.begin()->first); if (cat_btns.contains(cat_id)) cat_btns[cat_id]->SetValue(B_CONTROL_ON); enable_cat = get_option("ui.enable_cat", false); @@ -173,7 +191,7 @@ void HaikuPrefsWindow::MessageReceived(BMessage *msg) { update_label_setting(); next_handler->PostMessage(CMD_UPDATE_LABEL_SETTING); BMessage *cat_msg = new BMessage(CMD_SET_CAT); - if (enable_cat) cat_msg->AddBitmap("cat", cats[cat_id]) + if (enable_cat) cat_msg->AddPointer("cat", cats[cat_id]); next_handler->PostMessage(cat_msg); } break; case CMD_FRONTEND: {