mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-07-15 11:45:00 +00:00
Fix Text Tool Overwriting Existing Text on Editing Text Layer (#1356)
fix: text edit overwriting existing text
This commit is contained in:
parent
40c26af564
commit
50b67bf6f6
4 changed files with 6 additions and 6 deletions
|
@ -1680,7 +1680,7 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||||
DocumentInputType::none(),
|
DocumentInputType::none(),
|
||||||
DocumentInputType::value("Text", TaggedValue::String("hello world".to_string()), false),
|
DocumentInputType::value("Text", TaggedValue::String("hello world".to_string()), false),
|
||||||
DocumentInputType::value("Font", TaggedValue::Font(Font::new(DEFAULT_FONT_FAMILY.into(), DEFAULT_FONT_STYLE.into())), false),
|
DocumentInputType::value("Font", TaggedValue::Font(Font::new(DEFAULT_FONT_FAMILY.into(), DEFAULT_FONT_STYLE.into())), false),
|
||||||
DocumentInputType::value("Size", TaggedValue::F32(24.), false),
|
DocumentInputType::value("Size", TaggedValue::F64(24.), false),
|
||||||
],
|
],
|
||||||
outputs: vec![DocumentOutputType::new("Vector", FrontendGraphDataType::Subpath)],
|
outputs: vec![DocumentOutputType::new("Vector", FrontendGraphDataType::Subpath)],
|
||||||
properties: node_properties::node_section_font,
|
properties: node_properties::node_section_font,
|
||||||
|
@ -2020,7 +2020,7 @@ pub fn new_vector_network(subpaths: Vec<bezier_rs::Subpath<uuid::ManipulatorGrou
|
||||||
network
|
network
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_text_network(text: String, font: Font, size: f32) -> NodeNetwork {
|
pub fn new_text_network(text: String, font: Font, size: f64) -> NodeNetwork {
|
||||||
let text_generator = resolve_document_node_type("Text").expect("Text node does not exist");
|
let text_generator = resolve_document_node_type("Text").expect("Text node does not exist");
|
||||||
let transform = resolve_document_node_type("Transform").expect("Transform node does not exist");
|
let transform = resolve_document_node_type("Transform").expect("Transform node does not exist");
|
||||||
let fill = resolve_document_node_type("Fill").expect("Fill node does not exist");
|
let fill = resolve_document_node_type("Fill").expect("Fill node does not exist");
|
||||||
|
@ -2037,7 +2037,7 @@ pub fn new_text_network(text: String, font: Font, size: f32) -> NodeNetwork {
|
||||||
NodeInput::Network(concrete!(WasmEditorApi)),
|
NodeInput::Network(concrete!(WasmEditorApi)),
|
||||||
NodeInput::value(TaggedValue::String(text), false),
|
NodeInput::value(TaggedValue::String(text), false),
|
||||||
NodeInput::value(TaggedValue::Font(font), false),
|
NodeInput::value(TaggedValue::Font(font), false),
|
||||||
NodeInput::value(TaggedValue::F32(size), false),
|
NodeInput::value(TaggedValue::F64(size), false),
|
||||||
],
|
],
|
||||||
DocumentNodeMetadata::position((0, 4)),
|
DocumentNodeMetadata::position((0, 4)),
|
||||||
),
|
),
|
||||||
|
|
|
@ -330,7 +330,7 @@ impl TextToolData {
|
||||||
else if let Some(editing_text) = self.editing_text.as_ref().filter(|_| state == TextToolFsmState::Ready) {
|
else if let Some(editing_text) = self.editing_text.as_ref().filter(|_| state == TextToolFsmState::Ready) {
|
||||||
responses.add(DocumentMessage::StartTransaction);
|
responses.add(DocumentMessage::StartTransaction);
|
||||||
|
|
||||||
let network = new_text_network(String::new(), editing_text.font.clone(), editing_text.font_size as f32);
|
let network = new_text_network(String::new(), editing_text.font.clone(), editing_text.font_size);
|
||||||
|
|
||||||
responses.add(Operation::AddFrame {
|
responses.add(Operation::AddFrame {
|
||||||
path: self.layer_path.clone(),
|
path: self.layer_path.clone(),
|
||||||
|
|
|
@ -15,7 +15,7 @@ pub struct TextGenerator<Text, FontName, Size> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[node_fn(TextGenerator)]
|
#[node_fn(TextGenerator)]
|
||||||
fn generate_text<'a: 'input, T>(editor: EditorApi<'a, T>, text: String, font_name: Font, font_size: f32) -> crate::vector::VectorData {
|
fn generate_text<'a: 'input, T>(editor: EditorApi<'a, T>, text: String, font_name: Font, font_size: f64) -> crate::vector::VectorData {
|
||||||
let buzz_face = editor.font_cache.get(&font_name).map(|data| load_face(data));
|
let buzz_face = editor.font_cache.get(&font_name).map(|data| load_face(data));
|
||||||
crate::vector::VectorData::from_subpaths(to_path(&text, buzz_face, font_size as f64, None))
|
crate::vector::VectorData::from_subpaths(to_path(&text, buzz_face, font_size as f64, None))
|
||||||
}
|
}
|
||||||
|
|
|
@ -532,7 +532,7 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
|
||||||
input: Vec<graphene_core::vector::bezier_rs::Subpath<graphene_core::uuid::ManipulatorGroupId>>,
|
input: Vec<graphene_core::vector::bezier_rs::Subpath<graphene_core::uuid::ManipulatorGroupId>>,
|
||||||
params: [Vec<graphene_core::uuid::ManipulatorGroupId>]
|
params: [Vec<graphene_core::uuid::ManipulatorGroupId>]
|
||||||
),
|
),
|
||||||
register_node!(graphene_core::text::TextGenerator<_, _, _>, input: WasmEditorApi, params: [String, graphene_core::text::Font, f32]),
|
register_node!(graphene_core::text::TextGenerator<_, _, _>, input: WasmEditorApi, params: [String, graphene_core::text::Font, f64]),
|
||||||
register_node!(graphene_std::brush::VectorPointsNode, input: VectorData, params: []),
|
register_node!(graphene_std::brush::VectorPointsNode, input: VectorData, params: []),
|
||||||
register_node!(graphene_core::ExtractImageFrame, input: WasmEditorApi, params: []),
|
register_node!(graphene_core::ExtractImageFrame, input: WasmEditorApi, params: []),
|
||||||
register_node!(graphene_core::ConstructLayerNode<_, _, _, _, _, _, _>, input: graphene_core::vector::VectorData, params: [String, BlendMode, f32, bool, bool, bool, graphene_core::GraphicGroup]),
|
register_node!(graphene_core::ConstructLayerNode<_, _, _, _, _, _, _>, input: graphene_core::vector::VectorData, params: [String, BlendMode, f32, bool, bool, bool, graphene_core::GraphicGroup]),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue