From 1f0e4f7480e47fd2f0552547b174ff9d938435ee Mon Sep 17 00:00:00 2001 From: Manuel Menezes de Sequeira Date: Sun, 9 Mar 2014 21:59:32 +0000 Subject: Add localization support for SymbolMorph menu items. --- byob.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'byob.js') diff --git a/byob.js b/byob.js index 4b581e1..5946fd5 100644 --- a/byob.js +++ b/byob.js @@ -2579,7 +2579,7 @@ InputSlotDialogMorph.prototype.symbolMenu = function () { myself = this; SymbolMorph.prototype.names.forEach(function (symbol) { symbols.push([ - [new SymbolMorph(symbol, myself.fontSize, symbolColor), symbol], + [new SymbolMorph(symbol, myself.fontSize, symbolColor), localize(symbol)], '$' + symbol ]); }); -- cgit v1.3.1 From ebb4b9301055ba94f53328f18a2c26657c66972f Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 30 Apr 2014 12:30:19 +0200 Subject: integrate localisation changes --- byob.js | 7 +++++-- paint.js | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'byob.js') diff --git a/byob.js b/byob.js index 5946fd5..9e0c067 100644 --- a/byob.js +++ b/byob.js @@ -106,7 +106,7 @@ SymbolMorph, isNil*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2014-January-10'; +modules.byob = '2014-April-30'; // Declarations @@ -2579,7 +2579,10 @@ InputSlotDialogMorph.prototype.symbolMenu = function () { myself = this; SymbolMorph.prototype.names.forEach(function (symbol) { symbols.push([ - [new SymbolMorph(symbol, myself.fontSize, symbolColor), localize(symbol)], + [ + new SymbolMorph(symbol, myself.fontSize, symbolColor), + localize(symbol) + ], '$' + symbol ]); }); diff --git a/paint.js b/paint.js index fd53122..44c988b 100644 --- a/paint.js +++ b/paint.js @@ -52,6 +52,7 @@ September 16 - flood fill freeze fix (Kartik) Jan 08 - mouse leave dragging fix (Kartik) Feb 11 - dynamically adjust to stage dimensions (Jens) + Apr 30 - localizations (Manuel) */ @@ -65,7 +66,7 @@ // Global stuff //////////////////////////////////////////////////////// -modules.paint = '2014-February-11'; +modules.paint = '2014-April-30'; // Declarations -- cgit v1.3.1 From a469f44afcf2c9b30c93f96d197f8e9862829933 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 30 Apr 2014 14:41:51 +0200 Subject: partial fix for #407 the label still is wrong --- byob.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'byob.js') diff --git a/byob.js b/byob.js index 9e0c067..e47f7c5 100644 --- a/byob.js +++ b/byob.js @@ -167,6 +167,9 @@ CustomBlockDefinition.prototype.templateInstance = function () { var block; block = this.blockInstance(); block.refreshDefaults(); + if (!block.zebraContrast) { + block.forceNormalColoring(); // label still is wrong + } block.isDraggable = false; block.isTemplate = true; return block; -- cgit v1.3.1 From f6561867d24f18b5ae803385f1475fce973fd548 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Fri, 2 May 2014 10:55:03 +0200 Subject: fixed #407 (custom-block coloring w/ zebra off) --- byob.js | 11 ++++++----- history.txt | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'byob.js') diff --git a/byob.js b/byob.js index e47f7c5..6a10110 100644 --- a/byob.js +++ b/byob.js @@ -106,7 +106,7 @@ SymbolMorph, isNil*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2014-April-30'; +modules.byob = '2014-May-02'; // Declarations @@ -167,9 +167,6 @@ CustomBlockDefinition.prototype.templateInstance = function () { var block; block = this.blockInstance(); block.refreshDefaults(); - if (!block.zebraContrast) { - block.forceNormalColoring(); // label still is wrong - } block.isDraggable = false; block.isTemplate = true; return block; @@ -375,8 +372,12 @@ CustomCommandBlockMorph.prototype.refresh = function () { this.setCategory(def.category); if (this.blockSpec !== newSpec) { oldInputs = this.inputs(); + if (!this.zebraContrast) { + this.forceNormalColoring(); + } else { + this.fixBlockColor(); + } this.setSpec(newSpec); - this.fixBlockColor(); this.fixLabelColor(); this.restoreInputs(oldInputs); } else { // update all input slots' drop-downs diff --git a/history.txt b/history.txt index bcf8e5c..af54766 100755 --- a/history.txt +++ b/history.txt @@ -2124,3 +2124,4 @@ ______ 140502 ------ * error message when trying to import a non-text file into a variable, thanks, Nate! +* fixed #407 (custom-block coloring w/ zebra off) -- cgit v1.3.1 From 50203901eaac7f4ed277bb8ab981037dcc28687f Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 4 Jun 2014 12:40:03 +0200 Subject: BYOB: new scriptsPicture() method for custom block definitions --- byob.js | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'byob.js') diff --git a/byob.js b/byob.js index 6a10110..0f79acf 100644 --- a/byob.js +++ b/byob.js @@ -106,7 +106,7 @@ SymbolMorph, isNil*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2014-May-02'; +modules.byob = '2014-Jun-04'; // Declarations @@ -336,6 +336,43 @@ CustomBlockDefinition.prototype.parseSpec = function (spec) { return parts; }; +// CustomBlockDefinition picturing + +CustomBlockDefinition.prototype.scriptsPicture = function () { + var scripts, proto, block, comment; + + scripts = new ScriptsMorph(); + scripts.cleanUpMargin = 10; + proto = new PrototypeHatBlockMorph(this); + proto.setPosition(scripts.position().add(10)); + if (this.comment !== null) { + comment = this.comment.fullCopy(); + proto.comment = comment; + comment.block = proto; + } + if (this.body !== null) { + proto.nextBlock(this.body.expression.fullCopy()); + } + scripts.add(proto); + proto.fixBlockColor(null, true); + this.scripts.forEach(function (element) { + block = element.fullCopy(); + block.setPosition(scripts.position().add(element.position())); + scripts.add(block); + if (block instanceof BlockMorph) { + block.allComments().forEach(function (comment) { + comment.align(block); + }); + } + }); + proto.allComments().forEach(function (comment) { + comment.align(proto); + }); + proto.children[0].fixLayout(); + scripts.fixMultiArgs(); + return scripts.scriptsPicture(); +}; + // CustomCommandBlockMorph ///////////////////////////////////////////// // CustomCommandBlockMorph inherits from CommandBlockMorph: -- cgit v1.3.1 From 7f8d5a3d1eacdc78f61da8e82ac481bbbb825938 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Fri, 6 Jun 2014 13:57:45 +0200 Subject: relabelling custom blocks (experimental) --- blocks.js | 9 +++++++++ byob.js | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- history.txt | 1 + 3 files changed, 58 insertions(+), 1 deletion(-) (limited to 'byob.js') diff --git a/blocks.js b/blocks.js index af5542f..159d1a2 100644 --- a/blocks.js +++ b/blocks.js @@ -2009,6 +2009,7 @@ BlockMorph.prototype.userMenu = function () { var menu = new MenuMorph(this), world = this.world(), myself = this, + alternatives, blck; menu.addItem( @@ -2066,6 +2067,14 @@ BlockMorph.prototype.userMenu = function () { ); } ); + } else if (this.definition && this.alternatives) { // custom block + alternatives = this.alternatives(); + if (alternatives.length > 0) { + menu.addItem( + 'relabel...', + function () {myself.relabel(alternatives); } + ); + } } menu.addItem( diff --git a/byob.js b/byob.js index 0f79acf..a17f976 100644 --- a/byob.js +++ b/byob.js @@ -106,7 +106,7 @@ SymbolMorph, isNil*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2014-Jun-04'; +modules.byob = '2014-Jun-06'; // Declarations @@ -745,6 +745,7 @@ CustomCommandBlockMorph.prototype.userMenu = function () { } else { menu.addLine(); } + // menu.addItem("export definition...", 'exportBlockDefinition'); menu.addItem("delete block definition...", 'deleteBlockDefinition'); } @@ -846,6 +847,44 @@ CustomCommandBlockMorph.prototype.popUpbubbleHelp = function ( ).popUp(this.world(), this.rightCenter().add(new Point(-8, 0))); }; +// CustomCommandBlockMorph relabelling + +CustomCommandBlockMorph.prototype.relabel = function (alternatives) { + var menu = new MenuMorph(this), + oldInputs = this.inputs().map( + function (each) {return each.fullCopy(); } + ), + myself = this; + alternatives.forEach(function (def) { + var block = def.blockInstance(); + block.restoreInputs(oldInputs); + block.fixBlockColor(null, true); + block.addShadow(new Point(3, 3)); + menu.addItem( + block, + function () { + myself.definition = def; + myself.refresh(); + } + ); + }); + menu.popup(this.world(), this.bottomLeft().subtract(new Point( + 8, + this instanceof CommandBlockMorph ? this.corner : 0 + ))); +}; + +CustomCommandBlockMorph.prototype.alternatives = function () { + var rcvr = this.receiver(), + stage = rcvr.parentThatIsA(StageMorph), + allDefs = rcvr.customBlocks.concat(stage.globalBlocks), + myself = this; + return allDefs.filter(function (each) { + return each !== myself.definition && + each.type === myself.definition.type; + }); +}; + // CustomReporterBlockMorph //////////////////////////////////////////// // CustomReporterBlockMorph inherits from ReporterBlockMorph: @@ -961,6 +1000,14 @@ CustomReporterBlockMorph.prototype.bubbleHelp CustomReporterBlockMorph.prototype.popUpbubbleHelp = CustomCommandBlockMorph.prototype.popUpbubbleHelp; +// CustomReporterBlockMorph relabelling + +CustomReporterBlockMorph.prototype.relabel + = CustomCommandBlockMorph.prototype.relabel; + +CustomReporterBlockMorph.prototype.alternatives + = CustomCommandBlockMorph.prototype.alternatives; + // JaggedBlockMorph //////////////////////////////////////////////////// /* diff --git a/history.txt b/history.txt index 97b487e..02fc2a0 100755 --- a/history.txt +++ b/history.txt @@ -2165,3 +2165,4 @@ ______ * Blocks, objects: enable relabelling blocks with C-Slots * Blocks: enable relabelling blocks across categories * Objects: more relabelling options for SAY, THINK, ASK +* BYOB, Blocks: relabelling custom blocks (experimental) -- cgit v1.3.1