mirror of
https://github.com/danbulant/cushy
synced 2026-06-11 10:30:49 +00:00
While this was a workaround for a docs.rs issue (Px/Lp are not linked), I decided having the shorter import path would look better in the examples. It probably wasn't necessary to update all of the references in the internal code, but I decided it was worth the consistency.
22 lines
781 B
Rust
22 lines
781 B
Rust
use cushy::styles::components::{TextColor, TextSize};
|
|
use cushy::widget::MakeWidget;
|
|
use cushy::widgets::stack::Stack;
|
|
use cushy::widgets::Style;
|
|
use cushy::Run;
|
|
use figures::units::Lp;
|
|
use kludgine::Color;
|
|
|
|
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)
|
|
}
|