Skip to content

Commit

Permalink
#77 in progress!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
nednoodlehead committed Sep 20, 2024
1 parent 0f3379d commit d3064ef
Show file tree
Hide file tree
Showing 18 changed files with 26 additions and 346 deletions.
2 changes: 1 addition & 1 deletion src/db/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub fn create_playlist(new_playlist: UserPlaylist) -> Result<(), DatabaseErrors>
// although it would seem intelligent to include the length of the song, there is nowhere where that data can really live, and make sense
// like when we select from the table, should length be included? sounds sort of stupid. so we just query it here...
/// order num is the current length of the playlist. so if there is 3 songs, order_num should be three
pub fn add_to_playlist_bulk(
pub fn _add_to_playlist_bulk(
playlist_uuid: &str,
uniqueid: Vec<String>,
order_num: usize,
Expand Down
1 change: 0 additions & 1 deletion src/db/update.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use super::insert::add_to_playlist;
use crate::types::{DatabaseErrors, UserPlaylist};
use log::info;
use rusqlite::{params, Connection};
Expand Down
1 change: 0 additions & 1 deletion src/gui/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

use crate::types::{AppError, PungeMusicObject, UserPlaylist};
use crate::types::{MusicData, YouTubeData};
use rodio::Sink;
use serde::{ser, Deserialize, Serialize};
use tokio::sync::mpsc as async_sender;
#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down
3 changes: 0 additions & 3 deletions src/gui/persistent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,6 @@ impl App {
.spacing(5),
)
.height(iced::Length::Fill)
// .style(iced::theme::Container::Custom(Box::new(
// ContainerWithBorder,
// )))
.into()
}
}
1 change: 0 additions & 1 deletion src/gui/song_edit_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ impl SongEditPage {
author: self.author.clone(),
album: self.album.clone(),
uniqueid: self.uniqueid.clone(),
row_num: 0, // doesn't matter. we're using this type for convinence sake...
}
))
.style(|t, status| punge_button_style(status)),
Expand Down
25 changes: 5 additions & 20 deletions src/gui/start.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::db::fetch::{get_all_from_playlist, get_all_main, get_all_playlists, get_obj_from_uuid};
use crate::db::insert::create_playlist;
use crate::db::update::{
delete_from_playlist, delete_playlist, move_song_down_one, move_song_up_one,
quick_swap_title_author, update_auth_album, update_song,
delete_from_playlist, move_song_down_one, move_song_up_one, quick_swap_title_author,
update_auth_album, update_song,
};
use crate::gui::messages::{
AppEvent, CheckBoxType, ComboBoxType, Context, Page, ProgramCommands, PungeCommand, TextType,
Expand Down Expand Up @@ -167,12 +167,10 @@ impl Default for App {
table_content: get_all_main()
.unwrap()
.into_iter()
.enumerate()
.map(|(count, item)| crate::gui::widgets::row::RowData {
.map(|item| crate::gui::widgets::row::RowData {
title: item.title.clone(),
author: item.author.clone(),
album: item.album.clone(),
row_num: count,
uniqueid: item.uniqueid.clone(),
})
.collect(),
Expand Down Expand Up @@ -986,15 +984,6 @@ impl App {

Command::none()
}
ProgramCommands::DeletePlaylist(id) => {
// you cannot delete main.
if id.to_lowercase() != "main" {
delete_playlist(&id).unwrap();
// refresh the playlist...
self.user_playlists = get_all_playlists().unwrap();
}
Command::none()
}
ProgramCommands::UpdatePlaylist => {
crate::db::update::update_playlist(
&self.playlist_page.user_title,
Expand Down Expand Up @@ -1208,27 +1197,23 @@ impl App {
let new = get_all_main().unwrap();
self.table_content = new
.into_iter()
.enumerate()
.map(|(count, item)| crate::gui::widgets::row::RowData {
.map(|item| crate::gui::widgets::row::RowData {
title: item.title,
author: item.author,
album: item.album,
uniqueid: item.uniqueid,
row_num: count,
})
.collect();
} else {
let new = get_all_from_playlist(&self.viewing_playlist).unwrap();
debug!("viewing_playlist: {:?}", &self.viewing_playlist);
self.table_content = new
.into_iter()
.enumerate()
.map(|(count, item)| crate::gui::widgets::row::RowData {
.map(|item| crate::gui::widgets::row::RowData {
title: item.title,
author: item.author,
album: item.album,
uniqueid: item.uniqueid,
row_num: count,
})
.collect();
}
Expand Down
6 changes: 2 additions & 4 deletions src/gui/style/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ pub fn menu_button_style(status: Status) -> Style {
_ => Style::default(),
}
}

pub fn sub_menu_button_style(status: Status) -> Style {
// might come back and use this style..
pub fn _sub_menu_button_style(status: Status) -> Style {
match status {
Status::Active => Style {
background: None,
Expand Down Expand Up @@ -332,7 +332,5 @@ pub fn punge_button_style(status: Status) -> Style {
},
shadow: Shadow::default(),
},

_ => Style::default(),
}
}
5 changes: 2 additions & 3 deletions src/gui/style/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ use iced::border::Radius;
use iced::widget::container::Style;
use iced::{Background, Border, Color, Shadow, Vector};

pub struct ContainerWithBorder;

pub fn container_with_border() -> Style {
// most was for debugging the container size lol
pub fn _container_with_border() -> Style {
Style {
text_color: None,
background: None,
Expand Down
13 changes: 0 additions & 13 deletions src/gui/subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ impl App {
album: music_obj.current_object.album.clone(),
thumbnail: music_obj.current_object.savelocationjpg.clone(),
song_id: music_obj.current_object.uniqueid.clone(),
previous_id: None, // doesnt matter unless we are on skip_forward
volume: music_obj.sink.volume(),
is_playing: false,
shuffle: music_obj.shuffle,
Expand Down Expand Up @@ -151,7 +150,6 @@ impl App {
album: music_obj.current_object.album.clone(),
thumbnail: music_obj.current_object.savelocationjpg.clone(),
song_id: music_obj.current_object.uniqueid.clone(),
previous_id: None, // i dont think we can know this here?
volume: music_obj.sink.volume(),
is_playing: true,
shuffle: music_obj.shuffle,
Expand All @@ -166,7 +164,6 @@ impl App {
PungeCommand::SkipForwards => {
// so i guess the answer is doing .stop()? not .clear(). ig cause .stop() also clears the queue
music_obj.sink.stop();
let old_id = music_obj.current_object.uniqueid.clone();
music_obj.count =
change_count(true, music_obj.count, music_obj.list.len());
music_obj.current_object = music_obj.list[music_obj.count].clone();
Expand All @@ -183,7 +180,6 @@ impl App {
album: music_obj.current_object.album.clone(),
thumbnail: music_obj.current_object.savelocationjpg.clone(),
song_id: music_obj.current_object.uniqueid.clone(),
previous_id: Some(old_id),
volume: music_obj.sink.volume(),
is_playing: true,
shuffle: music_obj.shuffle,
Expand Down Expand Up @@ -212,7 +208,6 @@ impl App {
album: music_obj.current_object.album.clone(),
thumbnail: music_obj.current_object.savelocationjpg.clone(),
song_id: music_obj.current_object.uniqueid.clone(),
previous_id: None,
volume: music_obj.sink.volume(),
is_playing: true,
shuffle: music_obj.shuffle,
Expand Down Expand Up @@ -249,7 +244,6 @@ impl App {
album: music_obj.current_object.album.clone(),
thumbnail: music_obj.current_object.savelocationjpg.clone(),
song_id: music_obj.current_object.uniqueid.clone(),
previous_id: None,
volume: music_obj.sink.volume(),
is_playing: true,
shuffle: music_obj.shuffle,
Expand Down Expand Up @@ -287,7 +281,6 @@ impl App {
album: music_obj.current_object.album.clone(),
thumbnail: music_obj.current_object.savelocationjpg.clone(),
song_id: music_obj.current_object.uniqueid.clone(),
previous_id: None,
volume: music_obj.sink.volume(),
is_playing: false,
shuffle: music_obj.shuffle,
Expand Down Expand Up @@ -395,7 +388,6 @@ impl App {
.current_object
.uniqueid
.clone(),
previous_id: None, // not known.
volume: music_obj.sink.volume(),
is_playing: false, // we can only pause...
shuffle: music_obj.shuffle,
Expand Down Expand Up @@ -439,7 +431,6 @@ impl App {
.current_object
.uniqueid
.clone(),
previous_id: Some(old_id),
volume: music_obj.sink.volume(),
is_playing: true,
shuffle: music_obj.shuffle,
Expand Down Expand Up @@ -486,7 +477,6 @@ impl App {
.current_object
.uniqueid
.clone(),
previous_id: None,
volume: music_obj.sink.volume(),
is_playing: true,
shuffle: music_obj.shuffle,
Expand Down Expand Up @@ -530,7 +520,6 @@ impl App {
.current_object
.uniqueid
.clone(),
previous_id: None,
volume: music_obj.sink.volume(),
is_playing: true,
shuffle: music_obj.shuffle,
Expand Down Expand Up @@ -645,7 +634,6 @@ impl App {
.current_object
.uniqueid
.clone(),
previous_id: None,
volume: music_obj.sink.volume(),
is_playing: true,
shuffle: music_obj.shuffle,
Expand Down Expand Up @@ -696,7 +684,6 @@ impl App {
album: music_obj.current_object.album.clone(),
thumbnail: music_obj.current_object.savelocationjpg.clone(),
song_id: music_obj.current_object.uniqueid.clone(),
previous_id: None,
volume: music_obj.sink.volume(),
is_playing: true,
shuffle: music_obj.shuffle,
Expand Down
12 changes: 5 additions & 7 deletions src/gui/widgets/hover_menu.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
use crate::gui::style::button::punge_button_style;
use crate::gui::widgets::row::{RowState, RowWidget};
use crate::gui::widgets::row::RowState;
use iced::advanced::layout::Limits;
use iced::advanced::text::Editor;
use iced::advanced::{layout, renderer, widget::Tree, widget::Widget, Overlay};
use iced::advanced::{mouse, overlay};
use iced::event::Status;
use iced::widget::{button, column, row, text, Button, Row};
use iced::{Border, Color, Element, Event, Length, Point, Shadow, Size, Theme, Vector};
use iced::advanced::mouse;
use iced::advanced::{layout, renderer, widget::Tree, Overlay};
use iced::widget::{button, column, text};
use iced::{Element, Event, Size};

pub fn create_hover_menu<'a, Message, Theme, Renderer>(
add_to_msg: fn(String, String) -> Message,
Expand Down
9 changes: 4 additions & 5 deletions src/gui/widgets/playlist_button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use iced::advanced::layout::Limits;
// and a right-click will show some playlist options (edit, move up, move down, duplicate, play)
use iced::advanced::{layout, renderer, widget::Tree, widget::Widget};
use iced::advanced::{mouse, Overlay};
use iced::widget::{button};
use iced::Event;
use iced::{Element, Length, Point, Size, Vector};

Expand Down Expand Up @@ -176,7 +175,7 @@ where
}
iced::event::Status::Ignored
}
Event::Mouse(mouse::Event::CursorMoved { position }) => {
Event::Mouse(mouse::Event::CursorMoved { position: _ }) => {
if st.show_menu {
let tmp = cursor.position();
match tmp {
Expand Down Expand Up @@ -228,7 +227,7 @@ where
pub struct PlaylistButtonOverlay<'a, Message, Theme, Renderer>
where
Message: 'a + Clone,
Theme: button::Catalog,
Theme: iced::widget::button::Catalog,
Renderer: iced::advanced::Renderer + iced::advanced::text::Renderer,
{
pub tree: &'a mut Tree,
Expand All @@ -240,7 +239,7 @@ impl<'a, Message, Theme, Renderer> Overlay<Message, Theme, Renderer>
for PlaylistButtonOverlay<'a, Message, Theme, Renderer>
where
Message: Clone,
Theme: button::Catalog + iced::widget::text::Catalog,
Theme: iced::widget::button::Catalog + iced::widget::text::Catalog,
Renderer: iced::advanced::Renderer + iced::advanced::text::Renderer,
{
fn layout(&mut self, renderer: &Renderer, bounds: Size) -> layout::Node {
Expand Down Expand Up @@ -296,7 +295,7 @@ impl<'a, Message, Theme, Renderer> From<PlaylistButtonOverlay<'a, Message, Theme
for iced::advanced::overlay::Element<'a, Message, Theme, Renderer>
where
Message: 'a + Clone,
Theme: 'a + button::Catalog + iced::widget::text::Catalog,
Theme: 'a + iced::widget::button::Catalog + iced::widget::text::Catalog,
Renderer: 'a + iced::advanced::Renderer + iced::advanced::text::Renderer,
{
fn from(overlay: PlaylistButtonOverlay<'a, Message, Theme, Renderer>) -> Self {
Expand Down
27 changes: 2 additions & 25 deletions src/gui/widgets/row.rs
Original file line number Diff line number Diff line change
@@ -1,41 +1,18 @@
use crate::gui::widgets::hover_menu::create_hover_menu;
use crate::gui::widgets::row_overlay::OverlayButtons;
use iced::advanced::mouse;
use iced::advanced::{layout, renderer, widget::Tree, widget::Widget};
use iced::widget::{button, column, row, text, Column, Row};
use iced::widget::{button, row, text};
use iced::Event;
use iced::{Border, Color, Element, Length, Point, Shadow, Size, Theme, Vector};
use iced::{Border, Color, Element, Length, Point, Size, Vector};

use crate::gui::style::button::punge_button_style;
// i dont think this is the best way to make this work. but passing in the Element from main.rs just caused issues
// like if it is held by the main struct, we cannot pass it into the overlay!?
pub fn create_menu<'a, 'b, Message, Theme, Renderer>(
delete_msg: Message,
quick_swap_msg: Message,
add_to_msg: fn(String, String) -> Message,
uuid_list: Vec<(String, String)>,
) -> Element<'a, Message, Theme, Renderer>
where
Message: 'a + Clone,
Theme: 'a + button::Catalog + iced::widget::text::Catalog,
Renderer: 'a + iced::advanced::Renderer + iced::advanced::text::Renderer,
'b: 'a,
{
column![
button(text("delete")).on_press(delete_msg),
button(text("Edit")),
button(text("Quickswap 1")).on_press(quick_swap_msg),
button(text("Add to..."))
]
.into()
}

#[derive(Debug, Clone)]
pub struct RowData {
pub title: String,
pub author: String,
pub album: String,
pub row_num: usize,
pub uniqueid: String,
}

Expand Down
9 changes: 4 additions & 5 deletions src/gui/widgets/row_overlay.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use crate::gui::widgets::row::{create_menu, RowState, RowWidget};
use crate::gui::widgets::row::RowState;
use iced::advanced::layout::Limits;
use iced::advanced::{layout, renderer, widget::Tree, widget::Widget, Overlay};
use iced::advanced::{layout, renderer, widget::Tree, Overlay};
use iced::advanced::{mouse, overlay};
use iced::event::Status;
use iced::widget::{button, column, row, text, Button, Row};
use iced::{Border, Color, Element, Event, Length, Padding, Point, Shadow, Size, Theme, Vector};
use iced::widget::button;
use iced::{Element, Event, Point, Size};

pub struct OverlayButtons<'a, Message, Theme, Renderer>
where
Expand Down
4 changes: 1 addition & 3 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ pub enum DatabaseErrors {
}

#[derive(Debug, Clone)]
#[allow(dead_code)] // nice to have for errors...
pub enum AppError {
DatabaseError(DatabaseErrors),
YoutubeError(String), // url, what went wrong
Expand Down Expand Up @@ -171,7 +172,6 @@ pub struct MusicData {
pub album: String,
pub thumbnail: String, // path to the thumbnail
pub song_id: String,
pub previous_id: Option<String>, // used only inside of skip_forward database subscription, None otherwise.
pub volume: f32,
pub is_playing: bool,
pub shuffle: bool,
Expand All @@ -189,7 +189,6 @@ impl MusicData {
album: "".to_string(),
thumbnail: "".to_string(),
song_id: "".to_string(),
previous_id: None,
volume: 0.0,
is_playing: false,
shuffle: false,
Expand Down Expand Up @@ -232,7 +231,6 @@ pub struct YouTubeData {
pub title: String,
pub author: String,
pub album: String,
pub url: String,
}

#[derive(Debug, Clone)]
Expand Down
Loading

0 comments on commit d3064ef

Please sign in to comment.