Create iced_core and iced_native

This commit is contained in:
Héctor Ramón Jiménez 2019-09-20 19:15:31 +02:00
parent b83a4b42dd
commit b9e0f74948
81 changed files with 2576 additions and 2709 deletions

View file

@ -1,8 +1,8 @@
use crate::{Bus, Element, Widget};
use crate::{Bus, Element, Length, Widget};
use dodrio::bumpalo;
pub type Image<'a> = iced::Image<&'a str>;
pub type Image<'a> = iced_core::Image<&'a str>;
impl<'a, Message> Widget<Message> for Image<'a> {
fn node<'b>(
@ -12,13 +12,21 @@ impl<'a, Message> Widget<Message> for Image<'a> {
) -> dodrio::Node<'b> {
use dodrio::builder::*;
let src = bumpalo::format!(in bump, "{}", self.image);
let src = bumpalo::format!(in bump, "{}", self.handle);
let mut image = img(bump).attr("src", src.into_bump_str());
if let Some(width) = self.width {
let width = bumpalo::format!(in bump, "{}", width);
image = image.attr("width", width.into_bump_str());
match self.width {
Length::Shrink => {}
Length::Fill => {
image = image.attr("width", "100%");
}
Length::Units(px) => {
image = image.attr(
"width",
bumpalo::format!(in bump, "{}px", px).into_bump_str(),
);
}
}
image.finish()