Skip to content

Commit bdad9d0

Browse files
Keavonjackfruitdog
authored andcommitted
Add tooltip documentation to the Text node and tidy up node catalog categorization (GraphiteEditor#3645)
* Add more node doc comments * Tidy up node categories
1 parent b4810f2 commit bdad9d0

10 files changed

Lines changed: 40 additions & 18 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,7 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
14521452
#[cfg(feature = "gpu")]
14531453
DocumentNodeDefinition {
14541454
identifier: "Upload Texture",
1455-
category: "Debug: GPU",
1455+
category: "Debug",
14561456
node_template: NodeTemplate {
14571457
document_node: DocumentNode {
14581458
implementation: DocumentNodeImplementation::Network(NodeNetwork {

node-graph/libraries/wgpu-executor/src/texture_conversion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ impl<'i> Convert<Raster<CPU>, &'i WgpuExecutor> for Raster<GPU> {
254254
}
255255
}
256256

257-
/// Uploads an raster texture from the CPU to the GPU. This Is now deprecated and the Convert node should be used in the future.
257+
/// Uploads an raster texture from the CPU to the GPU. This is now deprecated and the Convert node should be used in the future.
258258
///
259259
/// Accepts either individual raster data or a table of raster elements and converts it to the GPU format using the WgpuExecutor's device and queue.
260260
#[node_macro::node(category(""))]

node-graph/nodes/brush/src/brush.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl<P: Pixel + Alpha> Sample for BrushStampGenerator<P> {
6060
/// Controls the brush shape with diameter and hardness, plus color and opacity (via flow).
6161
/// The feather exponent is calculated from hardness to determine edge softness.
6262
/// Used internally to create the brush texture before stamping it repeatedly along a stroke path.
63-
#[node_macro::node(skip_impl)]
63+
#[node_macro::node(category(""), skip_impl)]
6464
fn brush_stamp_generator(#[unit(" px")] diameter: f64, color: Color, hardness: f64, flow: f64) -> BrushStampGenerator<Color> {
6565
// Diameter
6666
let radius = diameter / 2.;
@@ -80,7 +80,7 @@ fn brush_stamp_generator(#[unit(" px")] diameter: f64, color: Color, hardness: f
8080
}
8181

8282
/// Used to efficiently paint brush strokes. Applies the same texture repeatedly at different positions with proper blending and boundary handling.
83-
#[node_macro::node(skip_impl)]
83+
#[node_macro::node(category(""), skip_impl)]
8484
fn blit<BlendFn>(mut target: Table<Raster<CPU>>, texture: Raster<CPU>, positions: Vec<DVec2>, blend_mode: BlendFn) -> Table<Raster<CPU>>
8585
where
8686
BlendFn: for<'any_input> Node<'any_input, (Color, Color), Output = Color>,

node-graph/nodes/gcore/src/context_modification.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use raster_types::{CPU, GPU, Raster};
1010

1111
/// Filters out what should be unused components of the context based on the specified requirements.
1212
/// This node is inserted by the compiler to "zero out" unused context components.
13-
#[node_macro::node(category("Internal"))]
13+
#[node_macro::node(category(""))]
1414
async fn context_modification<T>(
1515
ctx: impl Ctx + CloneVarArgs + ExtractAll,
1616
/// The data to pass through, evaluated with the stripped down context.

node-graph/nodes/gcore/src/ops.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ pub use core_types::ops::TypeNode;
77
// TODO: Rename to "Passthrough" and make this the node that users use, not the one defined in document_node_definitions.rs
88
/// Passes-through the input value without changing it.
99
/// This is useful for rerouting wires for organization purposes.
10-
#[node_macro::node(skip_impl)]
10+
#[node_macro::node(category(""), skip_impl)]
1111
fn identity<'i, T: 'i + Send>(value: T) -> T {
1212
value
1313
}
1414

15-
#[node_macro::node(skip_impl)]
15+
#[node_macro::node(category(""), skip_impl)]
1616
fn into<'i, T: 'i + Send + Into<O>, O: 'i + Send>(_: impl Ctx, value: T, _out_ty: PhantomData<O>) -> O {
1717
value.into()
1818
}
1919

20-
#[node_macro::node(skip_impl)]
20+
#[node_macro::node(category(""), skip_impl)]
2121
async fn convert<'i, T: 'i + Send + Convert<O, C>, O: 'i + Send, C: 'i + Send>(ctx: impl Ctx + ExtractFootprint, value: T, converter: C, _out_ty: PhantomData<O>) -> O {
2222
value.convert(*ctx.try_footprint().unwrap_or(&Footprint::DEFAULT), converter).await
2323
}

node-graph/nodes/gstd/src/text.rs

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,63 @@ use graph_craft::wasm_application_io::WasmEditorApi;
33
use graphic_types::Vector;
44
pub use text_nodes::*;
55

6+
/// Draws a text string as vector geometry with a choice of font and styling.
67
#[node_macro::node(category("Text"))]
78
fn text<'i: 'n>(
89
_: impl Ctx,
9-
#[scope("editor-api")] editor_resources: &'i WasmEditorApi,
10+
/// The Graphite editor's source for global font resources.
11+
#[scope("editor-api")]
12+
editor_resources: &'i WasmEditorApi,
13+
/// The text content to be drawn.
1014
#[widget(ParsedWidgetOverride::Custom = "text_area")]
1115
#[default("Lorem ipsum")]
1216
text: String,
13-
#[widget(ParsedWidgetOverride::Custom = "text_font")] font: Font,
17+
/// The typeface used to draw the text.
18+
#[widget(ParsedWidgetOverride::Custom = "text_font")]
19+
font: Font,
20+
/// The font size used to draw the text.
1421
#[unit(" px")]
1522
#[default(24.)]
1623
#[hard_min(1.)]
1724
size: f64,
25+
/// The line height ratio, relative to the font size. Each line is drawn lower than its previous line by the distance of *Size* × *Line Height*.
26+
///
27+
/// 0 means all lines overlap. 1 means all lines are spaced by just the font size. 1.2 is a common default for readable text. 2 means double-spaced text.
1828
#[unit("x")]
1929
#[hard_min(0.)]
2030
#[step(0.1)]
2131
#[default(1.2)]
2232
line_height: f64,
33+
/// Additional spacing, in pixels, added between each character.
2334
#[unit(" px")]
2435
#[step(0.1)]
2536
character_spacing: f64,
26-
#[widget(ParsedWidgetOverride::Hidden)] has_max_width: bool,
37+
/// Whether the *Max Width* property is enabled so that lines can wrap to fit its specified block width.
38+
#[widget(ParsedWidgetOverride::Hidden)]
39+
has_max_width: bool,
40+
/// The maximum width that the text block can occupy before wrapping to a new line. Otherwise, lines do not wrap.
2741
#[unit(" px")]
2842
#[hard_min(1.)]
2943
#[widget(ParsedWidgetOverride::Custom = "optional_f64")]
3044
max_width: f64,
31-
#[widget(ParsedWidgetOverride::Hidden)] has_max_height: bool,
45+
/// Whether the *Max Height* property is enabled so that lines beyond it are not drawn.
46+
#[widget(ParsedWidgetOverride::Hidden)]
47+
has_max_height: bool,
48+
/// The maximum height that the text block can occupy. Excess lines are not drawn.
3249
#[unit(" px")]
3350
#[hard_min(1.)]
3451
#[widget(ParsedWidgetOverride::Custom = "optional_f64")]
3552
max_height: f64,
53+
/// The angle of faux italic slant applied to each glyph.
3654
#[unit("°")]
3755
#[hard_min(-85.)]
3856
#[hard_max(85.)]
3957
tilt: f64,
40-
#[widget(ParsedWidgetOverride::Custom = "text_align")] align: TextAlign,
58+
/// The horizontal alignment of each line of text within its surrounding box.
59+
/// To have an effect on a single line of text, *Max Width* must be set.
60+
#[widget(ParsedWidgetOverride::Custom = "text_align")]
61+
align: TextAlign,
62+
/// Whether to split every letterform into its own vector path element. Otherwise, a single compound path is produced.
4163
separate_glyph_elements: bool,
4264
) -> Table<Vector> {
4365
let typesetting = TypesettingConfig {

node-graph/nodes/gstd/src/wasm_application_io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use web_sys::{CanvasRenderingContext2d, HtmlCanvasElement};
2929

3030
/// Allocates GPU memory and a rendering context for vector-to-raster conversion.
3131
#[cfg(feature = "wgpu")]
32-
#[node_macro::node(category("Debug: GPU"))]
32+
#[node_macro::node(category(""))]
3333
async fn create_surface<'a: 'n>(_: impl Ctx, editor: &'a WasmEditorApi) -> Arc<WasmSurfaceHandle> {
3434
Arc::new(editor.application_io.as_ref().unwrap().create_window())
3535
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ fn vec2_value(_: impl Ctx, _primary: (), x: f64, y: f64) -> DVec2 {
758758

759759
/// Constructs a color value which may be set to any color, or no color.
760760
#[node_macro::node(category("Value"))]
761-
fn color_value(_: impl Ctx, _primary: (), #[default(Color::RED)] color: Table<Color>) -> Table<Color> {
761+
fn color_value(_: impl Ctx, _primary: (), #[default(Color::BLACK)] color: Table<Color>) -> Table<Color> {
762762
color
763763
}
764764

node-graph/nodes/raster/src/std_nodes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl From<std::io::Error> for Error {
2929
}
3030
}
3131

32-
#[node_macro::node(category("Debug: Raster"))]
32+
#[node_macro::node(category("Debug"))]
3333
pub fn sample_image(ctx: impl ExtractFootprint + Clone + Send, image_frame: Table<Raster<CPU>>) -> Table<Raster<CPU>> {
3434
image_frame
3535
.into_iter()
@@ -279,7 +279,7 @@ pub fn extend_image_to_bounds(_: impl Ctx, image: Table<Raster<CPU>>, bounds: DA
279279
.collect()
280280
}
281281

282-
#[node_macro::node(category("Debug: Raster"))]
282+
#[node_macro::node(category("Debug"))]
283283
pub fn empty_image(_: impl Ctx, transform: DAffine2, color: Table<Color>) -> Table<Raster<CPU>> {
284284
let width = transform.transform_vector2(DVec2::new(1., 0.)).length() as u32;
285285
let height = transform.transform_vector2(DVec2::new(0., 1.)).length() as u32;

node-graph/nodes/vector/src/vector_nodes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ async fn stroke<V, L: IntoF64Vec>(
176176
/// The stroke color.
177177
#[default(Color::BLACK)]
178178
color: Table<Color>,
179-
/// The stroke weight.
179+
/// The stroke thickness.
180180
#[unit(" px")]
181181
#[default(2.)]
182182
weight: f64,

0 commit comments

Comments
 (0)