mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-19 02:48:12 +08:00
Add tooltip documentation to the Text node and tidy up node catalog categorization (#3645)
* Add more node doc comments * Tidy up node categories
This commit is contained in:
@@ -3,41 +3,63 @@ use graph_craft::wasm_application_io::WasmEditorApi;
|
||||
use graphic_types::Vector;
|
||||
pub use text_nodes::*;
|
||||
|
||||
/// Draws a text string as vector geometry with a choice of font and styling.
|
||||
#[node_macro::node(category("Text"))]
|
||||
fn text<'i: 'n>(
|
||||
_: impl Ctx,
|
||||
#[scope("editor-api")] editor_resources: &'i WasmEditorApi,
|
||||
/// The Graphite editor's source for global font resources.
|
||||
#[scope("editor-api")]
|
||||
editor_resources: &'i WasmEditorApi,
|
||||
/// The text content to be drawn.
|
||||
#[widget(ParsedWidgetOverride::Custom = "text_area")]
|
||||
#[default("Lorem ipsum")]
|
||||
text: String,
|
||||
#[widget(ParsedWidgetOverride::Custom = "text_font")] font: Font,
|
||||
/// The typeface used to draw the text.
|
||||
#[widget(ParsedWidgetOverride::Custom = "text_font")]
|
||||
font: Font,
|
||||
/// The font size used to draw the text.
|
||||
#[unit(" px")]
|
||||
#[default(24.)]
|
||||
#[hard_min(1.)]
|
||||
size: f64,
|
||||
/// 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*.
|
||||
///
|
||||
/// 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.
|
||||
#[unit("x")]
|
||||
#[hard_min(0.)]
|
||||
#[step(0.1)]
|
||||
#[default(1.2)]
|
||||
line_height: f64,
|
||||
/// Additional spacing, in pixels, added between each character.
|
||||
#[unit(" px")]
|
||||
#[step(0.1)]
|
||||
character_spacing: f64,
|
||||
#[widget(ParsedWidgetOverride::Hidden)] has_max_width: bool,
|
||||
/// Whether the *Max Width* property is enabled so that lines can wrap to fit its specified block width.
|
||||
#[widget(ParsedWidgetOverride::Hidden)]
|
||||
has_max_width: bool,
|
||||
/// The maximum width that the text block can occupy before wrapping to a new line. Otherwise, lines do not wrap.
|
||||
#[unit(" px")]
|
||||
#[hard_min(1.)]
|
||||
#[widget(ParsedWidgetOverride::Custom = "optional_f64")]
|
||||
max_width: f64,
|
||||
#[widget(ParsedWidgetOverride::Hidden)] has_max_height: bool,
|
||||
/// Whether the *Max Height* property is enabled so that lines beyond it are not drawn.
|
||||
#[widget(ParsedWidgetOverride::Hidden)]
|
||||
has_max_height: bool,
|
||||
/// The maximum height that the text block can occupy. Excess lines are not drawn.
|
||||
#[unit(" px")]
|
||||
#[hard_min(1.)]
|
||||
#[widget(ParsedWidgetOverride::Custom = "optional_f64")]
|
||||
max_height: f64,
|
||||
/// The angle of faux italic slant applied to each glyph.
|
||||
#[unit("°")]
|
||||
#[hard_min(-85.)]
|
||||
#[hard_max(85.)]
|
||||
tilt: f64,
|
||||
#[widget(ParsedWidgetOverride::Custom = "text_align")] align: TextAlign,
|
||||
/// The horizontal alignment of each line of text within its surrounding box.
|
||||
/// To have an effect on a single line of text, *Max Width* must be set.
|
||||
#[widget(ParsedWidgetOverride::Custom = "text_align")]
|
||||
align: TextAlign,
|
||||
/// Whether to split every letterform into its own vector path element. Otherwise, a single compound path is produced.
|
||||
separate_glyph_elements: bool,
|
||||
) -> Table<Vector> {
|
||||
let typesetting = TypesettingConfig {
|
||||
|
||||
@@ -29,7 +29,7 @@ use web_sys::{CanvasRenderingContext2d, HtmlCanvasElement};
|
||||
|
||||
/// Allocates GPU memory and a rendering context for vector-to-raster conversion.
|
||||
#[cfg(feature = "wgpu")]
|
||||
#[node_macro::node(category("Debug: GPU"))]
|
||||
#[node_macro::node(category(""))]
|
||||
async fn create_surface<'a: 'n>(_: impl Ctx, editor: &'a WasmEditorApi) -> Arc<WasmSurfaceHandle> {
|
||||
Arc::new(editor.application_io.as_ref().unwrap().create_window())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user