Skip to content

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

Integration: feathers inherit from object styles; merge closes its functions (#390)

aiongg27312c1cf90a
diff --git a/crates/idml/src/import.rs b/crates/idml/src/import.rs
index eda364410..f35baae85 100644
--- a/crates/idml/src/import.rs
+++ b/crates/idml/src/import.rs
@@ -2845,6 +2845,8 @@ fn overlay(base: &mut El, top: &El, depth: usize) {
_ => {}
}
}
+}
+
fn finite(v: Option<f64>) -> Option<f64> {
v.filter(|v| v.is_finite())
}
diff --git a/crates/idml/src/tests.rs b/crates/idml/src/tests.rs
index 880314136..f7c4bcc10 100644
--- a/crates/idml/src/tests.rs
+++ b/crates/idml/src/tests.rs
@@ -2761,6 +2761,8 @@ fn imports_and_round_trips_text_wrap_side_and_contour_type() {
let back = import_idml(&export_idml(&d)).unwrap();
let w = back.spreads[0].items.iter().find(|i| i.graphic().is_some()).unwrap().wrap;
assert_eq!((w.side, w.contour), (designcraft_doc::WrapSide::AwayFromSpine, designcraft_doc::ContourType::DetectEdges));
+}
+
fn feather_fixture(transparency: &str) -> Document {
let designmap = r#"<Document xmlns:idPkg="http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging" Self="d">
<idPkg:Spread src="Spreads/Spread_s.xml"/>
diff --git a/crates/idml/src/tests/object_styles.rs b/crates/idml/src/tests/object_styles.rs
index 85ec0aa49..301771bd2 100644
--- a/crates/idml/src/tests/object_styles.rs
+++ b/crates/idml/src/tests/object_styles.rs
@@ -190,3 +190,37 @@ fn text_wrap_side_and_contour_come_from_the_style_for_frames_and_placed_graphics
assert_eq!(g.wrap.side, designcraft_doc::WrapSide::RightSide, "the graphic's own side wins");
assert_eq!(g.wrap.contour, designcraft_doc::ContourType::BoundingBox);
}
+
+#[test]
+fn feathers_come_from_the_object_style_unless_its_category_turns_them_off() {
+ let styles = r#"<ObjectStyle Self="ObjectStyle/Fade" Name="Fade">
+ <Properties><BasedOn type="string">$ID/[None]</BasedOn></Properties>
+ <TransparencySetting>
+ <GradientFeatherSetting Applied="true" Type="Radial">
+ <OpacityGradientStop Self="s0" Opacity="100" Location="0"/>
+ <OpacityGradientStop Self="s1" Opacity="0" Location="100"/>
+ </GradientFeatherSetting>
+ <DirectionalFeatherSetting Applied="true" LeftWidth="3" RightWidth="4" TopWidth="5" BottomWidth="6"/>
+ </TransparencySetting>
+ </ObjectStyle>
+ <ObjectStyle Self="ObjectStyle/NoGradient" Name="NoGradient">
+ <Properties><BasedOn type="object">ObjectStyle/Fade</BasedOn></Properties>
+ <ObjectStyleObjectEffectsCategorySettings EnableGradientFeather="false"/>
+ </ObjectStyle>"#;
+ let d = fixture(
+ styles,
+ &[
+ (r#"AppliedObjectStyle="ObjectStyle/Fade""#, ""),
+ (r#"AppliedObjectStyle="ObjectStyle/NoGradient""#, ""),
+ (r#"AppliedObjectStyle="ObjectStyle/Fade""#, r#"<TransparencySetting><DirectionalFeatherSetting Applied="false"/></TransparencySetting>"#),
+ ],
+ );
+ let fx: Vec<&designcraft_doc::Effects> = d.spreads[0].items.iter().map(|i| &i.effects).collect();
+ assert!(fx[0].gradient_feather.on && fx[0].gradient_feather.radial, "{:?}", fx[0]);
+ assert!(fx[0].directional_feather.on);
+ assert_eq!(fx[0].directional_feather.widths, [5.0, 3.0, 6.0, 4.0]);
+ assert!(!fx[1].gradient_feather.on, "the category flag turns the style's gradient feather off");
+ assert!(fx[1].directional_feather.on);
+ assert!(fx[2].gradient_feather.on);
+ assert!(!fx[2].directional_feather.on, "the item's own setting wins");
+}