Skip to content

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

Merge wrap-placed-graphic: text wrap set on a placed graphic wraps text

aionggd32134d33710
diff --cc crates/compose/src/lib.rs
index d661d4af7,ed4c9cd5b..3e8f25ec9
--- a/crates/compose/src/lib.rs
+++ b/crates/compose/src/lib.rs
@@@ -35,11 -29,11 +35,11 @@@ use std::rc::Rc
use std::sync::{Arc, Mutex};
use designcraft_doc::{
- Align, Document, FirstBaseline, GridAlign, ItemId, ListAlign, ListCounter, ParaProps, SpanColumns, StartParagraph, Story, StoryId, TabAlign,
- Align, Composer, Content, Document, FirstBaseline, GridAlign, Item, ItemId, ParaProps, SpanColumns, StartParagraph, Story, StoryId, TabAlign,
-- TextFrameOptions, VerticalJustification, WrapMode, story,
++ Align, Content, Document, FirstBaseline, GridAlign, Item, ItemId, ListAlign, ListCounter, ParaProps, SpanColumns, StartParagraph, Story, StoryId,
++ TabAlign, TextFrameOptions, VerticalJustification, WrapMode, story,
};
use designcraft_fonts::{FontDb, ScopedFonts};
- use designcraft_geom::{Point, Rect};
+ use designcraft_geom::{Affine, Point, Rect};
use crate::breaker::{Break, Spacing};
pub use crate::cache::Cache;
@@@ -405,18 -395,12 +437,12 @@@ pub fn frame_specs(doc: &Document, sid
if doc.layer(other.layer).is_some_and(|l| !l.visible) {
continue;
}
- let o = other.wrap.offsets;
- let b = other.bounds();
- let r = Rect::new(b.x0 - o[1], b.y0 - o[0], b.x1 + o[3], b.y1 + o[2]);
- let inner = inv.transform_rect_bbox(r);
- exclusions.push(Exclusion { rect: inner, mode: other.wrap.mode });
+ wrap_obstacles(other, Affine::IDENTITY, item.id, 0, &mut obstacles);
}
+ exclusions.extend(obstacles.into_iter().map(|(r, mode)| Exclusion { rect: inv.transform_rect_bbox(r), mode }));
}
- let (page_name, page, left_page) = match (loc.spread, spread) {
- (designcraft_doc::SpreadRef::Doc(si), Some(sp)) => {
+ let (page_name, page, left_page) = match (spread_ref, spread) {
+ (Some(designcraft_doc::SpreadRef::Doc(si)), Some(sp)) => {
let c = item.bounds().center();
let pi = sp.page_at_x(c.x).unwrap_or(0);
let abs = doc.first_page_of_spread(si) + pi;
diff --cc crates/engine/src/cmd/datamerge/fill.rs
index 5628aef2d,a9aa84606..47087937b
--- a/crates/engine/src/cmd/datamerge/fill.rs
+++ b/crates/engine/src/cmd/datamerge/fill.rs
@@@ -367,10 -367,18 +367,18 @@@ fn place_image
link,
data: Arc::new(bytes),
pixels: Some((pw, ph)),
- page: 0,
+ ..Default::default()
}),
);
- let mut g = Graphic { asset: aid, size: (nw, nh), xf: Affine::translate((inner.x0, inner.y0)), auto_fit: mode, fit_align: 0, crop: [0.0; 4] };
+ let mut g = Graphic {
+ asset: aid,
+ size: (nw, nh),
+ xf: Affine::translate((inner.x0, inner.y0)),
+ auto_fit: mode,
+ fit_align: 0,
+ crop: [0.0; 4],
+ wrap: Default::default(),
+ };
if let Some(xf) = g.fitted(inner, mode) {
g.xf = xf;
}
diff --cc crates/idml/src/tests.rs
index 3cedb04ac,81f274850..e9855ba10
--- a/crates/idml/src/tests.rs
+++ b/crates/idml/src/tests.rs
@@@ -8,7 -8,7 +8,8 @@@ use designcraft_geom::{Rect, shapes}
use super::*;
mod decorations;
+mod variables;
+ mod wrap;
fn zip_files(files: &[(&str, &str)]) -> Vec<u8> {
use zip::write::SimpleFileOptions;
diff --cc crates/ui-egui/src/panels/mod.rs
index a82d05f3c,c99e0a38a..169c4b95b
--- a/crates/ui-egui/src/panels/mod.rs
+++ b/crates/ui-egui/src/panels/mod.rs
@@@ -108,8 -68,15 +108,13 @@@ pub fn sel_info(app: &DesignApp) -> Opt
let b = b?;
let first = d.item(st.selection.items[0])?;
let loc = d.find(first.id)?;
- let sp = d.spread(loc.spread)?;
- let pi = sp.page_at_x(b.center().x).unwrap_or(0);
- let px = sp.pages.get(pi).map(|p| p.x).unwrap_or(0.0);
+ let o = d.ruler_origin(loc.spread, b.center().x)?;
- let wrap = match first.wrap.mode {
+ // With the graphic selected (Direct Selection), the Text Wrap panel shows its own wrap.
+ let tw = match (&first.content, st.selection.content) {
+ (Content::Graphic(g), true) => &g.wrap,
+ _ => &first.wrap,
+ };
+ let wrap = match tw.mode {
WrapMode::None => "none",
WrapMode::BoundingBox => "boundingBox",
WrapMode::Contour => "contour",