Add iced widget helper to display the iced logo ☄️

This commit is contained in:
Héctor Ramón Jiménez 2024-07-11 04:33:19 +02:00
parent 70f44a6e26
commit 5e6c9eeb7e
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
7 changed files with 56 additions and 30 deletions

View file

@ -890,6 +890,41 @@ where
crate::Svg::new(handle)
}
/// Creates an [`Element`] that displays the iced logo with the given `text_size`.
///
/// Useful for showing some love to your favorite GUI library in your "About" screen,
/// for instance.
#[cfg(feature = "svg")]
pub fn iced<'a, Message, Theme, Renderer>(
text_size: impl Into<Pixels>,
) -> Element<'a, Message, Theme, Renderer>
where
Message: 'a,
Renderer: core::Renderer
+ core::text::Renderer<Font = core::Font>
+ core::svg::Renderer
+ 'a,
Theme: text::Catalog + crate::svg::Catalog + 'a,
{
use crate::core::{Alignment, Font};
use crate::svg;
use once_cell::sync::Lazy;
static LOGO: Lazy<svg::Handle> = Lazy::new(|| {
svg::Handle::from_memory(include_bytes!("../assets/iced-logo.svg"))
});
let text_size = text_size.into();
row![
svg(LOGO.clone()).width(text_size * 1.3),
text("iced").size(text_size).font(Font::MONOSPACE)
]
.spacing(text_size.0 / 3.0)
.align_items(Alignment::Center)
.into()
}
/// Creates a new [`Canvas`].
///
/// [`Canvas`]: crate::Canvas

View file

@ -237,7 +237,7 @@ where
let steps = (percent * (end - start) / step).round();
let value = steps * step + start;
T::from_f64(value)
T::from_f64(value.min(end))
};
new_value

View file

@ -239,7 +239,7 @@ where
let steps = (percent * (end - start) / step).round();
let value = steps * step + start;
T::from_f64(value)
T::from_f64(value.min(end))
};
new_value