mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-02 02:58:13 +08:00
@@ -92,7 +92,7 @@ pub enum GraphOperationMessage {
|
|||||||
id: NodeId,
|
id: NodeId,
|
||||||
text: String,
|
text: String,
|
||||||
font: Font,
|
font: Font,
|
||||||
size: f64,
|
size: f32,
|
||||||
parent: LayerNodeIdentifier,
|
parent: LayerNodeIdentifier,
|
||||||
insert_index: isize,
|
insert_index: isize,
|
||||||
},
|
},
|
||||||
|
|||||||
+2
-2
@@ -205,13 +205,13 @@ impl<'a> ModifyInputsContext<'a> {
|
|||||||
self.responses.add(NodeGraphMessage::SendGraph { should_rerender: true });
|
self.responses.add(NodeGraphMessage::SendGraph { should_rerender: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn insert_text(&mut self, text: String, font: Font, size: f64, layer: NodeId) {
|
fn insert_text(&mut self, text: String, font: Font, size: f32, layer: NodeId) {
|
||||||
let text = resolve_document_node_type("Text").expect("Text node does not exist").to_document_node(
|
let text = resolve_document_node_type("Text").expect("Text node does not exist").to_document_node(
|
||||||
[
|
[
|
||||||
NodeInput::Network(graph_craft::concrete!(graphene_std::wasm_application_io::WasmEditorApi)),
|
NodeInput::Network(graph_craft::concrete!(graphene_std::wasm_application_io::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::F64(size), false),
|
NodeInput::value(TaggedValue::F32(size), false),
|
||||||
],
|
],
|
||||||
Default::default(),
|
Default::default(),
|
||||||
);
|
);
|
||||||
|
|||||||
+1
-1
@@ -2483,7 +2483,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||||||
NodeInput::Network(concrete!(application_io::EditorApi<graphene_std::wasm_application_io::WasmApplicationIo>)),
|
NodeInput::Network(concrete!(application_io::EditorApi<graphene_std::wasm_application_io::WasmApplicationIo>)),
|
||||||
NodeInput::Network(concrete!(String)),
|
NodeInput::Network(concrete!(String)),
|
||||||
NodeInput::Network(concrete!(graphene_core::text::Font)),
|
NodeInput::Network(concrete!(graphene_core::text::Font)),
|
||||||
NodeInput::Network(concrete!(f64)),
|
NodeInput::Network(concrete!(f32)),
|
||||||
],
|
],
|
||||||
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::text::TextGeneratorNode<_, _, _>")),
|
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::text::TextGeneratorNode<_, _, _>")),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ pub fn get_text_id(layer: LayerNodeIdentifier, document_network: &NodeNetwork) -
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Gets properties from the Text node
|
/// Gets properties from the Text node
|
||||||
pub fn get_text(layer: LayerNodeIdentifier, document_network: &NodeNetwork) -> Option<(&String, &Font, f64)> {
|
pub fn get_text(layer: LayerNodeIdentifier, document_network: &NodeNetwork) -> Option<(&String, &Font, f32)> {
|
||||||
let inputs = NodeGraphLayer::new(layer, document_network)?.find_node_inputs("Text")?;
|
let inputs = NodeGraphLayer::new(layer, document_network)?.find_node_inputs("Text")?;
|
||||||
let NodeInput::Value {
|
let NodeInput::Value {
|
||||||
tagged_value: TaggedValue::String(text),
|
tagged_value: TaggedValue::String(text),
|
||||||
@@ -171,7 +171,7 @@ pub fn get_text(layer: LayerNodeIdentifier, document_network: &NodeNetwork) -> O
|
|||||||
};
|
};
|
||||||
|
|
||||||
let NodeInput::Value {
|
let NodeInput::Value {
|
||||||
tagged_value: TaggedValue::F64(font_size),
|
tagged_value: TaggedValue::F32(font_size),
|
||||||
..
|
..
|
||||||
} = inputs[3]
|
} = inputs[3]
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ enum TextToolFsmState {
|
|||||||
pub struct EditingText {
|
pub struct EditingText {
|
||||||
text: String,
|
text: String,
|
||||||
font: Font,
|
font: Font,
|
||||||
font_size: f64,
|
font_size: f32,
|
||||||
color: Option<Color>,
|
color: Option<Color>,
|
||||||
transform: DAffine2,
|
transform: DAffine2,
|
||||||
}
|
}
|
||||||
@@ -235,7 +235,7 @@ impl TextToolData {
|
|||||||
responses.add(FrontendMessage::DisplayEditableTextbox {
|
responses.add(FrontendMessage::DisplayEditableTextbox {
|
||||||
text: editing_text.text.clone(),
|
text: editing_text.text.clone(),
|
||||||
line_width: None,
|
line_width: None,
|
||||||
font_size: editing_text.font_size,
|
font_size: editing_text.font_size as f64,
|
||||||
color: editing_text.color.unwrap_or(Color::BLACK),
|
color: editing_text.color.unwrap_or(Color::BLACK),
|
||||||
url: font_cache.get_preview_url(&editing_text.font).cloned().unwrap_or_default(),
|
url: font_cache.get_preview_url(&editing_text.font).cloned().unwrap_or_default(),
|
||||||
transform: editing_text.transform.to_cols_array(),
|
transform: editing_text.transform.to_cols_array(),
|
||||||
@@ -326,7 +326,7 @@ impl TextToolData {
|
|||||||
fn get_bounds(&self, text: &str, font_cache: &FontCache) -> Option<[DVec2; 2]> {
|
fn get_bounds(&self, text: &str, font_cache: &FontCache) -> Option<[DVec2; 2]> {
|
||||||
let editing_text = self.editing_text.as_ref()?;
|
let editing_text = self.editing_text.as_ref()?;
|
||||||
let buzz_face = font_cache.get(&editing_text.font).map(|data| load_face(data));
|
let buzz_face = font_cache.get(&editing_text.font).map(|data| load_face(data));
|
||||||
let subpaths = graphene_core::text::to_path(text, buzz_face, editing_text.font_size, None);
|
let subpaths = graphene_core::text::to_path(text, buzz_face, editing_text.font_size as f64, None);
|
||||||
let bounds = subpaths.iter().filter_map(|subpath| subpath.bounding_box());
|
let bounds = subpaths.iter().filter_map(|subpath| subpath.bounding_box());
|
||||||
let combined_bounds = bounds.reduce(|a, b| [a[0].min(b[0]), a[1].max(b[1])]).unwrap_or_default();
|
let combined_bounds = bounds.reduce(|a, b| [a[0].min(b[0]), a[1].max(b[1])]).unwrap_or_default();
|
||||||
Some(combined_bounds)
|
Some(combined_bounds)
|
||||||
@@ -381,7 +381,7 @@ impl Fsm for TextToolFsmState {
|
|||||||
});
|
});
|
||||||
if let Some(editing_text) = tool_data.editing_text.as_ref() {
|
if let Some(editing_text) = tool_data.editing_text.as_ref() {
|
||||||
let buzz_face = font_cache.get(&editing_text.font).map(|data| load_face(data));
|
let buzz_face = font_cache.get(&editing_text.font).map(|data| load_face(data));
|
||||||
let far = graphene_core::text::bounding_box(&tool_data.new_text, buzz_face, editing_text.font_size, None);
|
let far = graphene_core::text::bounding_box(&tool_data.new_text, buzz_face, editing_text.font_size as f64, None);
|
||||||
if far.x != 0. && far.y != 0. {
|
if far.x != 0. && far.y != 0. {
|
||||||
let quad = Quad::from_box([DVec2::ZERO, far]);
|
let quad = Quad::from_box([DVec2::ZERO, far]);
|
||||||
let transformed_quad = document.metadata().transform_to_viewport(tool_data.layer) * quad;
|
let transformed_quad = document.metadata().transform_to_viewport(tool_data.layer) * quad;
|
||||||
@@ -397,7 +397,7 @@ impl Fsm for TextToolFsmState {
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let buzz_face = font_cache.get(font).map(|data| load_face(data));
|
let buzz_face = font_cache.get(font).map(|data| load_face(data));
|
||||||
let far = graphene_core::text::bounding_box(text, buzz_face, font_size, None);
|
let far = graphene_core::text::bounding_box(text, buzz_face, font_size as f64, None);
|
||||||
let quad = Quad::from_box([DVec2::ZERO, far]);
|
let quad = Quad::from_box([DVec2::ZERO, far]);
|
||||||
let multiplied = document.metadata().transform_to_viewport(layer) * quad;
|
let multiplied = document.metadata().transform_to_viewport(layer) * quad;
|
||||||
overlay_context.quad(multiplied);
|
overlay_context.quad(multiplied);
|
||||||
@@ -409,7 +409,7 @@ impl Fsm for TextToolFsmState {
|
|||||||
tool_data.editing_text = Some(EditingText {
|
tool_data.editing_text = Some(EditingText {
|
||||||
text: String::new(),
|
text: String::new(),
|
||||||
transform: DAffine2::from_translation(input.mouse.position),
|
transform: DAffine2::from_translation(input.mouse.position),
|
||||||
font_size: tool_options.font_size as f64,
|
font_size: tool_options.font_size as f32,
|
||||||
font: Font::new(tool_options.font_name.clone(), tool_options.font_style.clone()),
|
font: Font::new(tool_options.font_name.clone(), tool_options.font_style.clone()),
|
||||||
color: tool_options.fill.active_color(),
|
color: tool_options.fill.active_color(),
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user