@@ -3,7 +3,7 @@ use iced::keyboard;
33use iced:: mouse;
44use iced:: widget:: {
55 button, canvas, center, center_y, checkbox, column, container, pick_list,
6- pin, row, rule, scrollable, space, stack, text,
6+ pin, responsive , row, rule, scrollable, space, stack, text,
77} ;
88use iced:: {
99 Center , Element , Fill , Font , Length , Point , Rectangle , Renderer , Shrink ,
@@ -153,6 +153,10 @@ impl Example {
153153 title : "Pinning" ,
154154 view : pinning,
155155 } ,
156+ Self {
157+ title : "Responsive" ,
158+ view : responsive_,
159+ } ,
156160 ] ;
157161
158162 fn is_first ( self ) -> bool {
@@ -333,6 +337,42 @@ fn pinning<'a>() -> Element<'a, Message> {
333337 . into ( )
334338}
335339
340+ fn responsive_ < ' a > ( ) -> Element < ' a , Message > {
341+ column ! [
342+ responsive( |size| {
343+ container( center(
344+ text!( "{}x{}px" , size. width, size. width) . font( Font :: MONOSPACE ) ,
345+ ) )
346+ . clip( true )
347+ . width( size. width / 4.0 )
348+ . height( size. width / 4.0 )
349+ . style( container:: bordered_box)
350+ . into( )
351+ } )
352+ . width( Shrink )
353+ . height( Shrink ) ,
354+ responsive( |size| {
355+ let size = size. ratio( 16.0 / 9.0 ) ;
356+
357+ container( center(
358+ text!( "{:.0}x{:.0}px (16:9)" , size. width, size. height)
359+ . font( Font :: MONOSPACE ) ,
360+ ) )
361+ . clip( true )
362+ . width( size. width)
363+ . height( size. height)
364+ . style( container:: bordered_box)
365+ . into( )
366+ } )
367+ . width( Shrink )
368+ . height( Shrink )
369+ ]
370+ . align_x ( Center )
371+ . spacing ( 10 )
372+ . padding ( 10 )
373+ . into ( )
374+ }
375+
336376fn square < ' a > ( size : impl Into < Length > + Copy ) -> Element < ' a , Message > {
337377 struct Square ;
338378
0 commit comments