migrated sprite icon button rendering

pull/95/head
jmoenig 2020-03-05 09:11:53 +01:00
rodzic d5f4a05c54
commit 2ba72b1c9d
1 zmienionych plików z 19 dodań i 33 usunięć

Wyświetl plik

@ -78,7 +78,7 @@ Animation, BoxMorph, BlockEditorMorph, BlockDialogMorph, Note*/
// Global stuff ////////////////////////////////////////////////////////
modules.gui = '2020-March-03';
modules.gui = '2020-March-05';
// Declarations
@ -8276,39 +8276,25 @@ SpriteIconMorph.prototype.mouseDoubleClick = function () {
// SpriteIconMorph drawing
SpriteIconMorph.prototype.createBackgrounds = function () {
// only draw the edges if I am selected
var context,
ext = this.extent();
if (this.template) { // take the backgrounds images from the template
this.image = this.template.image;
this.normalImage = this.template.normalImage;
this.highlightImage = this.template.highlightImage;
this.pressImage = this.template.pressImage;
return null;
}
this.normalImage = newCanvas(ext, false, this.normalImage);
context = this.normalImage.getContext('2d');
this.drawBackground(context, this.color);
this.highlightImage = newCanvas(ext, false, this.highlightImage);
context = this.highlightImage.getContext('2d');
this.drawBackground(context, this.highlightColor);
this.pressImage = newCanvas(ext, false, this.pressImage);
context = this.pressImage.getContext('2d');
this.drawOutline(context);
this.drawBackground(context, this.pressColor);
SpriteIconMorph.prototype.render = function (ctx) {
// only draw the edges if I am selected
switch (this.userState) {
case 'highlight':
this.drawBackground(ctx, this.highlightColor);
break;
case 'pressed':
this.drawOutline(ctx);
this.drawBackground(ctx, this.pressColor);
this.drawEdges(
context,
ctx,
this.pressColor,
this.pressColor.lighter(this.contrast),
this.pressColor.darker(this.contrast)
this.pressColor.lighter(40),
this.pressColor.darker(40)
);
this.image = this.normalImage;
break;
default:
this.drawBackground(ctx, this.color);
}
};
// SpriteIconMorph drag & drop