Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Merge place-no-autofit: an image placed into a frame leaves Auto-Fit off

aionggd8f1e6988204
diff --cc crates/engine/src/cmd/file.rs
index a0bf1f897,0e46ad033..c07aa8b64
--- a/crates/engine/src/cmd/file.rs
+++ b/crates/engine/src/cmd/file.rs
@@@ -467,17 -350,16 +467,17 @@@ fn file_place(s: &mut Session, p: &Valu
let id = if let Some(fid) = target_frame {
let it = d.item_mut(fid).ok_or(designcraft_doc::DocError::NoItem(fid))?;
let r = it.inner_bounds();
- // Fill frame proportionally.
+ // Fill the frame proportionally once. Auto-Fit stays off, so resizing the frame crops.
- let k = (r.width() / nw).max(r.height() / nh);
- let (gw, gh) = (nw * k, nh * k);
+ let k = (r.width() / bw).max(r.height() / bh);
+ let (gw, gh) = (bw * k, bh * k);
it.content = Content::Graphic(Graphic {
asset: aid,
- size: (nw, nh),
+ size: (bw, bh),
xf: Affine::translate((r.x0 + (r.width() - gw) / 2.0, r.y0 + (r.height() - gh) / 2.0)) * Affine::scale(k),
- auto_fit: designcraft_doc::Fitting::FillProportionally,
+ auto_fit: Default::default(),
fit_align: 4,
crop: [0.0; 4],
+ wrap: Default::default(),
});
fid
} else {
@@@ -607,10 -471,9 +607,10 @@@ fn place_drop(s: &mut Session, p: &Valu
asset: aid,
size: (nw, nh),
xf: Affine::translate((r.x0 + (r.width() - nw * k) / 2.0, r.y0 + (r.height() - nh * k) / 2.0)) * Affine::scale(k),
- auto_fit: designcraft_doc::Fitting::FillProportionally,
+ auto_fit: Default::default(),
fit_align: 4,
crop: [0.0; 4],
+ wrap: Default::default(),
});
fid
}