chore(wallpaper): use new FlexRow widget from libcosmic
This commit is contained in:
parent
66d54b487f
commit
fd67781eaf
1 changed files with 16 additions and 20 deletions
|
|
@ -2,8 +2,7 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
use super::Message;
|
use super::Message;
|
||||||
use cosmic::iced_core::{self, gradient::Linear, Background, BorderRadius, Color, Degrees};
|
use cosmic::iced_core::{self, gradient::Linear, Background, BorderRadius, Color, Degrees, Length};
|
||||||
use cosmic::iced_core::{alignment, Length};
|
|
||||||
use cosmic::iced_runtime::core::image::Handle as ImageHandle;
|
use cosmic::iced_runtime::core::image::Handle as ImageHandle;
|
||||||
use cosmic::prelude::*;
|
use cosmic::prelude::*;
|
||||||
use cosmic::widget::{button, container, image, space};
|
use cosmic::widget::{button, container, image, space};
|
||||||
|
|
@ -12,8 +11,6 @@ use cosmic_settings_desktop::wallpaper;
|
||||||
use slotmap::DefaultKey;
|
use slotmap::DefaultKey;
|
||||||
|
|
||||||
const COLOR_WIDTH: u16 = 70;
|
const COLOR_WIDTH: u16 = 70;
|
||||||
const WALLPAPER_WIDTH: u16 = 158;
|
|
||||||
|
|
||||||
const COLUMN_SPACING: u16 = 12;
|
const COLUMN_SPACING: u16 = 12;
|
||||||
const ROW_SPACING: u16 = 16;
|
const ROW_SPACING: u16 = 16;
|
||||||
|
|
||||||
|
|
@ -68,34 +65,33 @@ pub fn color_image(
|
||||||
|
|
||||||
/// Color selection list
|
/// Color selection list
|
||||||
pub fn color_select_options() -> Element<'static, Message> {
|
pub fn color_select_options() -> Element<'static, Message> {
|
||||||
flex_select_row(|vec, _size| {
|
let mut vec = Vec::with_capacity(wallpaper::DEFAULT_COLORS.len());
|
||||||
for color in wallpaper::DEFAULT_COLORS {
|
|
||||||
vec.push(color_button(color.clone()));
|
|
||||||
}
|
|
||||||
|
|
||||||
COLOR_WIDTH
|
for color in wallpaper::DEFAULT_COLORS {
|
||||||
})
|
vec.push(color_button(color.clone()));
|
||||||
|
}
|
||||||
|
|
||||||
|
flex_select_row(vec)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Background selection list
|
/// Background selection list
|
||||||
pub fn wallpaper_select_options(page: &super::Page) -> Element<Message> {
|
pub fn wallpaper_select_options(page: &super::Page) -> Element<Message> {
|
||||||
flex_select_row(move |vec, _size| {
|
let mut vec = Vec::with_capacity(page.selection.selection_handles.len());
|
||||||
for (id, handle) in &page.selection.selection_handles {
|
|
||||||
vec.push(wallpaper_button(handle, id));
|
|
||||||
}
|
|
||||||
|
|
||||||
WALLPAPER_WIDTH
|
for (id, handle) in &page.selection.selection_handles {
|
||||||
})
|
vec.push(wallpaper_button(handle, id));
|
||||||
|
}
|
||||||
|
|
||||||
|
flex_select_row(vec)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flex_select_row<'a>(
|
fn flex_select_row(elements: Vec<Element<Message>>) -> Element<Message> {
|
||||||
elements: impl Fn(&mut Vec<Element<'a, Message>>, iced_core::Size) -> u16 + 'a,
|
|
||||||
) -> Element<'a, Message> {
|
|
||||||
cosmic::widget::flex_row(elements)
|
cosmic::widget::flex_row(elements)
|
||||||
.column_spacing(COLUMN_SPACING)
|
.column_spacing(COLUMN_SPACING)
|
||||||
.row_spacing(ROW_SPACING)
|
.row_spacing(ROW_SPACING)
|
||||||
|
.apply(container)
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
.align_x(alignment::Horizontal::Center)
|
.center_x()
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue