mirror of
https://github.com/arabianq/pipewire-soundpad.git
synced 2026-04-28 06:21:23 +00:00
feat: you can now collapse every audio track
This commit is contained in:
+35
-36
@@ -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,46 +95,45 @@ 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);
|
if self.audio_player_state.tracks.is_empty() {
|
||||||
});
|
ui.label("No tracks playing");
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
fn draw_controls(&mut self, ui: &mut Ui) {
|
let tracks = self.audio_player_state.tracks.clone();
|
||||||
if self.audio_player_state.tracks.is_empty() {
|
let mut action = None;
|
||||||
ui.label("No tracks playing");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let tracks = self.audio_player_state.tracks.clone();
|
for track in tracks {
|
||||||
let mut action = None;
|
CollapsingHeader::new(
|
||||||
|
RichText::new(
|
||||||
for track in tracks {
|
track
|
||||||
ui.label(
|
.path
|
||||||
RichText::new(
|
.file_stem()
|
||||||
track
|
.unwrap_or_default()
|
||||||
.path
|
.to_str()
|
||||||
.file_stem()
|
.unwrap_or_default(),
|
||||||
.unwrap_or_default()
|
)
|
||||||
.to_str()
|
.color(Color32::WHITE)
|
||||||
.unwrap_or_default(),
|
.family(FontFamily::Monospace),
|
||||||
)
|
)
|
||||||
.color(Color32::WHITE)
|
.default_open(true)
|
||||||
.family(FontFamily::Monospace),
|
.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();
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(action) = action {
|
if let Some(action) = action {
|
||||||
match action {
|
match action {
|
||||||
TrackAction::Pause(id) => self.pause(Some(id)),
|
TrackAction::Pause(id) => self.pause(Some(id)),
|
||||||
TrackAction::Resume(id) => self.resume(Some(id)),
|
TrackAction::Resume(id) => self.resume(Some(id)),
|
||||||
TrackAction::ToggleLoop(id) => self.toggle_loop(Some(id)),
|
TrackAction::ToggleLoop(id) => self.toggle_loop(Some(id)),
|
||||||
TrackAction::Stop(id) => self.stop(Some(id)),
|
TrackAction::Stop(id) => self.stop(Some(id)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_track_control(
|
fn draw_track_control(
|
||||||
|
|||||||
Reference in New Issue
Block a user