kopia lustrzana https://github.com/backface/turtlestitch
improved importing costumes
by dragging in pictures from other web pages, which now allows for dragging links to pictures as wellpull/3/merge
rodzic
b8c48040a2
commit
09e3a296c2
7
gui.js
7
gui.js
|
@ -68,7 +68,7 @@ sb, CommentMorph, CommandBlockMorph*/
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.gui = '2013-June-26';
|
modules.gui = '2013-June-28';
|
||||||
|
|
||||||
// Declarations
|
// Declarations
|
||||||
|
|
||||||
|
@ -1477,7 +1477,10 @@ IDE_Morph.prototype.reactToWorldResize = function (rect) {
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.droppedImage = function (aCanvas, name) {
|
IDE_Morph.prototype.droppedImage = function (aCanvas, name) {
|
||||||
var costume = new Costume(aCanvas, name.split('.')[0]); // up to period
|
var costume = new Costume(
|
||||||
|
aCanvas,
|
||||||
|
name ? name.split('.')[0] : '' // up to period
|
||||||
|
);
|
||||||
this.currentSprite.addCostume(costume);
|
this.currentSprite.addCostume(costume);
|
||||||
this.currentSprite.wearCostume(costume);
|
this.currentSprite.wearCostume(costume);
|
||||||
this.spriteBar.tabBar.tabTo('costumes');
|
this.spriteBar.tabBar.tabTo('costumes');
|
||||||
|
|
|
@ -1769,3 +1769,7 @@ ______
|
||||||
130627
|
130627
|
||||||
------
|
------
|
||||||
* Objects: fixed speech bubble scaling when sprite is not onstage (reported in the forums)
|
* Objects: fixed speech bubble scaling when sprite is not onstage (reported in the forums)
|
||||||
|
|
||||||
|
130628
|
||||||
|
------
|
||||||
|
* Morphic, GUI: improved importing costumes by dragging in pictures from other web pages
|
||||||
|
|
22
morphic.js
22
morphic.js
|
@ -1035,7 +1035,7 @@
|
||||||
/*global window, HTMLCanvasElement, getMinimumFontHeight, FileReader, Audio,
|
/*global window, HTMLCanvasElement, getMinimumFontHeight, FileReader, Audio,
|
||||||
FileList, getBlurredShadowSupport*/
|
FileList, getBlurredShadowSupport*/
|
||||||
|
|
||||||
var morphicVersion = '2013-June-21';
|
var morphicVersion = '2013-June-28';
|
||||||
var modules = {}; // keep track of additional loaded modules
|
var modules = {}; // keep track of additional loaded modules
|
||||||
var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug
|
var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug
|
||||||
|
|
||||||
|
@ -9708,6 +9708,8 @@ HandMorph.prototype.processDrop = function (event) {
|
||||||
var files = event instanceof FileList ? event
|
var files = event instanceof FileList ? event
|
||||||
: event.target.files || event.dataTransfer.files,
|
: event.target.files || event.dataTransfer.files,
|
||||||
file,
|
file,
|
||||||
|
url = event.dataTransfer ?
|
||||||
|
event.dataTransfer.getData('URL') : null,
|
||||||
txt = event.dataTransfer ?
|
txt = event.dataTransfer ?
|
||||||
event.dataTransfer.getData('Text/HTML') : null,
|
event.dataTransfer.getData('Text/HTML') : null,
|
||||||
src,
|
src,
|
||||||
|
@ -9818,6 +9820,24 @@ HandMorph.prototype.processDrop = function (event) {
|
||||||
readBinary(file);
|
readBinary(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (url) {
|
||||||
|
if (
|
||||||
|
contains(
|
||||||
|
['gif', 'png', 'jpg', 'jpeg', 'bmp'],
|
||||||
|
url.slice(url.lastIndexOf('.') + 1).toLowerCase()
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
while (!target.droppedImage) {
|
||||||
|
target = target.parent;
|
||||||
|
}
|
||||||
|
img = new Image();
|
||||||
|
img.onload = function () {
|
||||||
|
canvas = newCanvas(new Point(img.width, img.height));
|
||||||
|
canvas.getContext('2d').drawImage(img, 0, 0);
|
||||||
|
target.droppedImage(canvas);
|
||||||
|
};
|
||||||
|
img.src = url;
|
||||||
|
}
|
||||||
} else if (txt) {
|
} else if (txt) {
|
||||||
while (!target.droppedImage) {
|
while (!target.droppedImage) {
|
||||||
target = target.parent;
|
target = target.parent;
|
||||||
|
|
Ładowanie…
Reference in New Issue