looper/backends/ui/haiku/main_window.h

97 lines
2.5 KiB
C
Raw Normal View History

2024-11-12 14:53:44 -08:00
#pragma once
#include <Window.h>
#include <Application.h>
#include <GroupLayout.h>
#include <Slider.h>
2024-12-09 15:28:12 -08:00
#include <StringView.h>
2024-11-12 14:53:44 -08:00
#include <playback.h>
#include <thread>
#include <FilePanel.h>
#include <Bitmap.h>
#include <Menu.h>
#include <MenuItem.h>
#include <vector>
#include "aboutwindow.h"
#include "slider.h"
#include "prefs.h"
#include <atomic>
2024-11-20 08:15:45 -08:00
#include <util.hpp>
2024-11-12 14:53:44 -08:00
#define CMD_UPDATE_LABEL_SETTING 0x1000
extern bool show_labels;
extern bool show_icons;
extern bool quitting;
class Subwindow {
public:
BWindow *window;
static std::vector<Subwindow*> windows;
std::atomic_bool Showing = false;
std::atomic_bool ShownEver = false;
private:
2024-11-20 08:15:45 -08:00
inline Subwindow(BWindow *window)
2024-11-12 14:53:44 -08:00
: window(window)
{ }
public:
inline static Subwindow *Add(BWindow *window) {
auto output = new Subwindow(window);
windows.push_back(output);
return output;
}
inline void Show() {
Showing.store(true);
}
};
2024-11-21 10:22:34 -08:00
class HaikuLooperRefHandler;
class HaikuLooperWindow : public BWindow {
2024-11-12 14:53:44 -08:00
BSlider *slider;
2024-12-09 15:28:12 -08:00
BStringView *position_label;
2024-11-12 14:53:44 -08:00
BBitmap *pause_bitmap;
BBitmap *resume_bitmap;
BBitmap *refresh_bitmap;
BBitmap *stop_bitmap;
BMenu *file_menu;
BMenuItem *open_item;
BMenuItem *prefs_item;
BMenuItem *quit_item;
BMenu *help_menu;
BMenuItem *about_item;
BGroupLayout *layout;
Playback *playback;
BButton *restart_btn;
BButton *stop_btn;
BButton *pause_resume_btn;
2024-12-21 14:23:00 -08:00
BView *spacer;
void UpdateCat(BBitmap *cat);
2024-11-12 14:53:44 -08:00
bool volume_clicked = false;
bool speed_clicked = false;
bool pitch_clicked = false;
bool tempo_clicked = false;
bool seek_clicked = false;
void UpdateViewFlags(BView *view);
void UpdateViewFlags(BLayout *layout);
2024-11-21 10:22:34 -08:00
HaikuLooperSlider *volume_slider;
HaikuLooperSlider *speed_slider;
2024-11-12 14:53:44 -08:00
BFilePanel *file_panel;
2024-11-21 10:22:34 -08:00
HaikuLooperSlider *pitch_slider;
HaikuLooperSlider *tempo_slider;
HaikuLooperRefHandler *ref_handler;
2024-11-12 14:53:44 -08:00
std::thread *update_thread = nullptr;
bool done = false;
void Pulse();
void ThreadFunc();
const char *file_to_play = nullptr;
public:
Subwindow *about_subwindow;
Subwindow *prefs_subwindow;
void FrameResized(float newWidth, float newHeight) override;
void MessageReceived(BMessage *msg) override;
2024-11-21 10:22:34 -08:00
HaikuLooperWindow(Playback *playback);
~HaikuLooperWindow();
2024-11-12 14:53:44 -08:00
};
2024-11-21 10:22:34 -08:00
class HaikuLooperRefHandler : public BHandler {
HaikuLooperWindow *win;
2024-11-12 14:53:44 -08:00
BHandler *next_handler;
public:
void MessageReceived(BMessage *msg) override;
2024-11-21 10:22:34 -08:00
HaikuLooperRefHandler(HaikuLooperWindow *win);
2024-11-12 14:53:44 -08:00
};