kopia lustrzana https://github.com/backface/turtlestitch
rodzic
7ed29240c8
commit
0d5ac936d4
175
gui.js
175
gui.js
|
@ -1544,44 +1544,44 @@ IDE_Morph.prototype.createCorralBar = function () {
|
|||
);
|
||||
this.corralBar.add(paintbutton);
|
||||
|
||||
cambutton = new PushButtonMorph(
|
||||
this,
|
||||
"newCamSprite",
|
||||
new SymbolMorph("camera", 15)
|
||||
);
|
||||
cambutton.corner = 12;
|
||||
cambutton.color = colors[0];
|
||||
cambutton.highlightColor = colors[1];
|
||||
cambutton.pressColor = colors[2];
|
||||
cambutton.labelMinExtent = new Point(36, 18);
|
||||
cambutton.padding = 0;
|
||||
cambutton.labelShadowOffset = new Point(-1, -1);
|
||||
cambutton.labelShadowColor = colors[1];
|
||||
cambutton.labelColor = this.buttonLabelColor;
|
||||
cambutton.contrast = this.buttonContrast;
|
||||
cambutton.drawNew();
|
||||
cambutton.hint = "take a camera snapshot and\nimport it as a new sprite";
|
||||
cambutton.fixLayout();
|
||||
cambutton.setCenter(this.corralBar.center());
|
||||
cambutton.setLeft(
|
||||
this.corralBar.left() +
|
||||
padding +
|
||||
newbutton.width() +
|
||||
padding +
|
||||
paintbutton.width() +
|
||||
padding
|
||||
);
|
||||
|
||||
this.corralBar.add(cambutton);
|
||||
|
||||
document.addEventListener(
|
||||
'cameraDisabled',
|
||||
function (event) {
|
||||
cambutton.disable();
|
||||
cambutton.hint =
|
||||
CamSnapshotDialogMorph.prototype.notSupportedMessage;
|
||||
}
|
||||
);
|
||||
if (CamSnapshotDialogMorph.prototype.enableCamera) {
|
||||
cambutton = new PushButtonMorph(
|
||||
this,
|
||||
"newCamSprite",
|
||||
new SymbolMorph("camera", 15)
|
||||
);
|
||||
cambutton.corner = 12;
|
||||
cambutton.color = colors[0];
|
||||
cambutton.highlightColor = colors[1];
|
||||
cambutton.pressColor = colors[2];
|
||||
cambutton.labelMinExtent = new Point(36, 18);
|
||||
cambutton.padding = 0;
|
||||
cambutton.labelShadowOffset = new Point(-1, -1);
|
||||
cambutton.labelShadowColor = colors[1];
|
||||
cambutton.labelColor = this.buttonLabelColor;
|
||||
cambutton.contrast = this.buttonContrast;
|
||||
cambutton.drawNew();
|
||||
cambutton.hint = "take a camera snapshot and\nimport it as a new sprite";
|
||||
cambutton.fixLayout();
|
||||
cambutton.setCenter(this.corralBar.center());
|
||||
cambutton.setLeft(
|
||||
this.corralBar.left() +
|
||||
padding +
|
||||
newbutton.width() +
|
||||
padding +
|
||||
paintbutton.width() +
|
||||
padding
|
||||
);
|
||||
this.corralBar.add(cambutton);
|
||||
document.addEventListener(
|
||||
'cameraDisabled',
|
||||
function (event) {
|
||||
cambutton.disable();
|
||||
cambutton.hint =
|
||||
CamSnapshotDialogMorph.prototype.notSupportedMessage;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
IDE_Morph.prototype.createCorral = function () {
|
||||
|
@ -1980,6 +1980,14 @@ IDE_Morph.prototype.toggleSingleStepping = function () {
|
|||
this.controlBar.refreshSlider();
|
||||
};
|
||||
|
||||
IDE_Morph.prototype.toggleCameraSupport = function () {
|
||||
CamSnapshotDialogMorph.prototype.enableCamera =
|
||||
!CamSnapshotDialogMorph.prototype.enableCamera;
|
||||
this.spriteBar.tabBar.tabTo(this.currentTab);
|
||||
this.createCorralBar();
|
||||
this.fixLayout();
|
||||
};
|
||||
|
||||
IDE_Morph.prototype.startFastTracking = function () {
|
||||
this.stage.isFastTracked = true;
|
||||
this.stage.fps = 0;
|
||||
|
@ -2631,6 +2639,14 @@ IDE_Morph.prototype.settingsMenu = function () {
|
|||
'check to turn on\n visible stepping (slow)',
|
||||
false
|
||||
);
|
||||
addPreference(
|
||||
'Camera support',
|
||||
'toggleCameraSupport',
|
||||
CamSnapshotDialogMorph.prototype.enableCamera,
|
||||
'uncheck to disable\ncamera support',
|
||||
'check to enable\ncamera support',
|
||||
true
|
||||
);
|
||||
menu.addLine(); // everything visible below is persistent
|
||||
addPreference(
|
||||
'Blurred shadows',
|
||||
|
@ -7339,7 +7355,7 @@ CostumeIconMorph.prototype.duplicateCostume = function () {
|
|||
CostumeIconMorph.prototype.removeCostume = function () {
|
||||
var wardrobe = this.parentThatIsA(WardrobeMorph),
|
||||
idx = this.parent.children.indexOf(this),
|
||||
off = 3,
|
||||
off = CamSnapshotDialogMorph.prototype.enableCamera ? 3 : 2,
|
||||
ide = this.parentThatIsA(IDE_Morph);
|
||||
wardrobe.removeCostumeAt(idx - off); // ignore paintbrush and camera buttons
|
||||
if (ide.currentSprite.costume === this.object) {
|
||||
|
@ -7659,43 +7675,45 @@ WardrobeMorph.prototype.updateList = function () {
|
|||
|
||||
this.addContents(paintbutton);
|
||||
|
||||
cambutton = new PushButtonMorph(
|
||||
this,
|
||||
"newFromCam",
|
||||
new SymbolMorph("camera", 15)
|
||||
);
|
||||
cambutton.padding = 0;
|
||||
cambutton.corner = 12;
|
||||
cambutton.color = IDE_Morph.prototype.groupColor;
|
||||
cambutton.highlightColor = IDE_Morph.prototype.frameColor.darker(50);
|
||||
cambutton.pressColor = paintbutton.highlightColor;
|
||||
cambutton.labelMinExtent = new Point(36, 18);
|
||||
cambutton.labelShadowOffset = new Point(-1, -1);
|
||||
cambutton.labelShadowColor = paintbutton.highlightColor;
|
||||
cambutton.labelColor = TurtleIconMorph.prototype.labelColor;
|
||||
cambutton.contrast = this.buttonContrast;
|
||||
cambutton.drawNew();
|
||||
cambutton.hint = "Import a new costume from your webcam";
|
||||
cambutton.setPosition(new Point(x, y));
|
||||
cambutton.fixLayout();
|
||||
cambutton.setCenter(paintbutton.center());
|
||||
cambutton.setLeft(paintbutton.right() + toolsPadding);
|
||||
if (CamSnapshotDialogMorph.prototype.enableCamera) {
|
||||
cambutton = new PushButtonMorph(
|
||||
this,
|
||||
"newFromCam",
|
||||
new SymbolMorph("camera", 15)
|
||||
);
|
||||
cambutton.padding = 0;
|
||||
cambutton.corner = 12;
|
||||
cambutton.color = IDE_Morph.prototype.groupColor;
|
||||
cambutton.highlightColor = IDE_Morph.prototype.frameColor.darker(50);
|
||||
cambutton.pressColor = paintbutton.highlightColor;
|
||||
cambutton.labelMinExtent = new Point(36, 18);
|
||||
cambutton.labelShadowOffset = new Point(-1, -1);
|
||||
cambutton.labelShadowColor = paintbutton.highlightColor;
|
||||
cambutton.labelColor = TurtleIconMorph.prototype.labelColor;
|
||||
cambutton.contrast = this.buttonContrast;
|
||||
cambutton.drawNew();
|
||||
cambutton.hint = "Import a new costume from your webcam";
|
||||
cambutton.setPosition(new Point(x, y));
|
||||
cambutton.fixLayout();
|
||||
cambutton.setCenter(paintbutton.center());
|
||||
cambutton.setLeft(paintbutton.right() + toolsPadding);
|
||||
|
||||
this.addContents(cambutton);
|
||||
this.addContents(cambutton);
|
||||
|
||||
if (!CamSnapshotDialogMorph.prototype.enabled) {
|
||||
cambutton.disable();
|
||||
cambutton.hint = CamSnapshotDialogMorph.prototype.notSupportedMessage;
|
||||
}
|
||||
|
||||
document.addEventListener(
|
||||
'cameraDisabled',
|
||||
function () {
|
||||
if (!CamSnapshotDialogMorph.prototype.enabled) {
|
||||
cambutton.disable();
|
||||
cambutton.hint =
|
||||
CamSnapshotDialogMorph.prototype.notSupportedMessage;
|
||||
cambutton.hint = CamSnapshotDialogMorph.prototype.notSupportedMessage;
|
||||
}
|
||||
);
|
||||
|
||||
document.addEventListener(
|
||||
'cameraDisabled',
|
||||
function () {
|
||||
cambutton.disable();
|
||||
cambutton.hint =
|
||||
CamSnapshotDialogMorph.prototype.notSupportedMessage;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
txt = new TextMorph(localize(
|
||||
"costumes tab help" // look up long string in translator
|
||||
|
@ -8394,6 +8412,9 @@ PaletteHandleMorph.prototype.mouseDoubleClick = function () {
|
|||
/*
|
||||
I am a dialog morph that lets users take a snapshot using their webcam
|
||||
and use it as a costume for their sprites or a background for the Stage.
|
||||
|
||||
NOTE: Currently disabled because of issues with experimental technology
|
||||
in Safari.
|
||||
*/
|
||||
|
||||
// CamSnapshotDialogMorph inherits from DialogBoxMorph:
|
||||
|
@ -8404,6 +8425,7 @@ CamSnapshotDialogMorph.uber = DialogBoxMorph.prototype;
|
|||
|
||||
// CamSnapshotDialogMorph settings
|
||||
|
||||
CamSnapshotDialogMorph.prototype.enableCamera = false; // off while experimental
|
||||
CamSnapshotDialogMorph.prototype.enabled = true;
|
||||
|
||||
CamSnapshotDialogMorph.prototype.notSupportedMessage =
|
||||
|
@ -8463,6 +8485,15 @@ CamSnapshotDialogMorph.prototype.buildContents = function () {
|
|||
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
|
||||
navigator.mediaDevices.getUserMedia({ video: true })
|
||||
.then(function (stream) {
|
||||
/*
|
||||
there are issues at this point with current Safari 11:
|
||||
URL.createObjectURL is still considered experimental
|
||||
and needs to be prefixed with webkitURL for URL,
|
||||
and - worse - does not accept a stream as argument,
|
||||
throwing a type error. Until these issues are resolved
|
||||
we'll disable camera support, treating it as a hidden
|
||||
experimental feature. -Jens
|
||||
*/
|
||||
myself.videoElement.src = window.URL.createObjectURL(stream);
|
||||
myself.videoElement.play().catch(noCameraSupport);
|
||||
myself.videoElement.stream = stream;
|
||||
|
|
|
@ -3649,6 +3649,7 @@ Fixes:
|
|||
* GUI, Symbols: added “visible stepping” toggle button to the control bar
|
||||
* 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
|
||||
|
||||
|
||||
v4.1 Features:
|
||||
|
@ -3657,7 +3658,7 @@ v4.1 Features:
|
|||
* inheritance of sprite attributes (x, y, direction, size, costumes, costume #, sounds, scripts)
|
||||
* first-class costumes and sounds
|
||||
* visual indicator (map-pin icon) for sprite-local custom blocks (i.e. methods)
|
||||
* camera snapshots for costumes and new sprites
|
||||
* [experimental hidden] camera snapshots for costumes and new sprites
|
||||
* 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
|
||||
|
|
Ładowanie…
Reference in New Issue