Hi,
I agree with Mark that mutators are one of the more complex parts of Blockly.
Don't worry too much about the import statements. These just import the pieces of Blockly used by the logic blocks.
Here's some suggestions on how to break the controls_if mutator into understandable pieces:
2) Read the code to learn how
decompose constructs the mutator workspace from the
controls_if block in the main workspace. (
decompose is called by the mutator icon.)
3) Read the code to learn how
compose updates the
controls_if block in the main workspace every time you make a change in the mutator workspace. (
compose is also called by the mutator icon.) This is also a good time to look at how
compose uses
updateShape_.
4) In the playground, connect some boolean blocks and statement blocks to your
controls_if block. Now change the shape of the
controls_if block using the mutator block and see what happens to these blocks. Next, read the code in
saveConnections and
reconnectChildBlocks_ to see how this works. This code takes some time to understand.
5) Look at the
call to registerMutator -- this registers the mutator with Blockly so the mutator icon knows what functions to call. The last argument of this call is an array that tells the mutator icon which blocks to put in the mutator workspace's toolbox.
6) Look at the code in
saveExtraState and
loadExtraState, which saves state to/loads state from JSON. You can ignore
mutationToDom,
domToMutation, and
rebuildShape_ unless you want to save to/load from XML.
Good luck!