Skip to content

Commit 13aa961

Browse files
committed
shear migration for text node
- add shear property - set character spacing to 0
1 parent a1b7163 commit 13aa961

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

editor/src/messages/portfolio/document/utility_types/network_interface.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,8 +1161,7 @@ impl NodeNetworkInterface {
11611161
.and_then(|node_metadata| node_metadata.persistent_metadata.input_properties.get(index))
11621162
}
11631163

1164-
pub fn insert_input_properties_row(&mut self, node_id: &NodeId, index: usize, network_path: &[NodeId]) {
1165-
let row = ("", "TODO").into();
1164+
pub fn insert_input_properties_row(&mut self, node_id: &NodeId, index: usize, network_path: &[NodeId], row: PropertiesRow) {
11661165
let _ = self
11671166
.node_metadata_mut(node_id, network_path)
11681167
.map(|node_metadata| node_metadata.persistent_metadata.input_properties.insert(index - 1, row));

editor/src/messages/portfolio/document_migration.rs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ use graphene_std::vector::style::{Fill, FillType, Gradient, PaintOrder, StrokeAl
1414
use graphene_std::vector::{VectorData, VectorDataTable};
1515
use std::collections::HashMap;
1616

17+
use super::document::utility_types::network_interface::{NumberInputSettings, PropertiesRow, WidgetOverride};
18+
1719
const TEXT_REPLACEMENTS: &[(&str, &str)] = &[
1820
("graphene_core::vector::vector_nodes::SamplePointsNode", "graphene_core::vector::SamplePolylineNode"),
1921
("graphene_core::vector::vector_nodes::SubpathSegmentLengthsNode", "graphene_core::vector::SubpathSegmentLengthsNode"),
@@ -308,8 +310,8 @@ pub fn document_migration_upgrades(document: &mut DocumentMessageHandler, reset_
308310
let node_definition = resolve_document_node_type(reference).unwrap();
309311
let document_node = node_definition.default_node_template().document_node;
310312
document.network_interface.replace_implementation(node_id, network_path, document_node.implementation.clone());
311-
document.network_interface.insert_input_properties_row(node_id, 8, network_path);
312-
document.network_interface.insert_input_properties_row(node_id, 9, network_path);
313+
document.network_interface.insert_input_properties_row(node_id, 8, network_path, ("", "TODO").into());
314+
document.network_interface.insert_input_properties_row(node_id, 9, network_path, ("", "TODO").into());
313315

314316
let old_inputs = document.network_interface.replace_inputs(node_id, document_node.inputs.clone(), network_path);
315317
let align_input = NodeInput::value(TaggedValue::StrokeAlign(StrokeAlign::Center), false);
@@ -402,7 +404,7 @@ pub fn document_migration_upgrades(document: &mut DocumentMessageHandler, reset_
402404
}
403405

404406
// Upgrade Text node to include line height and character spacing, which were previously hardcoded to 1, from https://github.com/GraphiteEditor/Graphite/pull/2016
405-
if reference == "Text" && inputs_count != 8 {
407+
if reference == "Text" && inputs_count != 9 {
406408
let node_definition = resolve_document_node_type(reference).unwrap();
407409
let document_node = node_definition.default_node_template().document_node;
408410
document.network_interface.replace_implementation(node_id, network_path, document_node.implementation.clone());
@@ -441,6 +443,31 @@ pub fn document_migration_upgrades(document: &mut DocumentMessageHandler, reset_
441443
NodeInput::value(TaggedValue::OptionalF64(TypesettingConfig::default().max_height), false),
442444
network_path,
443445
);
446+
document.network_interface.insert_input_properties_row(
447+
node_id,
448+
9,
449+
network_path,
450+
PropertiesRow::with_override(
451+
"Shear",
452+
"TODO",
453+
WidgetOverride::Number(NumberInputSettings {
454+
min: Some(-85.),
455+
456+
max: Some(85.),
457+
unit: Some("°".to_string()),
458+
..Default::default()
459+
}),
460+
),
461+
);
462+
document.network_interface.set_input(
463+
&InputConnector::node(*node_id, 8),
464+
if inputs_count >= 9 {
465+
old_inputs[8].clone()
466+
} else {
467+
NodeInput::value(TaggedValue::F64(TypesettingConfig::default().shear), false)
468+
},
469+
network_path,
470+
);
444471
}
445472

446473
// Upgrade Sine, Cosine, and Tangent nodes to include a boolean input for whether the output should be in radians, which was previously the only option but is now not the default

editor/src/messages/tool/common_functionality/utility_functions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use bezier_rs::Bezier;
1212
use glam::{DAffine2, DVec2};
1313
use graphene_std::renderer::Quad;
1414
use graphene_std::text::{FontCache, load_font};
15-
use graphene_std::vector::{HandleId, ManipulatorPointId, PointId, SegmentId, VectorData, VectorModificationType};
15+
use graphene_std::vector::{HandleExt, HandleId, ManipulatorPointId, PointId, SegmentId, VectorData, VectorModificationType};
1616

1717
/// Determines if a path should be extended. Goal in viewport space. Returns the path and if it is extending from the start, if applicable.
1818
pub fn should_extend(

0 commit comments

Comments
 (0)