mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-02 15:28:12 +08:00
Fix regression with double-click in the Path tool not working (#2963)
* Fix double click in path tool not working * Remove debug line --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
08ec1d08f6
commit
f15023ef58
@@ -3,6 +3,7 @@ use crate::messages::prelude::*;
|
|||||||
#[impl_message(Message, Defer)]
|
#[impl_message(Message, Defer)]
|
||||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum DeferMessage {
|
pub enum DeferMessage {
|
||||||
|
SetGraphSubmissionIndex(u64),
|
||||||
TriggerGraphRun(u64),
|
TriggerGraphRun(u64),
|
||||||
AfterGraphRun { messages: Vec<Message> },
|
AfterGraphRun { messages: Vec<Message> },
|
||||||
TriggerNavigationReady,
|
TriggerNavigationReady,
|
||||||
|
|||||||
@@ -17,15 +17,23 @@ impl MessageHandler<DeferMessage, ()> for DeferMessageHandler {
|
|||||||
DeferMessage::AfterNavigationReady { messages } => {
|
DeferMessage::AfterNavigationReady { messages } => {
|
||||||
self.after_viewport_resize.extend_from_slice(&messages);
|
self.after_viewport_resize.extend_from_slice(&messages);
|
||||||
}
|
}
|
||||||
|
DeferMessage::SetGraphSubmissionIndex(execution_id) => {
|
||||||
|
self.current_graph_submission_id = execution_id + 1;
|
||||||
|
}
|
||||||
DeferMessage::TriggerGraphRun(execution_id) => {
|
DeferMessage::TriggerGraphRun(execution_id) => {
|
||||||
self.current_graph_submission_id = execution_id;
|
if self.after_graph_run.is_empty() {
|
||||||
for message in self.after_graph_run.extract_if(.., |x| x.0 < self.current_graph_submission_id) {
|
return;
|
||||||
responses.push_front(message.1);
|
}
|
||||||
|
// Find the index of the last message we can process
|
||||||
|
let num_elements_to_remove = self.after_graph_run.binary_search_by_key(&(execution_id + 1), |x| x.0).unwrap_or_else(|pos| pos - 1);
|
||||||
|
let elements = self.after_graph_run.drain(0..=num_elements_to_remove);
|
||||||
|
for (_, message) in elements.rev() {
|
||||||
|
responses.add_front(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DeferMessage::TriggerNavigationReady => {
|
DeferMessage::TriggerNavigationReady => {
|
||||||
for message in self.after_viewport_resize.drain(..) {
|
for message in self.after_viewport_resize.drain(..).rev() {
|
||||||
responses.push_front(message);
|
responses.add_front(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1880,14 +1880,15 @@ impl DocumentMessageHandler {
|
|||||||
|
|
||||||
let previous_network = std::mem::replace(&mut self.network_interface, network_interface);
|
let previous_network = std::mem::replace(&mut self.network_interface, network_interface);
|
||||||
|
|
||||||
// TODO: Remove once the footprint is used to load the imports/export distances from the edge
|
|
||||||
responses.push_front(NodeGraphMessage::UnloadWires.into());
|
|
||||||
responses.push_front(NodeGraphMessage::SetGridAlignedEdges.into());
|
|
||||||
|
|
||||||
// Push the UpdateOpenDocumentsList message to the bus in order to update the save status of the open documents
|
// Push the UpdateOpenDocumentsList message to the bus in order to update the save status of the open documents
|
||||||
responses.push_front(NodeGraphMessage::ForceRunDocumentGraph.into());
|
responses.add(PortfolioMessage::UpdateOpenDocumentsList);
|
||||||
responses.push_front(NodeGraphMessage::SelectedNodesUpdated.into());
|
responses.add(NodeGraphMessage::SelectedNodesUpdated);
|
||||||
responses.push_front(PortfolioMessage::UpdateOpenDocumentsList.into());
|
responses.add(NodeGraphMessage::ForceRunDocumentGraph);
|
||||||
|
|
||||||
|
// TODO: Remove once the footprint is used to load the imports/export distances from the edge
|
||||||
|
responses.add(NodeGraphMessage::UnloadWires);
|
||||||
|
responses.add(NodeGraphMessage::SetGridAlignedEdges);
|
||||||
|
|
||||||
Some(previous_network)
|
Some(previous_network)
|
||||||
}
|
}
|
||||||
pub fn redo_with_history(&mut self, ipp: &InputPreprocessorMessageHandler, responses: &mut VecDeque<Message>) {
|
pub fn redo_with_history(&mut self, ipp: &InputPreprocessorMessageHandler, responses: &mut VecDeque<Message>) {
|
||||||
|
|||||||
@@ -363,13 +363,15 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
|||||||
self.executor.update_font_cache(self.persistent_data.font_cache.clone());
|
self.executor.update_font_cache(self.persistent_data.font_cache.clone());
|
||||||
for document_id in self.document_ids.iter() {
|
for document_id in self.document_ids.iter() {
|
||||||
let inspect_node = self.inspect_node_id();
|
let inspect_node = self.inspect_node_id();
|
||||||
let _ = self.executor.submit_node_graph_evaluation(
|
if let Ok(message) = self.executor.submit_node_graph_evaluation(
|
||||||
self.documents.get_mut(document_id).expect("Tried to render non-existent document"),
|
self.documents.get_mut(document_id).expect("Tried to render non-existent document"),
|
||||||
ipp.viewport_bounds.size().as_uvec2(),
|
ipp.viewport_bounds.size().as_uvec2(),
|
||||||
timing_information,
|
timing_information,
|
||||||
inspect_node,
|
inspect_node,
|
||||||
true,
|
true,
|
||||||
);
|
) {
|
||||||
|
responses.add(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.active_document_mut().is_some() {
|
if self.active_document_mut().is_some() {
|
||||||
@@ -846,11 +848,14 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
|||||||
ignore_hash,
|
ignore_hash,
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Err(description) = result {
|
match result {
|
||||||
responses.add(DialogMessage::DisplayDialogError {
|
Err(description) => {
|
||||||
title: "Unable to update node graph".to_string(),
|
responses.add(DialogMessage::DisplayDialogError {
|
||||||
description,
|
title: "Unable to update node graph".to_string(),
|
||||||
});
|
description,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Ok(message) => responses.add(message),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PortfolioMessage::ToggleRulers => {
|
PortfolioMessage::ToggleRulers => {
|
||||||
|
|||||||
@@ -67,10 +67,12 @@ pub trait Responses {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Responses for VecDeque<Message> {
|
impl Responses for VecDeque<Message> {
|
||||||
|
#[inline(always)]
|
||||||
fn add(&mut self, message: impl Into<Message>) {
|
fn add(&mut self, message: impl Into<Message>) {
|
||||||
self.push_back(message.into());
|
self.push_back(message.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
fn add_front(&mut self, message: impl Into<Message>) {
|
fn add_front(&mut self, message: impl Into<Message>) {
|
||||||
self.push_front(message.into());
|
self.push_front(message.into());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2229,7 +2229,9 @@ impl Fsm for PathToolFsmState {
|
|||||||
tool_data.snapping_axis = None;
|
tool_data.snapping_axis = None;
|
||||||
tool_data.sliding_point_info = None;
|
tool_data.sliding_point_info = None;
|
||||||
|
|
||||||
responses.add(DocumentMessage::EndTransaction);
|
if drag_occurred || extend_selection {
|
||||||
|
responses.add(DocumentMessage::EndTransaction);
|
||||||
|
}
|
||||||
responses.add(PathToolMessage::SelectedPointUpdated);
|
responses.add(PathToolMessage::SelectedPointUpdated);
|
||||||
tool_data.snap_manager.cleanup(responses);
|
tool_data.snap_manager.cleanup(responses);
|
||||||
tool_data.opposite_handle_position = None;
|
tool_data.opposite_handle_position = None;
|
||||||
@@ -2282,7 +2284,9 @@ impl Fsm for PathToolFsmState {
|
|||||||
tool_data.saved_points_before_anchor_convert_smooth_sharp.clear();
|
tool_data.saved_points_before_anchor_convert_smooth_sharp.clear();
|
||||||
|
|
||||||
responses.add(DocumentMessage::EndTransaction);
|
responses.add(DocumentMessage::EndTransaction);
|
||||||
responses.add(PathToolMessage::SelectedPointUpdated);
|
responses.add(DeferMessage::AfterGraphRun {
|
||||||
|
messages: vec![PathToolMessage::SelectedPointUpdated.into()],
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return PathToolFsmState::Ready;
|
return PathToolFsmState::Ready;
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ impl NodeGraphExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Adds an evaluate request for whatever current network is cached.
|
/// Adds an evaluate request for whatever current network is cached.
|
||||||
pub(crate) fn submit_current_node_graph_evaluation(&mut self, document: &mut DocumentMessageHandler, viewport_resolution: UVec2, time: TimingInformation) -> Result<(), String> {
|
pub(crate) fn submit_current_node_graph_evaluation(&mut self, document: &mut DocumentMessageHandler, viewport_resolution: UVec2, time: TimingInformation) -> Result<Message, String> {
|
||||||
let render_config = RenderConfig {
|
let render_config = RenderConfig {
|
||||||
viewport: Footprint {
|
viewport: Footprint {
|
||||||
transform: document.metadata().document_to_viewport,
|
transform: document.metadata().document_to_viewport,
|
||||||
@@ -155,7 +155,7 @@ impl NodeGraphExecutor {
|
|||||||
|
|
||||||
self.futures.insert(execution_id, ExecutionContext { export_config: None });
|
self.futures.insert(execution_id, ExecutionContext { export_config: None });
|
||||||
|
|
||||||
Ok(())
|
Ok(DeferMessage::SetGraphSubmissionIndex(execution_id).into())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Evaluates a node graph, computing the entire graph
|
/// Evaluates a node graph, computing the entire graph
|
||||||
@@ -166,11 +166,9 @@ impl NodeGraphExecutor {
|
|||||||
time: TimingInformation,
|
time: TimingInformation,
|
||||||
inspect_node: Option<NodeId>,
|
inspect_node: Option<NodeId>,
|
||||||
ignore_hash: bool,
|
ignore_hash: bool,
|
||||||
) -> Result<(), String> {
|
) -> Result<Message, String> {
|
||||||
self.update_node_graph(document, inspect_node, ignore_hash)?;
|
self.update_node_graph(document, inspect_node, ignore_hash)?;
|
||||||
self.submit_current_node_graph_evaluation(document, viewport_resolution, time)?;
|
self.submit_current_node_graph_evaluation(document, viewport_resolution, time)
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Evaluates a node graph for export
|
/// Evaluates a node graph for export
|
||||||
|
|||||||
Reference in New Issue
Block a user