M3.17: the stop popover survives its opening double-click, and the selected stop belongs to its gradient

The double-click that opens the popover lands outside it in the same frame, so the popover
closed as soon as it opened; only a later click elsewhere closes it now. The selected stop
remembers the document, first selected object and proxy it was picked on (Session::selected_stop),
so selecting other art or toggling Fill/Stroke no longer lets Delete or the arrows edit a stop
on a different gradient.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bflatastic
2026-10-04 17:52:28 +07:00
co-authored by Claude Opus 5.5
parent 3786cfaf36
commit d3dc4a2af3
8 changed files with 83 additions and 18 deletions
+26 -1
View File
@@ -71,10 +71,35 @@ fn select_stop(s: &mut Session, p: &Value) -> Result<Value> {
Some(i)
}
};
s.gradient_stop = index;
s.gradient_stop = index.map(|i| (i, StopOwner::of(s)));
Ok(json!({ "index": index }))
}
/// Whose gradient a selected stop belongs to: the active document, its first selected object
/// (None: the default paint) and the proxy in front. Selecting other art or toggling the proxy
/// leaves no stop selected.
#[derive(Clone, Copy, Debug, PartialEq)]
pub(crate) struct StopOwner {
doc: Option<usize>,
object: Option<NodeId>,
fill: bool,
}
impl StopOwner {
fn of(s: &Session) -> Self {
Self { doc: s.active, object: s.active().and_then(|d| d.selection.objects.first().copied()), fill: s.fill_active }
}
}
impl Session {
/// The selected gradient stop (`gradient.selectStop`), while the gradient it was selected on
/// is still the one behind the active proxy. Callers check it against the stop count (an undo
/// can remove stops).
pub fn selected_stop(&self) -> Option<usize> {
self.gradient_stop.filter(|(_, owner)| *owner == StopOwner::of(self)).map(|(i, _)| i)
}
}
type Parsed<T> = std::result::Result<T, String>;
/// Parse a kind name.
+1 -1
View File
@@ -15,7 +15,7 @@ mod edit;
mod effectcmd;
pub mod fileio;
mod fonts;
mod gradient;
pub(crate) mod gradient;
pub(crate) mod graph;
pub mod help;
mod layer;