diff options
| author | jmoenig <jens@moenig.org> | 2013-04-03 12:03:34 +0200 |
|---|---|---|
| committer | jmoenig <jens@moenig.org> | 2013-04-03 12:03:34 +0200 |
| commit | 18821f7bc1807b6ae199e2c207a865439ee6167f (patch) | |
| tree | ea996b1b5e634bca04f756bdc9f93fadb51d5e3f | |
| parent | 4804d8cfc82ecaad3e0906090994f6e804243b01 (diff) | |
| download | snap-yow-18821f7bc1807b6ae199e2c207a865439ee6167f.tar.gz snap-yow-18821f7bc1807b6ae199e2c207a865439ee6167f.zip | |
PrototypeHatBlocks accept anchored comments
You can now "stick" comments to the prototype hat block in the block
editor
| -rw-r--r-- | blocks.js | 4 | ||||
| -rw-r--r-- | byob.js | 15 | ||||
| -rwxr-xr-x | history.txt | 3 | ||||
| -rw-r--r-- | store.js | 12 |
4 files changed, 26 insertions, 8 deletions
@@ -153,7 +153,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2013-April-02'; +modules.blocks = '2013-April-03'; var SyntaxElementMorph; var BlockMorph; @@ -4223,7 +4223,6 @@ ScriptsMorph.prototype.closestBlock = function (comment, hand) { all, function (block) { return !block.comment - && !(block instanceof PrototypeHatBlockMorph) && !block.isPrototype && block.bounds.containsPoint(handPos); } @@ -4236,7 +4235,6 @@ ScriptsMorph.prototype.closestBlock = function (comment, hand) { all, function (block) { return !block.comment - && !(block instanceof PrototypeHatBlockMorph) && !block.isPrototype && block.bounds.intersects(fb); } @@ -105,7 +105,7 @@ CommentMorph, localize, CSlotMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2013-April-02'; +modules.byob = '2013-April-03'; // Declarations @@ -137,6 +137,7 @@ function CustomBlockDefinition(spec, receiver) { this.type = 'command'; this.spec = spec || ''; this.declarations = {}; // {'inputName' : [type, default]} + this.comment = null; // don't serialize (not needed for functionality): this.receiver = receiver || null; // for serialization only (pointer) @@ -1400,7 +1401,7 @@ function BlockEditorMorph(definition, target) { } BlockEditorMorph.prototype.init = function (definition, target) { - var scripts, proto, scriptsFrame, block, myself = this; + var scripts, proto, scriptsFrame, block, comment, myself = this; // additional properties: this.definition = definition; @@ -1428,6 +1429,12 @@ BlockEditorMorph.prototype.init = function (definition, target) { proto = new PrototypeHatBlockMorph(this.definition); proto.setPosition(scripts.position().add(10)); + if (definition.comment !== null) { + comment = definition.comment.fullCopy(); + proto.comment = comment; + comment.block = proto; + } + if (definition.body !== null) { proto.nextBlock(definition.body.expression.fullCopy()); } @@ -1577,6 +1584,10 @@ BlockEditorMorph.prototype.updateDefinition = function () { if (head) { this.definition.category = head.blockCategory; this.definition.type = head.type; + if (head.comment) { + this.definition.comment = head.comment.fullCopy(); + this.definition.comment.block = true; // serialize in short form + } } this.definition.body = this.context(head); diff --git a/history.txt b/history.txt index 44dc921..9929d4c 100755 --- a/history.txt +++ b/history.txt @@ -1577,4 +1577,5 @@ ______ 130403 ------ -* YPR converter fix: No more text area in upper left corner of the Snap! IDE
\ No newline at end of file +* YPR converter fix: No more text area in upper left corner of the Snap! IDE +* Blocks, BYOB, Store: PrototypeHatBlocks in the BlockEditor accept anchored comments
\ No newline at end of file @@ -61,7 +61,7 @@ SyntaxElementMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.store = '2013-March-19'; +modules.store = '2013-April-03'; // XML_Serializer /////////////////////////////////////////////////////// @@ -627,8 +627,9 @@ SnapSerializer.prototype.loadCustomBlocks = function ( isGlobal ) { // private + var myself = this; element.children.forEach(function (child) { - var definition, names, inputs, i; + var definition, names, inputs, comment, i; if (child.tag !== 'block-definition') { return; } @@ -665,6 +666,11 @@ SnapSerializer.prototype.loadCustomBlocks = function ( = [child.attributes.type, child.contents]; }); } + + comment = child.childNamed('comment'); + if (comment) { + definition.comment = myself.loadComment(comment); + } }); }; @@ -1482,11 +1488,13 @@ CustomBlockDefinition.prototype.toXML = function (serializer) { return serializer.format( '<block-definition s="@" type="@" category="@">' + + '%' + '<inputs>%</inputs>%%' + '</block-definition>', this.spec, this.type, this.category || 'other', + this.comment ? this.comment.toXML(serializer) : '', Object.keys(this.declarations).reduce(function (xml, decl) { return xml + serializer.format( '<input type="@">$</input>', |
