Skip to content

Commit

Permalink
Remove from quieue buttom
Browse files Browse the repository at this point in the history
  • Loading branch information
SO9010 authored and SO9010 committed Jun 30, 2024
1 parent 2ffb38a commit 1b0d7c5
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 33 deletions.
7 changes: 5 additions & 2 deletions psst-gui/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,16 @@ pub const PLAY_PREVIOUS: Selector = Selector::new("app.play-previous");
pub const PLAY_PAUSE: Selector = Selector::new("app.play-pause");
pub const PLAY_RESUME: Selector = Selector::new("app.play-resume");
pub const PLAY_NEXT: Selector = Selector::new("app.play-next");
// Todo Skip by
pub const SKIP_BY: Selector = Selector::new("app.skip-by");
pub const PLAY_STOP: Selector = Selector::new("app.play-stop");
pub const ADD_TO_QUEUE: Selector<(QueueEntry, PlaybackItem)> = Selector::new("app.add-to-queue");
pub const PLAY_QUEUE_BEHAVIOR: Selector<QueueBehavior> = Selector::new("app.play-queue-behavior");
pub const PLAY_SEEK: Selector<f64> = Selector::new("app.play-seek");

// Queue control
// Todo Skip by
pub const SKIP_BY: Selector = Selector::new("app.skip-by");
pub const REMOVE_FROM_QUEUE: Selector<usize> = Selector::new("app.remove-from-queue");

// Sorting control
pub const SORT_BY_DATE_ADDED: Selector = Selector::new("app.sort-by-date-added");
pub const SORT_BY_TITLE: Selector = Selector::new("app.sort-by-title");
Expand Down
17 changes: 12 additions & 5 deletions psst-gui/src/controller/playback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use druid::{
Code, ExtEventSink, InternalLifeCycle, KbKey, WindowHandle,
};
use psst_core::{
audio::{normalize::NormalizationLevel, output::DefaultAudioOutput},
audio::{normalize::{self, NormalizationLevel}, output::DefaultAudioOutput},
cache::Cache,
cdn::Cdn,
player::{item::PlaybackItem, PlaybackConfig, Player, PlayerCommand, PlayerEvent},
Expand Down Expand Up @@ -412,10 +412,6 @@ where
self.next();
ctx.set_handled();
}
Event::Command(cmd) if cmd.is(cmd::SKIP_BY) => {
// self.
// ctx.set_handled();
}
Event::Command(cmd) if cmd.is(cmd::PLAY_STOP) => {
self.stop();
ctx.set_handled();
Expand Down Expand Up @@ -444,6 +440,17 @@ where
}
ctx.set_handled();
}
Event::Command(cmd) if cmd.is(cmd::SKIP_BY) => {
let no = cmd.get_unchecked(cmd::SKIP_BY);

ctx.set_handled();
}
Event::Command(cmd) if cmd.is(cmd::REMOVE_FROM_QUEUE) => {
let item = cmd.get_unchecked(cmd::REMOVE_FROM_QUEUE);
// We must also remove from the other queue
data.added_queue.remove(item.clone());
ctx.set_handled();
}
// Keyboard shortcuts.
Event::KeyDown(key) if key.code == Code::Space => {
self.pause_or_resume();
Expand Down
39 changes: 13 additions & 26 deletions psst-gui/src/ui/queued.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
data::{
AppState, QueueEntry
},
widget::{Border, MyWidgetExt},
widget::{icons, Border, MyWidgetExt},
};

use super::theme;
Expand Down Expand Up @@ -66,36 +66,23 @@ fn queue_list_widget() -> impl Widget<Vector<QueueEntry>> {
// We need to make a function which takes the song index when clicked on then we need to skip by that amount.
ctx.submit_notification(TODO)
})*/
//.context_menu(queue_menu_widget()),
//.context_menu(queue_menu_widget(|item: &Vec<QueueEntry>, _env: &Env| item.len()),
1.0,
)
.with_default_spacer()
.with_flex_spacer(3.0)
.with_child(icons::CLOSE_CIRCLE
.scale((24.0, 24.0))
.padding(theme::grid(0.25))
.link()
.rounded(100.0)
.on_click(move |ctx, _, _| {

ctx.submit_command(cmd::REMOVE_FROM_QUEUE.with(0/* Add song index here */));
})
)
.padding(theme::grid(1.0))
.link()

.rounded(theme::BUTTON_BORDER_RADIUS)
.padding(theme::grid(1.0))
})
}
fn queue_menu_widget() -> Menu<AppState> {
//.with_child(queue_menu_item_widget("Clear Queue", Command::ClearQueue))
//.with_child(queue_menu_item_widget("Remove from queue", Command::RemoveFromQueue))
let mut menu = Menu::new("Queue");

// Create menu items for sorting options
let sort_by_title = MenuItem::new("Title").command(cmd::SORT_BY_TITLE);
let sort_by_album = MenuItem::new("Album").command(cmd::SORT_BY_ALBUM);
let sort_by_date_added = MenuItem::new("Date Added").command(cmd::SORT_BY_DATE_ADDED);
let sort_by_duration = MenuItem::new("Duration").command(cmd::SORT_BY_DURATION);
let sort_by_artist = MenuItem::new("Artist").command(cmd::SORT_BY_ARTIST);


// Add the items and checkboxes to the menu
menu = menu.entry(sort_by_album);
menu = menu.entry(sort_by_artist);
menu = menu.entry(sort_by_date_added);
menu = menu.entry(sort_by_duration);
menu = menu.entry(sort_by_title);

menu
}
6 changes: 6 additions & 0 deletions psst-gui/src/widget/icons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ pub static HEART_OUTLINE: SvgIcon = SvgIcon {
svg_size: Size::new(24.0, 24.0),
op: PaintOp::Fill,
};
// Font Awesome - Close-circle
pub static CLOSE_CIRCLE: SvgIcon = SvgIcon {
svg_path: "M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm0-11.414L9.172 7.757 7.757 9.172 10.586 12l-2.829 2.828 1.415 1.415L12 13.414l2.828 2.829 1.415-1.415L13.414 12l2.829-2.828-1.415-1.415L12 10.586z",
svg_size: Size::new(24.0, 24.0),
op: PaintOp::Fill,
};

#[derive(Copy, Clone)]
pub enum PaintOp {
Expand Down

0 comments on commit 1b0d7c5

Please sign in to comment.