|
| 1 | + struct heliumExampleStruct |
| 2 | + ( |
| 3 | + |
| 4 | + function refresh rol control = |
| 5 | + ( |
| 6 | + if heliumOps.targetControl != control then |
| 7 | + ( |
| 8 | + heliumOps.targetRollout = rol |
| 9 | + heliumOps.targetControl = control |
| 10 | + heliumOps.useMousePos = false |
| 11 | + ) |
| 12 | + ), |
| 13 | + |
| 14 | + function rolloutPreOpen ca rol control = |
| 15 | + ( |
| 16 | + -- if you attach helium to a material, you must make sure that here the material editor is open: |
| 17 | + -- max mtledit |
| 18 | + print "preOpen" |
| 19 | + ), |
| 20 | + |
| 21 | + function rolloutPostOpen ca rol control = (print "postOpen"), |
| 22 | + function rolloutClose ca rol control = (print "Rollout close"), |
| 23 | + function resized ca rol control size = (print "reSized"), |
| 24 | + function rolledUp ca rol control state = (print "rolledUp"), |
| 25 | + |
| 26 | + |
| 27 | + function lbuttondown ca rol control = |
| 28 | + ( |
| 29 | + print "lbuttondown" |
| 30 | + refresh rol control |
| 31 | + ), |
| 32 | + |
| 33 | + function lbuttonup ca rol control = (print "lbuttonup"), |
| 34 | + function lbuttonDblclk ca rol control = (print "lbuttonDblclk"), |
| 35 | + function mbuttonup ca rol control = (print "mbuttonup"), |
| 36 | + function mbuttondown ca rol control = (print "mbuttondown"), |
| 37 | + function rbuttondown ca rol control = (print "rbuttondown"), |
| 38 | + function rbuttonup ca rol control = |
| 39 | + ( |
| 40 | + print "rbuttonup" |
| 41 | + refresh rol control |
| 42 | + popupmenu HeliumMenu pop:mouse.screenpos |
| 43 | + ), |
| 44 | + |
| 45 | + function mouseMoved ca rol control = (/*print "mouseMoved"*/), |
| 46 | + function mouseScroll ca rol control = (print "mouseScroll"), |
| 47 | + |
| 48 | + function nodeClicked ca rol control index = (print "nodeClicked"), |
| 49 | + function nodesDeleted ca rol control = (print "nodesDeleted"), |
| 50 | + function connectionChanged ca rol control sourceNode targetNode inSocket outSocket status connectionCount = (print "connectionChanged"), |
| 51 | + |
| 52 | + endOfStruct |
| 53 | + ) |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | +-- example for adding helium UI to a custom attribute: |
| 60 | + |
| 61 | +heliumPar_string = ( "parameters helium_pBlock rollout:heliumRollout \n") |
| 62 | +append heliumPar_string ( " (\n" ) |
| 63 | +append heliumPar_string ( " heliumStruct type:#string \n" ) |
| 64 | +append heliumPar_string ( " )\n" ) |
| 65 | + |
| 66 | + |
| 67 | +append heliumPar_string ( "rollout heliumRollout \"Helium\" autolayoutonresize:true \n") |
| 68 | +append heliumPar_string ( " (\n" ) |
| 69 | +append heliumPar_string ( " schematicControl s \"\" height:300 \n" ) |
| 70 | + |
| 71 | +append heliumPar_string ( " on heliumRollout open do \n") |
| 72 | +append heliumPar_string ( " ( \n") |
| 73 | +append heliumPar_string ( " if hStruct == undefined then hStruct = execute(heliumStruct) \n") |
| 74 | +append heliumPar_string ( " if (isProperty hStruct \"rolloutPreOpen\") then hStruct.rolloutPreOpen this heliumRollout s \n") |
| 75 | +append heliumPar_string ( " if (isProperty hStruct \"rolloutPostOpen\") then hStruct.rolloutPostOpen this heliumRollout s \n") |
| 76 | +append heliumPar_string ( " ) \n") |
| 77 | + |
| 78 | +append heliumPar_string ( " on heliumRollout close do ( if (isProperty hStruct \"rolloutClose\") then hStruct.rolloutClose this heliumRollout s ) \n") |
| 79 | +append heliumPar_string ( " on heliumRollout resized size do ( if (isProperty hStruct \"resized\") then hStruct.resized this heliumRollout s size ) \n") |
| 80 | +append heliumPar_string ( " on heliumRollout rolledUp state do ( if (isProperty hStruct \"rolledUp\") then hStruct.rolledUp this heliumRollout s state ) \n") |
| 81 | + |
| 82 | + |
| 83 | +append heliumPar_string ( " on s lbuttondown do ( if (isProperty hStruct \"lbuttondown\") then hStruct.lbuttondown this heliumRollout s ) \n") |
| 84 | +append heliumPar_string ( " on s lbuttonup do ( if (isProperty hStruct \"lbuttonup\") then hStruct.lbuttonup this heliumRollout s ) \n") |
| 85 | +append heliumPar_string ( " on s lbuttonDblclk do ( if (isProperty hStruct \"lbuttonDblclk\") then hStruct.lbuttonDblclk this heliumRollout s ) \n") |
| 86 | +append heliumPar_string ( " on s mbuttondown do ( if (isProperty hStruct \"mbuttondown\") then hStruct.mbuttondown this heliumRollout s ) \n") |
| 87 | +append heliumPar_string ( " on s mbuttonup do ( if (isProperty hStruct \"mbuttonup\") then hStruct.mbuttonup this heliumRollout s ) \n") |
| 88 | +append heliumPar_string ( " on s rbuttondown do ( if (isProperty hStruct \"rbuttondown\") then hStruct.rbuttondown this heliumRollout s ) \n") |
| 89 | +append heliumPar_string ( " on s rbuttonup do ( if (isProperty hStruct \"rbuttonup\") then hStruct.rbuttonup this heliumRollout s ) \n") |
| 90 | + |
| 91 | +append heliumPar_string ( " on s mouseMoved do ( if (isProperty hStruct \"mouseMoved\") then hStruct.mouseMoved this heliumRollout s ) \n") |
| 92 | +append heliumPar_string ( " on s mouseScroll do ( if (isProperty hStruct \"mouseScroll\") then hStruct.mouseScroll this heliumRollout s ) \n") |
| 93 | + |
| 94 | +append heliumPar_string ( " on s nodeClicked index do ( if (isProperty hStruct \"nodeClicked\") then hStruct.nodeClicked this heliumRollout s index ) \n") |
| 95 | +append heliumPar_string ( " on s nodesDeleted do ( if (isProperty hStruct \"nodesDeleted\") then hStruct.nodesDeleted this heliumRollout s ) \n") |
| 96 | +append heliumPar_string ( " on s connectionChanged sourceNode targetNode inSocket outSocket status connectionCount do ( if (isProperty hStruct \"connectionChanged\") then hStruct.connectionChanged this heliumRollout s sourceNode targetNode inSocket outSocket status connectionCount ) \n") |
| 97 | + |
| 98 | +append heliumPar_string ( " )\n" ) |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | +--create CA string: |
| 103 | +heliumCA_string = "" |
| 104 | +append heliumCA_string "MCA = attributes heliumCA\n" |
| 105 | +append heliumCA_string "(\n" |
| 106 | +append heliumCA_string "local unusedDummyVar\n" -- prevent a bug in old max versions |
| 107 | +append heliumCA_string "local hStruct \n" |
| 108 | +append heliumCA_string heliumPar_string |
| 109 | +append heliumCA_string ")\n" |
| 110 | +myheliumCA = execute(heliumCA_string) |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | + |
| 117 | +if selection.count > 0 then |
| 118 | + ( |
| 119 | + |
| 120 | + custAttributes.add $ myHeliumCA #unique |
| 121 | + $.heliumStruct = "heliumExampleStruct()" |
| 122 | + |
| 123 | + ) |
| 124 | +-- end selection.count |
| 125 | + |
| 126 | + |
| 127 | + |
0 commit comments