Fix some more compiler errors
Some checks failed
Build / build-deb (push) Blocked by required conditions
Build / build-appimage (push) Blocked by required conditions
Build / build-android (push) Blocked by required conditions
Build / build-windows (push) Blocked by required conditions
Build / build-gentoo (push) Failing after 1m8s
Build / download-system-deps (push) Successful in 4m30s
Build / get-source-code (push) Has been cancelled

This commit is contained in:
Zachary Hall 2024-12-22 13:12:01 -08:00
parent a2c297592d
commit 8e242d345b
2 changed files with 27 additions and 24 deletions

View file

@ -63,22 +63,7 @@ void HaikuLooperWindow::UpdateViewFlags(BLayout *layout) {
} }
UpdateViewFlags(owner); 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) { HaikuLooperWindow::HaikuLooperWindow(Playback *playback) : BWindow(BRect(100, 100, 500, 100), "Looper", B_TITLED_WINDOW, 0) {
pause_bitmap = load_icon(ICON_PAUSE); pause_bitmap = load_icon(ICON_PAUSE);
resume_bitmap = load_icon(ICON_PLAY); resume_bitmap = load_icon(ICON_PLAY);
@ -198,9 +183,9 @@ void HaikuLooperWindow::UpdateCat(BBitmap *cat) {
} }
} }
BRect dst(sw - w, sh - h, w, h); 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 { } else {
spacer->ClearOverlayBitmap(); spacer->ClearViewBitmap();
} }
} }
HaikuLooperWindow::~HaikuLooperWindow() { HaikuLooperWindow::~HaikuLooperWindow() {
@ -289,7 +274,7 @@ void HaikuLooperWindow::MessageReceived(BMessage *msg) {
} break; } break;
case CMD_SET_CAT: { case CMD_SET_CAT: {
BBitmap *cat = NULL; BBitmap *cat = NULL;
if (msg->FindPointer("cat", &cat) != B_OK) { if (msg->FindPointer("cat", (void**)&cat) != B_OK) {
cat = NULL; cat = NULL;
} }
UpdateCat(cat); UpdateCat(cat);

View file

@ -7,6 +7,8 @@
#include <Box.h> #include <Box.h>
#include <map> #include <map>
#include "main_window.h" #include "main_window.h"
#include <cats.hpp>
#include <TranslationUtils.h>
using namespace Looper::Options; using namespace Looper::Options;
#define CMD_UPDATE_LABEL_SETTING 0x1000 #define CMD_UPDATE_LABEL_SETTING 0x1000
#define CMD_FRONTEND 0x1001 #define CMD_FRONTEND 0x1001
@ -15,6 +17,22 @@ using namespace Looper::Options;
#define CMD_APPLY 0x1004 #define CMD_APPLY 0x1004
#define CMD_SET_SETTING_CHECKBOX 0x1005 #define CMD_SET_SETTING_CHECKBOX 0x1005
bool show_icons, show_labels; 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) { 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; 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); BRadioButton *cat_radio = new BRadioButton(fmt::format("prefs:cat:{}", kv.first).c_str(), msg);
cat_btns[kv.first] = cat_radio; cat_btns[kv.first] = cat_radio;
BBitmap *cat_bmp = kv.second; BBitmap *cat_bmp = kv.second;
BRect src = cat_bmp->bounds(); BRect src = cat_bmp->Bounds();
float w = src.Width(), h = src.Height(); float w = src.Width(), h = src.Height();
float rw = cat_radio->Bounds().Width(), rh = cat_radio->Bounds().Height(); float rw = cat_radio->Bounds().Width(), rh = cat_radio->Bounds().Height();
if (w > rw || h > rh) { 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); 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); root_layout->AddView(box, 3.0);
BGroupView *btn_view = new BGroupView(B_HORIZONTAL); BGroupView *btn_view = new BGroupView(B_HORIZONTAL);
@ -149,7 +167,7 @@ void HaikuPrefsWindow::MessageReceived(BMessage *msg) {
set_option<bool>("ui.enable_cat", enable_cat); set_option<bool>("ui.enable_cat", enable_cat);
next_handler->PostMessage(CMD_UPDATE_LABEL_SETTING); next_handler->PostMessage(CMD_UPDATE_LABEL_SETTING);
BMessage *cat_msg = new BMessage(CMD_SET_CAT); 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); next_handler->PostMessage(cat_msg);
} break; } break;
case CMD_REVERT: { case CMD_REVERT: {
@ -165,7 +183,7 @@ void HaikuPrefsWindow::MessageReceived(BMessage *msg) {
break; break;
} }
} }
cat_btns[cat_id].SetValue(B_CONTROL_OFF); 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);
@ -173,7 +191,7 @@ void HaikuPrefsWindow::MessageReceived(BMessage *msg) {
update_label_setting(); update_label_setting();
next_handler->PostMessage(CMD_UPDATE_LABEL_SETTING); next_handler->PostMessage(CMD_UPDATE_LABEL_SETTING);
BMessage *cat_msg = new BMessage(CMD_SET_CAT); 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); next_handler->PostMessage(cat_msg);
} break; } break;
case CMD_FRONTEND: { case CMD_FRONTEND: {