code-dot-org/code-dot-org — pull request #70 by Bjvanminnen (2014-09-30 18:30:15+00:00)
Title: block svg cleanup

Some more readability changes in blockly_svg. Might be easiest to look 1 commit at a time. I'm open to feedback if you dont like any of these approaches. I did the following things

(1) Instead of passing around 4 different types of steps everywhere, have a single steps object that contains the four types. Ultimately, I'd try to have the logic be more additive instead of passing these around everywhere (i.e. instead of calling renderFoo and passing it the steps object, call getStepsNeededToRenderFoo and append the return to our steps object). The goal in doing this would be to try and separate out clearly what functions do/don't have side effects.

(2) There were a lot of places we were doing (Blockly.RTL ? -foo : foo). I replaced this with a helper. I'm open to suggestions for a better name.

(3) I found it difficult to read all these constants that were Blockly.BlockSvg.FOO_AND_BAR. My earlier approach was to separate some of these out (like SPACE_X). The downside to doing that is if we were to change the value externally, it would now be different than our local copy. We do that for some of these items (like NOTCH_WIDTH in jigsaw). This new approach gives us a local C (for constant) that allows us to reference the object with a little less clutter.