@@ -4,17 +4,16 @@ use cosmic::iced::clipboard::dnd::{
44} ;
55use cosmic:: iced:: clipboard:: mime:: AsMimeTypes ;
66use cosmic:: iced:: id:: Internal ;
7- use cosmic:: iced:: { alignment , Vector } ;
7+ use cosmic:: iced:: Vector ;
88
99use cosmic:: iced_core;
1010use cosmic:: widget:: { button, column, container, icon, list_column, row, text, text_input, Column } ;
1111
1212use cosmic:: {
1313 cosmic_config:: { Config , CosmicConfigEntry } ,
1414 iced:: {
15- alignment:: { Horizontal , Vertical } ,
16- core:: window,
17- event, mouse, overlay, touch, Alignment , Color , Length , Point , Rectangle , Size ,
15+ core:: window, event, mouse, overlay, touch, Alignment , Color , Length , Point , Rectangle ,
16+ Size ,
1817 } ,
1918 iced_runtime:: { core:: id:: Id , Task } ,
2019 iced_widget:: core:: {
@@ -120,14 +119,13 @@ impl page::Page<crate::pages::Message> for Page {
120119 }
121120
122121 fn header_view ( & self ) -> Option < Element < ' _ , crate :: pages:: Message > > {
123- let theme = cosmic:: theme:: active ( ) ;
124- let spacing = theme. cosmic ( ) . spacing ;
122+ let space_xxs = theme:: active ( ) . cosmic ( ) . spacing . space_xxs ;
125123 let content = row:: with_capacity ( 2 )
126- . spacing ( spacing . space_xxs )
124+ . spacing ( space_xxs)
127125 . push ( button:: standard ( fl ! ( "add-applet" ) ) . on_press ( Message :: AddAppletDrawer ) )
128126 . apply ( container)
129127 . width ( Length :: Fill )
130- . align_x ( alignment :: Horizontal :: Right )
128+ . align_x ( Alignment :: End )
131129 . apply ( Element :: from)
132130 . map ( crate :: pages:: Message :: PanelApplet ) ;
133131
@@ -226,7 +224,13 @@ impl Page {
226224 & self ,
227225 msg_map : T ,
228226 ) -> Element < crate :: pages:: Message > {
229- let spacing = cosmic:: theme:: active ( ) . cosmic ( ) . spacing ;
227+ let cosmic:: cosmic_theme:: Spacing {
228+ space_xxxs,
229+ space_xxs,
230+ space_xs,
231+ space_l,
232+ ..
233+ } = theme:: active ( ) . cosmic ( ) . spacing ;
230234 let mut list_column = list_column ( ) ;
231235 let mut has_some = false ;
232236 for info in self
@@ -259,7 +263,7 @@ impl Page {
259263 column:: with_capacity( 2 )
260264 . push( text:: body( info. name. clone( ) ) )
261265 . push( text:: caption( info. description. clone( ) ) )
262- . spacing( spacing . space_xxxs)
266+ . spacing( space_xxxs)
263267 . width( Length :: Fill )
264268 . into( ) ,
265269 button:: standard( fl!( "add" ) )
@@ -291,16 +295,16 @@ impl Page {
291295 . on_press( msg_map( Message :: AddApplet ( info. clone( ) ) ) )
292296 . into( ) ,
293297 ] )
294- . padding ( [ 0 , spacing . space_l ] )
295- . spacing ( spacing . space_xs )
298+ . padding ( [ 0 , space_l] )
299+ . spacing ( space_xs)
296300 . align_y ( Alignment :: Center ) ,
297301 ) ;
298302 }
299303 if !has_some {
300304 list_column = list_column. add (
301305 text:: body ( fl ! ( "no-applets-found" ) )
302306 . width ( Length :: Fill )
303- . align_x ( Horizontal :: Center ) ,
307+ . align_x ( Alignment :: Center ) ,
304308 ) ;
305309 }
306310
@@ -313,7 +317,7 @@ impl Page {
313317 list_column. into( ) ,
314318 ] )
315319 . align_x ( Alignment :: Center )
316- . spacing ( spacing . space_xxs )
320+ . spacing ( space_xxs)
317321 . into ( )
318322 }
319323
@@ -456,7 +460,12 @@ pub fn lists<
456460 msg_map : T ,
457461) -> Section < crate :: pages:: Message > {
458462 Section :: default ( ) . view :: < P > ( move |_binder, page, _section| {
459- let spacing = cosmic:: theme:: active ( ) . cosmic ( ) . spacing ;
463+ let cosmic:: cosmic_theme:: Spacing {
464+ space_xxs,
465+ space_xs,
466+ space_s,
467+ ..
468+ } = theme:: active ( ) . cosmic ( ) . spacing ;
460469 let page = page. inner ( ) ;
461470 let Some ( config) = page. current_config . as_ref ( ) else {
462471 return Element :: from ( text:: body ( fl ! ( "unknown" ) ) ) ;
@@ -492,7 +501,7 @@ pub fn lists<
492501 )
493502 . into( ) ,
494503 ] )
495- . spacing( spacing . space_xxs)
504+ . spacing( space_xxs)
496505 . into( ) ,
497506 column:: with_children( vec![
498507 text:: body( fl!( "center-segment" ) ) . into( ) ,
@@ -522,7 +531,7 @@ pub fn lists<
522531 )
523532 . into( ) ,
524533 ] )
525- . spacing( spacing . space_xxs)
534+ . spacing( space_xxs)
526535 . into( ) ,
527536 column:: with_children( vec![
528537 text:: body( fl!( "end-segment" ) ) . into( ) ,
@@ -553,11 +562,11 @@ pub fn lists<
553562 )
554563 . into( ) ,
555564 ] )
556- . spacing( spacing . space_xxs)
565+ . spacing( space_xxs)
557566 . into( ) ,
558567 ] )
559- . padding ( [ 0 , spacing . space_s ] )
560- . spacing ( spacing . space_xs )
568+ . padding ( [ 0 , space_s] )
569+ . spacing ( space_xs)
561570 . apply ( Element :: from)
562571 . map ( msg_map)
563572 } )
@@ -651,7 +660,12 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
651660 on_cancel : Message ,
652661 active_dnd : Option < Applet < ' a > > ,
653662 ) -> Self {
654- let spacing = cosmic:: theme:: active ( ) . cosmic ( ) . spacing ;
663+ let cosmic:: cosmic_theme:: Spacing {
664+ space_xxxs,
665+ space_xxs,
666+ space_xs,
667+ ..
668+ } = theme:: active ( ) . cosmic ( ) . spacing ;
655669 let applet_buttons = info
656670 . clone ( )
657671 . into_iter ( )
@@ -666,7 +680,7 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
666680 . into( ) ,
667681 icon:: from_name( info. icon) . size( 32 ) . into( ) ,
668682 column:: with_capacity( 2 )
669- . spacing( spacing . space_xxxs)
683+ . spacing( space_xxxs)
670684 . width( Length :: Fill )
671685 . push( text:: body( info. name) )
672686 . push_maybe( if info. description. is_empty( ) {
@@ -680,7 +694,7 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
680694 . on_press( on_remove( id_clone. clone( ) ) )
681695 . into( ) ,
682696 ] )
683- . spacing ( spacing . space_xs )
697+ . spacing ( space_xs)
684698 . align_y ( Alignment :: Center ) ,
685699 )
686700 . width ( Length :: Fill )
@@ -711,8 +725,8 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
711725 text:: body ( fl ! ( "drop-here" ) )
712726 . width ( Length :: Fill )
713727 . height ( Length :: Fill )
714- . align_y ( Vertical :: Center )
715- . align_x ( Horizontal :: Center ) ,
728+ . align_y ( Alignment :: Center )
729+ . align_x ( Alignment :: Center ) ,
716730 )
717731 . width ( Length :: Fill )
718732 . height ( Length :: Fixed ( 48.0 ) )
@@ -728,7 +742,7 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
728742 . into ( )
729743 } else {
730744 Column :: with_children ( applet_buttons)
731- . spacing ( spacing . space_xxs )
745+ . spacing ( space_xxs)
732746 . into ( )
733747 } ,
734748 active_applet_offer : active_dnd,
@@ -746,7 +760,7 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
746760 pos : Point ,
747761 offered_applet : Applet < ' a > ,
748762 ) -> Vec < Applet < ' a > > {
749- let spacing = cosmic :: theme:: active ( ) . cosmic ( ) . spacing ;
763+ let space_xxs = theme:: active ( ) . cosmic ( ) . spacing . space_xxs ;
750764 let mut reordered: Vec < _ > = self . info . clone ( ) ;
751765
752766 if !layout. bounds ( ) . contains ( pos) {
@@ -767,8 +781,7 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
767781 return reordered;
768782 }
769783
770- let height = ( layout. bounds ( ) . height
771- - spacing. space_xxs as f32 * ( self . info . len ( ) - 1 ) as f32 )
784+ let height = ( layout. bounds ( ) . height - space_xxs as f32 * ( self . info . len ( ) - 1 ) as f32 )
772785 / self . info . len ( ) as f32 ;
773786
774787 let mut found = false ;
@@ -778,7 +791,7 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
778791 if i == 0 || i == reordered. len ( ) {
779792 y += height / 2.0 ;
780793 } else {
781- y += height + spacing . space_xxs as f32 ;
794+ y += height + space_xxs as f32 ;
782795 }
783796 if pos. y <= y {
784797 reordered. insert ( i, offered_applet. clone ( ) ) ;
@@ -926,7 +939,7 @@ where
926939 shell : & mut Shell < ' _ , Message > ,
927940 viewport : & Rectangle ,
928941 ) -> event:: Status {
929- let spacing = cosmic :: theme:: active ( ) . cosmic ( ) . spacing ;
942+ let space_xxs = theme:: active ( ) . cosmic ( ) . spacing . space_xxs ;
930943 let mut ret = match self . inner . as_widget_mut ( ) . on_event (
931944 & mut tree. children [ 0 ] ,
932945 event. clone ( ) ,
@@ -942,7 +955,7 @@ where
942955 } ;
943956
944957 let height = ( layout. bounds ( ) . height
945- - spacing . space_xxs as f32 * ( self . info . len ( ) . saturating_sub ( 1 ) ) as f32 )
958+ - space_xxs as f32 * ( self . info . len ( ) . saturating_sub ( 1 ) ) as f32 )
946959 / self . info . len ( ) as f32 ;
947960 let state = tree. state . downcast_mut :: < ReorderWidgetState > ( ) ;
948961
@@ -995,8 +1008,7 @@ where
9951008 self . info . iter ( ) . enumerate ( ) . find ( |( i, _) | {
9961009 start. y
9971010 < layout. bounds ( ) . y
998- + ( * i + 1 ) as f32
999- * ( height + spacing. space_xxs as f32 )
1011+ + ( * i + 1 ) as f32 * ( height + space_xxs as f32 )
10001012 } )
10011013 {
10021014 let applet = applet. clone ( ) . into_owned ( ) ;
0 commit comments