Fix combined Haiku/Qt backend build
Some checks failed
Build / get-source-code (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 1m14s
Build / download-system-deps (push) Has been cancelled
Some checks failed
Build / get-source-code (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 1m14s
Build / download-system-deps (push) Has been cancelled
This commit is contained in:
parent
ae74999276
commit
da9b7322f2
9 changed files with 82 additions and 79 deletions
|
@ -7,12 +7,12 @@
|
||||||
#include <ScrollView.h>
|
#include <ScrollView.h>
|
||||||
#include "main_window.h"
|
#include "main_window.h"
|
||||||
#define CMD_LOAD_LICENSE 0x40
|
#define CMD_LOAD_LICENSE 0x40
|
||||||
LicenseItem::LicenseItem(const LicenseData license) : BStringItem("") {
|
HaikuLicenseItem::HaikuLicenseItem(const LicenseData license) : BStringItem("") {
|
||||||
SetText(fmt::format("{} ({})", license.Project, license.Spdx).c_str());
|
SetText(fmt::format("{} ({})", license.Project, license.Spdx).c_str());
|
||||||
this->license_text = license.LicenseContents;
|
this->license_text = license.LicenseContents;
|
||||||
}
|
}
|
||||||
|
|
||||||
AboutWindow::AboutWindow() : BWindow(BRect(100, 100, 600, 400), "About Looper", B_TITLED_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS) {
|
HaikuAboutWindow::HaikuAboutWindow() : BWindow(BRect(100, 100, 600, 400), "About Looper", B_TITLED_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS) {
|
||||||
BGroupLayout *root_layout = new BGroupLayout(B_VERTICAL);
|
BGroupLayout *root_layout = new BGroupLayout(B_VERTICAL);
|
||||||
float minW, minH, maxW, maxH;
|
float minW, minH, maxW, maxH;
|
||||||
GetSizeLimits(&minW, &maxW, &minH, &maxH);
|
GetSizeLimits(&minW, &maxW, &minH, &maxH);
|
||||||
|
@ -55,14 +55,14 @@ AboutWindow::AboutWindow() : BWindow(BRect(100, 100, 600, 400), "About Looper",
|
||||||
InvalidateLayout(true);
|
InvalidateLayout(true);
|
||||||
UpdateIfNeeded();
|
UpdateIfNeeded();
|
||||||
}
|
}
|
||||||
void AboutWindow::Show() {
|
void HaikuAboutWindow::Show() {
|
||||||
BWindow::Show();
|
BWindow::Show();
|
||||||
}
|
}
|
||||||
bool AboutWindow::QuitRequested() {
|
bool HaikuAboutWindow::QuitRequested() {
|
||||||
Hide();
|
Hide();
|
||||||
return quitting;
|
return quitting;
|
||||||
}
|
}
|
||||||
void AboutWindow::MessageReceived(BMessage *msg) {
|
void HaikuAboutWindow::MessageReceived(BMessage *msg) {
|
||||||
if (msg->IsSystem()) return;
|
if (msg->IsSystem()) return;
|
||||||
if (msg->what == CMD_LOAD_LICENSE) {
|
if (msg->what == CMD_LOAD_LICENSE) {
|
||||||
auto selection = license_list->ItemAt(msg->GetInt32("index", 0));
|
auto selection = license_list->ItemAt(msg->GetInt32("index", 0));
|
||||||
|
|
|
@ -7,12 +7,13 @@
|
||||||
#include <StringItem.h>
|
#include <StringItem.h>
|
||||||
#include <ListView.h>
|
#include <ListView.h>
|
||||||
#include <license.hpp>
|
#include <license.hpp>
|
||||||
class LicenseItem : public BStringItem {
|
#include "utils.h"
|
||||||
|
class HaikuLicenseItem : public BStringItem {
|
||||||
public:
|
public:
|
||||||
std::string license_text;
|
std::string license_text;
|
||||||
LicenseItem(const LicenseData license);
|
HaikuLicenseItem(const LicenseData license);
|
||||||
};
|
};
|
||||||
class AboutWindow : public BWindow
|
class HaikuAboutWindow : public BWindow
|
||||||
{
|
{
|
||||||
BListView *license_list;
|
BListView *license_list;
|
||||||
BTextView *license_text;
|
BTextView *license_text;
|
||||||
|
@ -20,5 +21,5 @@ class AboutWindow : public BWindow
|
||||||
bool QuitRequested() override;
|
bool QuitRequested() override;
|
||||||
void Show() override;
|
void Show() override;
|
||||||
void MessageReceived(BMessage *msg) override;
|
void MessageReceived(BMessage *msg) override;
|
||||||
AboutWindow();
|
HaikuAboutWindow();
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,20 +37,20 @@
|
||||||
#define SLIDER_SCALE 1000
|
#define SLIDER_SCALE 1000
|
||||||
#define D(x) ((double)(x))
|
#define D(x) ((double)(x))
|
||||||
std::vector<Subwindow*> Subwindow::windows;
|
std::vector<Subwindow*> Subwindow::windows;
|
||||||
BMessage *make_slider_msg(uint32_t what, bool down) {
|
static BMessage *make_slider_msg(uint32_t what, bool down) {
|
||||||
BMessage *msg = new BMessage(what);
|
BMessage *msg = new BMessage(what);
|
||||||
msg->SetBool(CMD_MOUSE_DOWN_KEY, down);
|
msg->SetBool(CMD_MOUSE_DOWN_KEY, down);
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
bool is_slider_down_msg(BMessage *msg) {
|
static bool is_slider_down_msg(BMessage *msg) {
|
||||||
return msg->HasBool(CMD_MOUSE_DOWN_KEY) && msg->GetBool(CMD_MOUSE_DOWN_KEY);
|
return msg->HasBool(CMD_MOUSE_DOWN_KEY) && msg->GetBool(CMD_MOUSE_DOWN_KEY);
|
||||||
}
|
}
|
||||||
void LooperWindow::UpdateViewFlags(BView *view) {
|
void HaikuLooperWindow::UpdateViewFlags(BView *view) {
|
||||||
if (view == NULL) return;
|
if (view == NULL) return;
|
||||||
view->SetFlags(view->Flags()|B_SUPPORTS_LAYOUT|B_FRAME_EVENTS);
|
view->SetFlags(view->Flags()|B_SUPPORTS_LAYOUT|B_FRAME_EVENTS);
|
||||||
view->SetResizingMode(B_FOLLOW_ALL_SIDES);
|
view->SetResizingMode(B_FOLLOW_ALL_SIDES);
|
||||||
}
|
}
|
||||||
void LooperWindow::UpdateViewFlags(BLayout *layout) {
|
void HaikuLooperWindow::UpdateViewFlags(BLayout *layout) {
|
||||||
BView *owner = layout->Owner();
|
BView *owner = layout->Owner();
|
||||||
if (owner == NULL) {
|
if (owner == NULL) {
|
||||||
owner = layout->View();
|
owner = layout->View();
|
||||||
|
@ -60,12 +60,12 @@ void LooperWindow::UpdateViewFlags(BLayout *layout) {
|
||||||
}
|
}
|
||||||
UpdateViewFlags(owner);
|
UpdateViewFlags(owner);
|
||||||
}
|
}
|
||||||
LooperWindow::LooperWindow(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);
|
||||||
stop_bitmap = load_icon(ICON_STOP);
|
stop_bitmap = load_icon(ICON_STOP);
|
||||||
refresh_bitmap = load_icon(ICON_REFRESH);
|
refresh_bitmap = load_icon(ICON_REFRESH);
|
||||||
ref_handler = new LooperRefHandler(this);
|
ref_handler = new HaikuLooperRefHandler(this);
|
||||||
this->playback = playback;
|
this->playback = playback;
|
||||||
float minW, minH, maxW, maxH;
|
float minW, minH, maxW, maxH;
|
||||||
GetSizeLimits(&minW, &maxW, &minH, &maxH);
|
GetSizeLimits(&minW, &maxW, &minH, &maxH);
|
||||||
|
@ -113,24 +113,24 @@ LooperWindow::LooperWindow(Playback *playback) : BWindow(BRect(100, 100, 500, 10
|
||||||
stop_btn = new BButton(NULL, new BMessage(CMD_STOP));
|
stop_btn = new BButton(NULL, new BMessage(CMD_STOP));
|
||||||
stop_btn->SetTarget(this);
|
stop_btn->SetTarget(this);
|
||||||
top_row->AddChild(stop_btn);
|
top_row->AddChild(stop_btn);
|
||||||
volume_slider = new LooperSlider("volume", "Volume", new BMessage(CMD_VOLUME), 0, 0, 100, 1, false);
|
volume_slider = new HaikuLooperSlider("volume", "Volume", new BMessage(CMD_VOLUME), 0, 0, 100, 1, false);
|
||||||
volume_slider->SetLimitLabels("Muted", "Full Volume");
|
volume_slider->SetLimitLabels("Muted", "Full Volume");
|
||||||
volume_slider->SetTarget(this);
|
volume_slider->SetTarget(this);
|
||||||
top_row->AddChild(volume_slider);
|
top_row->AddChild(volume_slider);
|
||||||
speed_slider = new LooperSlider("speed", "Speed", new BMessage(CMD_SPEED), 0, 0.25, 4.0, 0.01, true);
|
speed_slider = new HaikuLooperSlider("speed", "Speed", new BMessage(CMD_SPEED), 0, 0.25, 4.0, 0.01, true);
|
||||||
speed_slider->SetLimitLabels("0.25x", "4.00x");
|
speed_slider->SetLimitLabels("0.25x", "4.00x");
|
||||||
speed_slider->SetTarget(this);
|
speed_slider->SetTarget(this);
|
||||||
bottom_row->AddChild(speed_slider);
|
bottom_row->AddChild(speed_slider);
|
||||||
tempo_slider = new LooperSlider("tempo", "Tempo", new BMessage(CMD_TEMPO), 0, 0.25, 4.0, 0.01, true);
|
tempo_slider = new HaikuLooperSlider("tempo", "Tempo", new BMessage(CMD_TEMPO), 0, 0.25, 4.0, 0.01, true);
|
||||||
tempo_slider->SetLimitLabels("0.25x", "4.00x");
|
tempo_slider->SetLimitLabels("0.25x", "4.00x");
|
||||||
tempo_slider->SetTarget(this);
|
tempo_slider->SetTarget(this);
|
||||||
bottom_row->AddChild(tempo_slider);
|
bottom_row->AddChild(tempo_slider);
|
||||||
pitch_slider = new LooperSlider("pitch", "Pitch", new BMessage(CMD_PITCH), 0, 0.25, 4.0, 0.01, true);
|
pitch_slider = new HaikuLooperSlider("pitch", "Pitch", new BMessage(CMD_PITCH), 0, 0.25, 4.0, 0.01, true);
|
||||||
pitch_slider->SetLimitLabels("0.25x", "4.00x");
|
pitch_slider->SetLimitLabels("0.25x", "4.00x");
|
||||||
pitch_slider->SetTarget(this);
|
pitch_slider->SetTarget(this);
|
||||||
bottom_row->AddChild(pitch_slider);
|
bottom_row->AddChild(pitch_slider);
|
||||||
file_panel = new BFilePanel(B_OPEN_PANEL, new BMessenger(this));
|
file_panel = new BFilePanel(B_OPEN_PANEL, new BMessenger(this));
|
||||||
auto prefs_window = new PrefsWindow(this);
|
auto prefs_window = new HaikuPrefsWindow(this);
|
||||||
prefs_subwindow = Subwindow::Add(prefs_window);
|
prefs_subwindow = Subwindow::Add(prefs_window);
|
||||||
about_subwindow = Subwindow::Add(about_window);
|
about_subwindow = Subwindow::Add(about_window);
|
||||||
EnableUpdates();
|
EnableUpdates();
|
||||||
|
@ -147,7 +147,7 @@ LooperWindow::LooperWindow(Playback *playback) : BWindow(BRect(100, 100, 500, 10
|
||||||
MessageReceived(msg);
|
MessageReceived(msg);
|
||||||
delete msg;
|
delete msg;
|
||||||
}
|
}
|
||||||
LooperWindow::~LooperWindow() {
|
HaikuLooperWindow::~HaikuLooperWindow() {
|
||||||
delete ref_handler;
|
delete ref_handler;
|
||||||
delete pause_bitmap;
|
delete pause_bitmap;
|
||||||
delete resume_bitmap;
|
delete resume_bitmap;
|
||||||
|
@ -158,7 +158,7 @@ LooperWindow::~LooperWindow() {
|
||||||
update_thread->join();
|
update_thread->join();
|
||||||
delete update_thread;
|
delete update_thread;
|
||||||
}
|
}
|
||||||
void LooperWindow::MessageReceived(BMessage *msg) {
|
void HaikuLooperWindow::MessageReceived(BMessage *msg) {
|
||||||
SDL_Event ev;
|
SDL_Event ev;
|
||||||
while (SDL_PollEvent(&ev)) {
|
while (SDL_PollEvent(&ev)) {
|
||||||
if (ev.type == SDL_DROPFILE) {
|
if (ev.type == SDL_DROPFILE) {
|
||||||
|
@ -279,7 +279,7 @@ void LooperWindow::MessageReceived(BMessage *msg) {
|
||||||
} break;
|
} break;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
void LooperWindow::Pulse() {
|
void HaikuLooperWindow::Pulse() {
|
||||||
auto len = playback->GetLength();
|
auto len = playback->GetLength();
|
||||||
auto pos = playback->GetPosition();
|
auto pos = playback->GetPosition();
|
||||||
auto pos_milliseconds = pos * 1000.0;
|
auto pos_milliseconds = pos * 1000.0;
|
||||||
|
@ -316,12 +316,12 @@ void LooperWindow::Pulse() {
|
||||||
tempo_slider->SetLabel(fmt::format("Tempo: {:.02f}x", tempo).c_str());
|
tempo_slider->SetLabel(fmt::format("Tempo: {:.02f}x", tempo).c_str());
|
||||||
UpdateIfNeeded();
|
UpdateIfNeeded();
|
||||||
}
|
}
|
||||||
void LooperWindow::FrameResized(float newWidth, float newHeight) {
|
void HaikuLooperWindow::FrameResized(float newWidth, float newHeight) {
|
||||||
InvalidateLayout(true);
|
InvalidateLayout(true);
|
||||||
Layout(true);
|
Layout(true);
|
||||||
layout->SetExplicitSize(BSize(newWidth, newHeight));
|
layout->SetExplicitSize(BSize(newWidth, newHeight));
|
||||||
}
|
}
|
||||||
void LooperWindow::ThreadFunc() {
|
void HaikuLooperWindow::ThreadFunc() {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (done) return;
|
if (done) return;
|
||||||
if (Lock()) {
|
if (Lock()) {
|
||||||
|
@ -349,7 +349,7 @@ void LooperWindow::ThreadFunc() {
|
||||||
std::this_thread::sleep_for(1s / 60.0);
|
std::this_thread::sleep_for(1s / 60.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LooperRefHandler::LooperRefHandler(LooperWindow *win) {
|
HaikuLooperRefHandler::HaikuLooperRefHandler(LooperWindow *win) {
|
||||||
this->win = win;
|
this->win = win;
|
||||||
be_app->Lock();
|
be_app->Lock();
|
||||||
this->next_handler = be_app->PreferredHandler();
|
this->next_handler = be_app->PreferredHandler();
|
||||||
|
@ -361,7 +361,7 @@ LooperRefHandler::LooperRefHandler(LooperWindow *win) {
|
||||||
AddFilter(new BMessageFilter(B_REFS_RECEIVED));
|
AddFilter(new BMessageFilter(B_REFS_RECEIVED));
|
||||||
be_app->Unlock();
|
be_app->Unlock();
|
||||||
}
|
}
|
||||||
void LooperRefHandler::MessageReceived(BMessage *msg) {
|
void HaikuLooperRefHandler::MessageReceived(BMessage *msg) {
|
||||||
if (msg->what == B_REFS_RECEIVED) {
|
if (msg->what == B_REFS_RECEIVED) {
|
||||||
win->PostMessage(msg);
|
win->PostMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,8 @@ class Subwindow {
|
||||||
Showing.store(true);
|
Showing.store(true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
class LooperRefHandler;
|
class HaikuLooperRefHandler;
|
||||||
class LooperWindow : public BWindow {
|
class HaikuLooperWindow : public BWindow {
|
||||||
BSlider *slider;
|
BSlider *slider;
|
||||||
BBitmap *pause_bitmap;
|
BBitmap *pause_bitmap;
|
||||||
BBitmap *resume_bitmap;
|
BBitmap *resume_bitmap;
|
||||||
|
@ -64,12 +64,12 @@ class LooperWindow : public BWindow {
|
||||||
bool seek_clicked = false;
|
bool seek_clicked = false;
|
||||||
void UpdateViewFlags(BView *view);
|
void UpdateViewFlags(BView *view);
|
||||||
void UpdateViewFlags(BLayout *layout);
|
void UpdateViewFlags(BLayout *layout);
|
||||||
LooperSlider *volume_slider;
|
HaikuLooperSlider *volume_slider;
|
||||||
LooperSlider *speed_slider;
|
HaikuLooperSlider *speed_slider;
|
||||||
BFilePanel *file_panel;
|
BFilePanel *file_panel;
|
||||||
LooperSlider *pitch_slider;
|
HaikuLooperSlider *pitch_slider;
|
||||||
LooperSlider *tempo_slider;
|
HaikuLooperSlider *tempo_slider;
|
||||||
LooperRefHandler *ref_handler;
|
HaikuLooperRefHandler *ref_handler;
|
||||||
std::thread *update_thread = nullptr;
|
std::thread *update_thread = nullptr;
|
||||||
bool done = false;
|
bool done = false;
|
||||||
void Pulse();
|
void Pulse();
|
||||||
|
@ -80,13 +80,13 @@ public:
|
||||||
Subwindow *prefs_subwindow;
|
Subwindow *prefs_subwindow;
|
||||||
void FrameResized(float newWidth, float newHeight) override;
|
void FrameResized(float newWidth, float newHeight) override;
|
||||||
void MessageReceived(BMessage *msg) override;
|
void MessageReceived(BMessage *msg) override;
|
||||||
LooperWindow(Playback *playback);
|
HaikuLooperWindow(Playback *playback);
|
||||||
~LooperWindow();
|
~HaikuLooperWindow();
|
||||||
};
|
};
|
||||||
class LooperRefHandler : public BHandler {
|
class HaikuLooperRefHandler : public BHandler {
|
||||||
LooperWindow *win;
|
HaikuLooperWindow *win;
|
||||||
BHandler *next_handler;
|
BHandler *next_handler;
|
||||||
public:
|
public:
|
||||||
void MessageReceived(BMessage *msg) override;
|
void MessageReceived(BMessage *msg) override;
|
||||||
LooperRefHandler(LooperWindow *win);
|
HaikuLooperRefHandler(HaikuLooperWindow *win);
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,7 +15,7 @@ using namespace Looper::Options;
|
||||||
#define CMD_APPLY 0x1004
|
#define CMD_APPLY 0x1004
|
||||||
bool show_icons, show_labels;
|
bool show_icons, show_labels;
|
||||||
|
|
||||||
PrefsWindow::PrefsWindow(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;
|
||||||
auto *root_layout = new BGroupLayout(B_VERTICAL);
|
auto *root_layout = new BGroupLayout(B_VERTICAL);
|
||||||
SetLayout(root_layout);
|
SetLayout(root_layout);
|
||||||
|
@ -72,15 +72,15 @@ PrefsWindow::PrefsWindow(BLooper *next_handler) : BWindow(BRect(100, 100, 0, 0),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PrefsWindow::QuitRequested() {
|
bool HaikuPrefsWindow::QuitRequested() {
|
||||||
Hide();
|
Hide();
|
||||||
return quitting;
|
return quitting;
|
||||||
}
|
}
|
||||||
void PrefsWindow::set_options_changed(bool changed) {
|
void HaikuPrefsWindow::set_options_changed(bool changed) {
|
||||||
revert_btn->SetEnabled(changed);
|
revert_btn->SetEnabled(changed);
|
||||||
apply_btn->SetEnabled(changed);
|
apply_btn->SetEnabled(changed);
|
||||||
}
|
}
|
||||||
void PrefsWindow::update_label_setting() {
|
void HaikuPrefsWindow::update_label_setting() {
|
||||||
|
|
||||||
std::map<std::string, BRadioButton*> label_settings_map({{"labels", labels_only}, {"icons", icons_only}, {"both", both_labels_icons}});
|
std::map<std::string, BRadioButton*> label_settings_map({{"labels", labels_only}, {"icons", icons_only}, {"both", both_labels_icons}});
|
||||||
auto cur_radio_btn = labels_only;
|
auto cur_radio_btn = labels_only;
|
||||||
|
@ -92,7 +92,7 @@ void PrefsWindow::update_label_setting() {
|
||||||
show_labels = new_label_setting != "icons";
|
show_labels = new_label_setting != "icons";
|
||||||
cur_radio_btn->SetValue(B_CONTROL_ON);
|
cur_radio_btn->SetValue(B_CONTROL_ON);
|
||||||
}
|
}
|
||||||
void PrefsWindow::MessageReceived(BMessage *msg) {
|
void HaikuPrefsWindow::MessageReceived(BMessage *msg) {
|
||||||
if (msg->IsSystem()) return;
|
if (msg->IsSystem()) return;
|
||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
case CMD_APPLY: {
|
case CMD_APPLY: {
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
class PrefsWindow : public BWindow {
|
class HaikuPrefsWindow : public BWindow {
|
||||||
std::vector<std::string> backend_ids;
|
std::vector<std::string> backend_ids;
|
||||||
int32 cur_option = 0;
|
int32 cur_option = 0;
|
||||||
BLooper *next_handler;
|
BLooper *next_handler;
|
||||||
|
@ -32,5 +32,5 @@ class PrefsWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
bool QuitRequested() override;
|
bool QuitRequested() override;
|
||||||
void MessageReceived(BMessage *msg) override;
|
void MessageReceived(BMessage *msg) override;
|
||||||
PrefsWindow(BLooper *next_handler);
|
HaikuPrefsWindow(BLooper *next_handler);
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
#define CMD_SLIDER_CHANGED 0x92
|
#define CMD_SLIDER_CHANGED 0x92
|
||||||
#define CMD_CHANGE_MODE 0x93
|
#define CMD_CHANGE_MODE 0x93
|
||||||
using namespace BPrivate;
|
using namespace BPrivate;
|
||||||
void LooperSlider::UpdateLogScaler() {
|
void HaikuLooperSlider::UpdateLogScaler() {
|
||||||
scaler->update_min_max(min, max);
|
scaler->update_min_max(min, max);
|
||||||
}
|
}
|
||||||
void LooperSlider::UpdateSlider(bool update_value) {
|
void HaikuLooperSlider::UpdateSlider(bool update_value) {
|
||||||
if (recreate_slider) {
|
if (recreate_slider) {
|
||||||
if (slider != NULL) {
|
if (slider != NULL) {
|
||||||
if (!text_edit_mode) text_layout->RemoveView(slider);
|
if (!text_edit_mode) text_layout->RemoveView(slider);
|
||||||
|
@ -53,39 +53,39 @@ void LooperSlider::UpdateSlider(bool update_value) {
|
||||||
}
|
}
|
||||||
recreate_slider = false;
|
recreate_slider = false;
|
||||||
}
|
}
|
||||||
void LooperSlider::set_min(double min) {
|
void HaikuLooperSlider::set_min(double min) {
|
||||||
this->min = min;
|
this->min = min;
|
||||||
recreate_slider = true;
|
recreate_slider = true;
|
||||||
}
|
}
|
||||||
void LooperSlider::set_max(double max) {
|
void HaikuLooperSlider::set_max(double max) {
|
||||||
this->max = max;
|
this->max = max;
|
||||||
recreate_slider = true;
|
recreate_slider = true;
|
||||||
}
|
}
|
||||||
void LooperSlider::SetMinLabel(const char *label) {
|
void HaikuLooperSlider::SetMinLabel(const char *label) {
|
||||||
if (min_label != NULL) free((void*)min_label);
|
if (min_label != NULL) free((void*)min_label);
|
||||||
min_label = label == NULL ? NULL : strdup(label);
|
min_label = label == NULL ? NULL : strdup(label);
|
||||||
UpdateSlider();
|
UpdateSlider();
|
||||||
}
|
}
|
||||||
void LooperSlider::SetMaxLabel(const char *label) {
|
void HaikuLooperSlider::SetMaxLabel(const char *label) {
|
||||||
if (max_label != NULL) free((void*)max_label);
|
if (max_label != NULL) free((void*)max_label);
|
||||||
max_label = label == NULL ? NULL : strdup(label);
|
max_label = label == NULL ? NULL : strdup(label);
|
||||||
UpdateSlider();
|
UpdateSlider();
|
||||||
}
|
}
|
||||||
void LooperSlider::set_tick(double value) {
|
void HaikuLooperSlider::set_tick(double value) {
|
||||||
this->tick = value;
|
this->tick = value;
|
||||||
recreate_slider = true;
|
recreate_slider = true;
|
||||||
}
|
}
|
||||||
const char *LooperSlider::MinLabel() {
|
const char *HaikuLooperSlider::MinLabel() {
|
||||||
return min_label;
|
return min_label;
|
||||||
}
|
}
|
||||||
const char *LooperSlider::MaxLabel() {
|
const char *HaikuLooperSlider::MaxLabel() {
|
||||||
return max_label;
|
return max_label;
|
||||||
}
|
}
|
||||||
void LooperSlider::SetLimitLabels(const char *min, const char *max) {
|
void HaikuLooperSlider::SetLimitLabels(const char *min, const char *max) {
|
||||||
SetMinLabel(min);
|
SetMinLabel(min);
|
||||||
SetMaxLabel(max);
|
SetMaxLabel(max);
|
||||||
}
|
}
|
||||||
LooperSlider::~LooperSlider() {
|
HaikuLooperSlider::~LooperSlider() {
|
||||||
if (min_label != NULL) free((void*)min_label);
|
if (min_label != NULL) free((void*)min_label);
|
||||||
if (max_label != NULL) free((void*)max_label);
|
if (max_label != NULL) free((void*)max_label);
|
||||||
delete slider;
|
delete slider;
|
||||||
|
@ -95,41 +95,41 @@ LooperSlider::~LooperSlider() {
|
||||||
delete text_mode_bitmap;
|
delete text_mode_bitmap;
|
||||||
delete slider_mode_bitmap;
|
delete slider_mode_bitmap;
|
||||||
}
|
}
|
||||||
void LooperSlider::SetMin(double min) {
|
void HaikuLooperSlider::SetMin(double min) {
|
||||||
set_min(min);
|
set_min(min);
|
||||||
UpdateSlider();
|
UpdateSlider();
|
||||||
}
|
}
|
||||||
void LooperSlider::SetMax(double max) {
|
void HaikuLooperSlider::SetMax(double max) {
|
||||||
set_max(max);
|
set_max(max);
|
||||||
UpdateSlider();
|
UpdateSlider();
|
||||||
}
|
}
|
||||||
double LooperSlider::Min() {
|
double HaikuLooperSlider::Min() {
|
||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
double LooperSlider::Max() {
|
double HaikuLooperSlider::Max() {
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
void LooperSlider::SetLimits(double min, double max) {
|
void HaikuLooperSlider::SetLimits(double min, double max) {
|
||||||
set_min(min);
|
set_min(min);
|
||||||
set_max(max);
|
set_max(max);
|
||||||
UpdateSlider();
|
UpdateSlider();
|
||||||
}
|
}
|
||||||
void LooperSlider::SetTick(double value) {
|
void HaikuLooperSlider::SetTick(double value) {
|
||||||
set_tick(value);
|
set_tick(value);
|
||||||
UpdateSlider();
|
UpdateSlider();
|
||||||
}
|
}
|
||||||
double LooperSlider::Tick() {
|
double HaikuLooperSlider::Tick() {
|
||||||
return tick;
|
return tick;
|
||||||
}
|
}
|
||||||
void LooperSlider::SetLogarithmic(bool logarithmic) {
|
void HaikuLooperSlider::SetLogarithmic(bool logarithmic) {
|
||||||
this->logarithmic = logarithmic;
|
this->logarithmic = logarithmic;
|
||||||
recreate_slider = true;
|
recreate_slider = true;
|
||||||
UpdateSlider(true);
|
UpdateSlider(true);
|
||||||
}
|
}
|
||||||
bool LooperSlider::IsLogarithmic() {
|
bool HaikuLooperSlider::IsLogarithmic() {
|
||||||
return this->logarithmic;
|
return this->logarithmic;
|
||||||
}
|
}
|
||||||
void LooperSlider::MessageReceived(BMessage *msg) {
|
void HaikuLooperSlider::MessageReceived(BMessage *msg) {
|
||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
case CMD_SLIDER_MOVED:
|
case CMD_SLIDER_MOVED:
|
||||||
case CMD_SLIDER_CHANGED: {
|
case CMD_SLIDER_CHANGED: {
|
||||||
|
@ -193,35 +193,35 @@ void LooperSlider::MessageReceived(BMessage *msg) {
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void LooperSlider::SendChangeMsg() {
|
void HaikuLooperSlider::SendChangeMsg() {
|
||||||
BMessage *msg = change_msg;
|
BMessage *msg = change_msg;
|
||||||
msg->SetDouble("be:value", this->value);
|
msg->SetDouble("be:value", this->value);
|
||||||
msg->SetBool("catmeow:pressed", pressed);
|
msg->SetBool("catmeow:pressed", pressed);
|
||||||
Invoke(msg);
|
Invoke(msg);
|
||||||
}
|
}
|
||||||
void LooperSlider::SetValue(int32 value) {
|
void HaikuLooperSlider::SetValue(int32 value) {
|
||||||
SetValueDouble(value * tick);
|
SetValueDouble(value * tick);
|
||||||
}
|
}
|
||||||
void LooperSlider::SetValueDouble(double value) {
|
void HaikuLooperSlider::SetValueDouble(double value) {
|
||||||
this->value = value;
|
this->value = value;
|
||||||
BControl::SetValue(std::round(value / tick));
|
BControl::SetValue(std::round(value / tick));
|
||||||
UpdateSlider(true);
|
UpdateSlider(true);
|
||||||
}
|
}
|
||||||
double LooperSlider::ValueDouble() {
|
double HaikuLooperSlider::ValueDouble() {
|
||||||
return this->value;
|
return this->value;
|
||||||
}
|
}
|
||||||
void LooperSlider::SetLabel(const char *label) {
|
void HaikuLooperSlider::SetLabel(const char *label) {
|
||||||
this->label = label;
|
this->label = label;
|
||||||
text_label->SetText(label);
|
text_label->SetText(label);
|
||||||
}
|
}
|
||||||
void LooperSlider::set_logarithmic(bool logarithmic) {
|
void HaikuLooperSlider::set_logarithmic(bool logarithmic) {
|
||||||
this->logarithmic = logarithmic;
|
this->logarithmic = logarithmic;
|
||||||
recreate_slider = true;
|
recreate_slider = true;
|
||||||
}
|
}
|
||||||
void LooperSlider::SetValueChangedMsg(BMessage *msg) {
|
void HaikuLooperSlider::SetValueChangedMsg(BMessage *msg) {
|
||||||
this->change_msg = msg;
|
this->change_msg = msg;
|
||||||
}
|
}
|
||||||
LooperSlider::LooperSlider(const char *name, const char *label, BMessage *msg, uint32_t flags, double min, double max, double tick, bool logarithmic) : BControl(name, label, msg, flags) {
|
HaikuLooperSlider::HaikuLooperSlider(const char *name, const char *label, BMessage *msg, uint32_t flags, double min, double max, double tick, bool logarithmic) : BControl(name, label, msg, flags) {
|
||||||
scaler = new LooperLogScaler(min, max);
|
scaler = new LooperLogScaler(min, max);
|
||||||
text_mode_bitmap = load_icon(ICON_EDIT_TEXT);
|
text_mode_bitmap = load_icon(ICON_EDIT_TEXT);
|
||||||
slider_mode_bitmap = load_icon(ICON_EDIT_SLIDER);
|
slider_mode_bitmap = load_icon(ICON_EDIT_SLIDER);
|
||||||
|
@ -263,7 +263,7 @@ LooperSlider::LooperSlider(const char *name, const char *label, BMessage *msg, u
|
||||||
SetLabel(label);
|
SetLabel(label);
|
||||||
InvalidateLayout(true);
|
InvalidateLayout(true);
|
||||||
}
|
}
|
||||||
void LooperSlider::AttachedToWindow() {
|
void HaikuLooperSlider::AttachedToWindow() {
|
||||||
{
|
{
|
||||||
BMessage *msg = make_self_msg(CMD_CHANGE_MODE);
|
BMessage *msg = make_self_msg(CMD_CHANGE_MODE);
|
||||||
MessageReceived(msg);
|
MessageReceived(msg);
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
#include <GroupView.h>
|
#include <GroupView.h>
|
||||||
class LooperLogScaler;
|
class LooperLogScaler;
|
||||||
class LooperSlider : public BControl {
|
class HaikuLooperSlider : public BControl {
|
||||||
inline BMessage *make_self_msg(int32 what) {
|
inline BMessage *make_self_msg(int32 what) {
|
||||||
auto output = new BMessage(what);
|
auto output = new BMessage(what);
|
||||||
output->AddPointer("catmeow:target", this);
|
output->AddPointer("catmeow:target", this);
|
||||||
|
@ -70,6 +70,6 @@ class LooperSlider : public BControl {
|
||||||
void SetValueChangedMsg(BMessage *msg);
|
void SetValueChangedMsg(BMessage *msg);
|
||||||
void MessageReceived(BMessage *msg) override;
|
void MessageReceived(BMessage *msg) override;
|
||||||
void AttachedToWindow() override;
|
void AttachedToWindow() override;
|
||||||
LooperSlider(const char *name, const char *label, BMessage *msg, uint32_t flags, double min, double max, double tick = 0.0001, bool logarithmic = false);
|
HaikuLooperSlider(const char *name, const char *label, BMessage *msg, uint32_t flags, double min, double max, double tick = 0.0001, bool logarithmic = false);
|
||||||
~LooperSlider();
|
~HaikuLooperSlider();
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,3 +30,5 @@ inline BBitmap *get_empty_icon() {
|
||||||
}
|
}
|
||||||
return empty_icon;
|
return empty_icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define CLASS(name) class Haiku##name
|
Loading…
Reference in a new issue