mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-05 13:32:45 -05:00
Type: a selected look matching the redefined default still styles new type
With New Art Has Basic Appearance off, new type took nothing from a selected object whose fills, strokes and effects matched the document's redefined Default Graphic Style without a link to it (after Break Link to Graphic Style, for example), because the check that keeps type plain for the document's default look also caught a look taken from the selection. That check now applies only to the look paint.default gives, so new type takes the selection's fills and effects, and new type made after paint.default still keeps its characters' color.
This commit is contained in:
1 parent
cdf866b0f3
commit
664d50c328
3 files changed
+26
-4
No files matched your search
@@ -370,13 +370,14 @@ impl Session {
|
||||
/// more than one plain fill and stroke or comes from a graphic style (of this document or
|
||||
/// another), else none of its own, so the characters' fill and stroke show. The document's own
|
||||
/// default look (its redefined Default Graphic Style, which [`reset`] gives new art) leaves type
|
||||
/// plain as the shipped default does. The template is not repainted with the fill and stroke
|
||||
/// proxies.
|
||||
/// plain as the shipped default does; the same look taken from the selection does not. The
|
||||
/// template is not repainted with the fill and stroke proxies.
|
||||
pub(crate) fn new_type_look(&self) -> NewArt {
|
||||
let plain = || NewArt::plain(Appearance::default());
|
||||
let Some(t) = self.template() else { return plain() };
|
||||
let styled = self.new_art_styled();
|
||||
let default_look = || self.active().and_then(|st| redefined_default_style(&st.doc)).is_some_and(|g| style_look(g).approx_eq(&t));
|
||||
let default_look =
|
||||
|| !self.paint.inherited && self.active().and_then(|st| redefined_default_style(&st.doc)).is_some_and(|g| style_look(g).approx_eq(&t));
|
||||
if !styled && (t.is_basic() || default_look()) {
|
||||
return plain();
|
||||
}
|
||||
|
||||
@@ -700,3 +700,23 @@ fn new_art_and_type_from_a_style_redefined_after_it_was_picked_keep_the_picked_l
|
||||
assert_eq!((n.appearance.effects.len(), n.appearance.fill_paint()), (1, picked.fill_paint()), "{cmd}: the picked look");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_type_takes_a_selected_look_that_matches_the_redefined_default_style() {
|
||||
let mut s = session();
|
||||
let src = fancy(&mut s);
|
||||
run(&mut s, "graphicStyle.redefine", json!({"name": "Default Graphic Style", "id": src.0}));
|
||||
run(&mut s, "graphicStyle.breakLink", json!({"ids": [src.0]}));
|
||||
run(&mut s, "appearance.setNewArtBasic", json!({"on": false}));
|
||||
run(&mut s, "select.set", json!({"ids": [src.0]}));
|
||||
run(&mut s, "select.none", json!({}));
|
||||
let n = new_type(&mut s, json!({"x": 200, "y": 200, "text": "in"}));
|
||||
assert_eq!(n.appearance.items.iter().filter(|i| i.is_fill()).count(), 2, "both fills from the selection");
|
||||
assert_eq!(n.appearance.effects.len(), 1, "the drop shadow from the selection");
|
||||
// The same look from paint.default is the document's default, so new type stays plain.
|
||||
run(&mut s, "select.none", json!({}));
|
||||
run(&mut s, "paint.default", json!({}));
|
||||
let d = new_type(&mut s, json!({"x": 200, "y": 260, "text": "df"}));
|
||||
assert!(d.appearance.items.is_empty() && d.appearance.effects.is_empty(), "plain type");
|
||||
assert_ne!(char_fill(&d), Paint::None);
|
||||
}
|
||||
+2
-1
@@ -11571,7 +11571,8 @@ resets it.
|
||||
New type (`text.create`) takes the template's fills, strokes and effects when the template is more than one plain fill
|
||||
and stroke or comes from a graphic style; otherwise it has no fills or strokes of its own and its characters keep their
|
||||
color. The look `paint.default` gives in a document whose Default Graphic Style was redefined is the document's default,
|
||||
and new type made with it keeps its characters' color too. With Override Character Color on, its characters lose the fill and stroke the template paints, as when a
|
||||
and new type made with it keeps its characters' color too. The same look taken from a selection (New Art Has Basic
|
||||
Appearance off) gives new type its fills, strokes and effects. With Override Character Color on, its characters lose the fill and stroke the template paints, as when a
|
||||
graphic style is applied to type; a `color` given to `text.create` keeps the characters' fill. Type made with a graphic
|
||||
style's look takes the style's opacity and blend mode and is linked to it; otherwise the type keeps its own opacity and
|
||||
blend mode. New art and type are linked to the style only in the document the style was picked in, or the selection
|
||||
|
||||
Reference in new issue
Block a user