Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksongoode committed Dec 20, 2024
1 parent aa80ec6 commit e5674a0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
3 changes: 3 additions & 0 deletions psst-gui/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,6 @@ pub const TOGGLE_SORT_ORDER: Selector = Selector::new("app.toggle-sort-order");
// Track credits
pub const SHOW_CREDITS_WINDOW: Selector<Arc<Track>> = Selector::new("app.credits-show-window");
pub const LOAD_TRACK_CREDITS: Selector<Arc<Track>> = Selector::new("app.credits-load");

// Artwork
pub const SHOW_ARTWORK: Selector = Selector::new("app.show-artwork");
11 changes: 8 additions & 3 deletions psst-gui/src/delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use druid::{
};
use threadpool::ThreadPool;

use crate::ui::playback;
use crate::ui::playlist::{
RENAME_PLAYLIST, RENAME_PLAYLIST_CONFIRM, UNFOLLOW_PLAYLIST, UNFOLLOW_PLAYLIST_CONFIRM,
};
Expand Down Expand Up @@ -208,7 +207,7 @@ impl AppDelegate<AppState> for Delegate {
} else if cmd.is(commands::QUIT_APP) {
data.config.save();
Handled::No
} else if cmd.is(playback::SHOW_ARTWORK) {
} else if cmd.is(crate::cmd::SHOW_ARTWORK) {
self.show_artwork(ctx);
Handled::Yes
} else {
Expand Down Expand Up @@ -259,7 +258,13 @@ impl AppDelegate<AppState> for Delegate {
data.config.window_size = size;
}
}
} else if self.preferences_window == Some(window_id) || self.artwork_window == Some(window_id) || self.credits_window == Some(window_id) {
} else if [
self.preferences_window,
self.artwork_window,
self.credits_window,
]
.contains(&Some(window_id))
{
if let Event::KeyDown(key_event) = &event {
if key_event.key == druid::KbKey::Escape {
ctx.submit_command(commands::CLOSE_WINDOW.to(window_id));
Expand Down
8 changes: 3 additions & 5 deletions psst-gui/src/ui/playback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ use druid::{
kurbo::{Affine, BezPath},
widget::{CrossAxisAlignment, Either, Flex, Label, LineBreaking, Spinner, ViewSwitcher},
BoxConstraints, Cursor, Data, Env, Event, EventCtx, LayoutCtx, LensExt, LifeCycle,
LifeCycleCtx, MouseButton, PaintCtx, Point, Rect, RenderContext, Selector, Size, UpdateCtx,
Widget, WidgetExt, WidgetPod,
LifeCycleCtx, MouseButton, PaintCtx, Point, Rect, RenderContext, Size, UpdateCtx, Widget,
WidgetExt, WidgetPod,
};
use itertools::Itertools;

use crate::{
cmd::{self, ADD_TO_QUEUE, TOGGLE_LYRICS},
cmd::{self, ADD_TO_QUEUE, SHOW_ARTWORK, TOGGLE_LYRICS},
controller::PlaybackController,
data::{
AppState, AudioAnalysis, Episode, NowPlaying, Playable, PlayableMatcher, Playback,
Expand All @@ -24,8 +24,6 @@ use crate::{

use super::{episode, library, theme, track, utils};

pub const SHOW_ARTWORK: Selector<()> = Selector::new("app.playback.show-artwork");

pub fn panel_widget() -> impl Widget<AppState> {
let seek_bar = Maybe::or_empty(SeekBar::new).lens(Playback::now_playing);
let item_info = Maybe::or_empty(playing_item_widget).lens(Playback::now_playing);
Expand Down

0 comments on commit e5674a0

Please sign in to comment.