Draft nodes for missing widgets

This commit is contained in:
Héctor Ramón Jiménez 2019-09-15 18:53:13 +02:00
parent 8834772fa7
commit 655978f480
16 changed files with 191 additions and 36 deletions

View file

@ -1,8 +1,29 @@
use crate::{Element, Widget};
use crate::{Bus, Element, Widget};
use dodrio::bumpalo;
pub type Image<'a> = iced::Image<&'a str>;
impl<'a, Message> Widget<Message> for Image<'a> {}
impl<'a, Message> Widget<Message> for Image<'a> {
fn node<'b>(
&self,
bump: &'b bumpalo::Bump,
_bus: &Bus<Message>,
) -> dodrio::Node<'b> {
use dodrio::builder::*;
let src = bumpalo::format!(in bump, "{}", self.image);
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());
}
image.finish()
}
}
impl<'a, Message> From<Image<'a>> for Element<'a, Message> {
fn from(image: Image<'a>) -> Element<'a, Message> {