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 <cmath>
#include <fmt/core.h> #include <fmt/core.h>
#include <fmt/format.h> #include <fmt/format.h>
#include <LayoutItem.h>
#include <SDL.h> #include <SDL.h>
#include "icons.h" #include "icons.h"
#include "utils.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 = new BButton(NULL, new BMessage(CMD_RESTART));
restart_btn->SetTarget(this); restart_btn->SetTarget(this);
top_row->AddChild(restart_btn); 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 = 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->SetModificationMessage(make_slider_msg(CMD_SEEK, true));
slider->SetTarget(this); 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 = 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);
@ -289,13 +302,22 @@ void HaikuLooperWindow::Pulse() {
auto component_count = TimeToComponentCount(len); auto component_count = TimeToComponentCount(len);
bool enable_ui = !playback->IsStopped(); bool enable_ui = !playback->IsStopped();
if (enable_ui) { if (enable_ui) {
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->SetLabel(fmt::format("Position: {}", TimeToString(pos, component_count)).c_str());
slider->SetLimitLabels(TimeToString(0, component_count).c_str(), TimeToString(len, 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_icons) pause_resume_btn->SetIcon(playback->IsPaused() ? resume_bitmap : pause_bitmap);
if (show_labels) pause_resume_btn->SetLabel(playback->IsPaused() ? "Resume" : "Pause"); if (show_labels) pause_resume_btn->SetLabel(playback->IsPaused() ? "Resume" : "Pause");
} else { } else {
slider->SetLabel("Position"); position_label->SetText("Stopped.");
slider->SetLimitLabels("N/A", "N/A"); slider->Hide();
position_label->Show();
if (show_icons) pause_resume_btn->SetIcon(pause_bitmap); if (show_icons) pause_resume_btn->SetIcon(pause_bitmap);
if (show_labels) pause_resume_btn->SetLabel("Pause"); if (show_labels) pause_resume_btn->SetLabel("Pause");
} }

View file

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