mirror of
https://github.com/danbulant/cushy
synced 2026-05-19 12:19:02 +00:00
22 lines
795 B
Rust
22 lines
795 B
Rust
use cushy::figures::units::Lp;
|
|
use cushy::kludgine::Color;
|
|
use cushy::styles::components::{TextColor, TextSize};
|
|
use cushy::widget::MakeWidget;
|
|
use cushy::widgets::stack::Stack;
|
|
use cushy::widgets::Style;
|
|
use cushy::Run;
|
|
|
|
fn main() -> cushy::Result {
|
|
Stack::rows("Green".and(red_text("Red")))
|
|
.with(&TextColor, Color::GREEN)
|
|
// Local styles are not inherited. In this situation, the text size is
|
|
// being applied to the stack, which has no text. The labels are
|
|
// children of the stack, and they will render at the default text size.
|
|
.with_local(&TextSize, Lp::inches(10))
|
|
.run()
|
|
}
|
|
|
|
/// Creating reusable style helpers that work with any Widget is straightfoward
|
|
fn red_text(w: impl MakeWidget) -> Style {
|
|
w.with(&TextColor, Color::RED)
|
|
}
|