@@ -81,15 +81,19 @@ fn render_showcase<D: DrawTarget<Color = Rgb565> + embedded_gui::PixelRead>(
8181 // Left Column: Spinbox (Top) + Linear Scale (Bottom)
8282 let left_area = cells[ 1 ] ;
8383 let spinbox_rect = Rect :: new ( left_area. x , left_area. y , left_area. w , 40 ) ;
84- spinbox. render (
84+
85+ let mut anim_spinbox = * spinbox;
86+ anim_spinbox. focused_digit = ( ( frame / 20 ) % 4 ) as u8 ;
87+ anim_spinbox. value = 2400 + ( ( frame as i32 * 7 ) % 600 ) ;
88+ anim_spinbox. render (
8589 & mut ctx,
8690 spinbox_rect,
8791 Style :: panel ( ) . into ( ) ,
8892 embedded_gui:: VisualState :: Normal ,
8993 ) ?;
9094
9195 let lin_scale_rect = Rect :: new ( left_area. x , left_area. y + 46 , left_area. w , 54 ) ;
92- let needle_val = 20 .0 + ( ( frame as f32 * 0.5 ) . sin ( ) * 20.0 ) ;
96+ let needle_val = 25 .0 + ( ( frame as f32 * 0.08 ) . sin ( ) * 20.0 ) ;
9397 let lin_scale = ScaleWidget :: linear_horizontal ( 0.0 , 50.0 , needle_val)
9498 . with_ticks ( 4 , 2 )
9599 . with_needle ( true , Rgb565 :: CSS_CYAN ) ;
@@ -103,15 +107,20 @@ fn render_showcase<D: DrawTarget<Color = Rgb565> + embedded_gui::PixelRead>(
103107 // Right Column: Table (Top) + Radial Speedometer (Bottom)
104108 let right_area = cells[ 2 ] ;
105109 let table_rect = Rect :: new ( right_area. x , right_area. y , right_area. w , 60 ) ;
106- table. render (
110+
111+ let mut anim_table = * table;
112+ let sel_row = ( ( frame / 25 ) % 2 ) as usize ;
113+ let sel_col = ( ( frame / 15 ) % 3 ) as usize ;
114+ anim_table. selected = Some ( ( sel_row, sel_col) ) ;
115+ anim_table. render (
107116 & mut ctx,
108117 table_rect,
109118 Style :: panel ( ) . into ( ) ,
110119 embedded_gui:: VisualState :: Normal ,
111120 ) ?;
112121
113122 let radial_rect = Rect :: new ( right_area. x + 30 , right_area. y + 64 , 90 , 44 ) ;
114- let speed_val = 60.0 + ( ( frame as f32 * 0.1 ) . sin ( ) * 40 .0) ;
123+ let speed_val = 60.0 + ( ( frame as f32 * 0.06 ) . sin ( ) * 45 .0) ;
115124 let radial_scale = ScaleWidget :: new ( 0.0 , 120.0 , speed_val)
116125 . with_ticks ( 6 , 2 )
117126 . with_angles ( 180 , 0 )
@@ -164,7 +173,53 @@ fn render_showcase<D: DrawTarget<Color = Rgb565> + embedded_gui::PixelRead>(
164173 Ok ( ( ) )
165174}
166175
176+ fn record_frames ( ) {
177+ let out_dir = std:: path:: Path :: new ( "target/controls_frames" ) ;
178+ let _ = std:: fs:: create_dir_all ( out_dir) ;
179+
180+ let mut fb = Framebuffer :: < FB_SIZE > :: new ( W , H ) ;
181+ let data: & [ & [ & str ] ] = & [
182+ & [ "Sensor 1" , "24.5 C" , "OK" ] ,
183+ & [ "Sensor 2" , "58.2 %" , "HIGH" ] ,
184+ ] ;
185+ let headers: & [ & str ] = & [ "Device" , "Value" , "State" ] ;
186+ let table = TableWidget :: new ( data) . with_headers ( headers) ;
187+ let spinbox = SpinboxWidget :: new ( 0 , 9999 , 2500 )
188+ . with_digits ( 4 )
189+ . with_decimals ( 2 ) ;
190+
191+ let total_frames = 90 ;
192+ println ! (
193+ "Recording {} frames to target/controls_frames..." ,
194+ total_frames
195+ ) ;
196+
197+ for f in 0 ..total_frames {
198+ render_showcase ( & mut fb, f, & table, & spinbox) . unwrap ( ) ;
199+
200+ let mut rgb888 = Vec :: with_capacity ( ( W * H * 3 ) as usize ) ;
201+ for p in fb. pixels ( ) {
202+ let r = ( p. r ( ) << 3 ) | ( p. r ( ) >> 2 ) ;
203+ let g = ( p. g ( ) << 2 ) | ( p. g ( ) >> 4 ) ;
204+ let b = ( p. b ( ) << 3 ) | ( p. b ( ) >> 2 ) ;
205+ rgb888. push ( r) ;
206+ rgb888. push ( g) ;
207+ rgb888. push ( b) ;
208+ }
209+
210+ let filename = out_dir. join ( format ! ( "frame_{:03}.raw" , f) ) ;
211+ std:: fs:: write ( filename, & rgb888) . unwrap ( ) ;
212+ }
213+ println ! ( "Frame recording complete!" ) ;
214+ }
215+
167216fn main ( ) {
217+ let args: Vec < String > = std:: env:: args ( ) . collect ( ) ;
218+ if args. iter ( ) . any ( |a| a == "--record-gif" ) {
219+ record_frames ( ) ;
220+ return ;
221+ }
222+
168223 println ! ( "=== embedded-gui: Rich Controls & Grid Layout Showcase ===" ) ;
169224
170225 let res = std:: panic:: catch_unwind ( || {
0 commit comments