Draft widget nodes and wire interaction

This commit is contained in:
Héctor Ramón Jiménez 2019-09-15 17:43:15 +02:00
parent 27ac85a9d9
commit 8834772fa7
10 changed files with 223 additions and 22 deletions

View file

@ -1,10 +1,27 @@
use crate::{Color, Element, Widget};
use crate::{Bus, Color, Element, Widget};
use dodrio::bumpalo;
pub use iced::text::HorizontalAlignment;
pub type Text = iced::Text<Color>;
impl<'a, Message> Widget<Message> for Text {}
impl<'a, Message> Widget<Message> for Text {
fn node<'b>(
&self,
bump: &'b bumpalo::Bump,
_publish: &Bus<Message>,
) -> dodrio::Node<'b> {
use dodrio::builder::*;
let content = bumpalo::format!(in bump, "{}", self.content);
let size = bumpalo::format!(in bump, "font-size: {}px", self.size.unwrap_or(20));
p(bump)
.attr("style", size.into_bump_str())
.children(vec![text(content.into_bump_str())])
.finish()
}
}
impl<'a, Message> From<Text> for Element<'a, Message> {
fn from(text: Text) -> Element<'a, Message> {