mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-27 13:18:12 +08:00
Refactor naming to deprecate "node graph frame" terminology (#1187)
This commit is contained in:
@@ -13,15 +13,15 @@ use glam::DAffine2;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct NodeGraphFrameTool {
|
||||
pub struct FrameTool {
|
||||
fsm_state: NodeGraphToolFsmState,
|
||||
tool_data: NodeGraphToolData,
|
||||
}
|
||||
|
||||
#[remain::sorted]
|
||||
#[impl_message(Message, ToolMessage, NodeGraphFrame)]
|
||||
#[impl_message(Message, ToolMessage, Frame)]
|
||||
#[derive(PartialEq, Eq, Clone, Debug, Hash, Serialize, Deserialize, specta::Type)]
|
||||
pub enum NodeGraphFrameToolMessage {
|
||||
pub enum FrameToolMessage {
|
||||
// Standard messages
|
||||
#[remain::unsorted]
|
||||
Abort,
|
||||
@@ -35,9 +35,9 @@ pub enum NodeGraphFrameToolMessage {
|
||||
},
|
||||
}
|
||||
|
||||
impl PropertyHolder for NodeGraphFrameTool {}
|
||||
impl PropertyHolder for FrameTool {}
|
||||
|
||||
impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for NodeGraphFrameTool {
|
||||
impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for FrameTool {
|
||||
fn process_message(&mut self, message: ToolMessage, responses: &mut VecDeque<Message>, tool_data: &mut ToolActionHandlerData<'a>) {
|
||||
self.fsm_state.process_event(message, &mut self.tool_data, tool_data, &(), responses, true);
|
||||
}
|
||||
@@ -46,10 +46,10 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for NodeGra
|
||||
use NodeGraphToolFsmState::*;
|
||||
|
||||
match self.fsm_state {
|
||||
Ready => actions!(NodeGraphFrameToolMessageDiscriminant;
|
||||
Ready => actions!(FrameToolMessageDiscriminant;
|
||||
DragStart,
|
||||
),
|
||||
Drawing => actions!(NodeGraphFrameToolMessageDiscriminant;
|
||||
Drawing => actions!(FrameToolMessageDiscriminant;
|
||||
DragStop,
|
||||
Abort,
|
||||
Resize,
|
||||
@@ -58,7 +58,7 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for NodeGra
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolMetadata for NodeGraphFrameTool {
|
||||
impl ToolMetadata for FrameTool {
|
||||
fn icon_name(&self) -> String {
|
||||
"RasterFrameTool".into()
|
||||
}
|
||||
@@ -66,15 +66,15 @@ impl ToolMetadata for NodeGraphFrameTool {
|
||||
"Frame Tool".into()
|
||||
}
|
||||
fn tool_type(&self) -> crate::messages::tool::utility_types::ToolType {
|
||||
ToolType::NodeGraphFrame
|
||||
ToolType::Frame
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolTransition for NodeGraphFrameTool {
|
||||
impl ToolTransition for FrameTool {
|
||||
fn event_to_message_map(&self) -> EventToMessageMap {
|
||||
EventToMessageMap {
|
||||
document_dirty: None,
|
||||
tool_abort: Some(NodeGraphFrameToolMessage::Abort.into()),
|
||||
tool_abort: Some(FrameToolMessage::Abort.into()),
|
||||
selection_changed: None,
|
||||
}
|
||||
}
|
||||
@@ -104,12 +104,12 @@ impl Fsm for NodeGraphToolFsmState {
|
||||
_tool_options: &Self::ToolOptions,
|
||||
responses: &mut VecDeque<Message>,
|
||||
) -> Self {
|
||||
use NodeGraphFrameToolMessage::*;
|
||||
use FrameToolMessage::*;
|
||||
use NodeGraphToolFsmState::*;
|
||||
|
||||
let mut shape_data = &mut tool_data.data;
|
||||
|
||||
if let ToolMessage::NodeGraphFrame(event) = event {
|
||||
if let ToolMessage::Frame(event) = event {
|
||||
match (self, event) {
|
||||
(Ready, DragStart) => {
|
||||
shape_data.start(responses, document, input, render_data);
|
||||
@@ -119,7 +119,7 @@ impl Fsm for NodeGraphToolFsmState {
|
||||
|
||||
let network = node_graph::new_image_network(8, 0);
|
||||
|
||||
responses.add(Operation::AddNodeGraphFrame {
|
||||
responses.add(Operation::AddFrame {
|
||||
path: shape_data.path.clone().unwrap(),
|
||||
insert_index: -1,
|
||||
transform: DAffine2::ZERO.to_cols_array(),
|
||||
@@ -136,7 +136,7 @@ impl Fsm for NodeGraphToolFsmState {
|
||||
}
|
||||
(Drawing, DragStop) => {
|
||||
if let Some(layer_path) = &shape_data.path {
|
||||
responses.add(DocumentMessage::NodeGraphFrameGenerate { layer_path: layer_path.to_vec() });
|
||||
responses.add(DocumentMessage::InputFrameRasterizeRegionBelowLayer { layer_path: layer_path.to_vec() });
|
||||
}
|
||||
|
||||
input.mouse.finish_transaction(shape_data.viewport_drag_start(document), responses);
|
||||
|
||||
@@ -148,8 +148,8 @@ impl Fsm for ImaginateToolFsmState {
|
||||
imaginate_node_type.to_document_node_default_inputs([Some(graph_craft::document::NodeInput::node(transform_node_id, 0))], next_pos()),
|
||||
);
|
||||
|
||||
// Add the node graph frame layer to the document
|
||||
responses.add(Operation::AddNodeGraphFrame {
|
||||
// Add a layer with a frame to the document
|
||||
responses.add(Operation::AddFrame {
|
||||
path: shape_data.path.clone().unwrap(),
|
||||
insert_index: -1,
|
||||
transform: DAffine2::ZERO.to_cols_array(),
|
||||
@@ -167,7 +167,7 @@ impl Fsm for ImaginateToolFsmState {
|
||||
}
|
||||
(Drawing, DragStop) => {
|
||||
if let Some(layer_path) = &shape_data.path {
|
||||
responses.add(DocumentMessage::NodeGraphFrameGenerate { layer_path: layer_path.to_vec() });
|
||||
responses.add(DocumentMessage::InputFrameRasterizeRegionBelowLayer { layer_path: layer_path.to_vec() });
|
||||
}
|
||||
|
||||
input.mouse.finish_transaction(shape_data.viewport_drag_start(document), responses);
|
||||
|
||||
@@ -377,7 +377,7 @@ impl SelectToolData {
|
||||
|
||||
// Since the selected layers have now moved back to their original transforms before the drag began, we rerender them to be displayed as if they weren't touched.
|
||||
for layer_path in self.not_duplicated_layers.iter().flatten() {
|
||||
responses.add(DocumentMessage::NodeGraphFrameGenerate { layer_path: layer_path.clone() });
|
||||
responses.add(DocumentMessage::InputFrameRasterizeRegionBelowLayer { layer_path: layer_path.clone() });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -974,7 +974,7 @@ impl Fsm for SelectToolFsmState {
|
||||
|
||||
fn rerender_selected_layers(tool_data: &mut SelectToolData, responses: &mut VecDeque<Message>) {
|
||||
for layer_path in &tool_data.layers_dragging {
|
||||
responses.add(DocumentMessage::NodeGraphFrameGenerate { layer_path: layer_path.clone() });
|
||||
responses.add(DocumentMessage::InputFrameRasterizeRegionBelowLayer { layer_path: layer_path.clone() });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1206,8 +1206,8 @@ fn edit_layer_deepest_manipulation(intersect: &Layer, responses: &mut VecDeque<M
|
||||
LayerDataType::Shape(_) => {
|
||||
responses.add_front(ToolMessage::ActivateTool { tool_type: ToolType::Path });
|
||||
}
|
||||
LayerDataType::NodeGraphFrame(graph_frame) if graph_frame.as_vector_data().is_some() => {
|
||||
if graph_frame.network.nodes.values().any(|node| node.name == "Text") {
|
||||
LayerDataType::Layer(layer) if layer.as_vector_data().is_some() => {
|
||||
if layer.network.nodes.values().any(|node| node.name == "Text") {
|
||||
responses.add_front(ToolMessage::ActivateTool { tool_type: ToolType::Text });
|
||||
responses.add(TextToolMessage::EditSelected);
|
||||
} else {
|
||||
|
||||
@@ -282,7 +282,7 @@ impl TextToolData {
|
||||
|
||||
let network = new_text_network(String::new(), editing_text.font.clone(), editing_text.font_size as f64);
|
||||
|
||||
responses.add(Operation::AddNodeGraphFrame {
|
||||
responses.add(Operation::AddFrame {
|
||||
path: self.layer_path.clone(),
|
||||
insert_index: -1,
|
||||
transform: DAffine2::ZERO.to_cols_array(),
|
||||
|
||||
Reference in New Issue
Block a user