mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-23 21:18:12 +08:00
Improve the Shape tool's arrow drawing controls (#3650)
* fixed the arrow's parameters Signed-off-by: krVatsal <kumarvatsal34@gmail.com> * shifted the arrow's origin to its tail Signed-off-by: krVatsal <kumarvatsal34@gmail.com> * modified arrow shapetype fucntion to be like other shapes * fixed rust formatting * Remove misleading part of comment referencing the origin --------- Signed-off-by: krVatsal <kumarvatsal34@gmail.com> Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
87739ff877
commit
82f7dc7062
@@ -15,16 +15,16 @@ use std::collections::VecDeque;
|
||||
pub struct Arrow;
|
||||
|
||||
impl Arrow {
|
||||
pub fn create_node(document: &DocumentMessageHandler, drag_start: DVec2) -> NodeTemplate {
|
||||
pub fn create_node(document: &DocumentMessageHandler, drag_start: DVec2, shaft_width: f64, head_width: f64, head_length: f64) -> NodeTemplate {
|
||||
let node_type = resolve_proto_node_type(graphene_std::vector_nodes::arrow::IDENTIFIER).expect("Arrow node does not exist");
|
||||
let viewport_pos = document.metadata().document_to_viewport.transform_point2(drag_start);
|
||||
node_type.node_template_input_override([
|
||||
None,
|
||||
Some(NodeInput::value(TaggedValue::DVec2(viewport_pos), false)), // start
|
||||
Some(NodeInput::value(TaggedValue::DVec2(viewport_pos), false)), // end
|
||||
Some(NodeInput::value(TaggedValue::F64(10.), false)), // shaft_width
|
||||
Some(NodeInput::value(TaggedValue::F64(30.), false)), // head_width
|
||||
Some(NodeInput::value(TaggedValue::F64(20.), false)), // head_length
|
||||
Some(NodeInput::value(TaggedValue::F64(shaft_width), false)), // shaft_width
|
||||
Some(NodeInput::value(TaggedValue::F64(head_width), false)), // head_width
|
||||
Some(NodeInput::value(TaggedValue::F64(head_length), false)), // head_length
|
||||
])
|
||||
}
|
||||
|
||||
@@ -56,12 +56,7 @@ impl Arrow {
|
||||
return;
|
||||
};
|
||||
|
||||
// Calculate proportional dimensions based on arrow length
|
||||
let shaft_width = length_document * 0.1;
|
||||
let head_width = length_document * 0.3;
|
||||
let head_length = length_document * 0.2;
|
||||
|
||||
// Update Arrow node parameters with document space coordinates (like Line tool)
|
||||
// Update Arrow node start and end points with document space coordinates
|
||||
responses.add(NodeGraphMessage::SetInput {
|
||||
input_connector: InputConnector::node(node_id, 1),
|
||||
input: NodeInput::value(TaggedValue::DVec2(start_document), false),
|
||||
@@ -70,18 +65,6 @@ impl Arrow {
|
||||
input_connector: InputConnector::node(node_id, 2),
|
||||
input: NodeInput::value(TaggedValue::DVec2(end_document), false),
|
||||
});
|
||||
responses.add(NodeGraphMessage::SetInput {
|
||||
input_connector: InputConnector::node(node_id, 3),
|
||||
input: NodeInput::value(TaggedValue::F64(shaft_width), false),
|
||||
});
|
||||
responses.add(NodeGraphMessage::SetInput {
|
||||
input_connector: InputConnector::node(node_id, 4),
|
||||
input: NodeInput::value(TaggedValue::F64(head_width), false),
|
||||
});
|
||||
responses.add(NodeGraphMessage::SetInput {
|
||||
input_connector: InputConnector::node(node_id, 5),
|
||||
input: NodeInput::value(TaggedValue::F64(head_length), false),
|
||||
});
|
||||
|
||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user