@@ -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,30 @@ fn static_input_properties() -> InputProperties {
22972199 } ] )
22982200 } ) ,
22992201 ) ;
2202+ map. insert (
2203+ "optional_number" . to_string ( ) ,
2204+ Box :: new ( |node_id, index, context| {
2205+ // TODO: Don't wipe out the previously set value (setting it back to the default of 100) when reenabling this checkbox back to Some from None
2206+ let toggle_enabled = move |checkbox_input : & CheckboxInput | TaggedValue :: OptionalF64 ( if checkbox_input. checked { Some ( 100. ) } else { None } ) ;
2207+ Ok ( vec ! [
2208+ Separator :: new( SeparatorStyle :: Unrelated ) . widget_instance( ) ,
2209+ Separator :: new( SeparatorStyle :: Related ) . widget_instance( ) ,
2210+ // The checkbox toggles if the value is Some or None
2211+ CheckboxInput :: new( x. is_some( ) )
2212+ . on_update( update_value( toggle_enabled, node_id, index) )
2213+ . on_commit( commit_value)
2214+ . widget_instance( ) ,
2215+ Separator :: new( SeparatorStyle :: Related ) . widget_instance( ) ,
2216+ Separator :: new( SeparatorStyle :: Unrelated ) . widget_instance( ) ,
2217+ number_props
2218+ . value( x)
2219+ . on_update( update_value( move |x: & NumberInput | TaggedValue :: OptionalF64 ( x. value) , node_id, index) )
2220+ . disabled( x. is_none( ) )
2221+ . on_commit( commit_value)
2222+ . widget_instance( ) ,
2223+ ] )
2224+ } ) ,
2225+ ) ;
23002226 map. insert (
23012227 "vec2" . to_string ( ) ,
23022228 Box :: new ( |node_id, index, context| {
0 commit comments