use saudade::mock::MockBackend;
use saudade::{Bevel, Button, Color, Container, Font, Label, Rect, Widget, WindowChrome};
const W: i32 = 260;
const H: i32 = 120;
fn main() {
let build = || -> Box<dyn Widget> {
Box::new(
Container::new(W, H)
.with_background(Color::LIGHT_GRAY)
.add(Bevel::sunken(Rect::new(16, 16, W - 32, 48)))
.add(Label::new(
Rect::new(28, 26, W - 56, 16),
"Saudade Utilities",
))
.add(Label::new(
Rect::new(28, 42, W - 56, 16),
"Version 1.0 — © 1992",
))
.add(Button::new(Rect::new((W - 80) / 2, 80, 80, 26), "OK").default(true)),
)
};
let shots = [
(
"chrome-resizable.png",
WindowChrome::resizable("About Saudade"),
),
("chrome-fixed.png", WindowChrome::fixed("About Saudade")),
("chrome-dialog.png", WindowChrome::dialog("About Saudade")),
];
for (file, chrome) in shots {
let mut backend = MockBackend::new(W, H).with_scale(2.0);
if let Some(font) = Font::load_sans() {
backend = backend.with_sans_font(font);
}
let snap = backend.render_framed(build().as_mut(), &chrome);
std::fs::write(file, snap.to_png()).unwrap_or_else(|e| panic!("write {file}: {e}"));
println!("wrote {file} ({}×{})", snap.width(), snap.height());
}
}