| 1 | use crate::comp::{ParamValue, vec2_lua}; |
| 2 | use crate::lua_value::{LuaKey, LuaTable, LuaValue}; |
| 3 | |
| 4 | pub(super) fn default_view_info_for_kind(kind: &str, pos: [f32; 2]) -> LuaTable { |
| 5 | let tag = match kind { |
| 6 | "PipeRouter" => "PipeRouterInfo", |
| 7 | "Underlay" => "UnderlayInfo", |
| 8 | "Note" | "StickyNote" => "StickyNoteInfo", |
| 9 | _ => "OperatorInfo", |
| 10 | }; |
| 11 | let mut vi = LuaTable { |
| 12 | tag: Some(tag.to_owned()), |
| 13 | entries: Vec::new(), |
| 14 | }; |
| 15 | vi.set( |
| 16 | LuaKey::Str("Pos".to_owned()), |
| 17 | vec2_lua(pos[0] as f64, pos[1] as f64), |
| 18 | ); |
| 19 | match kind { |
| 20 | "Underlay" => { |
| 21 | vi.set(LuaKey::Str("Size".to_owned()), vec2_lua(172.0, 166.364)); |
| 22 | } |
| 23 | "Note" | "StickyNote" => { |
| 24 | let mut flags = LuaTable::default(); |
| 25 | flags.set(LuaKey::Str("Expanded".to_owned()), LuaValue::Bool(true)); |
| 26 | vi.set(LuaKey::Str("Flags".to_owned()), LuaValue::Table(flags)); |
| 27 | vi.set(LuaKey::Str("Size".to_owned()), vec2_lua(196.0, 179.364)); |
| 28 | } |
| 29 | _ => {} |
| 30 | } |
| 31 | vi |
| 32 | } |
| 33 | |
| 34 | /// Returns sensible Fusion 21.1 default inputs for common tool classes so Fusion Studio opens |
| 35 | /// newly created nodes cleanly without errors. |
| 36 | pub(super) fn default_inputs_for_kind(kind: &str, width: u32, height: u32) -> Vec<(String, ParamValue)> { |
| 37 | let w = width as f64; |
| 38 | let h = height as f64; |
| 39 | let num = |k: &str, v: f64| (k.to_owned(), ParamValue::Number(v)); |
| 40 | let pt = |k: &str, x: f64, y: f64| (k.to_owned(), ParamValue::Point([x, y])); |
| 41 | let txt = |k: &str, s: &str| (k.to_owned(), ParamValue::Text(s.to_owned())); |
| 42 | let fuid = |k: &str, s: &str| (k.to_owned(), ParamValue::FuId(s.to_owned())); |
| 43 | |
| 44 | match kind { |
| 45 | "Background" => vec![ |
| 46 | num("Width", w), |
| 47 | num("Height", h), |
| 48 | num("UseFrameFormatSettings", 1.0), |
| 49 | num("TopLeftRed", 0.0), |
| 50 | num("TopLeftGreen", 0.0), |
| 51 | num("TopLeftBlue", 0.0), |
| 52 | num("TopLeftAlpha", 1.0), |
| 53 | ], |
| 54 | "Merge" => vec![ |
| 55 | num("PerformDepthMerge", 0.0), |
| 56 | pt("Center", 0.5, 0.5), |
| 57 | num("Size", 1.0), |
| 58 | num("Angle", 0.0), |
| 59 | num("Blend", 1.0), |
| 60 | ], |
| 61 | "Transform" => vec![ |
| 62 | pt("Center", 0.5, 0.5), |
| 63 | pt("Pivot", 0.5, 0.5), |
| 64 | num("Size", 1.0), |
| 65 | num("Angle", 0.0), |
| 66 | ], |
| 67 | "Blur" => vec![fuid("Filter", "Fast Gaussian"), num("XBlurSize", 1.0)], |
| 68 | "Glow" => vec![num("XGlowSize", 10.0), num("Glow", 0.8)], |
| 69 | "SoftGlow" => vec![ |
| 70 | fuid("Filter", "Gaussian"), |
| 71 | num("Gain", 2.0), |
| 72 | num("XGlowSize", 10.0), |
| 73 | ], |
| 74 | "BrightnessContrast" => vec![ |
| 75 | num("Gain", 1.0), |
| 76 | num("Lift", 0.0), |
| 77 | num("Gamma", 1.0), |
| 78 | num("Contrast", 0.0), |
| 79 | num("Brightness", 0.0), |
| 80 | num("Saturation", 1.0), |
| 81 | ], |
| 82 | "ColorCorrector" => vec![ |
| 83 | num("WheelSaturation1", 1.0), |
| 84 | num("MasterRGBGain", 1.0), |
| 85 | num("MasterRGBGamma", 1.0), |
| 86 | ], |
| 87 | "ColorGain" => vec![ |
| 88 | num("GainRed", 1.0), |
| 89 | num("GainGreen", 1.0), |
| 90 | num("GainBlue", 1.0), |
| 91 | num("GainAlpha", 1.0), |
| 92 | num("GammaRed", 1.0), |
| 93 | num("GammaGreen", 1.0), |
| 94 | num("GammaBlue", 1.0), |
| 95 | ], |
| 96 | "RectangleMask" => vec![ |
| 97 | num("MaskWidth", w), |
| 98 | num("MaskHeight", h), |
| 99 | pt("PixelAspect", 1.0, 1.0), |
| 100 | pt("Center", 0.5, 0.5), |
| 101 | num("Width", 0.5), |
| 102 | num("Height", 0.5), |
| 103 | num("CornerRadius", 0.0), |
| 104 | num("SoftEdge", 0.0), |
| 105 | ], |
| 106 | "EllipseMask" => vec![ |
| 107 | num("MaskWidth", w), |
| 108 | num("MaskHeight", h), |
| 109 | pt("PixelAspect", 1.0, 1.0), |
| 110 | pt("Center", 0.5, 0.5), |
| 111 | num("Width", 0.5), |
| 112 | num("Height", 0.5), |
| 113 | num("SoftEdge", 0.0), |
| 114 | ], |
| 115 | "PolylineMask" => vec![ |
| 116 | num("MaskWidth", w), |
| 117 | num("MaskHeight", h), |
| 118 | pt("PixelAspect", 1.0, 1.0), |
| 119 | num("SoftEdge", 0.0), |
| 120 | ], |
| 121 | "BitmapMask" => vec![ |
| 122 | num("MaskWidth", w), |
| 123 | num("MaskHeight", h), |
| 124 | pt("PixelAspect", 1.0, 1.0), |
| 125 | fuid("Channel", "Alpha"), |
| 126 | ], |
| 127 | "TextPlus" => vec![ |
| 128 | num("Width", w), |
| 129 | num("Height", h), |
| 130 | num("UseFrameFormatSettings", 1.0), |
| 131 | txt("StyledText", ""), |
| 132 | txt("Font", "Helvetica Neue"), |
| 133 | txt("Style", "Regular"), |
| 134 | num("Size", 0.08), |
| 135 | pt("Center", 0.5, 0.5), |
| 136 | ], |
| 137 | "Loader" => vec![], |
| 138 | "Saver" => vec![num("ProcessWhenBlendIs00", 0.0), num("CreateDir", 1.0)], |
| 139 | "Displace" => vec![ |
| 140 | num("Type", 0.0), |
| 141 | num("XRefraction", 0.0), |
| 142 | num("YRefraction", 0.0), |
| 143 | num("RefractionStrength", 0.05), |
| 144 | ], |
| 145 | "FastNoise" => vec![ |
| 146 | num("Width", w), |
| 147 | num("Height", h), |
| 148 | num("UseFrameFormatSettings", 1.0), |
| 149 | num("Detail", 2.0), |
| 150 | num("Contrast", 1.0), |
| 151 | num("XScale", 2.0), |
| 152 | num("Seethe", 0.0), |
| 153 | ], |
| 154 | "PipeRouter" | "Underlay" => vec![], |
| 155 | "Switch" => vec![num("Source", 0.0)], |
| 156 | "Fuse.Switch" => vec![num("Which", 1.0)], |
| 157 | "TimeStretcher" => vec![num("SourceTime", 0.0), num("InterpolateBetweenFrames", 1.0)], |
| 158 | "TimeSpeed" => vec![num("Speed", 1.0), num("Delay", 0.0)], |
| 159 | "Renderer3D" => vec![ |
| 160 | num("Width", w), |
| 161 | num("Height", h), |
| 162 | num("UseFrameFormatSettings", 1.0), |
| 163 | fuid("RendererType", "RendererOpenGL"), |
| 164 | ], |
| 165 | "Camera3D" => vec![num("FLength", 35.0), num("PlaneOfFocus", 5.0)], |
| 166 | "Merge3D" => vec![num("PassThroughLights", 1.0)], |
| 167 | "Transform3D" => vec![num("Transform3DOp.Scale.X", 1.0)], |
| 168 | "ImagePlane3D" => vec![ |
| 169 | num("SurfacePlaneInputs.Width", 1.0), |
| 170 | num("SurfacePlaneInputs.Height", 1.0), |
| 171 | ], |
| 172 | "Shape3D" => vec![fuid("Shape", "SurfacePlaneInputs")], |
| 173 | "Note" | "StickyNote" => vec![txt("Comments", "")], |
| 174 | _ => vec![], |
| 175 | } |
| 176 | } |
| 177 | |