From bac2180f28f4d0716457f03cbf80c1721973ef43 Mon Sep 17 00:00:00 2001 From: viktorstrate Date: Fri, 22 Nov 2024 21:01:09 +0100 Subject: [PATCH] Add background to copyright text in http_cats to make it more readable and to demonstrate more use cases of sized_box. --- xilem/examples/http_cats.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/xilem/examples/http_cats.rs b/xilem/examples/http_cats.rs index 6f1e8ba59..d34ce4926 100644 --- a/xilem/examples/http_cats.rs +++ b/xilem/examples/http_cats.rs @@ -10,7 +10,7 @@ use std::sync::Arc; -use masonry::widget::Alignment; +use masonry::widget::{Alignment, LineBreaking}; use vello::peniko::{Blob, Image}; use winit::dpi::LogicalSize; use winit::error::EventLoopError; @@ -200,9 +200,18 @@ impl Status { FlexSpacer::Fixed(10.), zstack(( image, + sized_box( + sized_box( + prose("Copyright ©️ https://http.cat") + .line_break_mode(LineBreaking::Clip) + .alignment(TextAlignment::End), + ) + .padding(4.) + .rounded(4.) + .background(Color::BLACK.multiply_alpha(0.5)), + ) // HACK: Trailing padding workaround scrollbar covering content - sized_box(prose("Copyright ©️ https://http.cat").alignment(TextAlignment::End)) - .padding((30., 40., 0., 0.)), + .padding((30., 42., 0., 0.)), )) .alignment(Alignment::TopTrailing), ))