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,
String, StringMorph, TextMorph, WorldMorph, contains, degrees, detect,
document, getDocumentPositionOf, isNaN, isString, newCanvas, nop, parseFloat,
radians, useBlurredShadows, SpeechBubbleMorph, modules, StageMorph,
radians, useBlurredShadows, SpeechBubbleMorph, modules, StageMorph, Sound,
fontHeight, TableFrameMorph, SpriteMorph, Context, ListWatcherMorph,
CellMorph, DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph,
Costume, IDE_Morph, BlockDialogMorph, BlockEditorMorph, localize, isNil,
@ -150,7 +150,7 @@ CustomCommandBlockMorph*/
// Global stuff ////////////////////////////////////////////////////////
modules.blocks = '2017-June-24';
modules.blocks = '2017-June-26';
var SyntaxElementMorph;
var BlockMorph;
@ -181,13 +181,12 @@ var ScriptFocusMorph;
WorldMorph.prototype.customMorphs = function () {
// add examples to the world's demo menu
return [];
/*
return [
new SymbolMorph(
'turnForward',
'notes',
50,
new Color(250, 250, 250),
new Point(-1, -1),
@ -1948,6 +1947,8 @@ SyntaxElementMorph.prototype.showBubble = function (value, exportPic, target) {
morphToShow.silentSetWidth(img.width);
morphToShow.silentSetHeight(img.height);
morphToShow.image = img;
} else if (value instanceof Sound) {
morphToShow = new SymbolMorph('notes', 30);
} else if (value instanceof Context) {
img = value.image();
morphToShow = new Morph();
@ -8233,7 +8234,7 @@ InputSlotMorph.prototype.gettablesMenu = function () {
}
dict.name = ['name'];
dict.costumes = ['costumes'];
// dict.sounds = ['sounds'];
dict.sounds = ['sounds'];
dict['dangling?'] = ['dangling?'];
dict['rotation x'] = ['rotation x'];
dict['rotation y'] = ['rotation y'];
@ -9823,7 +9824,8 @@ SymbolMorph.prototype.names = [
'arrowRight',
'arrowRightOutline',
'robot',
'magnifiyingGlass'
'magnifyingGlass',
'notes'
];
// SymbolMorph instance creation:
@ -9993,8 +9995,10 @@ SymbolMorph.prototype.symbolCanvasColored = function (aColor) {
return this.drawSymbolArrowRightOutline(canvas, aColor);
case 'robot':
return this.drawSymbolRobot(canvas, aColor);
case 'magnifiyingGlass':
case 'magnifyingGlass':
return this.drawSymbolMagnifyingGlass(canvas, aColor);
case 'notes':
return this.drawSymbolNotes(canvas, aColor);
default:
return canvas;
}
@ -11173,6 +11177,42 @@ SymbolMorph.prototype.drawSymbolMagnifyingGlass = function (canvas, color) {
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 //////////////////////////////////////////////////////
/*

16
gui.js
Wyświetl plik

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

Wyświetl plik

@ -3472,11 +3472,17 @@ Fixes:
* Blocks: experimented with first-class sounds, deferred for now
* 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:
* polymorphic sprite-local custom blocks
* inheritance of sprite-local custom blocks
* inheritance of sprite attributes (x, y, direction, size, costumes, costume #, scripts)
* first-class costumes and sounds
* localization support when typing expressions
* 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
@ -3487,9 +3493,11 @@ 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
Fixes:
* changed keyboard shortcut indicator for “find blocks” to “^”
* prevent Snap from “hanging” when encountering certain errors in visible stepping
* only mark implicit parameters if no formal ones exist
* 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 PaintEditorMorph, ListWatcherMorph, PushButtonMorph, ToggleMorph,
DialogBoxMorph, InputFieldMorph, SpriteIconMorph, BlockMorph,
DialogBoxMorph, InputFieldMorph, SpriteIconMorph, BlockMorph, SymbolMorph,
ThreadManager, VariableFrame, detect, BlockMorph, BoxMorph, Color,
CommandBlockMorph, FrameMorph, HatBlockMorph, MenuMorph, Morph, MultiArgMorph,
Point, ReporterBlockMorph, ScriptsMorph, StringMorph, SyntaxElementMorph,
@ -82,7 +82,7 @@ SpeechBubbleMorph, RingMorph, isNil, FileReader, TableDialogMorph,
BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, localize,
TableMorph, TableFrameMorph, normalizeCanvas, BooleanSlotMorph, HandleMorph*/
modules.objects = '2017-June-23';
modules.objects = '2017-June-26';
var SpriteMorph;
var StageMorph;
@ -3035,7 +3035,7 @@ SpriteMorph.prototype.addSound = function (audio, name) {
SpriteMorph.prototype.playSound = function (name) {
var stage = this.parentThatIsA(StageMorph),
sound = detect(
sound = name instanceof Sound ? name : detect(
this.sounds.asArray(),
function (s) {return s.name === name; }
),
@ -7409,6 +7409,8 @@ SpriteBubbleMorph.prototype.dataAsMorph = function (data, toggle) {
contents.silentSetWidth(img.width);
contents.silentSetHeight(img.height);
contents.image = img;
} else if (data instanceof Sound) {
contents = new SymbolMorph('notes', 30);
} else if (data instanceof HTMLCanvasElement) {
contents = new Morph();
contents.silentSetWidth(data.width);
@ -8309,6 +8311,8 @@ CellMorph.prototype.drawNew = function (toggle, type) {
this.contentsMorph.silentSetWidth(img.width);
this.contentsMorph.silentSetHeight(img.height);
this.contentsMorph.image = img;
} else if (this.contents instanceof Sound) {
this.contentsMorph = new SymbolMorph('notes', 30);
} else if (this.contents instanceof List) {
if ('table' === type || (!toggle && this.contents.isTable())) {
this.contentsMorph = new TableFrameMorph(new TableMorph(

Wyświetl plik

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

Wyświetl plik

@ -66,11 +66,11 @@
/*global modules, Point, newCanvas, Morph, fontHeight, SliderMorph, List,
MorphicPreferences, FrameMorph, HandleMorph, DialogBoxMorph, isString,
SpriteMorph, Context, Costume, ArgMorph, BlockEditorMorph,
SyntaxElementMorph, MenuMorph, SpriteBubbleMorph, SpeechBubbleMorph,
SpriteMorph, Context, Costume, ArgMorph, BlockEditorMorph, SymbolMorph,
SyntaxElementMorph, MenuMorph, SpriteBubbleMorph, SpeechBubbleMorph, Sound,
CellMorph, ListWatcherMorph, isNil, BoxMorph, Variable, isSnapObject*/
modules.tables = '2016-May-02';
modules.tables = '2017-June-26';
var Table;
var TableCellMorph;
@ -401,6 +401,8 @@ TableCellMorph.prototype.dataRepresentation = function (dta) {
return dta.image();
} else if (dta instanceof Costume) {
return dta.thumbnail(new Point(40, 40));
} else if (dta instanceof Sound) {
return new SymbolMorph('notes', 30).image;
} else if (dta instanceof List) {
return this.listSymbol;
// 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,
TableFrameMorph, ColorSlotMorph, isSnapObject*/
modules.threads = '2017-June-24';
modules.threads = '2017-June-26';
var ThreadManager;
var Process;
@ -3042,10 +3042,8 @@ Process.prototype.reportGet = function (query) {
return thisObj.parentThatIsA(StageMorph);
case 'costumes':
return thisObj.reportCostumes();
/*
case 'sounds':
return thisObj.sounds;
*/
}
}
return '';