feat: you can now collapse every audio track

This commit is contained in:
2026-01-28 00:03:56 +03:00
parent cdf306cfe9
commit 6df826f210
+8 -9
View File
@@ -1,7 +1,7 @@
use crate::gui::{SUPPORTED_EXTENSIONS, SoundpadGui}; use crate::gui::{SUPPORTED_EXTENSIONS, SoundpadGui};
use egui::{ use egui::{
Align, AtomExt, Button, Color32, ComboBox, CursorIcon, FontFamily, Label, Layout, RichText, Align, AtomExt, Button, CollapsingHeader, Color32, ComboBox, CursorIcon, FontFamily, Label,
ScrollArea, Sense, Slider, TextEdit, Ui, Vec2, Layout, RichText, ScrollArea, Sense, Slider, TextEdit, Ui, Vec2,
}; };
use egui_material_icons::icons; use egui_material_icons::icons;
use pwsp::types::audio_player::TrackInfo; use pwsp::types::audio_player::TrackInfo;
@@ -95,11 +95,6 @@ impl SoundpadGui {
fn draw_header(&mut self, ui: &mut Ui) { fn draw_header(&mut self, ui: &mut Ui) {
ui.vertical_centered_justified(|ui| { ui.vertical_centered_justified(|ui| {
self.draw_controls(ui);
});
}
fn draw_controls(&mut self, ui: &mut Ui) {
if self.audio_player_state.tracks.is_empty() { if self.audio_player_state.tracks.is_empty() {
ui.label("No tracks playing"); ui.label("No tracks playing");
return; return;
@@ -109,7 +104,7 @@ impl SoundpadGui {
let mut action = None; let mut action = None;
for track in tracks { for track in tracks {
ui.label( CollapsingHeader::new(
RichText::new( RichText::new(
track track
.path .path
@@ -120,10 +115,13 @@ impl SoundpadGui {
) )
.color(Color32::WHITE) .color(Color32::WHITE)
.family(FontFamily::Monospace), .family(FontFamily::Monospace),
); )
.default_open(true)
.show(ui, |ui| {
if let Some(act) = Self::draw_track_control(ui, &mut self.app_state, &track) { if let Some(act) = Self::draw_track_control(ui, &mut self.app_state, &track) {
action = Some(act); action = Some(act);
} }
});
ui.separator(); ui.separator();
} }
@@ -135,6 +133,7 @@ impl SoundpadGui {
TrackAction::Stop(id) => self.stop(Some(id)), TrackAction::Stop(id) => self.stop(Some(id)),
} }
} }
});
} }
fn draw_track_control( fn draw_track_control(