77
88use crate :: Id ;
99use crate :: draw:: DrawImpl ;
10- use std:: marker:: PhantomData ;
1110use std:: time:: { Duration , Instant } ;
1211
1312#[ derive( Debug ) ]
@@ -18,14 +17,13 @@ struct Config {
1817
1918/// State holding theme animation data
2019#[ derive( Debug ) ]
21- pub struct AnimState < D > {
20+ pub struct AnimState {
2221 c : Config ,
2322 now : Instant , // frame start time
2423 text_cursor : TextCursor ,
25- _d : PhantomData < D > ,
2624}
2725
28- impl < D > AnimState < D > {
26+ impl AnimState {
2927 pub fn new ( config : & crate :: config:: ThemeConfig ) -> Self {
3028 let c = Config {
3129 cursor_blink_rate : config. cursor_blink_rate ( ) ,
@@ -41,7 +39,6 @@ impl<D> AnimState<D> {
4139 state : false ,
4240 time : now,
4341 } ,
44- _d : PhantomData ,
4542 }
4643 }
4744
@@ -61,11 +58,14 @@ struct TextCursor {
6158 state : bool ,
6259 time : Instant ,
6360}
64- impl < D : DrawImpl > AnimState < D > {
61+ impl AnimState {
6562 /// Flashing text cursor: return true to draw
6663 ///
6764 /// Assumption: only one widget may draw a text cursor at any time.
68- pub fn text_cursor ( & mut self , draw : & mut D , id : & Id , byte : usize ) -> bool {
65+ pub fn text_cursor < D > ( & mut self , draw : & mut D , id : & Id , byte : usize ) -> bool
66+ where
67+ D : DrawImpl ,
68+ {
6969 let entry = & mut self . text_cursor ;
7070 let widget = id. to_nzu64 ( ) . get ( ) ;
7171 if entry. widget == widget && entry. byte == byte {
@@ -86,12 +86,15 @@ impl<D: DrawImpl> AnimState<D> {
8686 }
8787}
8888
89- impl < D : DrawImpl > AnimState < D > {
89+ impl AnimState {
9090 /// Fade over a boolean transition
9191 ///
9292 /// Normally returns `1.0` if `state` else `0.0`, but within a short time
9393 /// after a state change will linearly transition between these values.
94- pub fn fade_bool ( & mut self , draw : & mut D , state : bool , last_change : Option < Instant > ) -> f32 {
94+ pub fn fade_bool < D > ( & mut self , draw : & mut D , state : bool , last_change : Option < Instant > ) -> f32
95+ where
96+ D : DrawImpl ,
97+ {
9598 if let Some ( dur) = last_change. and_then ( |inst| self . elapsed ( inst) )
9699 && dur < self . c . fade_dur
97100 {
0 commit comments