use blinc_app::prelude::*;
use blinc_app::windowed::{WindowedApp, WindowedContext};
use blinc_core::Color;
fn main() -> Result<()> {
tracing_subscriber::fmt()
.with_max_level(tracing::Level::INFO)
.init();
let config = WindowConfig {
title: "Text Wrap Test".to_string(),
width: 800,
height: 600,
resizable: true,
..Default::default()
};
WindowedApp::run(config, |ctx| build_ui(ctx))
}
fn build_ui(ctx: &WindowedContext) -> impl ElementBuilder {
div()
.w(ctx.width)
.h(ctx.height)
.bg(Color::rgba(0.1, 0.1, 0.15, 1.0))
.flex_col()
.p(40.0)
.gap(24.0)
.overflow_clip()
.child(
text("Text Wrapping Test")
.size(32.0)
.weight(FontWeight::Bold)
.color(Color::WHITE),
)
.child(build_test_section(
"Test 1: Explicit \\n Characters",
text("Line 1\nLine 2\nLine 3")
.size(16.0)
.color(Color::WHITE),
))
.child(build_test_section(
"Test 2: Auto Word-Wrap (300px container)",
text("This is a long paragraph that should automatically wrap at the container boundary when it exceeds the available width.")
.size(16.0)
.color(Color::WHITE),
))
.child(build_test_section(
"Test 3: No Wrap (should overflow)",
text("This text has no_wrap() so it stays on a single line even when very long")
.size(16.0)
.no_wrap()
.color(Color::WHITE),
))
.child(build_test_section(
"Test 4: Newlines + Word Wrap",
text("Paragraph 1: This is the first paragraph with enough text to wrap.\n\nParagraph 2: Second paragraph after explicit newlines, also long enough to wrap at container bounds.")
.size(16.0)
.color(Color::WHITE),
))
}
fn build_test_section(title: &str, content: impl ElementBuilder + 'static) -> impl ElementBuilder {
div()
.flex_col()
.gap(8.0)
.child(
text(title)
.size(14.0)
.weight(FontWeight::Medium)
.color(Color::rgba(0.4, 0.8, 1.0, 1.0)),
)
.child(
div()
.w(300.0) .p(16.0)
.bg(Color::rgba(0.2, 0.2, 0.25, 0.9))
.rounded(8.0)
.child(content),
)
}