Skip to content

Commit

Permalink
ui updates, #34 here we come..
Browse files Browse the repository at this point in the history
  • Loading branch information
nednoodlehead committed Jun 4, 2024
1 parent fa49288 commit d73ae1d
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 21 deletions.
49 changes: 28 additions & 21 deletions src/gui/persistent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
// such as the 'current playing' bar at the bottom, and the buttons at the top to change pages
use crate::gui::messages::{Page, ProgramCommands};
use crate::gui::start::App;
use crate::gui::style::button::{JustText, MenuButton};
use crate::gui::style::button::{JustText, MenuButton, SubMenuButton};
use crate::gui::style::container::{BottomBarContainer, ContainerWithBorder};
use crate::gui::style::menu::PungeMenu;
use crate::gui::style::scrubber::ScrubberStyle;
use crate::gui::style::volume::VolumeStyle;
use iced::widget::{button, column, container, horizontal_space, row, slider, text, Column, Image};
Expand Down Expand Up @@ -98,13 +99,18 @@ impl App {
}
pub fn render_buttons_side(&self, ignore: Page) -> Element<'static, ProgramCommands> {
let playlist_add_to_menu = Item::with_menu(
text("Add to:"),
button(text("Add to... ->")) // this is mad goofy lol
.width(180)
.style(iced::theme::Button::Custom(Box::new(SubMenuButton)))
.on_press(ProgramCommands::Debug),
Menu::new(
self.user_playlists
.iter()
.map(|p| {
Item::new(
button(text(p.title.clone()))
.style(iced::theme::Button::Custom(Box::new(SubMenuButton)))
.width(150)
.on_press(ProgramCommands::AddToPlaylist(p.uniqueid.clone())),
)
})
Expand All @@ -115,20 +121,33 @@ impl App {
);
let menu = iced_aw::menu_bar!((
button("Edit song")
.clip(true)
.style(iced::theme::Button::Custom(Box::new(MenuButton)))
.on_press(ProgramCommands::Debug),
Menu::new(vec![
Item::new(button(text("Full Edit")).on_press(ProgramCommands::OpenSongEditPage)),
Item::new(
button(text("Full Edit"))
.on_press(ProgramCommands::OpenSongEditPage)
.style(iced::theme::Button::Custom(Box::new(SubMenuButton)))
.width(180)
),
Item::new(
button(text("Swap Title & Author"))
.on_press(ProgramCommands::QuickSwapTitleAuthor),
.style(iced::theme::Button::Custom(Box::new(SubMenuButton)))
.on_press(ProgramCommands::QuickSwapTitleAuthor)
.width(180),
),
Item::new(
button(text("Delete!!"))
.style(iced::theme::Button::Custom(Box::new(SubMenuButton)))
.on_press(ProgramCommands::DeleteSong)
.width(180)
),
Item::new(button(text("Delete!!")).on_press(ProgramCommands::DeleteSong)),
playlist_add_to_menu,
])
.offset(0.0)
.max_width(180.0)
));
))
.style(iced_aw::style::MenuBarStyle::Custom(Box::new(PungeMenu)));

let mut all_playlists_but_main = self.user_playlists.clone();
// user should always have the 'main' playlist
Expand All @@ -143,6 +162,7 @@ impl App {
playlist.uniqueid.clone(),
))
.style(iced::theme::Button::Custom(Box::new(JustText)))
.width(180)
.height(Length::Fixed(32.5)) // playlist button height :)
.into()
})
Expand All @@ -169,7 +189,7 @@ impl App {
}
})
.collect();
btn.push(row![text(" "), menu].into()); // the stupid button clips over the container border. so add this so it doesnt ...
btn.push(menu.into()); // the stupid button clips over the container border. so add this so it doesnt ...
btn.push(self.horizontal_separator().into()); // separater between buttons and playlists :)
btn.extend(playlist_buttons);
container(row![Column::with_children(btn), self.vertical_separator()].spacing(5))
Expand All @@ -179,19 +199,6 @@ impl App {
// )))
.into()
}
// pub fn render_search_result_box(
// &self,
// title: String,
// channel_name: String,
// views: String,
// duration: String,
// link: String,
// thumbnail: String,
// ) -> Element<'_, ProgramCommands> {
// // create a container that holds all of the stuff relating to a download
// // also downloads the images. they should be flushed on each search
// container()
// }
fn horizontal_separator(&self) -> quad::Quad {
quad::Quad {
quad_color: Color::from([0.5; 3]).into(),
Expand Down
76 changes: 76 additions & 0 deletions src/gui/style/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,79 @@ impl button::StyleSheet for MenuButton {
}
}
}

pub struct SubMenuButton;

impl button::StyleSheet for SubMenuButton {
type Style = iced::Theme;

fn hovered(&self, style: &Self::Style) -> button::Appearance {
button::Appearance {
shadow_offset: Vector { x: 2.0, y: 2.0 },
background: Some(Background::Color(Color {
r: 0.55,
g: 0.55,
b: 0.55,
a: 1.0,
})),
text_color: Color {
r: 0.9,
g: 0.9,
b: 0.9,
a: 1.0,
},
border: Border {
color: Color {
r: 0.8,
g: 0.8,
b: 0.8,
a: 1.0,
},
width: 2.0,
radius: Radius::from(0.0), // 20 -> 0
},
shadow: Shadow {
color: Color {
r: 0.1,
g: 0.1,
b: 0.1,
a: 0.1,
},
offset: Vector { x: 3.0, y: 3.0 },
blur_radius: 1.0,
},
}
}
fn active(&self, style: &Self::Style) -> button::Appearance {
button::Appearance {
shadow_offset: Vector { x: 2.0, y: 2.0 },
background: None,
text_color: Color {
r: 0.9,
g: 0.9,
b: 0.9,
a: 1.0,
},
border: Border {
color: Color {
r: 0.8,
g: 0.8,
b: 0.8,
a: 0.0,
},
width: 2.0,
radius: Radius::from(20.0),
},
shadow: Shadow {
color: Color {
r: 0.1,
g: 0.1,
b: 0.1,
a: 0.1,
},
offset: Vector { x: 3.0, y: 3.0 },
blur_radius: 1.0,
},
}
}
}
17 changes: 17 additions & 0 deletions src/gui/style/menu.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use iced_aw::menu::StyleSheet;
use iced_core::border::Radius;
use iced_core::{Background, Border, Color, Padding, Shadow, Vector};

pub struct PungeMenu;

impl StyleSheet for PungeMenu {
type Style = iced::Theme;
fn appearance(&self, style: &Self::Style) -> iced_aw::menu::Appearance {
iced_aw::menu::Appearance {
bar_background: Background::Color(Color::new(0.5, 0.5, 0.5, 0.0)),
menu_background: Background::Color(Color::new(0.2, 0.2, 0.2, 1.0)),
bar_background_expand: Padding::new(5.0),
..Default::default()
}
}
}
1 change: 1 addition & 0 deletions src/gui/style/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod button;
pub mod container;
pub mod menu;
pub mod scrubber;
pub mod volume;

0 comments on commit d73ae1d

Please sign in to comment.