diff --git a/backends/ui/haiku/main_window.cpp b/backends/ui/haiku/main_window.cpp index b6c456a..5abe30e 100644 --- a/backends/ui/haiku/main_window.cpp +++ b/backends/ui/haiku/main_window.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #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"); } diff --git a/backends/ui/haiku/main_window.h b/backends/ui/haiku/main_window.h index ac6cc6b..1ddc56e 100644 --- a/backends/ui/haiku/main_window.h +++ b/backends/ui/haiku/main_window.h @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -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;