Skip to content

Commit 5b5b369

Browse files
authored
Make selected Text category nodes show a multi-line text area instead of one-line text field (#2816)
* Make String Value node input a TextArea Signed-off-by: ezbaze <[email protected]> * Replace link to Tauri Signed-off-by: ezbaze <[email protected]> * Make String Concatenate node & Replace String node inputs into a TextArea Signed-off-by: ezbaze <[email protected]> --------- Signed-off-by: ezbaze <[email protected]>
1 parent f57163c commit 5b5b369

File tree

5 files changed

+9
-5
lines changed

5 files changed

+9
-5
lines changed

editor/src/messages/portfolio/document/node_graph/node_properties.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ pub(crate) fn property_from_type(
162162
Some("SeedValue") => number_widget(default_info, number_input.int().min(min(0.))).into(),
163163
Some("Resolution") => coordinate_widget(default_info, "W", "H", unit.unwrap_or(" px"), Some(64.)),
164164
Some("PixelSize") => coordinate_widget(default_info, "X", "Y", unit.unwrap_or(" px"), None),
165+
Some("TextArea") => text_area_widget(default_info).into(),
165166

166167
// For all other types, use TypeId-based matching
167168
_ => {

frontend/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The Graphite frontend is a web app that provides the presentation for the editor. It displays the GUI based on state from the backend and provides users with interactive widgets that send updates to the backend, which is the source of truth for state information. The frontend is built out of reactive components using the [Svelte](https://svelte.dev/) framework. The backend is written in Rust and compiled to WebAssembly (WASM) to be run in the browser alongside the JS code.
44

5-
For lack of other options, the frontend is currently written as a web app. Maintaining web compatibility will always be a requirement, but the long-term plan is to port this code to a Rust-based native GUI framework, either written by the Rust community or created by our project if necessary. As a medium-term compromise, we may wrap the web-based frontend in a desktop webview windowing solution like Electron (probably not) or [Tauri](https://tauri.studio/) (probably).
5+
For lack of other options, the frontend is currently written as a web app. Maintaining web compatibility will always be a requirement, but the long-term plan is to port this code to a Rust-based native GUI framework, either written by the Rust community or created by our project if necessary. As a medium-term compromise, we may wrap the web-based frontend in a desktop webview windowing solution like Electron (probably not) or [Tauri](https://tauri.app/) (probably).
66

77
## Bundled assets: `assets/`
88

node-graph/gcore/src/logic.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::Color;
33
use crate::GraphicElement;
44
use crate::GraphicGroupTable;
55
use crate::gradient::GradientStops;
6+
use crate::graphene_core::registry::types::TextArea;
67
use crate::raster_types::{CPU, GPU, RasterDataTable};
78
use crate::vector::VectorDataTable;
89
use crate::{Context, Ctx};
@@ -14,12 +15,12 @@ fn to_string<T: std::fmt::Debug>(_: impl Ctx, #[implementations(String, bool, f6
1415
}
1516

1617
#[node_macro::node(category("Text"))]
17-
fn string_concatenate(_: impl Ctx, #[implementations(String)] first: String, #[implementations(String)] second: String) -> String {
18+
fn string_concatenate(_: impl Ctx, #[implementations(String)] first: String, second: TextArea) -> String {
1819
first.clone() + &second
1920
}
2021

2122
#[node_macro::node(category("Text"))]
22-
fn string_replace(_: impl Ctx, #[implementations(String)] string: String, from: String, to: String) -> String {
23+
fn string_replace(_: impl Ctx, #[implementations(String)] string: String, from: TextArea, to: TextArea) -> String {
2324
string.replace(&from, &to)
2425
}
2526

node-graph/gcore/src/registry.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ pub mod types {
3030
pub type Resolution = glam::UVec2;
3131
/// DVec2 with px unit
3232
pub type PixelSize = glam::DVec2;
33+
/// String with one or more than one line
34+
pub type TextArea = String;
3335
}
3436

3537
// Translation struct between macro and definition

node-graph/gmath-nodes/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use glam::DVec2;
22
use graphene_core::gradient::GradientStops;
3-
use graphene_core::registry::types::{Fraction, Percentage};
3+
use graphene_core::registry::types::{Fraction, Percentage, TextArea};
44
use graphene_core::{Color, Ctx, num_traits};
55
use log::warn;
66
use math_parser::ast;
@@ -603,7 +603,7 @@ fn gradient_value(_: impl Ctx, _primary: (), gradient: GradientStops) -> Gradien
603603

604604
/// Constructs a string value which may be set to any plain text.
605605
#[node_macro::node(category("Value"))]
606-
fn string_value(_: impl Ctx, _primary: (), string: String) -> String {
606+
fn string_value(_: impl Ctx, _primary: (), string: TextArea) -> String {
607607
string
608608
}
609609

0 commit comments

Comments
 (0)