@@ -9,8 +9,7 @@ use crate::{app, pages};
9
9
use apply:: Apply ;
10
10
use arrangement:: Arrangement ;
11
11
use cosmic:: iced:: Length ;
12
- use cosmic:: iced_core:: Alignment ;
13
- use cosmic:: iced_widget:: scrollable:: { Direction , Properties } ;
12
+ use cosmic:: iced_widget:: scrollable:: { Direction , Properties , RelativeOffset } ;
14
13
use cosmic:: prelude:: CollectionWidget ;
15
14
use cosmic:: widget:: {
16
15
column, container, dropdown, list_column, segmented_button, toggler, view_switcher,
@@ -116,14 +115,28 @@ enum Randr {
116
115
}
117
116
118
117
/// The page struct for the display settings page.
119
- #[ derive( Default ) ]
120
118
pub struct Page {
121
119
list : List ,
122
120
display_tabs : segmented_button:: SingleSelectModel ,
123
121
active_display : OutputKey ,
124
122
config : Config ,
125
123
cache : ViewCache ,
126
124
context : Option < ContextDrawer > ,
125
+ display_arrangement_scrollable : cosmic:: widget:: Id ,
126
+ }
127
+
128
+ impl Default for Page {
129
+ fn default ( ) -> Self {
130
+ Self {
131
+ list : List :: default ( ) ,
132
+ display_tabs : segmented_button:: SingleSelectModel :: default ( ) ,
133
+ active_display : OutputKey :: default ( ) ,
134
+ config : Config :: default ( ) ,
135
+ cache : ViewCache :: default ( ) ,
136
+ context : None ,
137
+ display_arrangement_scrollable : cosmic:: widget:: Id :: unique ( ) ,
138
+ }
139
+ }
127
140
}
128
141
129
142
#[ derive( Default ) ]
@@ -360,7 +373,10 @@ impl Page {
360
373
}
361
374
}
362
375
363
- Command :: none ( )
376
+ cosmic:: iced:: widget:: scrollable:: snap_to (
377
+ self . display_arrangement_scrollable . clone ( ) ,
378
+ RelativeOffset { x : 0.5 , y : 0.5 } ,
379
+ )
364
380
}
365
381
366
382
/// View for the display arrangement section.
@@ -379,6 +395,7 @@ impl Page {
379
395
. on_select ( |id| pages:: Message :: Displays ( Message :: Display ( id) ) )
380
396
. on_placement ( |id, x, y| pages:: Message :: Displays ( Message :: Position ( id, x, y) ) )
381
397
. apply ( cosmic:: widget:: scrollable)
398
+ . id ( self . display_arrangement_scrollable . clone ( ) )
382
399
. width ( Length :: Shrink )
383
400
. direction ( Direction :: Horizontal ( Properties :: new ( ) ) )
384
401
. apply ( container)
0 commit comments