Square outline demo fix #15

This commit is contained in:
2025-08-02 06:16:09 -05:00
parent 36e06732d9
commit 2892176a76
2 changed files with 24 additions and 4 deletions
+8 -2
View File
@@ -15,13 +15,19 @@ pub fn app() -> Rsx {
FlexRow {
FlexCol {
@Transform::new().padding(2, 2);
@Style { foreground: None, background: Background::RoundedOutline(0x00ff00) }; // TODO: Outline doesn't work
@Style { foreground: None, background: Background::RoundedOutline(0x00ff00) };
Div {
"This is text inside a div"
}
@Transform::new().padding(2, 2);
@Style { foreground: None, background: Background::Outline(0x00ff00) };
Div {
"This is text inside a div with square outlines"
}
// TODO: div with width full
} (2)
} (1)
FlexCol {
Div {
+16 -2
View File
@@ -105,8 +105,22 @@ impl RenderScope {
match self.style.background {
crate::style::Background::NoBackground => {}
crate::style::Background::Outline(_c) => {
// TODO: Implement basic outline drawing if needed
crate::style::Background::Outline(c) => {
let width = width + self.transform.px * 2;
let height = height + self.transform.py * 2;
if width > 1 && height > 1 {
let d = "─".repeat(width as usize - 2);
utils::print_liner(
self.transform.x,
self.transform.y,
&utils::hex_ansi(c),
&format!(
"┌{d}┐{}\n└{d}┘",
format!("\n│{}│", " ".repeat(width as usize - 2))
.repeat(height as usize - 2),
),
);
}
}
crate::style::Background::RoundedOutline(c) => {
let width = width + self.transform.px * 2;