libcosmic updates

This commit is contained in:
Ashley Wulber 2024-10-16 20:36:46 -04:00 committed by Ashley Wulber
parent 9c62f19e4b
commit 0491c4baaa
91 changed files with 3550 additions and 2300 deletions

View file

@ -55,7 +55,10 @@ pub fn from_raster_bytes(
) -> Handle {
Handle {
symbolic: false,
data: Data::Image(image::Handle::from_memory(bytes)),
data: match bytes.into() {
Cow::Owned(b) => Data::Image(image::Handle::from_bytes(b)),
Cow::Borrowed(b) => Data::Image(image::Handle::from_bytes(b)),
},
}
}
@ -66,12 +69,14 @@ pub fn from_raster_pixels(
pixels: impl Into<Cow<'static, [u8]>>
+ std::convert::AsRef<[u8]>
+ std::marker::Send
+ std::marker::Sync
+ 'static,
+ std::marker::Sync,
) -> Handle {
Handle {
symbolic: false,
data: Data::Image(image::Handle::from_pixels(width, height, pixels)),
data: match pixels.into() {
Cow::Owned(pixels) => Data::Image(image::Handle::from_bytes(pixels)),
Cow::Borrowed(pixels) => Data::Image(image::Handle::from_bytes(pixels)),
},
}
}

View file

@ -24,7 +24,7 @@ pub fn icon(handle: Handle) -> Icon {
handle,
height: None,
size: 16,
style: crate::theme::Svg::default(),
class: crate::theme::Svg::default(),
width: None,
}
}
@ -40,7 +40,7 @@ pub fn from_name(name: impl Into<Arc<str>>) -> Named {
pub struct Icon {
#[setters(skip)]
handle: Handle,
style: crate::theme::Svg,
class: crate::theme::Svg,
pub(super) size: u16,
content_fit: ContentFit,
#[setters(strip_option)]
@ -86,7 +86,7 @@ impl Icon {
let from_svg = |handle| {
Svg::<crate::Theme>::new(handle)
.style(self.style.clone())
.class(self.class.clone())
.width(
self.width
.unwrap_or_else(|| Length::Fixed(f32::from(self.size))),