Haiku frontend updates
Some checks failed
Build / build-gentoo (push) Failing after 30s
Build / download-system-deps (push) Successful in 3m4s
Build / get-source-code (push) Successful in 9m44s
Build / build-appimage (push) Successful in 3m49s
Build / build-android (push) Failing after 2m49s
Build / build-windows (push) Failing after 7m18s

This commit is contained in:
Zachary Hall 2024-12-09 15:28:12 -08:00
parent 255fbe4c88
commit fc6753f575
2 changed files with 29 additions and 5 deletions

View file

@ -17,6 +17,7 @@
#include <cmath>
#include <fmt/core.h>
#include <fmt/format.h>
#include <LayoutItem.h>
#include <SDL.h>
#include "icons.h"
#include "utils.h"
@ -107,10 +108,22 @@ HaikuLooperWindow::HaikuLooperWindow(Playback *playback) : BWindow(BRect(100, 10
restart_btn = new BButton(NULL, new BMessage(CMD_RESTART));
restart_btn->SetTarget(this);
top_row->AddChild(restart_btn);
BView *slider_parent = new BView("main:slider_parent", B_SUPPORTS_LAYOUT);
BGroupLayout *slider_parent_layout = new BGroupLayout(B_HORIZONTAL, 0);
slider_parent_layout->SetInsets(0);
slider_parent->SetLayout(slider_parent_layout);
slider = new BSlider("seek_slider", "Seek", make_slider_msg(CMD_SEEK, false), 0, INT32_MAX, B_HORIZONTAL);
slider->SetModificationMessage(make_slider_msg(CMD_SEEK, true));
slider->SetTarget(this);
top_row->AddChild(slider);
auto *slider_item = slider_parent_layout->AddView(slider);
slider_item->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT));
position_label = new BStringView("main:position_label", "Stopped");
auto *pos_label_item = slider_parent_layout->AddView(position_label);
pos_label_item->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_VERTICAL_CENTER));
position_label->Show();
auto *slider_parent_item = top_row->GroupLayout()->AddView(slider_parent);
slider_parent_item->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT));
slider->Hide();
stop_btn = new BButton(NULL, new BMessage(CMD_STOP));
stop_btn->SetTarget(this);
top_row->AddChild(stop_btn);
@ -289,13 +302,22 @@ void HaikuLooperWindow::Pulse() {
auto component_count = TimeToComponentCount(len);
bool enable_ui = !playback->IsStopped();
if (enable_ui) {
slider->SetLabel(fmt::format("Position: {}", TimeToString(pos, component_count)).c_str());
slider->SetLimitLabels(TimeToString(0, component_count).c_str(), TimeToString(len, component_count).c_str());
if (len <= 0.0) {
position_label->SetText(fmt::format("Position: {} units", (int)pos).c_str());
slider->Hide();
position_label->Show();
} else {
slider->SetLabel(fmt::format("Position: {}", TimeToString(pos, component_count)).c_str());
slider->SetLimitLabels(TimeToString(0, component_count).c_str(), TimeToString(len, component_count).c_str());
position_label->Hide();
slider->Show();
}
if (show_icons) pause_resume_btn->SetIcon(playback->IsPaused() ? resume_bitmap : pause_bitmap);
if (show_labels) pause_resume_btn->SetLabel(playback->IsPaused() ? "Resume" : "Pause");
} else {
slider->SetLabel("Position");
slider->SetLimitLabels("N/A", "N/A");
position_label->SetText("Stopped.");
slider->Hide();
position_label->Show();
if (show_icons) pause_resume_btn->SetIcon(pause_bitmap);
if (show_labels) pause_resume_btn->SetLabel("Pause");
}

View file

@ -3,6 +3,7 @@
#include <Application.h>
#include <GroupLayout.h>
#include <Slider.h>
#include <StringView.h>
#include <playback.h>
#include <thread>
#include <FilePanel.h>
@ -42,6 +43,7 @@ class Subwindow {
class HaikuLooperRefHandler;
class HaikuLooperWindow : public BWindow {
BSlider *slider;
BStringView *position_label;
BBitmap *pause_bitmap;
BBitmap *resume_bitmap;
BBitmap *refresh_bitmap;