First-Class Sounds

upd4.1
Jens Mönig 2017-06-26 12:46:05 +02:00
rodzic b78aaf5766
commit 7b8602e367
7 zmienionych plików z 79 dodań i 25 usunięć

Wyświetl plik

@ -141,7 +141,7 @@ Color, ColorPaletteMorph, FrameMorph, Function, HandleMorph, Math, MenuMorph,
Morph, MorphicPreferences, Object, Point, ScrollFrameMorph, ShadowMorph, Morph, MorphicPreferences, Object, Point, ScrollFrameMorph, ShadowMorph,
String, StringMorph, TextMorph, WorldMorph, contains, degrees, detect, String, StringMorph, TextMorph, WorldMorph, contains, degrees, detect,
document, getDocumentPositionOf, isNaN, isString, newCanvas, nop, parseFloat, document, getDocumentPositionOf, isNaN, isString, newCanvas, nop, parseFloat,
radians, useBlurredShadows, SpeechBubbleMorph, modules, StageMorph, radians, useBlurredShadows, SpeechBubbleMorph, modules, StageMorph, Sound,
fontHeight, TableFrameMorph, SpriteMorph, Context, ListWatcherMorph, fontHeight, TableFrameMorph, SpriteMorph, Context, ListWatcherMorph,
CellMorph, DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, CellMorph, DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph,
Costume, IDE_Morph, BlockDialogMorph, BlockEditorMorph, localize, isNil, Costume, IDE_Morph, BlockDialogMorph, BlockEditorMorph, localize, isNil,
@ -150,7 +150,7 @@ CustomCommandBlockMorph*/
// Global stuff //////////////////////////////////////////////////////// // Global stuff ////////////////////////////////////////////////////////
modules.blocks = '2017-June-24'; modules.blocks = '2017-June-26';
var SyntaxElementMorph; var SyntaxElementMorph;
var BlockMorph; var BlockMorph;
@ -181,13 +181,12 @@ var ScriptFocusMorph;
WorldMorph.prototype.customMorphs = function () { WorldMorph.prototype.customMorphs = function () {
// add examples to the world's demo menu // add examples to the world's demo menu
return []; return [];
/* /*
return [ return [
new SymbolMorph( new SymbolMorph(
'turnForward', 'notes',
50, 50,
new Color(250, 250, 250), new Color(250, 250, 250),
new Point(-1, -1), new Point(-1, -1),
@ -1948,6 +1947,8 @@ SyntaxElementMorph.prototype.showBubble = function (value, exportPic, target) {
morphToShow.silentSetWidth(img.width); morphToShow.silentSetWidth(img.width);
morphToShow.silentSetHeight(img.height); morphToShow.silentSetHeight(img.height);
morphToShow.image = img; morphToShow.image = img;
} else if (value instanceof Sound) {
morphToShow = new SymbolMorph('notes', 30);
} else if (value instanceof Context) { } else if (value instanceof Context) {
img = value.image(); img = value.image();
morphToShow = new Morph(); morphToShow = new Morph();
@ -8233,7 +8234,7 @@ InputSlotMorph.prototype.gettablesMenu = function () {
} }
dict.name = ['name']; dict.name = ['name'];
dict.costumes = ['costumes']; dict.costumes = ['costumes'];
// dict.sounds = ['sounds']; dict.sounds = ['sounds'];
dict['dangling?'] = ['dangling?']; dict['dangling?'] = ['dangling?'];
dict['rotation x'] = ['rotation x']; dict['rotation x'] = ['rotation x'];
dict['rotation y'] = ['rotation y']; dict['rotation y'] = ['rotation y'];
@ -9823,7 +9824,8 @@ SymbolMorph.prototype.names = [
'arrowRight', 'arrowRight',
'arrowRightOutline', 'arrowRightOutline',
'robot', 'robot',
'magnifiyingGlass' 'magnifyingGlass',
'notes'
]; ];
// SymbolMorph instance creation: // SymbolMorph instance creation:
@ -9993,8 +9995,10 @@ SymbolMorph.prototype.symbolCanvasColored = function (aColor) {
return this.drawSymbolArrowRightOutline(canvas, aColor); return this.drawSymbolArrowRightOutline(canvas, aColor);
case 'robot': case 'robot':
return this.drawSymbolRobot(canvas, aColor); return this.drawSymbolRobot(canvas, aColor);
case 'magnifiyingGlass': case 'magnifyingGlass':
return this.drawSymbolMagnifyingGlass(canvas, aColor); return this.drawSymbolMagnifyingGlass(canvas, aColor);
case 'notes':
return this.drawSymbolNotes(canvas, aColor);
default: default:
return canvas; return canvas;
} }
@ -11173,6 +11177,42 @@ SymbolMorph.prototype.drawSymbolMagnifyingGlass = function (canvas, color) {
return canvas; return canvas;
}; };
SymbolMorph.prototype.drawSymbolNotes = function (canvas, color) {
// answer a canvas showing two musical notes
var ctx = canvas.getContext('2d'),
size = canvas.width,
r = size / 6,
l = Math.max(r / 3, 1);
ctx.strokeStyle = color.toString();
ctx.fillStyle = color.toString();
ctx.arc(r, size - r, r, radians(0), radians(360), false);
ctx.fill();
ctx.arc(size - r, size - (r * 2), r, radians(0), radians(360), false);
ctx.fill();
ctx.beginPath();
ctx.moveTo(r * 2 - l, r);
ctx.lineTo(size, 0);
ctx.lineTo(size, r);
ctx.lineTo(r * 2 - l, r * 2);
ctx.closePath();
ctx.fill();
ctx.lineWidth = l;
ctx.beginPath();
ctx.moveTo(r * 2 - (l / 2), size - r);
ctx.lineTo(r * 2 - (l / 2), r + l);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(size - (l / 2), size - (r * 2));
ctx.lineTo(size - (l / 2), l);
ctx.stroke();
return canvas;
};
// ColorSlotMorph ////////////////////////////////////////////////////// // ColorSlotMorph //////////////////////////////////////////////////////
/* /*

16
gui.js
Wyświetl plik

@ -74,7 +74,7 @@ isRetinaSupported, SliderMorph, Animation*/
// Global stuff //////////////////////////////////////////////////////// // Global stuff ////////////////////////////////////////////////////////
modules.gui = '2017-June-20'; modules.gui = '2017-June-26';
// Declarations // Declarations
@ -5331,7 +5331,7 @@ ProjectDialogMorph.prototype.init = function (ide, task) {
this.srcBar = null; this.srcBar = null;
this.nameField = null; this.nameField = null;
this.filterField = null; this.filterField = null;
this.magnifiyingGlass = null; this.magnifyingGlass = null;
this.listField = null; this.listField = null;
this.preview = null; this.preview = null;
this.notesText = null; this.notesText = null;
@ -5616,13 +5616,13 @@ ProjectDialogMorph.prototype.buildFilterField = function () {
var myself = this; var myself = this;
this.filterField = new InputFieldMorph(''); this.filterField = new InputFieldMorph('');
this.magnifiyingGlass = this.magnifyingGlass =
new SymbolMorph( new SymbolMorph(
'magnifiyingGlass', 'magnifyingGlass',
this.filterField.height(), this.filterField.height(),
this.titleBarColor.darker(50)); this.titleBarColor.darker(50));
this.body.add(this.magnifiyingGlass); this.body.add(this.magnifyingGlass);
this.body.add(this.filterField); this.body.add(this.filterField);
this.filterField.reactToKeystroke = function (evt) { this.filterField.reactToKeystroke = function (evt) {
@ -6225,9 +6225,9 @@ ProjectDialogMorph.prototype.fixLayout = function () {
this.body.height() - inputField.height() - this.padding this.body.height() - inputField.height() - this.padding
); );
if (this.magnifiyingGlass) { if (this.magnifyingGlass) {
this.magnifiyingGlass.setTop(inputField.top()); this.magnifyingGlass.setTop(inputField.top());
this.magnifiyingGlass.setLeft(this.listField.left()); this.magnifyingGlass.setLeft(this.listField.left());
} }
this.preview.setRight(this.body.right()); this.preview.setRight(this.body.right());

Wyświetl plik

@ -3472,11 +3472,17 @@ Fixes:
* Blocks: experimented with first-class sounds, deferred for now * Blocks: experimented with first-class sounds, deferred for now
* corrected a typo in the German translation. Thanks, Jadga, for reporting this! * corrected a typo in the German translation. Thanks, Jadga, for reporting this!
170626
------
* Objects, Blocks, Threads, Tables, Store: First-Class Sounds
* Block: new musical “notes” symbol
Features: Features:
* polymorphic sprite-local custom blocks * polymorphic sprite-local custom blocks
* inheritance of sprite-local custom blocks * inheritance of sprite-local custom blocks
* inheritance of sprite attributes (x, y, direction, size, costumes, costume #, scripts) * inheritance of sprite attributes (x, y, direction, size, costumes, costume #, scripts)
* first-class costumes and sounds
* localization support when typing expressions * localization support when typing expressions
* support for user-forced line-breaks in custom block labels * support for user-forced line-breaks in custom block labels
* ternary Boolean slot setting: support to limit Boolean input slots to “true/false” outside of rings and in palette * ternary Boolean slot setting: support to limit Boolean input slots to “true/false” outside of rings and in palette
@ -3487,9 +3493,11 @@ Features:
* spritess rotation centers can be adjusted onstage * spritess rotation centers can be adjusted onstage
* clones share their original sprites scripts, not a shallow-copy of them * 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 * a highlight-colored balloon indicates the number of active processes per shared script
* new musical “notes” symbol
Fixes: Fixes:
* changed keyboard shortcut indicator for “find blocks” to “^” * changed keyboard shortcut indicator for “find blocks” to “^”
* prevent Snap from “hanging” when encountering certain errors in visible stepping * prevent Snap from “hanging” when encountering certain errors in visible stepping
* only mark implicit parameters if no formal ones exist * only mark implicit parameters if no formal ones exist
* optimized thread-launch and script highlighting to a single frame instead of formerly two * optimized thread-launch and script highlighting to a single frame instead of formerly two
* fixed some typos

Wyświetl plik

@ -68,7 +68,7 @@
// Global stuff //////////////////////////////////////////////////////// // Global stuff ////////////////////////////////////////////////////////
/*global PaintEditorMorph, ListWatcherMorph, PushButtonMorph, ToggleMorph, /*global PaintEditorMorph, ListWatcherMorph, PushButtonMorph, ToggleMorph,
DialogBoxMorph, InputFieldMorph, SpriteIconMorph, BlockMorph, DialogBoxMorph, InputFieldMorph, SpriteIconMorph, BlockMorph, SymbolMorph,
ThreadManager, VariableFrame, detect, BlockMorph, BoxMorph, Color, ThreadManager, VariableFrame, detect, BlockMorph, BoxMorph, Color,
CommandBlockMorph, FrameMorph, HatBlockMorph, MenuMorph, Morph, MultiArgMorph, CommandBlockMorph, FrameMorph, HatBlockMorph, MenuMorph, Morph, MultiArgMorph,
Point, ReporterBlockMorph, ScriptsMorph, StringMorph, SyntaxElementMorph, Point, ReporterBlockMorph, ScriptsMorph, StringMorph, SyntaxElementMorph,
@ -82,7 +82,7 @@ SpeechBubbleMorph, RingMorph, isNil, FileReader, TableDialogMorph,
BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, localize, BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, localize,
TableMorph, TableFrameMorph, normalizeCanvas, BooleanSlotMorph, HandleMorph*/ TableMorph, TableFrameMorph, normalizeCanvas, BooleanSlotMorph, HandleMorph*/
modules.objects = '2017-June-23'; modules.objects = '2017-June-26';
var SpriteMorph; var SpriteMorph;
var StageMorph; var StageMorph;
@ -3035,7 +3035,7 @@ SpriteMorph.prototype.addSound = function (audio, name) {
SpriteMorph.prototype.playSound = function (name) { SpriteMorph.prototype.playSound = function (name) {
var stage = this.parentThatIsA(StageMorph), var stage = this.parentThatIsA(StageMorph),
sound = detect( sound = name instanceof Sound ? name : detect(
this.sounds.asArray(), this.sounds.asArray(),
function (s) {return s.name === name; } function (s) {return s.name === name; }
), ),
@ -7409,6 +7409,8 @@ SpriteBubbleMorph.prototype.dataAsMorph = function (data, toggle) {
contents.silentSetWidth(img.width); contents.silentSetWidth(img.width);
contents.silentSetHeight(img.height); contents.silentSetHeight(img.height);
contents.image = img; contents.image = img;
} else if (data instanceof Sound) {
contents = new SymbolMorph('notes', 30);
} else if (data instanceof HTMLCanvasElement) { } else if (data instanceof HTMLCanvasElement) {
contents = new Morph(); contents = new Morph();
contents.silentSetWidth(data.width); contents.silentSetWidth(data.width);
@ -8309,6 +8311,8 @@ CellMorph.prototype.drawNew = function (toggle, type) {
this.contentsMorph.silentSetWidth(img.width); this.contentsMorph.silentSetWidth(img.width);
this.contentsMorph.silentSetHeight(img.height); this.contentsMorph.silentSetHeight(img.height);
this.contentsMorph.image = img; this.contentsMorph.image = img;
} else if (this.contents instanceof Sound) {
this.contentsMorph = new SymbolMorph('notes', 30);
} else if (this.contents instanceof List) { } else if (this.contents instanceof List) {
if ('table' === type || (!toggle && this.contents.isTable())) { if ('table' === type || (!toggle && this.contents.isTable())) {
this.contentsMorph = new TableFrameMorph(new TableMorph( this.contentsMorph = new TableFrameMorph(new TableMorph(

Wyświetl plik

@ -61,7 +61,7 @@ normalizeCanvas, contains*/
// Global stuff //////////////////////////////////////////////////////// // Global stuff ////////////////////////////////////////////////////////
modules.store = '2017-May-31'; modules.store = '2017-June-26';
// XML_Serializer /////////////////////////////////////////////////////// // XML_Serializer ///////////////////////////////////////////////////////
@ -1207,6 +1207,7 @@ SnapSerializer.prototype.loadValue = function (model, object) {
myself.mediaDict[model.attributes.mediaID] = v; myself.mediaDict[model.attributes.mediaID] = v;
} }
} }
switch (model.tag) { switch (model.tag) {
case 'ref': case 'ref':
if (Object.prototype.hasOwnProperty.call(model.attributes, 'id')) { if (Object.prototype.hasOwnProperty.call(model.attributes, 'id')) {
@ -1443,6 +1444,7 @@ SnapSerializer.prototype.loadValue = function (model, object) {
)) { )) {
myself.mediaDict[model.attributes.mediaID] = v; myself.mediaDict[model.attributes.mediaID] = v;
} }
record();
return v; return v;
} }
return undefined; return undefined;

Wyświetl plik

@ -66,11 +66,11 @@
/*global modules, Point, newCanvas, Morph, fontHeight, SliderMorph, List, /*global modules, Point, newCanvas, Morph, fontHeight, SliderMorph, List,
MorphicPreferences, FrameMorph, HandleMorph, DialogBoxMorph, isString, MorphicPreferences, FrameMorph, HandleMorph, DialogBoxMorph, isString,
SpriteMorph, Context, Costume, ArgMorph, BlockEditorMorph, SpriteMorph, Context, Costume, ArgMorph, BlockEditorMorph, SymbolMorph,
SyntaxElementMorph, MenuMorph, SpriteBubbleMorph, SpeechBubbleMorph, SyntaxElementMorph, MenuMorph, SpriteBubbleMorph, SpeechBubbleMorph, Sound,
CellMorph, ListWatcherMorph, isNil, BoxMorph, Variable, isSnapObject*/ CellMorph, ListWatcherMorph, isNil, BoxMorph, Variable, isSnapObject*/
modules.tables = '2016-May-02'; modules.tables = '2017-June-26';
var Table; var Table;
var TableCellMorph; var TableCellMorph;
@ -401,6 +401,8 @@ TableCellMorph.prototype.dataRepresentation = function (dta) {
return dta.image(); return dta.image();
} else if (dta instanceof Costume) { } else if (dta instanceof Costume) {
return dta.thumbnail(new Point(40, 40)); return dta.thumbnail(new Point(40, 40));
} else if (dta instanceof Sound) {
return new SymbolMorph('notes', 30).image;
} else if (dta instanceof List) { } else if (dta instanceof List) {
return this.listSymbol; return this.listSymbol;
// return new ListWatcherMorph(dta).fullImageClassic(); // return new ListWatcherMorph(dta).fullImageClassic();

Wyświetl plik

@ -61,7 +61,7 @@ StageMorph, SpriteMorph, StagePrompterMorph, Note, modules, isString, copy,
isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph, isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph,
TableFrameMorph, ColorSlotMorph, isSnapObject*/ TableFrameMorph, ColorSlotMorph, isSnapObject*/
modules.threads = '2017-June-24'; modules.threads = '2017-June-26';
var ThreadManager; var ThreadManager;
var Process; var Process;
@ -3042,10 +3042,8 @@ Process.prototype.reportGet = function (query) {
return thisObj.parentThatIsA(StageMorph); return thisObj.parentThatIsA(StageMorph);
case 'costumes': case 'costumes':
return thisObj.reportCostumes(); return thisObj.reportCostumes();
/*
case 'sounds': case 'sounds':
return thisObj.sounds; return thisObj.sounds;
*/
} }
} }
return ''; return '';