Skip to content

Commit

Permalink
Add arrow seek
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksongoode committed Feb 7, 2024
1 parent 210b647 commit 1a629c4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 25 deletions.
23 changes: 21 additions & 2 deletions psst-gui/src/controller/playback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,30 @@ where
ctx.set_handled();
}
Event::KeyDown(key) if key.code == Code::ArrowRight => {
self.next();
if key.mods.shift() {
self.next();
} else {
if let Some(now_playing) = &data.playback.now_playing {
let current_position = now_playing.progress;
let max_position = now_playing.item.duration();
let seek_position =
(current_position + Duration::from_secs(10)).min(max_position);
self.seek(seek_position);
}
}
ctx.set_handled();
}
Event::KeyDown(key) if key.code == Code::ArrowLeft => {
self.previous();
if key.mods.shift() {
self.previous();
} else {
if let Some(now_playing) = &data.playback.now_playing {
let current_position = now_playing.progress;
let seek_position =
current_position.saturating_sub(Duration::from_secs(10));
self.seek(seek_position);
}
}
ctx.set_handled();
}
Event::KeyDown(key) if key.key == KbKey::Character("+".to_string()) => {
Expand Down
44 changes: 21 additions & 23 deletions psst-gui/src/ui/playback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,29 +90,27 @@ fn playing_item_widget() -> impl Widget<NowPlaying> {
Flex::row()
.with_child(cover_art)
.with_flex_child(
Flex::row()
.with_spacer(theme::grid(2.0))
.with_flex_child(
Flex::column()
.cross_axis_alignment(CrossAxisAlignment::Start)
.with_child(name)
.with_spacer(2.0)
.with_child(detail)
.with_spacer(2.0)
.with_child(origin)
.on_click(|ctx, now_playing, _| {
ctx.submit_command(cmd::NAVIGATE.with(now_playing.origin.to_nav()));
})
.context_menu(|now_playing| match &now_playing.item {
Playable::Track(track) => {
track::track_menu(track, &now_playing.library, &now_playing.origin)
}
Playable::Episode(episode) => {
episode::episode_menu(episode, &now_playing.library)
}
}),
1.0
),
Flex::row().with_spacer(theme::grid(2.0)).with_flex_child(
Flex::column()
.cross_axis_alignment(CrossAxisAlignment::Start)
.with_child(name)
.with_spacer(2.0)
.with_child(detail)
.with_spacer(2.0)
.with_child(origin)
.on_click(|ctx, now_playing, _| {
ctx.submit_command(cmd::NAVIGATE.with(now_playing.origin.to_nav()));
})
.context_menu(|now_playing| match &now_playing.item {
Playable::Track(track) => {
track::track_menu(track, &now_playing.library, &now_playing.origin)
}
Playable::Episode(episode) => {
episode::episode_menu(episode, &now_playing.library)
}
}),
1.0,
),
1.0,
)
.with_child(ViewSwitcher::new(
Expand Down

0 comments on commit 1a629c4

Please sign in to comment.