1
0
Fork 0
forked from wry/wry

Add animation style toggle

This commit is contained in:
atagen 2026-05-27 22:52:06 +10:00
parent 02222d5189
commit e7f9a5cb09
15 changed files with 238 additions and 20 deletions

View file

@ -270,6 +270,7 @@ pub struct UiDrag {
pub struct Animations {
pub enabled: Option<bool>,
pub duration_ms: Option<u32>,
pub style: Option<String>,
pub curve: Option<AnimationCurveConfig>,
}
@ -678,3 +679,13 @@ fn custom_animation_curve_parses() {
Some(AnimationCurveConfig::CubicBezier([0.25, 0.1, 0.25, 1.0]))
);
}
#[test]
fn animation_style_parses() {
let input = b"
[animations]
style = \"plain\"
";
let config = parse_config(input, &Default::default(), |_| ()).unwrap();
assert_eq!(config.animations.style.as_deref(), Some("plain"));
}

View file

@ -3,7 +3,7 @@ use {
config::{
AnimationCurveConfig, Animations,
context::Context,
extractor::{Extractor, ExtractorError, bol, n32, opt, recover, val},
extractor::{Extractor, ExtractorError, bol, n32, opt, recover, str, val},
parser::{DataType, ParseResult, Parser, UnexpectedDataType},
},
toml::{
@ -44,9 +44,10 @@ impl Parser for AnimationsParser<'_> {
table: &IndexMap<Spanned<String>, Spanned<Value>>,
) -> ParseResult<Self> {
let mut ext = Extractor::new(self.0, span, table);
let (enabled, duration_ms, curve) = ext.extract((
let (enabled, duration_ms, style, curve) = ext.extract((
recover(opt(bol("enabled"))),
recover(opt(n32("duration-ms"))),
recover(opt(str("style"))),
opt(val("curve")),
))?;
let curve = match curve {
@ -56,6 +57,7 @@ impl Parser for AnimationsParser<'_> {
Ok(Animations {
enabled: enabled.despan(),
duration_ms: duration_ms.despan(),
style: style.despan().map(|style| style.to_string()),
curve,
})
}

View file

@ -23,7 +23,7 @@ use {
ahash::{AHashMap, AHashSet},
error_reporter::Report,
jay_config::{
AnimationCurve, Axis,
AnimationCurve, AnimationStyle, Axis,
client::Client,
config, config_dir,
exec::{Command, set_env, unset_env},
@ -38,8 +38,9 @@ use {
keyboard::Keymap,
logging::{clean_logs_older_than, set_log_level},
on_devices_enumerated, on_idle, on_unload, quit, reload, set_animation_cubic_bezier,
set_animation_curve, set_animation_duration_ms, set_animations_enabled, set_autotile,
set_color_management_enabled, set_corner_radius, set_default_workspace_capture,
set_animation_curve, set_animation_duration_ms, set_animation_style,
set_animations_enabled, set_autotile, set_color_management_enabled, set_corner_radius,
set_default_workspace_capture,
set_explicit_sync_enabled, set_float_above_fullscreen, set_floating_titles, set_idle,
set_idle_grace_period, set_middle_click_paste_enabled, set_show_bar,
set_show_float_pin_icon, set_show_titles, set_tab_title_align, set_ui_drag_enabled,
@ -1652,6 +1653,11 @@ fn load_config(initial_load: bool, auto_reload: bool, persistent: &Rc<Persistent
}
set_animations_enabled(config.animations.enabled.unwrap_or(false));
set_animation_duration_ms(config.animations.duration_ms.unwrap_or(160));
match config.animations.style.as_deref().unwrap_or("multiphase") {
"plain" => set_animation_style(AnimationStyle::PLAIN),
"multiphase" => set_animation_style(AnimationStyle::MULTIPHASE),
style_name => log::warn!("Unknown animation style: {style_name}"),
}
match config
.animations
.curve