added "Make a block" button to every category

upd4.1
Jens Mönig 2017-09-25 15:58:11 +02:00
rodzic 0d5ac936d4
commit 055142e33a
2 zmienionych plików z 101 dodań i 63 usunięć

Wyświetl plik

@ -3650,6 +3650,7 @@ Fixes:
* fixed camera retina issues, thanks, Bernat!!
* Widgets: inverted property name for “enabled” to “isDisabled” for PushButtons
* GUI: hiding camera support (again), because of issues with Safari
* Objects: added "Make a block" button to every category
v4.1 Features:
@ -3669,7 +3670,7 @@ v4.1 Features:
* spritess rotation centers can be adjusted onstage
* clones share their original sprites scripts, not a shallow-copy of them
* a highlight-colored balloon indicates the number of active processes per shared script
* new musical “notes” symbol
* new musical “notes” and "location" symbols
* new “visible stepping” toggle button in the control bar
* turn on the “Inheritance support” setting per default
* Assert data types to list operations for more meaningful error messages
@ -3682,6 +3683,7 @@ v4.1 Features:
* splitting csv-text
* prevent context menu and dragging for stage watchers in presentation mode
* "floating" search button in the blocks palette
* "Make a block" button in every category
Fixes:
* changed keyboard shortcut indicator for “find blocks” to “^”

Wyświetl plik

@ -82,7 +82,7 @@ SpeechBubbleMorph, RingMorph, isNil, FileReader, TableDialogMorph,
BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, localize,
TableMorph, TableFrameMorph, normalizeCanvas, BooleanSlotMorph, HandleMorph*/
modules.objects = '2017-September-21';
modules.objects = '2017-September-25';
var SpriteMorph;
var StageMorph;
@ -1887,6 +1887,8 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push(block('yPosition', this.inheritsAttribute('y position')));
blocks.push(watcherToggle('direction'));
blocks.push(block('direction', this.inheritsAttribute('direction')));
blocks.push('=');
blocks.push(this.makeBlockButton(cat));
} else if (cat === 'looks') {
@ -1934,6 +1936,9 @@ SpriteMorph.prototype.blockTemplates = function (category) {
/////////////////////////////////
blocks.push('=');
blocks.push(this.makeBlockButton(cat));
} else if (cat === 'sound') {
blocks.push(block('playSound'));
@ -1948,6 +1953,8 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push(block('doSetTempo'));
blocks.push(watcherToggle('getTempo'));
blocks.push(block('getTempo'));
blocks.push('=');
blocks.push(this.makeBlockButton(cat));
} else if (cat === 'pen') {
@ -1970,6 +1977,8 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push(block('floodFill'));
blocks.push('-');
blocks.push(block('reportPenTrailsAsCostume'));
blocks.push('=');
blocks.push(this.makeBlockButton(cat));
} else if (cat === 'control') {
@ -2032,6 +2041,8 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push('-');
blocks.push(block('doTellTo'));
blocks.push(block('reportAskFor'));
blocks.push('=');
blocks.push(this.makeBlockButton(cat));
} else if (cat === 'sensing') {
@ -2090,6 +2101,11 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push(block('reportFrameCount'));
}
/////////////////////////////////
blocks.push('=');
blocks.push(this.makeBlockButton(cat));
} else if (cat === 'operators') {
blocks.push(block('reifyScript'));
@ -2149,6 +2165,9 @@ SpriteMorph.prototype.blockTemplates = function (category) {
/////////////////////////////////
blocks.push('=');
blocks.push(this.makeBlockButton(cat));
} else if (cat === 'variables') {
button = new PushButtonMorph(
@ -2265,42 +2284,68 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push('=');
}
button = new PushButtonMorph(
null,
function () {
var ide = myself.parentThatIsA(IDE_Morph),
stage = myself.parentThatIsA(StageMorph);
new BlockDialogMorph(
null,
function (definition) {
if (definition.spec !== '') {
if (definition.isGlobal) {
stage.globalBlocks.push(definition);
} else {
myself.customBlocks.push(definition);
}
ide.flushPaletteCache();
ide.refreshPalette();
new BlockEditorMorph(definition, myself).popUp();
}
},
myself
).prompt(
'Make a block',
null,
myself.world()
);
},
'Make a block'
);
button.userMenu = helpMenu;
button.selector = 'addCustomBlock';
button.showHelp = BlockMorph.prototype.showHelp;
blocks.push(button);
}
blocks.push(this.makeBlockButton());
}
return blocks;
};
SpriteMorph.prototype.makeBlockButton = function (category) {
// answer a button that prompts the user to make a new block
var myself = this,
button = new PushButtonMorph(
null,
function () {
var ide = myself.parentThatIsA(IDE_Morph),
stage = myself.parentThatIsA(StageMorph),
clr = SpriteMorph.prototype.blockColor[category],
dlg;
dlg = new BlockDialogMorph(
null,
function (definition) {
if (definition.spec !== '') {
if (definition.isGlobal) {
stage.globalBlocks.push(definition);
} else {
myself.customBlocks.push(definition);
}
ide.flushPaletteCache();
ide.refreshPalette();
new BlockEditorMorph(definition, myself).popUp();
}
},
myself
);
if (category) {
dlg.category = category;
dlg.categories.children.forEach(function (each) {
each.refresh();
});
dlg.types.children.forEach(function (each) {
each.setColor(clr);
each.refresh();
});
}
dlg.prompt(
'Make a block',
null,
myself.world()
);
},
'Make a block'
);
button.userMenu = function () {
var menu = new MenuMorph(this);
menu.addItem('help...', 'showHelp');
return menu;
};
button.selector = 'addCustomBlock';
button.showHelp = BlockMorph.prototype.showHelp;
return button;
};
SpriteMorph.prototype.palette = function (category) {
if (!this.paletteCache[category]) {
this.paletteCache[category] = this.freshPalette(category);
@ -6889,6 +6934,8 @@ StageMorph.prototype.blockTemplates = function (category) {
txt.fontSize = 9;
txt.setColor(this.paletteTextColor);
blocks.push(txt);
blocks.push('=');
blocks.push(this.makeBlockButton(cat));
} else if (cat === 'looks') {
@ -6923,6 +6970,9 @@ StageMorph.prototype.blockTemplates = function (category) {
/////////////////////////////////
blocks.push('=');
blocks.push(this.makeBlockButton(cat));
} else if (cat === 'sound') {
blocks.push(block('playSound'));
@ -6937,11 +6987,15 @@ StageMorph.prototype.blockTemplates = function (category) {
blocks.push(block('doSetTempo'));
blocks.push(watcherToggle('getTempo'));
blocks.push(block('getTempo'));
blocks.push('=');
blocks.push(this.makeBlockButton(cat));
} else if (cat === 'pen') {
blocks.push(block('clear'));
blocks.push(block('reportPenTrailsAsCostume'));
blocks.push('=');
blocks.push(this.makeBlockButton(cat));
} else if (cat === 'control') {
@ -6999,6 +7053,8 @@ StageMorph.prototype.blockTemplates = function (category) {
blocks.push('-');
blocks.push(block('doTellTo'));
blocks.push(block('reportAskFor'));
blocks.push('=');
blocks.push(this.makeBlockButton(cat));
} else if (cat === 'sensing') {
@ -7053,6 +7109,9 @@ StageMorph.prototype.blockTemplates = function (category) {
/////////////////////////////////
blocks.push('=');
blocks.push(this.makeBlockButton(cat));
} else if (cat === 'operators') {
blocks.push(block('reifyScript'));
@ -7112,6 +7171,9 @@ StageMorph.prototype.blockTemplates = function (category) {
//////////////////////////////////
blocks.push('=');
blocks.push(this.makeBlockButton(cat));
} else if (cat === 'variables') {
button = new PushButtonMorph(
@ -7211,34 +7273,7 @@ StageMorph.prototype.blockTemplates = function (category) {
blocks.push('=');
}
button = new PushButtonMorph(
null,
function () {
var ide = myself.parentThatIsA(IDE_Morph);
new BlockDialogMorph(
null,
function (definition) {
if (definition.spec !== '') {
if (definition.isGlobal) {
myself.globalBlocks.push(definition);
} else {
myself.customBlocks.push(definition);
}
ide.flushPaletteCache();
ide.refreshPalette();
new BlockEditorMorph(definition, myself).popUp();
}
},
myself
).prompt(
'Make a block',
null,
myself.world()
);
},
'Make a block'
);
blocks.push(button);
blocks.push(this.makeBlockButton());
}
return blocks;
};
@ -7383,6 +7418,7 @@ StageMorph.prototype.categories = SpriteMorph.prototype.categories;
StageMorph.prototype.blockColor = SpriteMorph.prototype.blockColor;
StageMorph.prototype.paletteColor = SpriteMorph.prototype.paletteColor;
StageMorph.prototype.setName = SpriteMorph.prototype.setName;
StageMorph.prototype.makeBlockButton = SpriteMorph.prototype.makeBlockButton;
StageMorph.prototype.palette = SpriteMorph.prototype.palette;
StageMorph.prototype.freshPalette = SpriteMorph.prototype.freshPalette;
StageMorph.prototype.blocksMatching = SpriteMorph.prototype.blocksMatching;