@@ -21,7 +21,6 @@ use graphene_std::extract_xy::XY;
2121use graphene_std:: raster:: { CellularDistanceFunction , CellularReturnType , Color , DomainWarpType , FractalType , NoiseType , RedGreenBlueAlpha } ;
2222use graphene_std:: raster_types:: { CPU , Raster } ;
2323use graphene_std:: table:: Table ;
24- use graphene_std:: text:: { Font , TypesettingConfig } ;
2524#[ allow( unused_imports) ]
2625use graphene_std:: transform:: Footprint ;
2726use graphene_std:: vector:: Vector ;
@@ -1653,103 +1652,6 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
16531652 properties: None ,
16541653 } ,
16551654 // TODO: Auto-generate this from its proto node macro
1656- DocumentNodeDefinition {
1657- identifier: "Text" ,
1658- category: "Text" ,
1659- node_template: NodeTemplate {
1660- document_node: DocumentNode {
1661- implementation: DocumentNodeImplementation :: ProtoNode ( text:: text:: IDENTIFIER ) ,
1662- inputs: vec![
1663- NodeInput :: scope( "editor-api" ) ,
1664- NodeInput :: value( TaggedValue :: String ( "Lorem ipsum" . to_string( ) ) , false ) ,
1665- NodeInput :: value(
1666- TaggedValue :: Font ( Font :: new( graphene_std:: consts:: DEFAULT_FONT_FAMILY . into( ) , graphene_std:: consts:: DEFAULT_FONT_STYLE . into( ) ) ) ,
1667- false ,
1668- ) ,
1669- NodeInput :: value( TaggedValue :: F64 ( TypesettingConfig :: default ( ) . font_size) , false ) ,
1670- NodeInput :: value( TaggedValue :: F64 ( TypesettingConfig :: default ( ) . line_height_ratio) , false ) ,
1671- NodeInput :: value( TaggedValue :: F64 ( TypesettingConfig :: default ( ) . character_spacing) , false ) ,
1672- NodeInput :: value( TaggedValue :: OptionalF64 ( TypesettingConfig :: default ( ) . max_width) , false ) ,
1673- NodeInput :: value( TaggedValue :: OptionalF64 ( TypesettingConfig :: default ( ) . max_height) , false ) ,
1674- NodeInput :: value( TaggedValue :: F64 ( TypesettingConfig :: default ( ) . tilt) , false ) ,
1675- NodeInput :: value( TaggedValue :: TextAlign ( text:: TextAlign :: default ( ) ) , false ) ,
1676- NodeInput :: value( TaggedValue :: Bool ( false ) , false ) ,
1677- ] ,
1678- ..Default :: default ( )
1679- } ,
1680- persistent_node_metadata: DocumentNodePersistentMetadata {
1681- input_metadata: vec![
1682- ( "Editor API" , "TODO" ) . into( ) ,
1683- InputMetadata :: with_name_description_override( "Text" , "TODO" , WidgetOverride :: Custom ( "text_area" . to_string( ) ) ) ,
1684- InputMetadata :: with_name_description_override( "Font" , "TODO" , WidgetOverride :: Custom ( "text_font" . to_string( ) ) ) ,
1685- InputMetadata :: with_name_description_override(
1686- "Size" ,
1687- "TODO" ,
1688- WidgetOverride :: Number ( NumberInputSettings {
1689- unit: Some ( " px" . to_string( ) ) ,
1690- min: Some ( 1. ) ,
1691- ..Default :: default ( )
1692- } ) ,
1693- ) ,
1694- InputMetadata :: with_name_description_override(
1695- "Line Height" ,
1696- "TODO" ,
1697- WidgetOverride :: Number ( NumberInputSettings {
1698- unit: Some ( "x" . to_string( ) ) ,
1699- min: Some ( 0. ) ,
1700- step: Some ( 0.1 ) ,
1701- ..Default :: default ( )
1702- } ) ,
1703- ) ,
1704- InputMetadata :: with_name_description_override(
1705- "Character Spacing" ,
1706- "TODO" ,
1707- WidgetOverride :: Number ( NumberInputSettings {
1708- unit: Some ( " px" . to_string( ) ) ,
1709- step: Some ( 0.1 ) ,
1710- ..Default :: default ( )
1711- } ) ,
1712- ) ,
1713- InputMetadata :: with_name_description_override(
1714- "Max Width" ,
1715- "TODO" ,
1716- WidgetOverride :: Number ( NumberInputSettings {
1717- unit: Some ( " px" . to_string( ) ) ,
1718- min: Some ( 1. ) ,
1719- blank_assist: false ,
1720- ..Default :: default ( )
1721- } ) ,
1722- ) ,
1723- InputMetadata :: with_name_description_override(
1724- "Max Height" ,
1725- "TODO" ,
1726- WidgetOverride :: Number ( NumberInputSettings {
1727- unit: Some ( " px" . to_string( ) ) ,
1728- min: Some ( 1. ) ,
1729- blank_assist: false ,
1730- ..Default :: default ( )
1731- } ) ,
1732- ) ,
1733- InputMetadata :: with_name_description_override(
1734- "Tilt" ,
1735- "Faux italic." ,
1736- WidgetOverride :: Number ( NumberInputSettings {
1737- min: Some ( -85. ) ,
1738- max: Some ( 85. ) ,
1739- unit: Some ( "°" . to_string( ) ) ,
1740- ..Default :: default ( )
1741- } ) ,
1742- ) ,
1743- InputMetadata :: with_name_description_override( "Align" , "TODO" , WidgetOverride :: Custom ( "text_align" . to_string( ) ) ) ,
1744- ( "Per-Glyph Instances" , "Splits each text glyph into its own row in the table of vector geometry." ) . into( ) ,
1745- ] ,
1746- output_names: vec![ "Vector" . to_string( ) ] ,
1747- ..Default :: default ( )
1748- } ,
1749- } ,
1750- description: Cow :: Borrowed ( "TODO" ) ,
1751- properties: None ,
1752- } ,
17531655 DocumentNodeDefinition {
17541656 identifier: "Transform" ,
17551657 category: "Math: Transform" ,
@@ -2297,6 +2199,43 @@ fn static_input_properties() -> InputProperties {
22972199 } ] )
22982200 } ) ,
22992201 ) ;
2202+ map. insert (
2203+ // The custom number input settings are only available on proto nodes
2204+ "optional_f64" . to_string ( ) ,
2205+ Box :: new ( |node_id, index, context| {
2206+ let node_metadata = registry:: NODE_METADATA . lock ( ) . unwrap ( ) ;
2207+ let mut number_input = NumberInput :: default ( ) ;
2208+ if let Some ( field) = context
2209+ . network_interface
2210+ . implementation ( & node_id, context. selection_network_path )
2211+ . and_then ( |implementation| if let DocumentNodeImplementation :: ProtoNode ( id) = implementation { Some ( id) } else { None } )
2212+ . and_then ( |proto_node_identifier| node_metadata. get ( proto_node_identifier) )
2213+ . and_then ( |metadata| metadata. fields . get ( index) )
2214+ {
2215+ if let Some ( unit) = field. unit {
2216+ number_input = number_input. unit ( unit) ;
2217+ }
2218+ if let Some ( number_min) = field. number_min {
2219+ number_input = number_input. min ( number_min) ;
2220+ }
2221+ if let Some ( number_max) = field. number_max {
2222+ number_input = number_input. max ( number_max) ;
2223+ }
2224+ if let Some ( ( range_min, range_max) ) = field. number_mode_range {
2225+ number_input = number_input. range_min ( Some ( range_min) ) ;
2226+ number_input = number_input. range_max ( Some ( range_max) ) ;
2227+ }
2228+ number_input = number_input. is_integer ( false ) ;
2229+ if let Some ( number_step) = field. number_step {
2230+ number_input = number_input. step ( number_step) ;
2231+ }
2232+ } ;
2233+ Ok ( vec ! [ LayoutGroup :: Row {
2234+ // NOTE: The bool input MUST be at the input index directly before the f64 input!
2235+ widgets: node_properties:: optional_f64_widget( ParameterWidgetsInfo :: new( node_id, index, false , context) , index - 1 , number_input) ,
2236+ } ] )
2237+ } ) ,
2238+ ) ;
23002239 map. insert (
23012240 "vec2" . to_string ( ) ,
23022241 Box :: new ( |node_id, index, context| {
0 commit comments