forge
Explore
Log in

Don't you dare go Hollow

config: Clean up animations struct names

Browse files at this commit

e5188da1f8e9d0656d8078cc0dc06aa5e41fb4c0Ivan MolodetskikhParent: 8269777
niri-config/src/animations.rsmodified+24 -24
@@ -54,11 +54,11 @@ impl Default for Animations {
54 #[derive(Debug, Clone, Copy, PartialEq)]54 #[derive(Debug, Clone, Copy, PartialEq)]
55 pub struct Animation {55 pub struct Animation {
56 pub off: bool,56 pub off: bool,
57- pub kind: AnimationKind,57+ pub kind: Kind,
58 }58 }
59 59
60 #[derive(Debug, Clone, Copy, PartialEq)]60 #[derive(Debug, Clone, Copy, PartialEq)]
61-pub enum AnimationKind {61+pub enum Kind {
62 Easing(EasingParams),62 Easing(EasingParams),
63 Spring(SpringParams),63 Spring(SpringParams),
64 }64 }
@@ -66,11 +66,11 @@ pub enum AnimationKind {
66 #[derive(Debug, Clone, Copy, PartialEq)]66 #[derive(Debug, Clone, Copy, PartialEq)]
67 pub struct EasingParams {67 pub struct EasingParams {
68 pub duration_ms: u32,68 pub duration_ms: u32,
69- pub curve: AnimationCurve,69+ pub curve: Curve,
70 }70 }
71 71
72 #[derive(knuffel::DecodeScalar, Debug, Clone, Copy, PartialEq)]72 #[derive(knuffel::DecodeScalar, Debug, Clone, Copy, PartialEq)]
73-pub enum AnimationCurve {73+pub enum Curve {
74 Linear,74 Linear,
75 EaseOutQuad,75 EaseOutQuad,
76 EaseOutCubic,76 EaseOutCubic,
@@ -91,7 +91,7 @@ impl Default for WorkspaceSwitchAnim {
91 fn default() -> Self {91 fn default() -> Self {
92 Self(Animation {92 Self(Animation {
93 off: false,93 off: false,
94- kind: AnimationKind::Spring(SpringParams {94+ kind: Kind::Spring(SpringParams {
95 damping_ratio: 1.,95 damping_ratio: 1.,
96 stiffness: 1000,96 stiffness: 1000,
97 epsilon: 0.0001,97 epsilon: 0.0001,
@@ -111,9 +111,9 @@ impl Default for WindowOpenAnim {
111 Self {111 Self {
112 anim: Animation {112 anim: Animation {
113 off: false,113 off: false,
114- kind: AnimationKind::Easing(EasingParams {114+ kind: Kind::Easing(EasingParams {
115 duration_ms: 150,115 duration_ms: 150,
116- curve: AnimationCurve::EaseOutExpo,116+ curve: Curve::EaseOutExpo,
117 }),117 }),
118 },118 },
119 custom_shader: None,119 custom_shader: None,
@@ -132,9 +132,9 @@ impl Default for WindowCloseAnim {
132 Self {132 Self {
133 anim: Animation {133 anim: Animation {
134 off: false,134 off: false,
135- kind: AnimationKind::Easing(EasingParams {135+ kind: Kind::Easing(EasingParams {
136 duration_ms: 150,136 duration_ms: 150,
137- curve: AnimationCurve::EaseOutQuad,137+ curve: Curve::EaseOutQuad,
138 }),138 }),
139 },139 },
140 custom_shader: None,140 custom_shader: None,
@@ -149,7 +149,7 @@ impl Default for HorizontalViewMovementAnim {
149 fn default() -> Self {149 fn default() -> Self {
150 Self(Animation {150 Self(Animation {
151 off: false,151 off: false,
152- kind: AnimationKind::Spring(SpringParams {152+ kind: Kind::Spring(SpringParams {
153 damping_ratio: 1.,153 damping_ratio: 1.,
154 stiffness: 800,154 stiffness: 800,
155 epsilon: 0.0001,155 epsilon: 0.0001,
@@ -165,7 +165,7 @@ impl Default for WindowMovementAnim {
165 fn default() -> Self {165 fn default() -> Self {
166 Self(Animation {166 Self(Animation {
167 off: false,167 off: false,
168- kind: AnimationKind::Spring(SpringParams {168+ kind: Kind::Spring(SpringParams {
169 damping_ratio: 1.,169 damping_ratio: 1.,
170 stiffness: 800,170 stiffness: 800,
171 epsilon: 0.0001,171 epsilon: 0.0001,
@@ -185,7 +185,7 @@ impl Default for WindowResizeAnim {
185 Self {185 Self {
186 anim: Animation {186 anim: Animation {
187 off: false,187 off: false,
188- kind: AnimationKind::Spring(SpringParams {188+ kind: Kind::Spring(SpringParams {
189 damping_ratio: 1.,189 damping_ratio: 1.,
190 stiffness: 800,190 stiffness: 800,
191 epsilon: 0.0001,191 epsilon: 0.0001,
@@ -203,7 +203,7 @@ impl Default for ConfigNotificationOpenCloseAnim {
203 fn default() -> Self {203 fn default() -> Self {
204 Self(Animation {204 Self(Animation {
205 off: false,205 off: false,
206- kind: AnimationKind::Spring(SpringParams {206+ kind: Kind::Spring(SpringParams {
207 damping_ratio: 0.6,207 damping_ratio: 0.6,
208 stiffness: 1000,208 stiffness: 1000,
209 epsilon: 0.001,209 epsilon: 0.001,
@@ -219,7 +219,7 @@ impl Default for ExitConfirmationOpenCloseAnim {
219 fn default() -> Self {219 fn default() -> Self {
220 Self(Animation {220 Self(Animation {
221 off: false,221 off: false,
222- kind: AnimationKind::Spring(SpringParams {222+ kind: Kind::Spring(SpringParams {
223 damping_ratio: 0.6,223 damping_ratio: 0.6,
224 stiffness: 500,224 stiffness: 500,
225 epsilon: 0.01,225 epsilon: 0.01,
@@ -235,9 +235,9 @@ impl Default for ScreenshotUiOpenAnim {
235 fn default() -> Self {235 fn default() -> Self {
236 Self(Animation {236 Self(Animation {
237 off: false,237 off: false,
238- kind: AnimationKind::Easing(EasingParams {238+ kind: Kind::Easing(EasingParams {
239 duration_ms: 200,239 duration_ms: 200,
240- curve: AnimationCurve::EaseOutQuad,240+ curve: Curve::EaseOutQuad,
241 }),241 }),
242 })242 })
243 }243 }
@@ -250,7 +250,7 @@ impl Default for OverviewOpenCloseAnim {
250 fn default() -> Self {250 fn default() -> Self {
251 Self(Animation {251 Self(Animation {
252 off: false,252 off: false,
253- kind: AnimationKind::Spring(SpringParams {253+ kind: Kind::Spring(SpringParams {
254 damping_ratio: 1.,254 damping_ratio: 1.,
255 stiffness: 800,255 stiffness: 800,
256 epsilon: 0.0001,256 epsilon: 0.0001,
@@ -446,9 +446,9 @@ impl Animation {
446 pub fn new_off() -> Self {446 pub fn new_off() -> Self {
447 Self {447 Self {
448 off: true,448 off: true,
449- kind: AnimationKind::Easing(EasingParams {449+ kind: Kind::Easing(EasingParams {
450 duration_ms: 0,450 duration_ms: 0,
451- curve: AnimationCurve::Linear,451+ curve: Curve::Linear,
452 }),452 }),
453 }453 }
454 }454 }
@@ -465,7 +465,7 @@ impl Animation {
465 #[derive(Default, PartialEq)]465 #[derive(Default, PartialEq)]
466 struct OptionalEasingParams {466 struct OptionalEasingParams {
467 duration_ms: Option<u32>,467 duration_ms: Option<u32>,
468- curve: Option<AnimationCurve>,468+ curve: Option<Curve>,
469 }469 }
470 470
471 expect_only_children(node, ctx);471 expect_only_children(node, ctx);
@@ -556,24 +556,24 @@ impl Animation {
556 556
557 let kind = if let Some(spring_params) = spring_params {557 let kind = if let Some(spring_params) = spring_params {
558 // Configured spring.558 // Configured spring.
559- AnimationKind::Spring(spring_params)559+ Kind::Spring(spring_params)
560 } else if easing_params == OptionalEasingParams::default() {560 } else if easing_params == OptionalEasingParams::default() {
561 // Did not configure anything.561 // Did not configure anything.
562 default.kind562 default.kind
563 } else {563 } else {
564 // Configured easing.564 // Configured easing.
565- let default = if let AnimationKind::Easing(easing) = default.kind {565+ let default = if let Kind::Easing(easing) = default.kind {
566 easing566 easing
567 } else {567 } else {
568 // Generic fallback values for when the default animation is spring, but the user568 // Generic fallback values for when the default animation is spring, but the user
569 // configured an easing animation.569 // configured an easing animation.
570 EasingParams {570 EasingParams {
571 duration_ms: 250,571 duration_ms: 250,
572- curve: AnimationCurve::EaseOutCubic,572+ curve: Curve::EaseOutCubic,
573 }573 }
574 };574 };
575 575
576- AnimationKind::Easing(EasingParams {576+ Kind::Easing(EasingParams {
577 duration_ms: easing_params.duration_ms.unwrap_or(default.duration_ms),577 duration_ms: easing_params.duration_ms.unwrap_or(default.duration_ms),
578 curve: easing_params.curve.unwrap_or(default.curve),578 curve: easing_params.curve.unwrap_or(default.curve),
579 })579 })
niri-config/src/lib.rsmodified+1 -3
@@ -22,9 +22,7 @@ pub mod utils;
22 pub mod window_rule;22 pub mod window_rule;
23 pub mod workspace;23 pub mod workspace;
24 24
25-pub use crate::animations::{25+pub use crate::animations::{Animation, Animations};
26- Animation, AnimationCurve, AnimationKind, Animations, EasingParams, SpringParams,
27-};
28 pub use crate::appearance::*;26 pub use crate::appearance::*;
29 pub use crate::binds::*;27 pub use crate::binds::*;
30 pub use crate::debug::DebugConfig;28 pub use crate::debug::DebugConfig;
src/animation/mod.rsmodified+8 -8
@@ -77,7 +77,7 @@ impl Animation {
77 let start_time = self.start_time;77 let start_time = self.start_time;
78 78
79 match config.kind {79 match config.kind {
80- niri_config::AnimationKind::Spring(p) => {80+ niri_config::animations::Kind::Spring(p) => {
81 let params = SpringParams::new(p.damping_ratio, f64::from(p.stiffness), p.epsilon);81 let params = SpringParams::new(p.damping_ratio, f64::from(p.stiffness), p.epsilon);
82 82
83 let spring = Spring {83 let spring = Spring {
@@ -88,7 +88,7 @@ impl Animation {
88 };88 };
89 *self = Self::spring(self.clock.clone(), spring);89 *self = Self::spring(self.clock.clone(), spring);
90 }90 }
91- niri_config::AnimationKind::Easing(p) => {91+ niri_config::animations::Kind::Easing(p) => {
92 *self = Self::ease(92 *self = Self::ease(
93 self.clock.clone(),93 self.clock.clone(),
94 self.from,94 self.from,
@@ -346,13 +346,13 @@ impl Curve {
346 }346 }
347 }347 }
348 348
349-impl From<niri_config::AnimationCurve> for Curve {349+impl From<niri_config::animations::Curve> for Curve {
350- fn from(value: niri_config::AnimationCurve) -> Self {350+ fn from(value: niri_config::animations::Curve) -> Self {
351 match value {351 match value {
352- niri_config::AnimationCurve::Linear => Curve::Linear,352+ niri_config::animations::Curve::Linear => Curve::Linear,
353- niri_config::AnimationCurve::EaseOutQuad => Curve::EaseOutQuad,353+ niri_config::animations::Curve::EaseOutQuad => Curve::EaseOutQuad,
354- niri_config::AnimationCurve::EaseOutCubic => Curve::EaseOutCubic,354+ niri_config::animations::Curve::EaseOutCubic => Curve::EaseOutCubic,
355- niri_config::AnimationCurve::EaseOutExpo => Curve::EaseOutExpo,355+ niri_config::animations::Curve::EaseOutExpo => Curve::EaseOutExpo,
356 }356 }
357 }357 }
358 }358 }
src/layout/tests/animations.rsmodified+3 -3
@@ -1,7 +1,7 @@
1 use std::fmt::Write as _;1 use std::fmt::Write as _;
2 2
3 use insta::assert_snapshot;3 use insta::assert_snapshot;
4-use niri_config::{AnimationCurve, AnimationKind, EasingParams};4+use niri_config::animations::{Curve, EasingParams, Kind};
5 5
6 use super::*;6 use super::*;
7 7
@@ -23,9 +23,9 @@ fn format_tiles(layout: &Layout<TestWindow>) -> String {
23 }23 }
24 24
25 fn make_options() -> Options {25 fn make_options() -> Options {
26- const LINEAR: AnimationKind = AnimationKind::Easing(EasingParams {26+ const LINEAR: Kind = Kind::Easing(EasingParams {
27 duration_ms: 1000,27 duration_ms: 1000,
28- curve: AnimationCurve::Linear,28+ curve: Curve::Linear,
29 });29 });
30 30
31 let mut options = Options {31 let mut options = Options {
src/tests/animations.rsmodified+4 -3
@@ -2,7 +2,8 @@ use std::fmt::Write as _;
2 use std::time::Duration;2 use std::time::Duration;
3 3
4 use insta::assert_snapshot;4 use insta::assert_snapshot;
5-use niri_config::{AnimationCurve, AnimationKind, Config, EasingParams, FloatOrInt};5+use niri_config::animations::{Curve, EasingParams, Kind};
6+use niri_config::{Config, FloatOrInt};
6 use niri_ipc::SizeChange;7 use niri_ipc::SizeChange;
7 use smithay::utils::{Point, Size};8 use smithay::utils::{Point, Size};
8 use wayland_client::protocol::wl_surface::WlSurface;9 use wayland_client::protocol::wl_surface::WlSurface;
@@ -73,9 +74,9 @@ fn set_time(niri: &mut Niri, time: Duration) {
73 74
74 // Sets up a fixture with linear animations, a renderer, and an output.75 // Sets up a fixture with linear animations, a renderer, and an output.
75 fn set_up() -> Fixture {76 fn set_up() -> Fixture {
76- const LINEAR: AnimationKind = AnimationKind::Easing(EasingParams {77+ const LINEAR: Kind = Kind::Easing(EasingParams {
77 duration_ms: 1000,78 duration_ms: 1000,
78- curve: AnimationCurve::Linear,79+ curve: Curve::Linear,
79 });80 });
80 81
81 let mut config = Config::default();82 let mut config = Config::default();