fix(display): snap display arrangement scrollable to center
This commit is contained in:
parent
219cb36d3c
commit
5bd6ca77c9
1 changed files with 21 additions and 4 deletions
|
|
@ -9,8 +9,7 @@ use crate::{app, pages};
|
||||||
use apply::Apply;
|
use apply::Apply;
|
||||||
use arrangement::Arrangement;
|
use arrangement::Arrangement;
|
||||||
use cosmic::iced::Length;
|
use cosmic::iced::Length;
|
||||||
use cosmic::iced_core::Alignment;
|
use cosmic::iced_widget::scrollable::{Direction, Properties, RelativeOffset};
|
||||||
use cosmic::iced_widget::scrollable::{Direction, Properties};
|
|
||||||
use cosmic::prelude::CollectionWidget;
|
use cosmic::prelude::CollectionWidget;
|
||||||
use cosmic::widget::{
|
use cosmic::widget::{
|
||||||
column, container, dropdown, list_column, segmented_button, toggler, view_switcher,
|
column, container, dropdown, list_column, segmented_button, toggler, view_switcher,
|
||||||
|
|
@ -116,7 +115,6 @@ enum Randr {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The page struct for the display settings page.
|
/// The page struct for the display settings page.
|
||||||
#[derive(Default)]
|
|
||||||
pub struct Page {
|
pub struct Page {
|
||||||
list: List,
|
list: List,
|
||||||
display_tabs: segmented_button::SingleSelectModel,
|
display_tabs: segmented_button::SingleSelectModel,
|
||||||
|
|
@ -124,6 +122,21 @@ pub struct Page {
|
||||||
config: Config,
|
config: Config,
|
||||||
cache: ViewCache,
|
cache: ViewCache,
|
||||||
context: Option<ContextDrawer>,
|
context: Option<ContextDrawer>,
|
||||||
|
display_arrangement_scrollable: cosmic::widget::Id,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Page {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
list: List::default(),
|
||||||
|
display_tabs: segmented_button::SingleSelectModel::default(),
|
||||||
|
active_display: OutputKey::default(),
|
||||||
|
config: Config::default(),
|
||||||
|
cache: ViewCache::default(),
|
||||||
|
context: None,
|
||||||
|
display_arrangement_scrollable: cosmic::widget::Id::unique(),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
@ -360,7 +373,10 @@ impl Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Command::none()
|
cosmic::iced::widget::scrollable::snap_to(
|
||||||
|
self.display_arrangement_scrollable.clone(),
|
||||||
|
RelativeOffset { x: 0.5, y: 0.5 },
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// View for the display arrangement section.
|
/// View for the display arrangement section.
|
||||||
|
|
@ -379,6 +395,7 @@ impl Page {
|
||||||
.on_select(|id| pages::Message::Displays(Message::Display(id)))
|
.on_select(|id| pages::Message::Displays(Message::Display(id)))
|
||||||
.on_placement(|id, x, y| pages::Message::Displays(Message::Position(id, x, y)))
|
.on_placement(|id, x, y| pages::Message::Displays(Message::Position(id, x, y)))
|
||||||
.apply(cosmic::widget::scrollable)
|
.apply(cosmic::widget::scrollable)
|
||||||
|
.id(self.display_arrangement_scrollable.clone())
|
||||||
.width(Length::Shrink)
|
.width(Length::Shrink)
|
||||||
.direction(Direction::Horizontal(Properties::new()))
|
.direction(Direction::Horizontal(Properties::new()))
|
||||||
.apply(container)
|
.apply(container)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue