image-viewer
Builds Divider ImageViewer


The code that drew it
A still frame holds a repeating animation at its first frame and a one-shot at its last, because a still of a moving thing is not reproducible. Run the gallery to review motion.
fn image_viewer(_window: &mut Window, cx: &mut App) -> AnyElement {
let theme = cx.theme().clone();
stack(&theme)
.w(px(860.0))
.child(
div()
.row()
.items_start()
.gap(px(theme.spacing.lg))
.child(
div().w(px(396.0)).child(
ImageViewer::new(
"scene.image.ready",
[
ImageFrame::new("graph", "The run graph")
.source("runs/graph.png")
.natural(1600, 900),
ImageFrame::new("trace", "The failing trace")
.source("runs/trace.png")
.natural(1200, 1200),
],
)
.showing("graph")
.fit(FitMode::Contain)
.height(200.0)
.image(|_, _, cx| Some(scene_picture("Supplied by the host", cx)))
.on_event(|_, _, _| {}),
),
)
.child(
div().w(px(396.0)).child(
ImageViewer::new(
"scene.image.refused",
[ImageFrame::new("scan", "Page 4 of the scan")
.source("scans/page-4.tiff")
.natural(2480, 3508)
.unavailable("The workspace is frozen for the release.")],
)
.height(200.0)
.image(|_, _, cx| Some(scene_picture("Supplied by the host", cx)))
.on_event(|_, _, _| {}),
),
),
)
.child(
Divider::new()
.id("scene.image.rule.unmeasured")
.label("A size the host never stated"),
)
.child(
div().w(px(396.0)).child(
ImageViewer::new(
"scene.image.unmeasured",
[ImageFrame::new("sketch", "A pasted sketch").source("clipboard")],
)
.height(200.0)
.image(|_, _, cx| Some(scene_picture("Size never stated", cx)))
.on_event(|_, _, _| {}),
),
)
.into_any_element()
}