@@ -47,11 +47,11 @@ pub struct Cursor {
4747 pub click_duration : f32 ,
4848 /// Visual cursor style: "default" (arrow) or "pointer" (hand).
4949 /// Currently both render as a bar; this is metadata for future SVG cursors.
50- #[ serde( default = "default_cursor_style" ) ]
51- pub cursor_style : String ,
50+ #[ serde( default ) ]
51+ pub cursor_style : CursorStyle ,
5252 /// Easing for movement between waypoints: "ease_in_out" (default), "linear", "ease_out".
53- #[ serde( default = "default_path_easing" ) ]
54- pub path_easing : String ,
53+ #[ serde( default ) ]
54+ pub path_easing : CursorPathEasing ,
5555 #[ serde( flatten) ]
5656 pub timing : TimingConfig ,
5757 #[ serde( default ) ]
@@ -86,12 +86,24 @@ fn default_click_duration() -> f32 {
8686 0.3
8787}
8888
89- fn default_cursor_style ( ) -> String {
90- "default" . to_string ( )
89+ /// Visual cursor style. Closed documented set; JSON values unchanged.
90+ #[ derive( Debug , Clone , Copy , PartialEq , Eq , Default , Serialize , Deserialize , JsonSchema ) ]
91+ #[ serde( rename_all = "snake_case" ) ]
92+ pub enum CursorStyle {
93+ #[ default]
94+ Default ,
95+ Pointer ,
9196}
9297
93- fn default_path_easing ( ) -> String {
94- "ease_in_out" . to_string ( )
98+ /// Easing of the cursor's waypoint path. Closed set, now matched
99+ /// exhaustively; previously-silent unknown values fail the typed parse.
100+ #[ derive( Debug , Clone , Copy , PartialEq , Eq , Default , Serialize , Deserialize , JsonSchema ) ]
101+ #[ serde( rename_all = "snake_case" ) ]
102+ pub enum CursorPathEasing {
103+ Linear ,
104+ EaseOut ,
105+ #[ default]
106+ EaseInOut ,
95107}
96108
97109rustmotion_core:: impl_traits!( Cursor {
@@ -161,11 +173,10 @@ impl Cursor {
161173 let raw_t = ( ( time - move_start) / move_duration) . clamp ( 0.0 , 1.0 ) ;
162174
163175 // Apply easing
164- let t = match self . path_easing . as_str ( ) {
165- "linear" => raw_t,
166- "ease_out" => 1.0 - ( 1.0 - raw_t) . powi ( 3 ) ,
167- _ => {
168- // ease_in_out
176+ let t = match self . path_easing {
177+ CursorPathEasing :: Linear => raw_t,
178+ CursorPathEasing :: EaseOut => 1.0 - ( 1.0 - raw_t) . powi ( 3 ) ,
179+ CursorPathEasing :: EaseInOut => {
169180 if raw_t < 0.5 {
170181 4.0 * raw_t * raw_t * raw_t
171182 } else {
0 commit comments