kopia lustrzana https://github.com/backface/turtlestitch
simplified palette context menu
rodzic
905cd6baa9
commit
aa42b393ce
|
@ -39,6 +39,7 @@
|
||||||
|
|
||||||
### 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
|
||||||
|
|
||||||
### 2021-10-06
|
### 2021-10-06
|
||||||
* threads: programmatically hide individual variables in palette
|
* threads: programmatically hide individual variables in palette
|
||||||
|
|
100
src/objects.js
100
src/objects.js
|
@ -3038,62 +3038,7 @@ SpriteMorph.prototype.freshPalette = function (category) {
|
||||||
|
|
||||||
// menu:
|
// menu:
|
||||||
palette.userMenu = function () {
|
palette.userMenu = function () {
|
||||||
var menu = new MenuMorph(),
|
var menu = new MenuMorph();
|
||||||
ide = this.parentThatIsA(IDE_Morph),
|
|
||||||
more = {
|
|
||||||
operators:
|
|
||||||
['reifyScript', 'reifyReporter', 'reifyPredicate'],
|
|
||||||
control:
|
|
||||||
['doWarp'],
|
|
||||||
variables:
|
|
||||||
[
|
|
||||||
'doDeclareVariables',
|
|
||||||
'reportNewList',
|
|
||||||
'reportNumbers',
|
|
||||||
'reportCONS',
|
|
||||||
'reportListItem',
|
|
||||||
'reportCDR',
|
|
||||||
'reportListAttribute',
|
|
||||||
'reportListIndex',
|
|
||||||
'reportConcatenatedLists',
|
|
||||||
'reportReshape',
|
|
||||||
'reportListContainsItem',
|
|
||||||
'reportListIsEmpty',
|
|
||||||
'doForEach',
|
|
||||||
'reportMap',
|
|
||||||
'reportKeep',
|
|
||||||
'reportFindFirst',
|
|
||||||
'reportCombine',
|
|
||||||
'doAddToList',
|
|
||||||
'doDeleteFromList',
|
|
||||||
'doInsertInList',
|
|
||||||
'doReplaceInList'
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
if (category === 'unified') {
|
|
||||||
more.unified = Object.values(more).reduce((x, y) =>
|
|
||||||
x.concat(y));
|
|
||||||
}
|
|
||||||
|
|
||||||
function hasHiddenPrimitives() {
|
|
||||||
var defs = SpriteMorph.prototype.blocks,
|
|
||||||
hiddens = StageMorph.prototype.hiddenPrimitives;
|
|
||||||
return Object.keys(hiddens).some(any =>
|
|
||||||
!isNil(defs[any]) && (category === 'unified' ||
|
|
||||||
(defs[any].category === category ||
|
|
||||||
contains((more[category] || []), any)))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function canHidePrimitives() {
|
|
||||||
return palette.contents.children.some(any =>
|
|
||||||
contains(
|
|
||||||
Object.keys(SpriteMorph.prototype.blocks),
|
|
||||||
any.selector
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
menu.addPair(
|
menu.addPair(
|
||||||
[
|
[
|
||||||
|
@ -3106,51 +3051,10 @@ SpriteMorph.prototype.freshPalette = function (category) {
|
||||||
() => myself.searchBlocks(),
|
() => myself.searchBlocks(),
|
||||||
'^F'
|
'^F'
|
||||||
);
|
);
|
||||||
if (canHidePrimitives()) {
|
menu.addItem(
|
||||||
menu.addItem(
|
|
||||||
'hide primitives',
|
|
||||||
function () {
|
|
||||||
var defs = SpriteMorph.prototype.blocks;
|
|
||||||
Object.keys(defs).forEach(sel => {
|
|
||||||
if (defs[sel].category === category ||
|
|
||||||
category === 'unified') {
|
|
||||||
StageMorph.prototype.hiddenPrimitives[sel] = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
(more[category] || []).forEach(sel =>
|
|
||||||
StageMorph.prototype.hiddenPrimitives[sel] = true
|
|
||||||
);
|
|
||||||
ide.flushBlocksCache(category);
|
|
||||||
ide.refreshPalette();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (hasHiddenPrimitives()) {
|
|
||||||
menu.addItem(
|
|
||||||
'show primitives',
|
|
||||||
function () {
|
|
||||||
var hiddens = StageMorph.prototype.hiddenPrimitives,
|
|
||||||
defs = SpriteMorph.prototype.blocks;
|
|
||||||
Object.keys(hiddens).forEach(sel => {
|
|
||||||
if (defs[sel] && (category === 'unified' ||
|
|
||||||
(defs[sel].category === category))) {
|
|
||||||
delete StageMorph.prototype.hiddenPrimitives[sel];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
(more[category] || []).forEach(sel =>
|
|
||||||
delete StageMorph.prototype.hiddenPrimitives[sel]
|
|
||||||
);
|
|
||||||
ide.flushBlocksCache(category);
|
|
||||||
ide.refreshPalette();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
menu.addItem( // +++
|
|
||||||
'hide blocks...',
|
'hide blocks...',
|
||||||
() => new BlockVisibilityDialogMorph(myself).popUp(myself.world())
|
() => new BlockVisibilityDialogMorph(myself).popUp(myself.world())
|
||||||
);
|
);
|
||||||
|
|
||||||
menu.addLine();
|
menu.addLine();
|
||||||
menu.addItem(
|
menu.addItem(
|
||||||
'make a category...',
|
'make a category...',
|
||||||
|
|
Ładowanie…
Reference in New Issue