mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-27 16:59:43 +01:00
Color: Show Opacity leaves out the art of a graph design
The fill and stroke opacity the Color Wheel panel shows now skips the art of a column or marker design in a graph series, which paint.setFill and paint.setStroke leave out. With only that art selected the panel shows no opacity, also when a row of the art is the Appearance panel's active item, instead of offering an edit the command refuses.
This commit is contained in:
1 parent
4c13ca2a74
commit
436bbe504a
2 files changed
+33
-5
No files matched your search
@@ -1443,6 +1443,27 @@ fn paint_targets_leave_a_graph_designs_copy_out() {
|
||||
assert_eq!(super::paint_targets(d, &[copy, art, mark]), [mark]);
|
||||
}
|
||||
|
||||
/// The fill opacity the proxies show leaves out the art of a column or marker design in a series, which
|
||||
/// `paint.setFill {opacity}` leaves out too: with only that art selected there is none, also with a row of the art
|
||||
/// active, and with a mark selected after it the mark's.
|
||||
#[test]
|
||||
fn proxy_opacity_leaves_a_graph_designs_art_out() {
|
||||
let (mut s, _, _, art, mark) = design_art();
|
||||
let (mut m, _, marker_art) = marker_design_art();
|
||||
for (s, art) in [(&mut s, art), (&mut m, marker_art)] {
|
||||
s.execute("select.set", &json!({"ids": [art.0]})).unwrap();
|
||||
assert_eq!(s.proxy_opacity(false), None);
|
||||
assert!(s.execute("paint.setFill", &json!({"opacity": 50})).is_err());
|
||||
let fill = top_row(s, art, true);
|
||||
s.execute("appearance.setActiveItem", &json!({"index": fill})).unwrap();
|
||||
assert_eq!(s.proxy_opacity(false), None, "with the art's fill row active");
|
||||
assert!(s.execute("paint.setFill", &json!({"opacity": 50})).is_err());
|
||||
}
|
||||
s.execute("paint.setFill", &json!({"ids": [mark.0], "opacity": 40})).unwrap();
|
||||
s.execute("select.set", &json!({"ids": [art.0, mark.0]})).unwrap();
|
||||
assert!((s.proxy_opacity(false).unwrap() - 0.4).abs() < 1e-6, "the mark's fill opacity");
|
||||
}
|
||||
|
||||
/// The art of a marker design in series 1 of a line graph: the design's copy and a path inside it.
|
||||
fn marker_design_art() -> (Session, NodeId, NodeId) {
|
||||
let mut s = Session::new();
|
||||
|
||||
@@ -217,7 +217,8 @@ impl Session {
|
||||
/// would edit are read in order (a group without an active Appearance row stands for its
|
||||
/// contents), and the first that exists answers. `None` with nothing selected, for an object
|
||||
/// selected in a symbol instance, while the Type tool has characters selected, and when only
|
||||
/// type characters or objects without that item are selected.
|
||||
/// type characters, objects without that item or the art of graph designs in a graph series
|
||||
/// are selected.
|
||||
pub fn proxy_opacity(&self, stroke: bool) -> Option<f32> {
|
||||
let st = self.active()?;
|
||||
if st.selection.symbol_part.is_some() {
|
||||
@@ -242,16 +243,22 @@ impl Session {
|
||||
if stroke { n.appearance.stroke_at(item).map(|s| s.opacity) } else { n.appearance.fill_at(item).map(|f| f.opacity) }
|
||||
};
|
||||
let subjects = st.selection.subjects();
|
||||
// The command leaves out the art of a graph design in a series, which the graph draws again
|
||||
// from the design, and a series group stands for the paths directly in it
|
||||
// (graph::paint_targets).
|
||||
let editable = |id: &&NodeId| !super::graph::is_design_art(&st.doc, **id);
|
||||
// As the command picks its rows (ItemTarget::of_kind): the active item when it is a row of
|
||||
// this kind in the first selected object's stack, read in the selected objects' own
|
||||
// stacks; else the topmost one of the painted leaves (a group's contents).
|
||||
let first = subjects.first().and_then(|id| st.doc.node(*id));
|
||||
// stacks; else the topmost one of the painted leaves (a group's contents). A row of a
|
||||
// graph design's art selected first stands for nothing (item_target_at).
|
||||
let first = subjects.first().filter(editable).and_then(|id| st.doc.node(*id));
|
||||
let active = item.filter(|i| first.and_then(|n| n.appearance.items.get(*i)).is_some_and(|it| it.is_fill() == !stroke));
|
||||
if active.is_some() {
|
||||
return subjects.iter().filter_map(|id| st.doc.node(*id)).find_map(|n| of(n, active));
|
||||
let targets = super::graph::series_group_marks_where(&st.doc, subjects, |n| n.extras().series_index.is_some());
|
||||
return targets.iter().filter(editable).filter_map(|id| st.doc.node(*id)).find_map(|n| of(n, active));
|
||||
}
|
||||
let leaves = super::leaf_targets(self, subjects).ok()?;
|
||||
leaves.iter().filter_map(|id| st.doc.node(*id)).find_map(|n| of(n, None))
|
||||
leaves.iter().filter(editable).filter_map(|id| st.doc.node(*id)).find_map(|n| of(n, None))
|
||||
}
|
||||
|
||||
pub(crate) fn remember_paint_now(&mut self, p: &Paint) {
|
||||
|
||||
Reference in new issue
Block a user