optimized bulk hiding & showing palette blocks

snap7
jmoenig 2021-10-07 16:48:46 +02:00
rodzic 98703c5bb8
commit 9acc2010b4
3 zmienionych plików z 19 dodań i 42 usunięć

Wyświetl plik

@ -41,7 +41,8 @@
### 2021-10-07 ### 2021-10-07
* objects, byob: new BlockVisibilityDialogMorph for bulk-selecting blocks to hide / show in the palette * objects, byob: new BlockVisibilityDialogMorph for bulk-selecting blocks to hide / show in the palette
* ojects: simplified palette context menu * ojects: simplified palette context menu
* blocks: removed "hide" option from context menu of primitive blocks in the palette * blocks: removed "hide" option from context menu of primitive blocks in the palette
* objects, byob: optimized bulk hiding & showing palette blocks
### 2021-10-06 ### 2021-10-06
* threads: programmatically hide individual variables in palette * threads: programmatically hide individual variables in palette

Wyświetl plik

@ -4584,13 +4584,14 @@ BlockVisibilityDialogMorph.prototype.hideBlocks = function () {
var ide = this.target.parentThatIsA(IDE_Morph); var ide = this.target.parentThatIsA(IDE_Morph);
this.blocks.forEach(block => this.target.changeBlockVisibility( this.blocks.forEach(block => this.target.changeBlockVisibility(
block, block,
contains(this.selection, block)) contains(this.selection, block),
); true // quick - without palette update
));
if (this.selection.length === 0) { if (this.selection.length === 0) {
StageMorph.prototype.hiddenPrimitives = []; StageMorph.prototype.hiddenPrimitives = [];
ide.flushBlocksCache();
ide.refreshPalette();
} }
ide.flushBlocksCache();
ide.refreshPalette();
}; };
// BlockVisibilityDialogMorph layout // BlockVisibilityDialogMorph layout

Wyświetl plik

@ -3175,28 +3175,22 @@ SpriteMorph.prototype.isHidingBlock = function (aBlock) {
return StageMorph.prototype.hiddenPrimitives[aBlock.selector] === true; return StageMorph.prototype.hiddenPrimitives[aBlock.selector] === true;
}; };
SpriteMorph.prototype.changeBlockVisibility = function (aBlock, hideIt) { SpriteMorph.prototype.changeBlockVisibility = function (aBlock, hideIt, quick) {
var ide, dict, cat;
if (aBlock.isCustomBlock) { if (aBlock.isCustomBlock) {
this.changeCustomBlockVisibility(aBlock, hideIt); (aBlock.isGlobal ? aBlock.definition
: this.getLocalMethod(aBlock.semanticSpec)
).isHelper = !!hideIt;
} else if (aBlock.selector === 'reportGetVar') { } else if (aBlock.selector === 'reportGetVar') {
this.changeVarBlockVisibility(aBlock.blockSpec, hideIt); this.variables.find(name).vars[name].isHidden = !!hideIt;
} else { } else {
this.changePrimitiveVisibility(aBlock, hideIt); if (hideIt) {
} StageMorph.prototype.hiddenPrimitives[aBlock.selector] = true;
}; } else {
delete StageMorph.prototype.hiddenPrimitives[aBlock.selector];
SpriteMorph.prototype.changePrimitiveVisibility = function (aBlock, hideIt) { }
var ide = this.parentThatIsA(IDE_Morph),
dict,
cat;
if (!ide || (aBlock.selector === 'evaluateCustomBlock')) {
return;
}
if (hideIt) {
StageMorph.prototype.hiddenPrimitives[aBlock.selector] = true;
} else {
delete StageMorph.prototype.hiddenPrimitives[aBlock.selector];
} }
if (quick) {return; }
dict = { dict = {
doWarp: 'control', doWarp: 'control',
reifyScript: 'operators', reifyScript: 'operators',
@ -3210,25 +3204,6 @@ SpriteMorph.prototype.changePrimitiveVisibility = function (aBlock, hideIt) {
ide.refreshPalette(); ide.refreshPalette();
}; };
SpriteMorph.prototype.changeCustomBlockVisibility = function (aBlock, hideIt) {
var ide = this.parentThatIsA(IDE_Morph),
method = aBlock.isGlobal ? aBlock.definition
: this.getLocalMethod(aBlock.semanticSpec);
if (!ide || !method || (aBlock.selector !== 'evaluateCustomBlock')) {
return;
}
method.isHelper = !!hideIt; // force type to be Boolean
ide.flushBlocksCache(aBlock.category);
ide.refreshPalette();
};
SpriteMorph.prototype.changeVarBlockVisibility = function (name, hideIt) {
var ide = this.parentThatIsA(IDE_Morph);
this.variables.find(name).vars[name].isHidden = !!hideIt;
ide.flushBlocksCache('variables');
ide.refreshPalette();
};
// SpriteMorph blocks searching // SpriteMorph blocks searching
SpriteMorph.prototype.blocksMatching = function ( SpriteMorph.prototype.blocksMatching = function (