Skip to content

Commit

Permalink
Context menu update
Browse files Browse the repository at this point in the history
  • Loading branch information
SO9010 authored and SO9010 committed Jul 29, 2024
1 parent 8c3b1ae commit ceb9caa
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
2 changes: 1 addition & 1 deletion psst-gui/src/controller/playback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ where
let track_pos = *cmd.get_unchecked(cmd::SKIP_TO_PLACE_IN_QUEUE);

// We need a way so it starts playing even if theres no playlist being played from!
if track_pos > 0{
if track_pos > 0 && !data.playback.queue.is_empty() {
data.added_queue = data.added_queue.split_off(track_pos);
self.skip_to_place_in_queue(&track_pos);
self.next();
Expand Down
1 change: 0 additions & 1 deletion psst-gui/src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ fn root_widget() -> impl Widget<AppState> {
.with_default_spacer()
.with_child(user::user_widget())
.center()
.fix_height(88.0)
.background(Border::Top.with_color(theme::GREY_500));

let left_bar = Flex::column()
Expand Down
36 changes: 29 additions & 7 deletions psst-gui/src/ui/queued.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use std::sync::Arc;

use crate::{
cmd,
data::{AppState, QueueEntry},
data::{self, AppState, Nav, PlaybackOrigin, QueueEntry, RecommendationsRequest},
ui::Vector,
widget::{icons, Border, Empty, MyWidgetExt},
};

use druid::{
widget::{CrossAxisAlignment, Either, Flex, Label, LineBreaking, List, Scroll}, Data, Env, Lens, LensExt, Menu, MenuItem, Widget, WidgetExt
widget::{CrossAxisAlignment, Either, Flex, Label, LineBreaking, List, Scroll}, Data, Env, Lens, LensExt, LocalizedString, Menu, MenuItem, Widget, WidgetExt
};
use druid_shell::Cursor;

Expand Down Expand Up @@ -107,11 +109,31 @@ fn queue_list_widget() -> impl Widget<Vector<QueueEntryWithIndex>> {
}

fn queue_entry_context_menu(item: QueueEntryWithIndex) -> Menu<AppState> {
Menu::new("")
.entry(MenuItem::new("Remove from Queue").on_activate(move |ctx, _, _| {
let mut menu = Menu::empty();

menu = menu.entry(MenuItem::new("Remove from Queue").on_activate(move |ctx, _, _| {
ctx.submit_command(cmd::REMOVE_FROM_QUEUE.with(item.index));
}))
.entry(MenuItem::new("Clear Queue").on_activate(move |ctx, _, _| {
}));

menu = menu.entry(MenuItem::new("Clear Queue").on_activate(move |ctx, _, _| {
ctx.submit_command(cmd::CLEAR_QUEUE);
}))
}));

menu = menu.entry(
MenuItem::new(
LocalizedString::new("menu-item-show-recommended")
.with_placeholder("Show Similar Tracks"),
)
.command(cmd::NAVIGATE.with(Nav::Recommendations(Arc::new(
RecommendationsRequest::for_track(crate::data::TrackId(item.entry.item.id())),
)))),
);

menu = menu.entry(MenuItem::new("Back to origin").on_activate(move |ctx, _, _| {
if let PlaybackOrigin::Playlist(playlist_link) = item.entry.origin.clone() {
ctx.submit_command(cmd::NAVIGATE.with(Nav::PlaylistDetail(playlist_link)));
}
}));

menu
}

0 comments on commit ceb9caa

Please sign in to comment.