mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-13 00:18:58 +00:00
Select: the font Same commands take their reference from the type on a selected layer
A layer that was selected (for example with select.set) gave no reference to Select > Same > Font Family, Font Family & Style, Font Family, Style & Size, Font Size and the text fill and stroke color commands: the layer itself is not selectable, so the type on it was never reached and the command returned "select a text object". A selected layer or sublayer now gives the type on it that can be selected. A hidden, locked or template layer gives none.
This commit is contained in:
@@ -328,8 +328,9 @@ fn same_text(s: &mut Session, cmd: &str, eq: fn(&CharStyle, &CharStyle) -> bool)
|
||||
|
||||
/// Call `f` with each type object among the selected objects and inside them, in selection order,
|
||||
/// keeping only those [`walk_selectable`] visits: none that is hidden, locked, on a hidden, locked
|
||||
/// or template layer, or outside the isolated group. A type object inside two selected objects is
|
||||
/// given twice. The walk stops when `f` returns false.
|
||||
/// or template layer, or outside the isolated group. A selected layer or sublayer gives the type
|
||||
/// on it that passes the same test. A type object inside two selected objects is given twice. The
|
||||
/// walk stops when `f` returns false.
|
||||
fn each_selected_text(s: &Session, mut f: impl FnMut(NodeId) -> bool) {
|
||||
fn inside(n: &Node, f: &mut impl FnMut(NodeId) -> bool) -> bool {
|
||||
if !n.visible || n.locked {
|
||||
@@ -340,12 +341,18 @@ fn each_selected_text(s: &Session, mut f: impl FnMut(NodeId) -> bool) {
|
||||
}
|
||||
n.children().into_iter().flatten().all(|c| inside(c, f))
|
||||
}
|
||||
fn from(n: &Node, selectable: &impl Fn(NodeId) -> bool, f: &mut impl FnMut(NodeId) -> bool) -> bool {
|
||||
if n.is_layer() {
|
||||
return n.children().into_iter().flatten().all(|c| from(c, selectable, f));
|
||||
}
|
||||
!selectable(n.id) || inside(n, f)
|
||||
}
|
||||
let Some(st) = s.active() else { return };
|
||||
let locks = st.doc.locked_artboards();
|
||||
let selectable = |id| is_selectable(&st.doc, st.isolation, &locks, id);
|
||||
for id in &st.selection.objects {
|
||||
if is_selectable(&st.doc, st.isolation, &locks, *id)
|
||||
&& let Some(n) = st.doc.node(*id)
|
||||
&& !inside(n, &mut f)
|
||||
if let Some(n) = st.doc.node(*id)
|
||||
&& !from(n, &selectable, &mut f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user