summaryrefslogtreecommitdiffstats
path: root/web/src/widget/text.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-09-15 17:43:15 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-09-15 17:43:15 +0200
commit8834772fa70850559f7bd82cc8432394e3fd9db7 (patch)
tree84522dca905c8a3803dc728726975c7095c06557 /web/src/widget/text.rs
parent27ac85a9d98474904c422a891e54888376dec00a (diff)
downloadiced-8834772fa70850559f7bd82cc8432394e3fd9db7.tar.gz
iced-8834772fa70850559f7bd82cc8432394e3fd9db7.tar.bz2
iced-8834772fa70850559f7bd82cc8432394e3fd9db7.zip
Draft widget nodes and wire interaction
Diffstat (limited to '')
-rw-r--r--web/src/widget/text.rs21
1 files changed, 19 insertions, 2 deletions
diff --git a/web/src/widget/text.rs b/web/src/widget/text.rs
index 0c1f75b6..b8fe9565 100644
--- a/web/src/widget/text.rs
+++ b/web/src/widget/text.rs
@@ -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> {