mirror of
https://github.com/Zenithsiz/zsw.git
synced 2026-02-03 09:50:31 +00:00
Removed zsw-profiles's dependency on zsw-panel.
This commit is contained in:
parent
953210575d
commit
f677578692
@ -4,4 +4,4 @@
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"singleAttributePerLine": true
|
||||
}
|
||||
}
|
||||
|
||||
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -3579,7 +3579,6 @@ dependencies = [
|
||||
"num-rational",
|
||||
"parking_lot",
|
||||
"rand",
|
||||
"serde",
|
||||
"tracing",
|
||||
"wgpu",
|
||||
"winit",
|
||||
@ -3611,7 +3610,6 @@ dependencies = [
|
||||
"parking_lot",
|
||||
"serde",
|
||||
"tracing",
|
||||
"zsw-panels",
|
||||
"zsw-util",
|
||||
]
|
||||
|
||||
|
||||
12
profile.json
12
profile.json
@ -14,8 +14,10 @@
|
||||
},
|
||||
"duration": 1800,
|
||||
"fade_point": 1440,
|
||||
"parallax_ratio": 0.98,
|
||||
"reverse_parallax": true
|
||||
"parallax": {
|
||||
"ratio": 0.98,
|
||||
"reverse": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
@ -30,8 +32,10 @@
|
||||
},
|
||||
"duration": 1800,
|
||||
"fade_point": 1440,
|
||||
"parallax_ratio": 0.98,
|
||||
"reverse_parallax": true
|
||||
"parallax": {
|
||||
"ratio": 0.98,
|
||||
"reverse": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -8,25 +8,22 @@ version = "0.1.0"
|
||||
[dependencies]
|
||||
|
||||
# Zsw
|
||||
zsw-img = {path = "../zsw-img"}
|
||||
zsw-input = {path = "../zsw-input"}
|
||||
zsw-util = {path = "../zsw-util"}
|
||||
zsw-wgpu = {path = "../zsw-wgpu"}
|
||||
zsw-img = { path = "../zsw-img" }
|
||||
zsw-input = { path = "../zsw-input" }
|
||||
zsw-util = { path = "../zsw-util" }
|
||||
zsw-wgpu = { path = "../zsw-wgpu" }
|
||||
|
||||
# Windowing
|
||||
winit = "0.27.5"
|
||||
|
||||
# Rendering
|
||||
wgpu = {version = "0.14.0", features = ["serde", "replay"]}
|
||||
wgpu = { version = "0.14.0", features = ["serde", "replay"] }
|
||||
|
||||
# Async
|
||||
futures = "0.3.25"
|
||||
|
||||
# Serialization
|
||||
serde = {version = "1.0.147", features = ["derive"]}
|
||||
|
||||
# Math
|
||||
cgmath = {version = "0.18.0", features = ["serde"]}
|
||||
cgmath = { version = "0.18.0", features = ["serde"] }
|
||||
|
||||
# Image
|
||||
image = "0.24.5"
|
||||
@ -41,9 +38,9 @@ anyhow = "1.0.66"
|
||||
tracing = "0.1.37"
|
||||
|
||||
# Util
|
||||
bytemuck = {version = "1.12.3", features = ["derive"]}
|
||||
bytemuck = { version = "1.12.3", features = ["derive"] }
|
||||
num-rational = "0.4.1"
|
||||
|
||||
# Threads
|
||||
crossbeam = "0.8.2"
|
||||
parking_lot = {version = "0.12.1", features = ["deadlock_detection"]}
|
||||
parking_lot = { version = "0.12.1", features = ["deadlock_detection"] }
|
||||
|
||||
@ -5,7 +5,6 @@ use zsw_util::Rect;
|
||||
|
||||
/// A panel
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
pub struct Panel {
|
||||
/// Geometry
|
||||
pub geometry: Rect<i32, u32>,
|
||||
@ -18,15 +17,12 @@ pub struct Panel {
|
||||
|
||||
// TODO: make parallax optional with a struct wrapped in `Option`
|
||||
/// Parallax scale, 0.0 .. 1.0
|
||||
#[serde(default = "default_parallax_ratio")]
|
||||
pub parallax_ratio: f32,
|
||||
|
||||
/// Parallax exponentiation
|
||||
#[serde(default = "default_parallax_exp")]
|
||||
pub parallax_exp: f32,
|
||||
|
||||
/// Reverse parallax
|
||||
#[serde(default = "default_reverse_parallax")]
|
||||
pub reverse_parallax: bool,
|
||||
}
|
||||
|
||||
@ -38,21 +34,9 @@ impl Panel {
|
||||
geometry,
|
||||
duration,
|
||||
fade_point,
|
||||
parallax_ratio: self::default_parallax_ratio(),
|
||||
parallax_exp: self::default_parallax_exp(),
|
||||
reverse_parallax: self::default_reverse_parallax(),
|
||||
parallax_ratio: zsw_util::default_panel_parallax_ratio(),
|
||||
parallax_exp: zsw_util::default_panel_parallax_exp(),
|
||||
reverse_parallax: zsw_util::default_panel_parallax_reverse(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn default_parallax_ratio() -> f32 {
|
||||
1.0
|
||||
}
|
||||
|
||||
fn default_parallax_exp() -> f32 {
|
||||
2.0
|
||||
}
|
||||
|
||||
fn default_reverse_parallax() -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
@ -8,7 +8,6 @@ version = "0.1.0"
|
||||
[dependencies]
|
||||
|
||||
# Zsw
|
||||
zsw-panels = { path = "../zsw-panels" } # TODO: Also remove dependency on?
|
||||
zsw-util = { path = "../zsw-util" }
|
||||
|
||||
# Async
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
#![feature(entry_insert)]
|
||||
|
||||
// Modules
|
||||
mod profile;
|
||||
pub mod profile;
|
||||
|
||||
// Exports
|
||||
pub use profile::Profile;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
//! Profile
|
||||
|
||||
// Imports
|
||||
use {std::path::PathBuf, zsw_panels::Panel};
|
||||
use {std::path::PathBuf, zsw_util::Rect};
|
||||
|
||||
/// A profile
|
||||
#[derive(Clone, Debug)]
|
||||
@ -13,3 +13,48 @@ pub struct Profile {
|
||||
/// All panels
|
||||
pub panels: Vec<Panel>,
|
||||
}
|
||||
|
||||
/// Profile panel
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
pub struct Panel {
|
||||
/// Geometry
|
||||
pub geometry: Rect<i32, u32>,
|
||||
|
||||
/// Duration (in frames)
|
||||
pub duration: u64,
|
||||
|
||||
/// Fade point (in frames)
|
||||
pub fade_point: u64,
|
||||
|
||||
/// Parallax
|
||||
#[serde(default)]
|
||||
pub parallax: PanelParallax,
|
||||
}
|
||||
|
||||
/// Panel parallax
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
pub struct PanelParallax {
|
||||
/// Parallax scale, 0.0 .. 1.0
|
||||
#[serde(default = "zsw_util::default_panel_parallax_ratio")]
|
||||
pub ratio: f32,
|
||||
|
||||
/// Parallax exponentiation
|
||||
#[serde(default = "zsw_util::default_panel_parallax_exp")]
|
||||
pub exp: f32,
|
||||
|
||||
/// Reverse parallax
|
||||
#[serde(default = "zsw_util::default_panel_parallax_reverse")]
|
||||
pub reverse: bool,
|
||||
}
|
||||
|
||||
impl Default for PanelParallax {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
ratio: zsw_util::default_panel_parallax_ratio(),
|
||||
exp: zsw_util::default_panel_parallax_exp(),
|
||||
reverse: zsw_util::default_panel_parallax_reverse(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,3 +200,20 @@ pub fn visit_dir<P: AsRef<Path>>(path: &P, visitor: &mut impl FnMut(PathBuf)) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO: Move these elsewhere?
|
||||
#[must_use]
|
||||
pub fn default_panel_parallax_ratio() -> f32 {
|
||||
1.0
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn default_panel_parallax_exp() -> f32 {
|
||||
2.0
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn default_panel_parallax_reverse() -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
@ -1,7 +1,12 @@
|
||||
//! Profile applier
|
||||
|
||||
// Imports
|
||||
use {super::Services, std::path::PathBuf, zsw_profiles::Profile};
|
||||
use {
|
||||
super::Services,
|
||||
std::path::PathBuf,
|
||||
zsw_panels::Panel,
|
||||
zsw_profiles::{profile, Profile},
|
||||
};
|
||||
|
||||
/// Profile applier
|
||||
#[derive(Clone, Debug)]
|
||||
@ -12,6 +17,32 @@ impl ProfileApplier {
|
||||
pub fn new() -> Self {
|
||||
Self {}
|
||||
}
|
||||
|
||||
/// Converts a `profile::Panel` to a `Panel`
|
||||
fn create_panel(panel: &profile::Panel) -> Panel {
|
||||
Panel {
|
||||
geometry: panel.geometry,
|
||||
duration: panel.duration,
|
||||
fade_point: panel.fade_point,
|
||||
parallax_ratio: panel.parallax.ratio,
|
||||
parallax_exp: panel.parallax.exp,
|
||||
reverse_parallax: panel.parallax.reverse,
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts a `Panel` to `profile::Panel`
|
||||
fn dump_panel(panel: &Panel) -> profile::Panel {
|
||||
profile::Panel {
|
||||
geometry: panel.geometry,
|
||||
duration: panel.duration,
|
||||
fade_point: panel.fade_point,
|
||||
parallax: profile::PanelParallax {
|
||||
ratio: panel.parallax_ratio,
|
||||
exp: panel.parallax_exp,
|
||||
reverse: panel.reverse_parallax,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl zsw_settings_window::ProfileApplier<Services> for ProfileApplier {
|
||||
@ -26,7 +57,7 @@ impl zsw_settings_window::ProfileApplier<Services> for ProfileApplier {
|
||||
services.playlist_manager.set_root_path(profile.root_path.clone());
|
||||
services
|
||||
.panels
|
||||
.replace_panels(panels_resource, profile.panels.iter().copied());
|
||||
.replace_panels(panels_resource, profile.panels.iter().map(Self::create_panel));
|
||||
}
|
||||
|
||||
fn current(&self, services: &Services, panels_resource: &mut zsw_panels::PanelsResource) -> zsw_profiles::Profile {
|
||||
@ -43,7 +74,7 @@ impl zsw_settings_window::ProfileApplier<Services> for ProfileApplier {
|
||||
.panels
|
||||
.panels(panels_resource)
|
||||
.iter()
|
||||
.map(|panel| panel.panel)
|
||||
.map(|panel| Self::dump_panel(&panel.panel))
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user