mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-25 22:58:11 +08:00
Polish node graph frames and rename them for clarity (#1104)
* Polish layer panel UI and layer type icons/text * Assorted UI text and comment cleanup * Insert Transform node before Imaginate node via tool * Rename "Node Graph Frame" to Layer type and Frame tool * Rename "Node Graph Frame" to "Frame" tool * Update Node Graph Frame -> Frame tool icon * Fix lint warnings
This commit is contained in:
@@ -11,8 +11,8 @@ use std::collections::VecDeque;
|
||||
/// Create a new vector layer from a vector of [`bezier_rs::Subpath`].
|
||||
pub fn new_vector_layer(subpaths: Vec<Subpath<ManipulatorGroupId>>, layer_path: Vec<LayerId>, responses: &mut VecDeque<Message>) {
|
||||
responses.push_back(DocumentMessage::DeselectAllLayers.into());
|
||||
let network = node_graph::new_vector_network(subpaths);
|
||||
|
||||
let network = node_graph::new_vector_network(subpaths);
|
||||
responses.push_back(
|
||||
Operation::AddNodeGraphFrame {
|
||||
path: layer_path.clone(),
|
||||
|
||||
+3
-3
@@ -60,10 +60,10 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for NodeGra
|
||||
|
||||
impl ToolMetadata for NodeGraphFrameTool {
|
||||
fn icon_name(&self) -> String {
|
||||
"RasterNodesTool".into()
|
||||
"RasterFrameTool".into()
|
||||
}
|
||||
fn tooltip(&self) -> String {
|
||||
"Node Graph Frame Tool".into()
|
||||
"Frame Tool".into()
|
||||
}
|
||||
fn tool_type(&self) -> crate::messages::tool::utility_types::ToolType {
|
||||
ToolType::NodeGraphFrame
|
||||
@@ -117,7 +117,7 @@ impl Fsm for NodeGraphToolFsmState {
|
||||
shape_data.path = Some(document.get_path_for_new_layer());
|
||||
responses.push_back(DocumentMessage::DeselectAllLayers.into());
|
||||
|
||||
let network = node_graph::new_image_network(20, 0);
|
||||
let network = node_graph::new_image_network(8, 0);
|
||||
|
||||
responses.push_back(
|
||||
Operation::AddNodeGraphFrame {
|
||||
@@ -119,18 +119,36 @@ impl Fsm for ImaginateToolFsmState {
|
||||
|
||||
use graph_craft::document::*;
|
||||
|
||||
// Utility function to offset the position of each consecutive node
|
||||
let mut pos = 8;
|
||||
let mut next_pos = || {
|
||||
pos += 8;
|
||||
graph_craft::document::DocumentNodeMetadata::position((pos, 4))
|
||||
};
|
||||
|
||||
// Get the node type for the Transform and Imaginate nodes
|
||||
let Some(transform_node_type) = crate::messages::portfolio::document::node_graph::resolve_document_node_type("Transform") else {
|
||||
warn!("Transform node should be in registry");
|
||||
return Drawing;
|
||||
};
|
||||
let imaginate_node_type = &*IMAGINATE_NODE;
|
||||
|
||||
let mut imaginate_inputs: Vec<NodeInput> = imaginate_node_type.inputs.iter().map(|input| input.default.clone()).collect();
|
||||
imaginate_inputs[0] = NodeInput::node(0, 0);
|
||||
// Give them a unique ID
|
||||
let [transform_node_id, imaginate_node_id] = [100, 101];
|
||||
|
||||
let imaginate_node_id = 100;
|
||||
// Create the network based on the Input -> Output passthrough default network
|
||||
let mut network = node_graph::new_image_network(16, imaginate_node_id);
|
||||
|
||||
// Insert the nodes into the default network
|
||||
network
|
||||
.nodes
|
||||
.insert(transform_node_id, transform_node_type.to_document_node_default_inputs([Some(NodeInput::node(0, 0))], next_pos()));
|
||||
network.nodes.insert(
|
||||
imaginate_node_id,
|
||||
imaginate_node_type.to_document_node(imaginate_inputs, graph_craft::document::DocumentNodeMetadata::position((16, 4))),
|
||||
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.push_back(
|
||||
Operation::AddNodeGraphFrame {
|
||||
path: shape_data.path.clone().unwrap(),
|
||||
@@ -140,6 +158,7 @@ impl Fsm for ImaginateToolFsmState {
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.push_back(NodeGraphMessage::ShiftNode { node_id: imaginate_node_id }.into());
|
||||
|
||||
Drawing
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ pub mod artboard_tool;
|
||||
pub mod ellipse_tool;
|
||||
pub mod eyedropper_tool;
|
||||
pub mod fill_tool;
|
||||
pub mod frame_tool;
|
||||
pub mod freehand_tool;
|
||||
pub mod gradient_tool;
|
||||
pub mod imaginate_tool;
|
||||
pub mod line_tool;
|
||||
pub mod navigate_tool;
|
||||
pub mod node_graph_frame_tool;
|
||||
pub mod path_tool;
|
||||
pub mod pen_tool;
|
||||
pub mod rectangle_tool;
|
||||
|
||||
@@ -472,7 +472,7 @@ impl Fsm for SelectToolFsmState {
|
||||
if let Ok(intersect) = document.document_legacy.layer(intersect_layer_path) {
|
||||
match tool_data.nested_selection_behavior {
|
||||
NestedSelectionBehavior::Shallowest => edit_layer_shallowest_manipulation(document, intersect_layer_path, tool_data, responses),
|
||||
NestedSelectionBehavior::Deepest => edit_layer_deepest_manipulation(intersect, intersect_layer_path, responses),
|
||||
NestedSelectionBehavior::Deepest => edit_layer_deepest_manipulation(intersect, responses),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1201,7 +1201,7 @@ fn edit_layer_shallowest_manipulation(document: &DocumentMessageHandler, interse
|
||||
}
|
||||
}
|
||||
|
||||
fn edit_layer_deepest_manipulation(intersect: &Layer, intersect_layer_path: &Vec<u64>, responses: &mut VecDeque<Message>) {
|
||||
fn edit_layer_deepest_manipulation(intersect: &Layer, responses: &mut VecDeque<Message>) {
|
||||
match &intersect.data {
|
||||
LayerDataType::Text(_) => {
|
||||
responses.push_front(ToolMessage::ActivateTool { tool_type: ToolType::Text }.into());
|
||||
|
||||
@@ -408,7 +408,7 @@ fn list_tools_in_groups() -> Vec<Vec<ToolAvailability>> {
|
||||
],
|
||||
vec![
|
||||
// Raster tool group
|
||||
ToolAvailability::Available(Box::<node_graph_frame_tool::NodeGraphFrameTool>::default()),
|
||||
ToolAvailability::Available(Box::<frame_tool::NodeGraphFrameTool>::default()),
|
||||
ToolAvailability::Available(Box::<imaginate_tool::ImaginateTool>::default()),
|
||||
ToolAvailability::ComingSoon(ToolEntry {
|
||||
tool_type: ToolType::Brush,
|
||||
|
||||
Reference in New Issue
Block a user