kopia lustrzana https://github.com/backface/turtlestitch
Merge branch 'master' into patch-3
commit
1457288500
25
HISTORY.md
25
HISTORY.md
|
@ -2,6 +2,31 @@
|
||||||
|
|
||||||
## in development:
|
## in development:
|
||||||
|
|
||||||
|
### 2020-07-22
|
||||||
|
* morphic, blocks, gui: tweaked block-fading mouse-over
|
||||||
|
* blocks, threads: tweaked context visualizations to be alpha-independent
|
||||||
|
* gui: save block-transparency in settings
|
||||||
|
* morphic: fixed input slider target update rendering
|
||||||
|
|
||||||
|
### 2020-07-21
|
||||||
|
* blocks: tweaked block highlights for fade-out
|
||||||
|
* widgets, gui: tweaked scripts tab for fade-out
|
||||||
|
* blocks, gui: tweaked default mode colors to slightly darker
|
||||||
|
|
||||||
|
### 2020-07-20
|
||||||
|
* objects: fixed a list-watcher direct-editing offset bug
|
||||||
|
* morphic: update the Hand's position on mouse-down - avoid triggering at the origin point
|
||||||
|
* symbols: added hooks for dynamic coloring
|
||||||
|
* blocks: added blocks-fading support for symbols (under construction)
|
||||||
|
* morphic: tweaked transparency of grabbed morphs
|
||||||
|
|
||||||
|
### 2020-07-19
|
||||||
|
* blocks: blocks-fade-out support for label arrows (under construction)
|
||||||
|
* blocks: blocks-fade-out support for multi-line inputs (under construction)
|
||||||
|
|
||||||
|
### 2020-07-17
|
||||||
|
* morphic, blocks: blocks-fadeout (under construction)
|
||||||
|
|
||||||
### 2020-07-15
|
### 2020-07-15
|
||||||
* morphic: made keyboard handler (more) invisible, thanks, Bernat!
|
* morphic: made keyboard handler (more) invisible, thanks, Bernat!
|
||||||
* gui: made remaining synchronous http requests asynch (url: #open, #run)
|
* gui: made remaining synchronous http requests asynch (url: #open, #run)
|
||||||
|
|
14
snap.html
14
snap.html
|
@ -4,13 +4,13 @@
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
<title>Snap! Build Your Own Blocks 6.0.1 - dev -</title>
|
<title>Snap! Build Your Own Blocks 6.0.1 - dev -</title>
|
||||||
<link rel="icon" href="src/favicon.ico">
|
<link rel="icon" href="src/favicon.ico">
|
||||||
<script src="src/morphic.js?version=2020-07-16"></script>
|
<script src="src/morphic.js?version=2020-07-22"></script>
|
||||||
<script src="src/symbols.js?version=2020-07-01"></script>
|
<script src="src/symbols.js?version=2020-07-21"></script>
|
||||||
<script src="src/widgets.js?version=2020-07-13"></script>
|
<script src="src/widgets.js?version=2020-07-21"></script>
|
||||||
<script src="src/blocks.js?version=2020-07-15"></script>
|
<script src="src/blocks.js?version=2020-07-22"></script>
|
||||||
<script src="src/threads.js?version=2020-07-09"></script>
|
<script src="src/threads.js?version=2020-07-22"></script>
|
||||||
<script src="src/objects.js?version=2020-07-13"></script>
|
<script src="src/objects.js?version=2020-07-20"></script>
|
||||||
<script src="src/gui.js?version=2020-07-16"></script>
|
<script src="src/gui.js?version=2020-07-22"></script>
|
||||||
<script src="src/paint.js?version=2020-05-17"></script>
|
<script src="src/paint.js?version=2020-05-17"></script>
|
||||||
<script src="src/lists.js?version=2020-07-01"></script>
|
<script src="src/lists.js?version=2020-07-01"></script>
|
||||||
<script src="src/byob.js?version=2020-07-01"></script>
|
<script src="src/byob.js?version=2020-07-01"></script>
|
||||||
|
|
350
src/blocks.js
350
src/blocks.js
|
@ -65,6 +65,12 @@
|
||||||
BoxMorph*
|
BoxMorph*
|
||||||
CommentMorph
|
CommentMorph
|
||||||
ScriptFocusMorph
|
ScriptFocusMorph
|
||||||
|
StringMorph*
|
||||||
|
BlockLabelMorph
|
||||||
|
InputSlotStringMorph
|
||||||
|
InputSlotTextMorph
|
||||||
|
SymbolMorph*
|
||||||
|
BlockSymbolMorph
|
||||||
|
|
||||||
* from morphic.js
|
* from morphic.js
|
||||||
|
|
||||||
|
@ -75,6 +81,8 @@
|
||||||
defined. Use this list to locate code in this document:
|
defined. Use this list to locate code in this document:
|
||||||
|
|
||||||
SyntaxElementMorph
|
SyntaxElementMorph
|
||||||
|
BlockLabelMorph
|
||||||
|
BlockSymbolMorph
|
||||||
BlockMorph
|
BlockMorph
|
||||||
CommandBlockMorph
|
CommandBlockMorph
|
||||||
HatBlockMorph
|
HatBlockMorph
|
||||||
|
@ -86,6 +94,8 @@
|
||||||
RingCommandSlotMorph
|
RingCommandSlotMorph
|
||||||
CSlotMorph
|
CSlotMorph
|
||||||
InputSlotMorph
|
InputSlotMorph
|
||||||
|
InputSlotStringMorph
|
||||||
|
InputSlotTextMorph
|
||||||
BooleanSlotMorph
|
BooleanSlotMorph
|
||||||
ArrowMorph
|
ArrowMorph
|
||||||
TextSlotMorph
|
TextSlotMorph
|
||||||
|
@ -142,16 +152,18 @@ document, getDocumentPositionOf, isNaN, isString, newCanvas, nop, parseFloat,
|
||||||
radians, useBlurredShadows, SpeechBubbleMorph, modules, StageMorph, Sound,
|
radians, useBlurredShadows, SpeechBubbleMorph, modules, StageMorph, Sound,
|
||||||
fontHeight, TableFrameMorph, SpriteMorph, Context, ListWatcherMorph, Rectangle,
|
fontHeight, TableFrameMorph, SpriteMorph, Context, ListWatcherMorph, Rectangle,
|
||||||
DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, WHITE, BLACK,
|
DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, WHITE, BLACK,
|
||||||
Costume, IDE_Morph, BlockDialogMorph, BlockEditorMorph, localize, isNil,
|
Costume, IDE_Morph, BlockDialogMorph, BlockEditorMorph, localize, isNil, CLEAR,
|
||||||
isSnapObject, PushButtonMorph, SpriteIconMorph, Process, AlignmentMorph,
|
isSnapObject, PushButtonMorph, SpriteIconMorph, Process, AlignmentMorph,
|
||||||
CustomCommandBlockMorph, SymbolMorph, ToggleButtonMorph, DialMorph*/
|
CustomCommandBlockMorph, SymbolMorph, ToggleButtonMorph, DialMorph*/
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.blocks = '2020-July-15';
|
modules.blocks = '2020-July-22';
|
||||||
|
|
||||||
var SyntaxElementMorph;
|
var SyntaxElementMorph;
|
||||||
var BlockMorph;
|
var BlockMorph;
|
||||||
|
var BlockLabelMorph;
|
||||||
|
var BlockSymbolMorph;
|
||||||
var CommandBlockMorph;
|
var CommandBlockMorph;
|
||||||
var ReporterBlockMorph;
|
var ReporterBlockMorph;
|
||||||
var ScriptsMorph;
|
var ScriptsMorph;
|
||||||
|
@ -159,6 +171,8 @@ var ArgMorph;
|
||||||
var CommandSlotMorph;
|
var CommandSlotMorph;
|
||||||
var CSlotMorph;
|
var CSlotMorph;
|
||||||
var InputSlotMorph;
|
var InputSlotMorph;
|
||||||
|
var InputSlotStringMorph;
|
||||||
|
var InputSlotTextMorph;
|
||||||
var BooleanSlotMorph;
|
var BooleanSlotMorph;
|
||||||
var ArrowMorph;
|
var ArrowMorph;
|
||||||
var ColorSlotMorph;
|
var ColorSlotMorph;
|
||||||
|
@ -771,6 +785,15 @@ SyntaxElementMorph.prototype.unflash = function () {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SyntaxElementMorph.prototype.doWithAlpha = function (alpha, callback) {
|
||||||
|
var current = SyntaxElementMorph.prototype.alpha,
|
||||||
|
result;
|
||||||
|
SyntaxElementMorph.prototype.alpha = alpha;
|
||||||
|
result = callback();
|
||||||
|
SyntaxElementMorph.prototype.alpha = current;
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
// SyntaxElementMorph zebra coloring
|
// SyntaxElementMorph zebra coloring
|
||||||
|
|
||||||
SyntaxElementMorph.prototype.fixBlockColor = function (
|
SyntaxElementMorph.prototype.fixBlockColor = function (
|
||||||
|
@ -1567,12 +1590,13 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
|
||||||
part.add(this.labelPart('%loopArrow'));
|
part.add(this.labelPart('%loopArrow'));
|
||||||
break;
|
break;
|
||||||
case '%loopArrow':
|
case '%loopArrow':
|
||||||
part = new SymbolMorph('loop');
|
part = new BlockSymbolMorph('loop');
|
||||||
part.size = this.fontSize * 0.7;
|
part.size = this.fontSize * 0.7;
|
||||||
part.color = WHITE;
|
part.color = WHITE;
|
||||||
part.shadowColor = this.color.darker(this.labelContrast);
|
part.shadowColor = this.color.darker(this.labelContrast);
|
||||||
part.shadowOffset = MorphicPreferences.isFlat ?
|
part.shadowOffset = MorphicPreferences.isFlat ?
|
||||||
ZERO : this.embossing;
|
ZERO : this.embossing;
|
||||||
|
part.isFading = true;
|
||||||
part.fixLayout();
|
part.fixLayout();
|
||||||
break;
|
break;
|
||||||
case '%clr':
|
case '%clr':
|
||||||
|
@ -1625,7 +1649,7 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
|
||||||
// symbols:
|
// symbols:
|
||||||
|
|
||||||
case '%turtle':
|
case '%turtle':
|
||||||
part = new SymbolMorph('turtle');
|
part = new BlockSymbolMorph('turtle');
|
||||||
part.size = this.fontSize * 1.2;
|
part.size = this.fontSize * 1.2;
|
||||||
part.color = WHITE;
|
part.color = WHITE;
|
||||||
part.shadowColor = this.color.darker(this.labelContrast);
|
part.shadowColor = this.color.darker(this.labelContrast);
|
||||||
|
@ -1634,7 +1658,7 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
|
||||||
part.fixLayout();
|
part.fixLayout();
|
||||||
break;
|
break;
|
||||||
case '%turtleOutline':
|
case '%turtleOutline':
|
||||||
part = new SymbolMorph('turtleOutline');
|
part = new BlockSymbolMorph('turtleOutline');
|
||||||
part.size = this.fontSize;
|
part.size = this.fontSize;
|
||||||
part.color = WHITE;
|
part.color = WHITE;
|
||||||
part.isProtectedLabel = true; // doesn't participate in zebraing
|
part.isProtectedLabel = true; // doesn't participate in zebraing
|
||||||
|
@ -1644,7 +1668,7 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
|
||||||
part.fixLayout();
|
part.fixLayout();
|
||||||
break;
|
break;
|
||||||
case '%clockwise':
|
case '%clockwise':
|
||||||
part = new SymbolMorph('turnRight');
|
part = new BlockSymbolMorph('turnRight');
|
||||||
part.size = this.fontSize * 1.5;
|
part.size = this.fontSize * 1.5;
|
||||||
part.color = WHITE;
|
part.color = WHITE;
|
||||||
part.isProtectedLabel = false; // zebra colors
|
part.isProtectedLabel = false; // zebra colors
|
||||||
|
@ -1654,7 +1678,7 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
|
||||||
part.fixLayout();
|
part.fixLayout();
|
||||||
break;
|
break;
|
||||||
case '%counterclockwise':
|
case '%counterclockwise':
|
||||||
part = new SymbolMorph('turnLeft');
|
part = new BlockSymbolMorph('turnLeft');
|
||||||
part.size = this.fontSize * 1.5;
|
part.size = this.fontSize * 1.5;
|
||||||
part.color = WHITE;
|
part.color = WHITE;
|
||||||
part.isProtectedLabel = false; // zebra colors
|
part.isProtectedLabel = false; // zebra colors
|
||||||
|
@ -1664,7 +1688,7 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
|
||||||
part.fixLayout();
|
part.fixLayout();
|
||||||
break;
|
break;
|
||||||
case '%greenflag':
|
case '%greenflag':
|
||||||
part = new SymbolMorph('flag');
|
part = new BlockSymbolMorph('flag');
|
||||||
part.size = this.fontSize * 1.5;
|
part.size = this.fontSize * 1.5;
|
||||||
part.color = new Color(0, 200, 0);
|
part.color = new Color(0, 200, 0);
|
||||||
part.isProtectedLabel = true; // doesn't participate in zebraing
|
part.isProtectedLabel = true; // doesn't participate in zebraing
|
||||||
|
@ -1674,7 +1698,7 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
|
||||||
part.fixLayout();
|
part.fixLayout();
|
||||||
break;
|
break;
|
||||||
case '%stop':
|
case '%stop':
|
||||||
part = new SymbolMorph('octagon');
|
part = new BlockSymbolMorph('octagon');
|
||||||
part.size = this.fontSize * 1.5;
|
part.size = this.fontSize * 1.5;
|
||||||
part.color = new Color(200, 0, 0);
|
part.color = new Color(200, 0, 0);
|
||||||
part.isProtectedLabel = true; // doesn't participate in zebraing
|
part.isProtectedLabel = true; // doesn't participate in zebraing
|
||||||
|
@ -1684,7 +1708,7 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
|
||||||
part.fixLayout();
|
part.fixLayout();
|
||||||
break;
|
break;
|
||||||
case '%pause':
|
case '%pause':
|
||||||
part = new SymbolMorph('pause');
|
part = new BlockSymbolMorph('pause');
|
||||||
part.size = this.fontSize;
|
part.size = this.fontSize;
|
||||||
part.color = new Color(255, 220, 0);
|
part.color = new Color(255, 220, 0);
|
||||||
part.isProtectedLabel = true; // doesn't participate in zebraing
|
part.isProtectedLabel = true; // doesn't participate in zebraing
|
||||||
|
@ -1694,7 +1718,7 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
|
||||||
part.fixLayout();
|
part.fixLayout();
|
||||||
break;
|
break;
|
||||||
case '%blitz':
|
case '%blitz':
|
||||||
part = new SymbolMorph('flash');
|
part = new BlockSymbolMorph('flash');
|
||||||
part.size = this.fontSize;
|
part.size = this.fontSize;
|
||||||
part.color = WHITE;
|
part.color = WHITE;
|
||||||
part.isProtectedLabel = false; // zebra colors
|
part.isProtectedLabel = false; // zebra colors
|
||||||
|
@ -1704,7 +1728,7 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
|
||||||
part.fixLayout();
|
part.fixLayout();
|
||||||
break;
|
break;
|
||||||
case '%list':
|
case '%list':
|
||||||
part = new SymbolMorph('list');
|
part = new BlockSymbolMorph('list');
|
||||||
part.size = this.fontSize;
|
part.size = this.fontSize;
|
||||||
part.color = WHITE;
|
part.color = WHITE;
|
||||||
part.shadowColor = this.color.darker(this.labelContrast);
|
part.shadowColor = this.color.darker(this.labelContrast);
|
||||||
|
@ -1756,7 +1780,7 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
|
||||||
part.fontStyle = this.labelFontStyle;
|
part.fontStyle = this.labelFontStyle;
|
||||||
part.fontSize = this.fontSize * (+tokens[1] || 1);
|
part.fontSize = this.fontSize * (+tokens[1] || 1);
|
||||||
} else {
|
} else {
|
||||||
part = new SymbolMorph(tokens[0]);
|
part = new BlockSymbolMorph(tokens[0]);
|
||||||
part.size = this.fontSize * (+tokens[1] || 1.2);
|
part.size = this.fontSize * (+tokens[1] || 1.2);
|
||||||
}
|
}
|
||||||
part.color = new Color(
|
part.color = new Color(
|
||||||
|
@ -1770,7 +1794,7 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
|
||||||
ZERO : this.embossing;
|
ZERO : this.embossing;
|
||||||
part.fixLayout();
|
part.fixLayout();
|
||||||
} else {
|
} else {
|
||||||
part = new StringMorph(
|
part = new BlockLabelMorph(
|
||||||
spec, // text
|
spec, // text
|
||||||
this.fontSize, // fontSize
|
this.fontSize, // fontSize
|
||||||
this.labelFontStyle, // fontStyle
|
this.labelFontStyle, // fontStyle
|
||||||
|
@ -1783,6 +1807,7 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
|
||||||
WHITE, // color
|
WHITE, // color
|
||||||
this.labelFontName // fontName
|
this.labelFontName // fontName
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
return part;
|
return part;
|
||||||
};
|
};
|
||||||
|
@ -2268,6 +2293,115 @@ SyntaxElementMorph.prototype.mappedCode = function (definitions) {
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// BlockLabelMorph ///////////////////////////////////////////////
|
||||||
|
|
||||||
|
/*
|
||||||
|
I am a piece of single-line text written on a block. I serve as a
|
||||||
|
container for sharing typographic attributes among my instances
|
||||||
|
*/
|
||||||
|
|
||||||
|
// BlockLabelMorph inherits from StringMorph:
|
||||||
|
|
||||||
|
BlockLabelMorph.prototype = new StringMorph();
|
||||||
|
BlockLabelMorph.prototype.constructor = BlockLabelMorph;
|
||||||
|
BlockLabelMorph.uber = StringMorph.prototype;
|
||||||
|
|
||||||
|
function BlockLabelMorph(
|
||||||
|
text,
|
||||||
|
fontSize,
|
||||||
|
fontStyle,
|
||||||
|
bold,
|
||||||
|
italic,
|
||||||
|
isNumeric,
|
||||||
|
shadowOffset,
|
||||||
|
shadowColor,
|
||||||
|
color,
|
||||||
|
fontName
|
||||||
|
) {
|
||||||
|
this.init(
|
||||||
|
text,
|
||||||
|
fontSize,
|
||||||
|
fontStyle,
|
||||||
|
bold,
|
||||||
|
italic,
|
||||||
|
isNumeric,
|
||||||
|
shadowOffset,
|
||||||
|
shadowColor,
|
||||||
|
color,
|
||||||
|
fontName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
BlockLabelMorph.prototype.getRenderColor = function () {
|
||||||
|
var block = this.parentThatIsA(BlockMorph);
|
||||||
|
if (MorphicPreferences.isFlat) {
|
||||||
|
return block.alpha > 0.4 ? this.color
|
||||||
|
: (block.alpha > 0.2 ? BLACK
|
||||||
|
: block.color.solid());
|
||||||
|
}
|
||||||
|
return block.alpha > 0.4 ? this.color
|
||||||
|
: (block.alpha > 0.2 ? WHITE
|
||||||
|
: block.color.solid());
|
||||||
|
};
|
||||||
|
|
||||||
|
BlockLabelMorph.prototype.getShadowRenderColor = function () {
|
||||||
|
return this.parentThatIsA(BlockMorph).alpha > 0.6 ?
|
||||||
|
this.shadowColor
|
||||||
|
: CLEAR;
|
||||||
|
};
|
||||||
|
|
||||||
|
// BlockSymbolMorph //////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/*
|
||||||
|
I am a pictogram written on a block. I serve as a
|
||||||
|
container for sharing typographic attributes among my instances.
|
||||||
|
NOTE: I have an additional attribute ".isFading" that governs
|
||||||
|
my behavior when fading out the blocks I'm embedded in
|
||||||
|
*/
|
||||||
|
|
||||||
|
// BlockSymbolMorph inherits from SymbolMorph:
|
||||||
|
|
||||||
|
BlockSymbolMorph.prototype = new SymbolMorph();
|
||||||
|
BlockSymbolMorph.prototype.constructor = BlockSymbolMorph;
|
||||||
|
BlockSymbolMorph.uber = SymbolMorph.prototype;
|
||||||
|
|
||||||
|
function BlockSymbolMorph(name, size, color, shadowOffset, shadowColor) {
|
||||||
|
this.init(name, size, color, shadowOffset, shadowColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockSymbolMorph.prototype.getRenderColor = function () {
|
||||||
|
if (MorphicPreferences.isFlat) {
|
||||||
|
if (this.isFading) {
|
||||||
|
return this.color.mixed(this.parent.alpha, WHITE);
|
||||||
|
}
|
||||||
|
if (this.color.eq(WHITE)) {
|
||||||
|
return this.parent.alpha > 0.4 ? this.color
|
||||||
|
: (this.parent.alpha > 0.2 ? BLACK
|
||||||
|
: this.parent.color.solid());
|
||||||
|
}
|
||||||
|
return this.color;
|
||||||
|
}
|
||||||
|
if (this.isFading) {
|
||||||
|
return this.color.mixed(
|
||||||
|
this.parent.alpha,
|
||||||
|
SpriteMorph.prototype.paletteColor
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (this.color.eq(BLACK)) {
|
||||||
|
return this.parent.alpha > 0.4 ? this.color
|
||||||
|
: (this.parent.alpha > 0.2 ? WHITE
|
||||||
|
: this.parent.color.solid());
|
||||||
|
}
|
||||||
|
if (this.color.eq(WHITE)) {
|
||||||
|
return this.parent.alpha > 0.2 ? WHITE
|
||||||
|
: this.parent.color.solid();
|
||||||
|
}
|
||||||
|
return this.color;
|
||||||
|
};
|
||||||
|
|
||||||
|
BlockSymbolMorph.prototype.getShadowRenderColor = function () {
|
||||||
|
return this.parent.alpha > 0.6 ? this.shadowColor : CLEAR;
|
||||||
|
};
|
||||||
|
|
||||||
// BlockMorph //////////////////////////////////////////////////////////
|
// BlockMorph //////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -4078,7 +4212,7 @@ BlockMorph.prototype.highlight = function (color, blur, border) {
|
||||||
BlockMorph.prototype.highlightImage = function (color, border) {
|
BlockMorph.prototype.highlightImage = function (color, border) {
|
||||||
var fb, img, hi, ctx, out;
|
var fb, img, hi, ctx, out;
|
||||||
fb = this.fullBounds().extent();
|
fb = this.fullBounds().extent();
|
||||||
img = this.fullImage();
|
this.doWithAlpha(1, () => img = this.fullImage());
|
||||||
|
|
||||||
hi = newCanvas(fb.add(border * 2));
|
hi = newCanvas(fb.add(border * 2));
|
||||||
ctx = hi.getContext('2d');
|
ctx = hi.getContext('2d');
|
||||||
|
@ -4108,7 +4242,7 @@ BlockMorph.prototype.highlightImage = function (color, border) {
|
||||||
BlockMorph.prototype.highlightImageBlurred = function (color, blur) {
|
BlockMorph.prototype.highlightImageBlurred = function (color, blur) {
|
||||||
var fb, img, hi, ctx;
|
var fb, img, hi, ctx;
|
||||||
fb = this.fullBounds().extent();
|
fb = this.fullBounds().extent();
|
||||||
img = this.fullImage();
|
this.doWithAlpha(1, () => img = this.fullImage());
|
||||||
|
|
||||||
hi = newCanvas(fb.add(blur * 2));
|
hi = newCanvas(fb.add(blur * 2));
|
||||||
ctx = hi.getContext('2d');
|
ctx = hi.getContext('2d');
|
||||||
|
@ -4368,6 +4502,20 @@ BlockMorph.prototype.activeProcess = function () {
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BlockMorph.prototype.mouseEnterBounds = function (dragged) {
|
||||||
|
if (!dragged && this.alpha < 1) {
|
||||||
|
this.alpha = Math.min(this.alpha + 0.2, 1);
|
||||||
|
this.rerender();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
BlockMorph.prototype.mouseLeaveBounds = function (dragged) {
|
||||||
|
if (SyntaxElementMorph.prototype.alpha < 1) {
|
||||||
|
delete this.alpha;
|
||||||
|
this.rerender();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// BlockMorph dragging and dropping
|
// BlockMorph dragging and dropping
|
||||||
|
|
||||||
BlockMorph.prototype.rootForGrab = function () {
|
BlockMorph.prototype.rootForGrab = function () {
|
||||||
|
@ -5597,7 +5745,7 @@ ReporterBlockMorph.prototype.prepareToBeGrabbed = function (handMorph) {
|
||||||
this.setPosition(oldPos);
|
this.setPosition(oldPos);
|
||||||
}
|
}
|
||||||
ReporterBlockMorph.uber.prepareToBeGrabbed.call(this, handMorph);
|
ReporterBlockMorph.uber.prepareToBeGrabbed.call(this, handMorph);
|
||||||
this.alpha = Math.min(this.alpha, 0.85);
|
handMorph.alpha = this.alpha < 1 ? 1 : 0.85;
|
||||||
this.cachedSlotSpec = null;
|
this.cachedSlotSpec = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6439,6 +6587,36 @@ ScriptsMorph.prototype.fullCopy = function () {
|
||||||
return cpy;
|
return cpy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ScriptsMorph rendering:
|
||||||
|
|
||||||
|
ScriptsMorph.prototype.render = function (aContext) {
|
||||||
|
aContext.fillStyle = this.getRenderColor().toString();
|
||||||
|
aContext.fillRect(0, 0, this.width(), this.height());
|
||||||
|
if (this.cachedTexture) {
|
||||||
|
this.renderCachedTexture(aContext);
|
||||||
|
} else if (this.texture) {
|
||||||
|
this.renderTexture(this.texture, aContext);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ScriptsMorph.prototype.getRenderColor = function () {
|
||||||
|
if (MorphicPreferences.isFlat ||
|
||||||
|
SyntaxElementMorph.prototype.alpha > 0.85) {
|
||||||
|
return this.color;
|
||||||
|
}
|
||||||
|
return this.color.mixed(
|
||||||
|
Math.max(SyntaxElementMorph.prototype.alpha - 0.15, 0),
|
||||||
|
SpriteMorph.prototype.paletteColor
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
ScriptsMorph.prototype.renderCachedTexture = function (ctx) {
|
||||||
|
// support blocks-to-text slider
|
||||||
|
if (SyntaxElementMorph.prototype.alpha > 0.8) {
|
||||||
|
ScriptsMorph.uber.renderCachedTexture.call(this, ctx);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// ScriptsMorph stepping:
|
// ScriptsMorph stepping:
|
||||||
|
|
||||||
ScriptsMorph.prototype.step = function () {
|
ScriptsMorph.prototype.step = function () {
|
||||||
|
@ -7383,6 +7561,9 @@ ArgMorph.prototype.init = function (type) {
|
||||||
ArgMorph.uber.init.call(this);
|
ArgMorph.uber.init.call(this);
|
||||||
this.color = new Color(0, 17, 173);
|
this.color = new Color(0, 17, 173);
|
||||||
this.createIcon();
|
this.createIcon();
|
||||||
|
if (type === 'list') {
|
||||||
|
this.alpha = 1;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// ArgMorph preferences settings:
|
// ArgMorph preferences settings:
|
||||||
|
@ -8556,11 +8737,13 @@ InputSlotMorph.prototype.init = function (
|
||||||
choiceDict,
|
choiceDict,
|
||||||
isReadOnly
|
isReadOnly
|
||||||
) {
|
) {
|
||||||
var contents = new StringMorph(''),
|
var contents = new InputSlotStringMorph(''),
|
||||||
arrow = new ArrowMorph(
|
arrow = new ArrowMorph(
|
||||||
'down',
|
'down',
|
||||||
0,
|
0,
|
||||||
Math.max(Math.floor(this.fontSize / 6), 1)
|
Math.max(Math.floor(this.fontSize / 6), 1),
|
||||||
|
BLACK,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
contents.fontSize = this.fontSize;
|
contents.fontSize = this.fontSize;
|
||||||
|
@ -9754,6 +9937,102 @@ InputSlotMorph.prototype.drawRoundBorder = function (ctx) {
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// InputSlotStringMorph ///////////////////////////////////////////////
|
||||||
|
|
||||||
|
/*
|
||||||
|
I am a piece of single-line text inside an input slot block. I serve as a
|
||||||
|
container for sharing typographic attributes among my instances
|
||||||
|
*/
|
||||||
|
|
||||||
|
// InputSlotStringMorph inherits from StringMorph:
|
||||||
|
|
||||||
|
InputSlotStringMorph.prototype = new StringMorph();
|
||||||
|
InputSlotStringMorph.prototype.constructor = InputSlotStringMorph;
|
||||||
|
InputSlotStringMorph.uber = StringMorph.prototype;
|
||||||
|
|
||||||
|
function InputSlotStringMorph(
|
||||||
|
text,
|
||||||
|
fontSize,
|
||||||
|
fontStyle,
|
||||||
|
bold,
|
||||||
|
italic,
|
||||||
|
isNumeric,
|
||||||
|
shadowOffset,
|
||||||
|
shadowColor,
|
||||||
|
color,
|
||||||
|
fontName
|
||||||
|
) {
|
||||||
|
this.init(
|
||||||
|
text,
|
||||||
|
fontSize,
|
||||||
|
fontStyle,
|
||||||
|
bold,
|
||||||
|
italic,
|
||||||
|
isNumeric,
|
||||||
|
shadowOffset,
|
||||||
|
shadowColor,
|
||||||
|
color,
|
||||||
|
fontName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
InputSlotStringMorph.prototype.getRenderColor = function () {
|
||||||
|
if (MorphicPreferences.isFlat) {
|
||||||
|
if (this.isEditable) {
|
||||||
|
return this.color;
|
||||||
|
}
|
||||||
|
return this.parent.alpha > 0.4 ? this.color : BLACK;
|
||||||
|
}
|
||||||
|
return this.parent.alpha > 0.3 ? this.color : WHITE;
|
||||||
|
};
|
||||||
|
|
||||||
|
InputSlotStringMorph.prototype.getShadowRenderColor = function () {
|
||||||
|
return this.parent.alpha > 0.6 ? this.shadowColor : CLEAR;
|
||||||
|
};
|
||||||
|
|
||||||
|
// InputSlotTextMorph ///////////////////////////////////////////////
|
||||||
|
|
||||||
|
/*
|
||||||
|
I am a piece of multi-line text inside an input slot block. I serve as a
|
||||||
|
container for sharing typographic attributes among my instances
|
||||||
|
*/
|
||||||
|
|
||||||
|
// InputSlotTextMorph inherits from TextMorph:
|
||||||
|
|
||||||
|
InputSlotTextMorph.prototype = new TextMorph();
|
||||||
|
InputSlotTextMorph.prototype.constructor = InputSlotTextMorph;
|
||||||
|
InputSlotTextMorph.uber = StringMorph.prototype;
|
||||||
|
|
||||||
|
function InputSlotTextMorph(
|
||||||
|
text,
|
||||||
|
fontSize,
|
||||||
|
fontStyle,
|
||||||
|
bold,
|
||||||
|
italic,
|
||||||
|
alignment,
|
||||||
|
width,
|
||||||
|
fontName,
|
||||||
|
shadowOffset,
|
||||||
|
shadowColor
|
||||||
|
) {
|
||||||
|
this.init(text,
|
||||||
|
fontSize,
|
||||||
|
fontStyle,
|
||||||
|
bold,
|
||||||
|
italic,
|
||||||
|
alignment,
|
||||||
|
width,
|
||||||
|
fontName,
|
||||||
|
shadowOffset,
|
||||||
|
shadowColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
InputSlotTextMorph.prototype.getRenderColor =
|
||||||
|
InputSlotStringMorph.prototype.getRenderColor;
|
||||||
|
|
||||||
|
InputSlotTextMorph.prototype.getShadowRenderColor =
|
||||||
|
InputSlotStringMorph.prototype.getShadowRenderColor;
|
||||||
|
|
||||||
// TemplateSlotMorph ///////////////////////////////////////////////////
|
// TemplateSlotMorph ///////////////////////////////////////////////////
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -9927,6 +10206,7 @@ BooleanSlotMorph.prototype.init = function (initialValue) {
|
||||||
this.isUnevaluated = false;
|
this.isUnevaluated = false;
|
||||||
this.progress = 0; // for animation state, not persisted
|
this.progress = 0; // for animation state, not persisted
|
||||||
BooleanSlotMorph.uber.init.call(this);
|
BooleanSlotMorph.uber.init.call(this);
|
||||||
|
this.alpha = 1;
|
||||||
this.fixLayout();
|
this.fixLayout();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10495,14 +10775,15 @@ ArrowMorph.uber = Morph.prototype;
|
||||||
|
|
||||||
// ArrowMorph instance creation:
|
// ArrowMorph instance creation:
|
||||||
|
|
||||||
function ArrowMorph(direction, size, padding, color) {
|
function ArrowMorph(direction, size, padding, color, isBlockLabel) {
|
||||||
this.init(direction, size, padding, color);
|
this.init(direction, size, padding, color, isBlockLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrowMorph.prototype.init = function (direction, size, padding, color) {
|
ArrowMorph.prototype.init = function (direction, size, padding, color, isLbl) {
|
||||||
this.direction = direction || 'down';
|
this.direction = direction || 'down';
|
||||||
this.size = size || ((size === 0) ? 0 : 50);
|
this.size = size || ((size === 0) ? 0 : 50);
|
||||||
this.padding = padding || 0;
|
this.padding = padding || 0;
|
||||||
|
this.isBlockLabel = isLbl || false;
|
||||||
|
|
||||||
ArrowMorph.uber.init.call(this);
|
ArrowMorph.uber.init.call(this);
|
||||||
this.color = color || BLACK;
|
this.color = color || BLACK;
|
||||||
|
@ -10530,7 +10811,7 @@ ArrowMorph.prototype.render = function (ctx) {
|
||||||
w = this.width(),
|
w = this.width(),
|
||||||
w2 = Math.floor(w / 2);
|
w2 = Math.floor(w / 2);
|
||||||
|
|
||||||
ctx.fillStyle = this.color.toString();
|
ctx.fillStyle = this.getRenderColor().toString();
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
if (this.direction === 'down') {
|
if (this.direction === 'down') {
|
||||||
ctx.moveTo(pad, h2);
|
ctx.moveTo(pad, h2);
|
||||||
|
@ -10553,6 +10834,16 @@ ArrowMorph.prototype.render = function (ctx) {
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ArrowMorph.prototype.getRenderColor = function () {
|
||||||
|
if (this.isBlockLabel) {
|
||||||
|
if (MorphicPreferences.isFlat) {
|
||||||
|
return this.color;
|
||||||
|
}
|
||||||
|
return SyntaxElementMorph.prototype.alpha > 0.5 ? this.color : WHITE;
|
||||||
|
}
|
||||||
|
return this.color;
|
||||||
|
};
|
||||||
|
|
||||||
// TextSlotMorph //////////////////////////////////////////////////////
|
// TextSlotMorph //////////////////////////////////////////////////////
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -10578,11 +10869,13 @@ TextSlotMorph.prototype.init = function (
|
||||||
choiceDict,
|
choiceDict,
|
||||||
isReadOnly
|
isReadOnly
|
||||||
) {
|
) {
|
||||||
var contents = new TextMorph(''),
|
var contents = new InputSlotTextMorph(''),
|
||||||
arrow = new ArrowMorph(
|
arrow = new ArrowMorph(
|
||||||
'down',
|
'down',
|
||||||
0,
|
0,
|
||||||
Math.max(Math.floor(this.fontSize / 6), 1)
|
Math.max(Math.floor(this.fontSize / 6), 1),
|
||||||
|
BLACK,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
contents.fontSize = this.fontSize;
|
contents.fontSize = this.fontSize;
|
||||||
|
@ -10657,6 +10950,7 @@ function ColorSlotMorph(clr) {
|
||||||
|
|
||||||
ColorSlotMorph.prototype.init = function (clr) {
|
ColorSlotMorph.prototype.init = function (clr) {
|
||||||
ColorSlotMorph.uber.init.call(this);
|
ColorSlotMorph.uber.init.call(this);
|
||||||
|
this.alpha = 1;
|
||||||
this.setColor(clr || new Color(145, 26, 68));
|
this.setColor(clr || new Color(145, 26, 68));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10910,7 +11204,8 @@ MultiArgMorph.prototype.init = function (
|
||||||
'left',
|
'left',
|
||||||
this.fontSize,
|
this.fontSize,
|
||||||
Math.max(Math.floor(this.fontSize / 6), 1),
|
Math.max(Math.floor(this.fontSize / 6), 1),
|
||||||
arrowColor
|
arrowColor,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
// right arrow:
|
// right arrow:
|
||||||
|
@ -10918,7 +11213,8 @@ MultiArgMorph.prototype.init = function (
|
||||||
'right',
|
'right',
|
||||||
this.fontSize,
|
this.fontSize,
|
||||||
Math.max(Math.floor(this.fontSize / 6), 1),
|
Math.max(Math.floor(this.fontSize / 6), 1),
|
||||||
arrowColor
|
arrowColor,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
// control panel:
|
// control panel:
|
||||||
|
|
122
src/gui.js
122
src/gui.js
|
@ -78,7 +78,7 @@ Animation, BoxMorph, BlockEditorMorph, BlockDialogMorph, Note, ZERO, BLACK*/
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.gui = '2020-July-16';
|
modules.gui = '2020-July-22';
|
||||||
|
|
||||||
// Declarations
|
// Declarations
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ IDE_Morph.uber = Morph.prototype;
|
||||||
|
|
||||||
IDE_Morph.prototype.setDefaultDesign = function () {
|
IDE_Morph.prototype.setDefaultDesign = function () {
|
||||||
MorphicPreferences.isFlat = false;
|
MorphicPreferences.isFlat = false;
|
||||||
SpriteMorph.prototype.paletteColor = new Color(35, 35, 35);
|
SpriteMorph.prototype.paletteColor = new Color(30, 30, 30);
|
||||||
SpriteMorph.prototype.paletteTextColor = new Color(230, 230, 230);
|
SpriteMorph.prototype.paletteTextColor = new Color(230, 230, 230);
|
||||||
StageMorph.prototype.paletteTextColor
|
StageMorph.prototype.paletteTextColor
|
||||||
= SpriteMorph.prototype.paletteTextColor;
|
= SpriteMorph.prototype.paletteTextColor;
|
||||||
|
@ -195,10 +195,10 @@ IDE_Morph.prototype.scriptsTexture = function () {
|
||||||
for (i = 0; i < 100; i += 4) {
|
for (i = 0; i < 100; i += 4) {
|
||||||
ctx.fillStyle = this.frameColor.toString();
|
ctx.fillStyle = this.frameColor.toString();
|
||||||
ctx.fillRect(i, 0, 1, 100);
|
ctx.fillRect(i, 0, 1, 100);
|
||||||
ctx.fillStyle = this.groupColor.lighter(4).toString();
|
ctx.fillStyle = this.groupColor.lighter(2).toString();
|
||||||
ctx.fillRect(i + 1, 0, 1, 100);
|
ctx.fillRect(i + 1, 0, 1, 100);
|
||||||
ctx.fillRect(i + 3, 0, 1, 100);
|
ctx.fillRect(i + 3, 0, 1, 100);
|
||||||
ctx.fillStyle = this.groupColor.toString();
|
ctx.fillStyle = this.groupColor.darker(2).toString();
|
||||||
ctx.fillRect(i + 2, 0, 1, 100);
|
ctx.fillRect(i + 2, 0, 1, 100);
|
||||||
}
|
}
|
||||||
return pic;
|
return pic;
|
||||||
|
@ -1173,6 +1173,7 @@ IDE_Morph.prototype.createCategories = function () {
|
||||||
this.categories = new Morph();
|
this.categories = new Morph();
|
||||||
this.categories.color = this.groupColor;
|
this.categories.color = this.groupColor;
|
||||||
this.categories.bounds.setWidth(this.paletteWidth);
|
this.categories.bounds.setWidth(this.paletteWidth);
|
||||||
|
this.categories.getRenderColor = ScriptsMorph.prototype.getRenderColor;
|
||||||
|
|
||||||
function addCategoryButton(category) {
|
function addCategoryButton(category) {
|
||||||
var labelWidth = 75,
|
var labelWidth = 75,
|
||||||
|
@ -1533,6 +1534,18 @@ IDE_Morph.prototype.createSpriteBar = function () {
|
||||||
tab.labelShadowOffset = new Point(-1, -1);
|
tab.labelShadowOffset = new Point(-1, -1);
|
||||||
tab.labelShadowColor = tabColors[1];
|
tab.labelShadowColor = tabColors[1];
|
||||||
tab.labelColor = this.buttonLabelColor;
|
tab.labelColor = this.buttonLabelColor;
|
||||||
|
|
||||||
|
tab.getPressRenderColor = function () {
|
||||||
|
if (MorphicPreferences.isFlat ||
|
||||||
|
SyntaxElementMorph.prototype.alpha > 0.85) {
|
||||||
|
return this.pressColor;
|
||||||
|
}
|
||||||
|
return this.pressColor.mixed(
|
||||||
|
Math.max(SyntaxElementMorph.prototype.alpha - 0.15, 0),
|
||||||
|
SpriteMorph.prototype.paletteColor
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
tab.fixLayout();
|
tab.fixLayout();
|
||||||
tabBar.add(tab);
|
tabBar.add(tab);
|
||||||
|
|
||||||
|
@ -1783,6 +1796,8 @@ IDE_Morph.prototype.createCorral = function () {
|
||||||
|
|
||||||
this.corral = new Morph();
|
this.corral = new Morph();
|
||||||
this.corral.color = this.groupColor;
|
this.corral.color = this.groupColor;
|
||||||
|
this.corral.getRenderColor = ScriptsMorph.prototype.getRenderColor;
|
||||||
|
|
||||||
this.add(this.corral);
|
this.add(this.corral);
|
||||||
|
|
||||||
this.corral.stageIcon = new SpriteIconMorph(this.stage);
|
this.corral.stageIcon = new SpriteIconMorph(this.stage);
|
||||||
|
@ -2380,6 +2395,7 @@ IDE_Morph.prototype.refreshIDE = function () {
|
||||||
IDE_Morph.prototype.applySavedSettings = function () {
|
IDE_Morph.prototype.applySavedSettings = function () {
|
||||||
var design = this.getSetting('design'),
|
var design = this.getSetting('design'),
|
||||||
zoom = this.getSetting('zoom'),
|
zoom = this.getSetting('zoom'),
|
||||||
|
fade = this.getSetting('fade'),
|
||||||
language = this.getSetting('language'),
|
language = this.getSetting('language'),
|
||||||
click = this.getSetting('click'),
|
click = this.getSetting('click'),
|
||||||
longform = this.getSetting('longform'),
|
longform = this.getSetting('longform'),
|
||||||
|
@ -2404,6 +2420,11 @@ IDE_Morph.prototype.applySavedSettings = function () {
|
||||||
SpriteMorph.prototype.initBlocks();
|
SpriteMorph.prototype.initBlocks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// blocks fade
|
||||||
|
if (!isNil(fade)) {
|
||||||
|
this.setBlockTransparency(+fade);
|
||||||
|
}
|
||||||
|
|
||||||
// language
|
// language
|
||||||
if (language && language !== 'en') {
|
if (language && language !== 'en') {
|
||||||
this.userLanguage = language;
|
this.userLanguage = language;
|
||||||
|
@ -3112,6 +3133,12 @@ IDE_Morph.prototype.settingsMenu = function () {
|
||||||
'Zoom blocks...',
|
'Zoom blocks...',
|
||||||
'userSetBlocksScale'
|
'userSetBlocksScale'
|
||||||
);
|
);
|
||||||
|
/*
|
||||||
|
menu.addItem(
|
||||||
|
'Fade blocks...',
|
||||||
|
'userFadeBlocks'
|
||||||
|
);
|
||||||
|
*/
|
||||||
menu.addItem(
|
menu.addItem(
|
||||||
'Stage size...',
|
'Stage size...',
|
||||||
'userSetStageSize'
|
'userSetStageSize'
|
||||||
|
@ -3124,32 +3151,6 @@ IDE_Morph.prototype.settingsMenu = function () {
|
||||||
'before it picks up an object',
|
'before it picks up an object',
|
||||||
new Color(100, 0, 0)
|
new Color(100, 0, 0)
|
||||||
);
|
);
|
||||||
/*
|
|
||||||
menu.addItem(
|
|
||||||
"Block alpha...",
|
|
||||||
() => {
|
|
||||||
world.prompt(
|
|
||||||
'Block alpha',
|
|
||||||
alpha => {
|
|
||||||
SyntaxElementMorph.prototype.setAlphaScaled(alpha);
|
|
||||||
this.rerender();
|
|
||||||
},
|
|
||||||
this,
|
|
||||||
(SyntaxElementMorph.prototype.alpha * 100).toString(),
|
|
||||||
null,
|
|
||||||
0,
|
|
||||||
100,
|
|
||||||
true,
|
|
||||||
alpha => {
|
|
||||||
SyntaxElementMorph.prototype.setAlphaScaled(alpha);
|
|
||||||
this.rerender();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
'set the blocks\'\nalpha value',
|
|
||||||
new Color(100, 0, 0)
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
menu.addItem(
|
menu.addItem(
|
||||||
'Microphone resolution...',
|
'Microphone resolution...',
|
||||||
|
@ -5607,7 +5608,9 @@ IDE_Morph.prototype.userSetBlocksScale = function () {
|
||||||
sample = new FrameMorph();
|
sample = new FrameMorph();
|
||||||
sample.acceptsDrops = false;
|
sample.acceptsDrops = false;
|
||||||
sample.color = IDE_Morph.prototype.groupColor;
|
sample.color = IDE_Morph.prototype.groupColor;
|
||||||
sample.cachedTexture = this.scriptsPaneTexture;
|
if (SyntaxElementMorph.prototype.alpha > 0.8) {
|
||||||
|
sample.cachedTexture = this.scriptsPaneTexture;
|
||||||
|
}
|
||||||
sample.setExtent(new Point(250, 180));
|
sample.setExtent(new Point(250, 180));
|
||||||
scrpt.setPosition(sample.position().add(10));
|
scrpt.setPosition(sample.position().add(10));
|
||||||
sample.add(scrpt);
|
sample.add(scrpt);
|
||||||
|
@ -5677,6 +5680,63 @@ IDE_Morph.prototype.setBlocksScale = function (num) {
|
||||||
this.saveSetting('zoom', num);
|
this.saveSetting('zoom', num);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// IDE_Morph blocks fading
|
||||||
|
|
||||||
|
IDE_Morph.prototype.userFadeBlocks = function () {
|
||||||
|
var dlg,
|
||||||
|
initial = 100 - (SyntaxElementMorph.prototype.alpha * 100);
|
||||||
|
|
||||||
|
dlg = new DialogBoxMorph(
|
||||||
|
null,
|
||||||
|
num => this.setBlockTransparency(num, true) // and save setting
|
||||||
|
).withKey('fadeBlocks');
|
||||||
|
if (MorphicPreferences.isTouchDevice) {
|
||||||
|
dlg.isDraggable = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
dlg.cancel = () => {
|
||||||
|
this.setBlockTransparency(initial);
|
||||||
|
dlg.destroy();
|
||||||
|
};
|
||||||
|
|
||||||
|
dlg.prompt(
|
||||||
|
'Fade blocks',
|
||||||
|
initial.toString(),
|
||||||
|
this.world(),
|
||||||
|
null, // pic
|
||||||
|
{
|
||||||
|
'block-solid (0)' : 0,
|
||||||
|
'reduced (39)' : 39,
|
||||||
|
'medium (49)' : 49,
|
||||||
|
'light (59)' : 59,
|
||||||
|
'semi (69)' : 69,
|
||||||
|
'glassy (79)' : 79,
|
||||||
|
'shimmering (80' : 80,
|
||||||
|
'elegant (90)' : 90,
|
||||||
|
'subtle (95)' : 95,
|
||||||
|
'text-only (100)' : 100
|
||||||
|
},
|
||||||
|
false, // read only?
|
||||||
|
true, // numeric
|
||||||
|
0, // slider min
|
||||||
|
100, // slider max
|
||||||
|
num => this.setBlockTransparency(num), // slider action
|
||||||
|
0 // decimals
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
IDE_Morph.prototype.setBlockTransparency = function (num, save) {
|
||||||
|
SyntaxElementMorph.prototype.setAlphaScaled(100 - num);
|
||||||
|
this.changed();
|
||||||
|
if (save) {
|
||||||
|
if (num === 0) {
|
||||||
|
this.removeSetting('fade');
|
||||||
|
} else {
|
||||||
|
this.saveSetting('fade', num);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// IDE_Morph stage size manipulation
|
// IDE_Morph stage size manipulation
|
||||||
|
|
||||||
IDE_Morph.prototype.userSetStageSize = function () {
|
IDE_Morph.prototype.userSetStageSize = function () {
|
||||||
|
|
|
@ -471,6 +471,8 @@
|
||||||
mouseLeave
|
mouseLeave
|
||||||
mouseEnterDragging
|
mouseEnterDragging
|
||||||
mouseLeaveDragging
|
mouseLeaveDragging
|
||||||
|
mouseEnterBounds
|
||||||
|
mouseLeaveBounds
|
||||||
mouseMove
|
mouseMove
|
||||||
mouseScroll
|
mouseScroll
|
||||||
|
|
||||||
|
@ -493,6 +495,8 @@
|
||||||
|
|
||||||
mouseEnterDragging(morph)
|
mouseEnterDragging(morph)
|
||||||
mouseLeaveDragging(morph)
|
mouseLeaveDragging(morph)
|
||||||
|
mouseEnterBounds(morph)
|
||||||
|
mouseLeaveBounds(morph)
|
||||||
|
|
||||||
event methods have as optional parameter the morph currently dragged by
|
event methods have as optional parameter the morph currently dragged by
|
||||||
the Hand, if any.
|
the Hand, if any.
|
||||||
|
@ -1276,13 +1280,14 @@
|
||||||
|
|
||||||
/*global window, HTMLCanvasElement, FileReader, Audio, FileList, Map*/
|
/*global window, HTMLCanvasElement, FileReader, Audio, FileList, Map*/
|
||||||
|
|
||||||
var morphicVersion = '2020-July-16';
|
var morphicVersion = '2020-July-22';
|
||||||
var modules = {}; // keep track of additional loaded modules
|
var modules = {}; // keep track of additional loaded modules
|
||||||
var useBlurredShadows = true;
|
var useBlurredShadows = true;
|
||||||
|
|
||||||
const ZERO = new Point();
|
const ZERO = new Point();
|
||||||
const BLACK = new Color();
|
const BLACK = new Color();
|
||||||
const WHITE = new Color(255, 255, 255);
|
const WHITE = new Color(255, 255, 255);
|
||||||
|
const CLEAR = new Color(0, 0, 0, 0);
|
||||||
|
|
||||||
Object.freeze(ZERO);
|
Object.freeze(ZERO);
|
||||||
Object.freeze(BLACK);
|
Object.freeze(BLACK);
|
||||||
|
@ -2304,6 +2309,14 @@ Color.prototype.inverted = function () {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Color.prototype.solid = function () {
|
||||||
|
return new Color(
|
||||||
|
this.r,
|
||||||
|
this.g,
|
||||||
|
this.b
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
// Points //////////////////////////////////////////////////////////////
|
// Points //////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Point instance creation:
|
// Point instance creation:
|
||||||
|
@ -3467,7 +3480,7 @@ Morph.prototype.getImage = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
Morph.prototype.render = function (aContext) {
|
Morph.prototype.render = function (aContext) {
|
||||||
aContext.fillStyle = this.color.toString();
|
aContext.fillStyle = this.getRenderColor().toString();
|
||||||
aContext.fillRect(0, 0, this.width(), this.height());
|
aContext.fillRect(0, 0, this.width(), this.height());
|
||||||
if (this.cachedTexture) {
|
if (this.cachedTexture) {
|
||||||
this.renderCachedTexture(aContext);
|
this.renderCachedTexture(aContext);
|
||||||
|
@ -3476,6 +3489,11 @@ Morph.prototype.render = function (aContext) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Morph.prototype.getRenderColor = function () {
|
||||||
|
// can be overriden by my heirs or instances
|
||||||
|
return this.color;
|
||||||
|
};
|
||||||
|
|
||||||
Morph.prototype.fixLayout = function () {
|
Morph.prototype.fixLayout = function () {
|
||||||
// implemented by my heirs
|
// implemented by my heirs
|
||||||
// determine my extent and arrange my submorphs, if any
|
// determine my extent and arrange my submorphs, if any
|
||||||
|
@ -8507,6 +8525,11 @@ StringMorph.prototype.font = function () {
|
||||||
this.fontStyle;
|
this.fontStyle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
StringMorph.prototype.getShadowRenderColor = function () {
|
||||||
|
// answer the shadow rendering color, can be overridden for my children
|
||||||
|
return this.shadowColor;
|
||||||
|
};
|
||||||
|
|
||||||
StringMorph.prototype.fixLayout = function (justMe) {
|
StringMorph.prototype.fixLayout = function (justMe) {
|
||||||
// determine my extent depending on my current settings
|
// determine my extent depending on my current settings
|
||||||
var width,
|
var width,
|
||||||
|
@ -8537,6 +8560,7 @@ StringMorph.prototype.fixLayout = function (justMe) {
|
||||||
StringMorph.prototype.render = function (ctx) {
|
StringMorph.prototype.render = function (ctx) {
|
||||||
var start, stop, i, p, c, x, y,
|
var start, stop, i, p, c, x, y,
|
||||||
shadowOffset = this.shadowOffset || ZERO,
|
shadowOffset = this.shadowOffset || ZERO,
|
||||||
|
shadowColor = this.getShadowRenderColor(),
|
||||||
txt = this.isPassword ?
|
txt = this.isPassword ?
|
||||||
this.password('*', this.text.length) : this.text;
|
this.password('*', this.text.length) : this.text;
|
||||||
|
|
||||||
|
@ -8546,17 +8570,17 @@ StringMorph.prototype.render = function (ctx) {
|
||||||
ctx.textBaseline = 'bottom';
|
ctx.textBaseline = 'bottom';
|
||||||
|
|
||||||
// first draw the shadow, if any
|
// first draw the shadow, if any
|
||||||
if (this.shadowColor) {
|
if (shadowColor) {
|
||||||
x = Math.max(shadowOffset.x, 0);
|
x = Math.max(shadowOffset.x, 0);
|
||||||
y = Math.max(shadowOffset.y, 0);
|
y = Math.max(shadowOffset.y, 0);
|
||||||
ctx.fillStyle = this.shadowColor.toString();
|
ctx.fillStyle = shadowColor.toString();
|
||||||
ctx.fillText(txt, x, fontHeight(this.fontSize) + y);
|
ctx.fillText(txt, x, fontHeight(this.fontSize) + y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// now draw the actual text
|
// now draw the actual text
|
||||||
x = Math.abs(Math.min(shadowOffset.x, 0));
|
x = Math.abs(Math.min(shadowOffset.x, 0));
|
||||||
y = Math.abs(Math.min(shadowOffset.y, 0));
|
y = Math.abs(Math.min(shadowOffset.y, 0));
|
||||||
ctx.fillStyle = this.color.toString();
|
ctx.fillStyle = this.getRenderColor().toString();
|
||||||
|
|
||||||
if (this.isShowingBlanks) {
|
if (this.isShowingBlanks) {
|
||||||
this.renderWithBlanks(
|
this.renderWithBlanks(
|
||||||
|
@ -8615,7 +8639,7 @@ StringMorph.prototype.renderWithBlanks = function (ctx, startX, y) {
|
||||||
}
|
}
|
||||||
isFirst = false;
|
isFirst = false;
|
||||||
if (word !== '') {
|
if (word !== '') {
|
||||||
ctx.fillStyle = this.color.toString();
|
ctx.fillStyle = this.getRenderColor().toString();
|
||||||
ctx.fillText(word, x, y);
|
ctx.fillText(word, x, y);
|
||||||
x += ctx.measureText(word).width;
|
x += ctx.measureText(word).width;
|
||||||
}
|
}
|
||||||
|
@ -9268,6 +9292,7 @@ TextMorph.prototype.fixLayout = function () {
|
||||||
TextMorph.prototype.render = function (ctx) {
|
TextMorph.prototype.render = function (ctx) {
|
||||||
var shadowWidth = Math.abs(this.shadowOffset.x),
|
var shadowWidth = Math.abs(this.shadowOffset.x),
|
||||||
shadowHeight = Math.abs(this.shadowOffset.y),
|
shadowHeight = Math.abs(this.shadowOffset.y),
|
||||||
|
shadowColor = this.getShadowRenderColor(),
|
||||||
i, line, width, offx, offy, x, y, start, stop, p, c;
|
i, line, width, offx, offy, x, y, start, stop, p, c;
|
||||||
|
|
||||||
// prepare context for drawing text
|
// prepare context for drawing text
|
||||||
|
@ -9282,10 +9307,10 @@ TextMorph.prototype.render = function (ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw the shadow, if any
|
// draw the shadow, if any
|
||||||
if (this.shadowColor) {
|
if (shadowColor) {
|
||||||
offx = Math.max(this.shadowOffset.x, 0);
|
offx = Math.max(this.shadowOffset.x, 0);
|
||||||
offy = Math.max(this.shadowOffset.y, 0);
|
offy = Math.max(this.shadowOffset.y, 0);
|
||||||
ctx.fillStyle = this.shadowColor.toString();
|
ctx.fillStyle = shadowColor.toString();
|
||||||
|
|
||||||
for (i = 0; i < this.lines.length; i = i + 1) {
|
for (i = 0; i < this.lines.length; i = i + 1) {
|
||||||
line = this.lines[i];
|
line = this.lines[i];
|
||||||
|
@ -9306,7 +9331,7 @@ TextMorph.prototype.render = function (ctx) {
|
||||||
// now draw the actual text
|
// now draw the actual text
|
||||||
offx = Math.abs(Math.min(this.shadowOffset.x, 0));
|
offx = Math.abs(Math.min(this.shadowOffset.x, 0));
|
||||||
offy = Math.abs(Math.min(this.shadowOffset.y, 0));
|
offy = Math.abs(Math.min(this.shadowOffset.y, 0));
|
||||||
ctx.fillStyle = this.color.toString();
|
ctx.fillStyle = this.getRenderColor().toString();
|
||||||
|
|
||||||
for (i = 0; i < this.lines.length; i = i + 1) {
|
for (i = 0; i < this.lines.length; i = i + 1) {
|
||||||
line = this.lines[i];
|
line = this.lines[i];
|
||||||
|
@ -9336,6 +9361,9 @@ TextMorph.prototype.render = function (ctx) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TextMorph.prototype.getShadowRenderColor =
|
||||||
|
StringMorph.prototype.getShadowRenderColor;
|
||||||
|
|
||||||
TextMorph.prototype.setExtent = function (aPoint) {
|
TextMorph.prototype.setExtent = function (aPoint) {
|
||||||
this.maxWidth = Math.max(aPoint.x, 0);
|
this.maxWidth = Math.max(aPoint.x, 0);
|
||||||
this.changed();
|
this.changed();
|
||||||
|
@ -11066,6 +11094,7 @@ HandMorph.prototype.init = function (aWorld) {
|
||||||
this.world = aWorld;
|
this.world = aWorld;
|
||||||
this.mouseButton = null;
|
this.mouseButton = null;
|
||||||
this.mouseOverList = [];
|
this.mouseOverList = [];
|
||||||
|
this.mouseOverBounds = [];
|
||||||
this.morphToGrab = null;
|
this.morphToGrab = null;
|
||||||
this.grabPosition = null;
|
this.grabPosition = null;
|
||||||
this.grabOrigin = null;
|
this.grabOrigin = null;
|
||||||
|
@ -11120,7 +11149,7 @@ HandMorph.prototype.fullDrawOn = function (ctx, rect) {
|
||||||
|
|
||||||
if (!clipped.extent().gt(ZERO)) {return; }
|
if (!clipped.extent().gt(ZERO)) {return; }
|
||||||
ctx.save();
|
ctx.save();
|
||||||
ctx.globalAlpha = this.children[0].alpha;
|
ctx.globalAlpha = this.alpha;
|
||||||
pic = this.cachedFullImage;
|
pic = this.cachedFullImage;
|
||||||
src = clipped.translateBy(pos.neg());
|
src = clipped.translateBy(pos.neg());
|
||||||
sl = src.left();
|
sl = src.left();
|
||||||
|
@ -11150,7 +11179,10 @@ HandMorph.prototype.morphAtPointer = function () {
|
||||||
|
|
||||||
HandMorph.prototype.allMorphsAtPointer = function () {
|
HandMorph.prototype.allMorphsAtPointer = function () {
|
||||||
return this.world.allChildren().filter(m => m.isVisible &&
|
return this.world.allChildren().filter(m => m.isVisible &&
|
||||||
m.visibleBounds().containsPoint(this.bounds.origin));
|
m.visibleBounds().containsPoint(this.bounds.origin) &&
|
||||||
|
!m.holes.some(any =>
|
||||||
|
any.translateBy(m.position()).containsPoint(this.bounds.origin))
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
// HandMorph dragging and dropping:
|
// HandMorph dragging and dropping:
|
||||||
|
@ -11201,6 +11233,7 @@ HandMorph.prototype.grab = function (aMorph) {
|
||||||
|
|
||||||
HandMorph.prototype.drop = function () {
|
HandMorph.prototype.drop = function () {
|
||||||
var target, morphToDrop;
|
var target, morphToDrop;
|
||||||
|
this.alpha = 1;
|
||||||
if (this.children.length !== 0) {
|
if (this.children.length !== 0) {
|
||||||
morphToDrop = this.children[0];
|
morphToDrop = this.children[0];
|
||||||
target = this.dropTargetFor(morphToDrop);
|
target = this.dropTargetFor(morphToDrop);
|
||||||
|
@ -11240,13 +11273,23 @@ HandMorph.prototype.drop = function () {
|
||||||
mouseLeave
|
mouseLeave
|
||||||
mouseEnterDragging
|
mouseEnterDragging
|
||||||
mouseLeaveDragging
|
mouseLeaveDragging
|
||||||
|
mouseEnterBounds
|
||||||
|
mouseLeaveBounds
|
||||||
mouseMove
|
mouseMove
|
||||||
mouseScroll
|
mouseScroll
|
||||||
*/
|
*/
|
||||||
|
|
||||||
HandMorph.prototype.processMouseDown = function (event) {
|
HandMorph.prototype.processMouseDown = function (event) {
|
||||||
var morph, actualClick;
|
var morph, actualClick,
|
||||||
|
posInDocument = getDocumentPositionOf(this.world.worldCanvas);
|
||||||
|
|
||||||
|
// update my position, in case I've just been initialized
|
||||||
|
this.setPosition(new Point(
|
||||||
|
event.pageX - posInDocument.x,
|
||||||
|
event.pageY - posInDocument.y
|
||||||
|
));
|
||||||
|
|
||||||
|
// process the actual event
|
||||||
this.destroyTemporaries();
|
this.destroyTemporaries();
|
||||||
this.contextMenuEnabled = true;
|
this.contextMenuEnabled = true;
|
||||||
this.morphToGrab = null;
|
this.morphToGrab = null;
|
||||||
|
@ -11385,6 +11428,7 @@ HandMorph.prototype.processMouseMove = function (event) {
|
||||||
var pos,
|
var pos,
|
||||||
posInDocument = getDocumentPositionOf(this.world.worldCanvas),
|
posInDocument = getDocumentPositionOf(this.world.worldCanvas),
|
||||||
mouseOverNew,
|
mouseOverNew,
|
||||||
|
mouseOverBoundsNew,
|
||||||
morph,
|
morph,
|
||||||
topMorph;
|
topMorph;
|
||||||
|
|
||||||
|
@ -11396,8 +11440,12 @@ HandMorph.prototype.processMouseMove = function (event) {
|
||||||
this.setPosition(pos);
|
this.setPosition(pos);
|
||||||
|
|
||||||
// determine the new mouse-over-list:
|
// determine the new mouse-over-list:
|
||||||
// mouseOverNew = this.allMorphsAtPointer();
|
|
||||||
mouseOverNew = this.morphAtPointer().allParents();
|
mouseOverNew = this.morphAtPointer().allParents();
|
||||||
|
mouseOverBoundsNew = mouseOverNew.filter(m => m.isVisible &&
|
||||||
|
m.visibleBounds().containsPoint(this.bounds.origin) &&
|
||||||
|
!m.holes.some(any =>
|
||||||
|
any.translateBy(m.position()).containsPoint(this.bounds.origin))
|
||||||
|
);
|
||||||
|
|
||||||
if (!this.children.length && this.mouseButton) {
|
if (!this.children.length && this.mouseButton) {
|
||||||
topMorph = this.morphAtPointer();
|
topMorph = this.morphAtPointer();
|
||||||
|
@ -11434,6 +11482,21 @@ HandMorph.prototype.processMouseMove = function (event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.mouseOverBounds.forEach(old => {
|
||||||
|
if (!contains(mouseOverBoundsNew, old)) {
|
||||||
|
if (old.mouseLeaveBounds) {
|
||||||
|
old.mouseLeaveBounds(this.children[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mouseOverBoundsNew.forEach(newMorph => {
|
||||||
|
if (!contains(this.mouseOverBounds, newMorph)) {
|
||||||
|
if (newMorph.mouseEnterBounds) {
|
||||||
|
newMorph.mouseEnterBounds(this.children[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this.mouseOverList.forEach(old => {
|
this.mouseOverList.forEach(old => {
|
||||||
if (!contains(mouseOverNew, old)) {
|
if (!contains(mouseOverNew, old)) {
|
||||||
if (old.mouseLeave) {
|
if (old.mouseLeave) {
|
||||||
|
@ -11471,6 +11534,7 @@ HandMorph.prototype.processMouseMove = function (event) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.mouseOverList = mouseOverNew;
|
this.mouseOverList = mouseOverNew;
|
||||||
|
this.mouseOverBounds = mouseOverBoundsNew;
|
||||||
};
|
};
|
||||||
|
|
||||||
HandMorph.prototype.processMouseScroll = function (event) {
|
HandMorph.prototype.processMouseScroll = function (event) {
|
||||||
|
@ -12553,6 +12617,7 @@ WorldMorph.prototype.slide = function (aStringOrTextMorph) {
|
||||||
slider.action = (num) => {
|
slider.action = (num) => {
|
||||||
aStringOrTextMorph.changed();
|
aStringOrTextMorph.changed();
|
||||||
aStringOrTextMorph.text = Math.round(num).toString();
|
aStringOrTextMorph.text = Math.round(num).toString();
|
||||||
|
aStringOrTextMorph.fixLayout();
|
||||||
aStringOrTextMorph.rerender();
|
aStringOrTextMorph.rerender();
|
||||||
aStringOrTextMorph.escalateEvent(
|
aStringOrTextMorph.escalateEvent(
|
||||||
'reactToSliderEdit',
|
'reactToSliderEdit',
|
||||||
|
|
|
@ -84,7 +84,7 @@ BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, BooleanSlotMorph,
|
||||||
localize, TableMorph, TableFrameMorph, normalizeCanvas, VectorPaintEditorMorph,
|
localize, TableMorph, TableFrameMorph, normalizeCanvas, VectorPaintEditorMorph,
|
||||||
HandleMorph, AlignmentMorph, Process, XML_Element, WorldMap, copyCanvas*/
|
HandleMorph, AlignmentMorph, Process, XML_Element, WorldMap, copyCanvas*/
|
||||||
|
|
||||||
modules.objects = '2020-July-13';
|
modules.objects = '2020-July-20';
|
||||||
|
|
||||||
var SpriteMorph;
|
var SpriteMorph;
|
||||||
var StageMorph;
|
var StageMorph;
|
||||||
|
@ -10965,7 +10965,7 @@ CellMorph.prototype.reactToEdit = function (textMorph) {
|
||||||
if (listWatcher) {
|
if (listWatcher) {
|
||||||
listWatcher.list.put(
|
listWatcher.list.put(
|
||||||
textMorph.text,
|
textMorph.text,
|
||||||
this.idx
|
this.idx + listWatcher.start - 1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.symbols = '2020-July-13';
|
modules.symbols = '2020-July-21';
|
||||||
|
|
||||||
var SymbolMorph;
|
var SymbolMorph;
|
||||||
|
|
||||||
|
@ -194,6 +194,13 @@ SymbolMorph.prototype.setLabelColor = function (
|
||||||
this.setColor(textColor);
|
this.setColor(textColor);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// SymbolMorph dynamic coloring:
|
||||||
|
|
||||||
|
SymbolMorph.prototype.getShadowRenderColor = function () {
|
||||||
|
// answer the shadow rendering color, can be overridden for my children
|
||||||
|
return this.shadowColor;
|
||||||
|
};
|
||||||
|
|
||||||
// SymbolMorph layout:
|
// SymbolMorph layout:
|
||||||
|
|
||||||
SymbolMorph.prototype.setExtent = function (aPoint) {
|
SymbolMorph.prototype.setExtent = function (aPoint) {
|
||||||
|
@ -221,12 +228,12 @@ SymbolMorph.prototype.render = function (ctx) {
|
||||||
if (this.shadowColor) {
|
if (this.shadowColor) {
|
||||||
ctx.save();
|
ctx.save();
|
||||||
ctx.translate(sx, sy);
|
ctx.translate(sx, sy);
|
||||||
this.renderShape(ctx, this.shadowColor);
|
this.renderShape(ctx, this.getShadowRenderColor());
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
}
|
}
|
||||||
ctx.save();
|
ctx.save();
|
||||||
ctx.translate(x, y);
|
ctx.translate(x, y);
|
||||||
this.renderShape(ctx, this.color);
|
this.renderShape(ctx, this.getRenderColor());
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ StageMorph, SpriteMorph, StagePrompterMorph, Note, modules, isString, copy, Map,
|
||||||
isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph, BLACK,
|
isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph, BLACK,
|
||||||
TableFrameMorph, ColorSlotMorph, isSnapObject, newCanvas, Symbol, SVG_Costume*/
|
TableFrameMorph, ColorSlotMorph, isSnapObject, newCanvas, Symbol, SVG_Costume*/
|
||||||
|
|
||||||
modules.threads = '2020-July-09';
|
modules.threads = '2020-July-22';
|
||||||
|
|
||||||
var ThreadManager;
|
var ThreadManager;
|
||||||
var Process;
|
var Process;
|
||||||
|
@ -6114,15 +6114,15 @@ Context.prototype.image = function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ring.embed(block, this.inputs);
|
ring.embed(block, this.inputs);
|
||||||
return ring.fullImage();
|
return ring.doWithAlpha(1, () => ring.fullImage());
|
||||||
}
|
}
|
||||||
if (this.expression instanceof Array) {
|
if (this.expression instanceof Array) {
|
||||||
block = this.expression[this.pc].fullCopy();
|
block = this.expression[this.pc].fullCopy();
|
||||||
if (block instanceof RingMorph && !block.contents()) { // empty ring
|
if (block instanceof RingMorph && !block.contents()) { // empty ring
|
||||||
return block.fullImage();
|
return block.doWithAlpha(1, () => block.fullImage());
|
||||||
}
|
}
|
||||||
ring.embed(block, this.isContinuation ? [] : this.inputs);
|
ring.embed(block, this.isContinuation ? [] : this.inputs);
|
||||||
return ring.fullImage();
|
return ring.doWithAlpha(1, () => ring.fullImage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise show an empty ring
|
// otherwise show an empty ring
|
||||||
|
@ -6135,7 +6135,7 @@ Context.prototype.image = function () {
|
||||||
ring.parts()[1].addInput(inp)
|
ring.parts()[1].addInput(inp)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return ring.fullImage();
|
return ring.doWithAlpha(1, () => ring.fullImage());
|
||||||
};
|
};
|
||||||
|
|
||||||
// Context continuations:
|
// Context continuations:
|
||||||
|
|
|
@ -85,7 +85,7 @@ HTMLCanvasElement, fontHeight, SymbolMorph, localize, SpeechBubbleMorph,
|
||||||
ArrowMorph, MenuMorph, isString, isNil, SliderMorph, MorphicPreferences,
|
ArrowMorph, MenuMorph, isString, isNil, SliderMorph, MorphicPreferences,
|
||||||
ScrollFrameMorph, MenuItemMorph, Note*/
|
ScrollFrameMorph, MenuItemMorph, Note*/
|
||||||
|
|
||||||
modules.widgets = '2020-July-13';
|
modules.widgets = '2020-July-21';
|
||||||
|
|
||||||
var PushButtonMorph;
|
var PushButtonMorph;
|
||||||
var ToggleButtonMorph;
|
var ToggleButtonMorph;
|
||||||
|
@ -728,7 +728,7 @@ ToggleButtonMorph.prototype.render = function (ctx) {
|
||||||
// note: don't invert the 3D-ish edges for 'pressed' state, because
|
// note: don't invert the 3D-ish edges for 'pressed' state, because
|
||||||
// it will stay that way, and should not look inverted (or should it?)
|
// it will stay that way, and should not look inverted (or should it?)
|
||||||
this.drawOutline(ctx);
|
this.drawOutline(ctx);
|
||||||
this.drawBackground(ctx, this.pressColor);
|
this.drawBackground(ctx, this.getPressRenderColor());
|
||||||
this.drawEdges(
|
this.drawEdges(
|
||||||
ctx,
|
ctx,
|
||||||
this.pressColor,
|
this.pressColor,
|
||||||
|
@ -748,6 +748,11 @@ ToggleButtonMorph.prototype.render = function (ctx) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ToggleButtonMorph.prototype.getPressRenderColor = function () {
|
||||||
|
// can be overridden by my children
|
||||||
|
return this.pressColor;
|
||||||
|
};
|
||||||
|
|
||||||
ToggleButtonMorph.prototype.drawEdges = function (
|
ToggleButtonMorph.prototype.drawEdges = function (
|
||||||
ctx,
|
ctx,
|
||||||
color,
|
color,
|
||||||
|
@ -1597,10 +1602,12 @@ DialogBoxMorph.prototype.prompt = function (
|
||||||
isNumeric, // optional
|
isNumeric, // optional
|
||||||
sliderMin, // optional for numeric sliders
|
sliderMin, // optional for numeric sliders
|
||||||
sliderMax, // optional for numeric sliders
|
sliderMax, // optional for numeric sliders
|
||||||
sliderAction // optional single-arg function for numeric slider
|
sliderAction, // optional single-arg function for numeric slider
|
||||||
|
decimals = 2 // optional number of decimal digits
|
||||||
) {
|
) {
|
||||||
var sld,
|
var sld,
|
||||||
head,
|
head,
|
||||||
|
precision = Math.pow(10, decimals),
|
||||||
txt = new InputFieldMorph(
|
txt = new InputFieldMorph(
|
||||||
defaultString,
|
defaultString,
|
||||||
isNumeric || false, // numeric?
|
isNumeric || false, // numeric?
|
||||||
|
@ -1616,10 +1623,10 @@ DialogBoxMorph.prototype.prompt = function (
|
||||||
}
|
}
|
||||||
if (!isNil(sliderMin) && !isNil(sliderMax)) {
|
if (!isNil(sliderMin) && !isNil(sliderMax)) {
|
||||||
sld = new SliderMorph(
|
sld = new SliderMorph(
|
||||||
sliderMin * 100,
|
sliderMin * precision,
|
||||||
sliderMax * 100,
|
sliderMax * precision,
|
||||||
parseFloat(defaultString) * 100,
|
parseFloat(defaultString) * precision,
|
||||||
(sliderMax - sliderMin) / 10 * 100,
|
(sliderMax - sliderMin) / 10 * precision, // knob size
|
||||||
'horizontal'
|
'horizontal'
|
||||||
);
|
);
|
||||||
sld.alpha = 1;
|
sld.alpha = 1;
|
||||||
|
@ -1628,9 +1635,9 @@ DialogBoxMorph.prototype.prompt = function (
|
||||||
sld.setWidth(txt.width());
|
sld.setWidth(txt.width());
|
||||||
sld.action = num => {
|
sld.action = num => {
|
||||||
if (sliderAction) {
|
if (sliderAction) {
|
||||||
sliderAction(num / 100);
|
sliderAction(num / precision);
|
||||||
}
|
}
|
||||||
txt.setContents(num / 100);
|
txt.setContents(num / precision);
|
||||||
txt.edit();
|
txt.edit();
|
||||||
};
|
};
|
||||||
if (!head) {
|
if (!head) {
|
||||||
|
@ -1649,7 +1656,7 @@ DialogBoxMorph.prototype.prompt = function (
|
||||||
|
|
||||||
this.reactToChoice = function (inp) {
|
this.reactToChoice = function (inp) {
|
||||||
if (sld) {
|
if (sld) {
|
||||||
sld.value = inp * 100;
|
sld.value = inp * precision;
|
||||||
sld.fixLayout();
|
sld.fixLayout();
|
||||||
sld.rerender();
|
sld.rerender();
|
||||||
}
|
}
|
||||||
|
@ -1662,7 +1669,7 @@ DialogBoxMorph.prototype.prompt = function (
|
||||||
var inp = txt.getValue();
|
var inp = txt.getValue();
|
||||||
if (sld) {
|
if (sld) {
|
||||||
inp = Math.max(inp, sliderMin);
|
inp = Math.max(inp, sliderMin);
|
||||||
sld.value = inp * 100;
|
sld.value = inp * precision;
|
||||||
sld.fixLayout();
|
sld.fixLayout();
|
||||||
sld.rerender();
|
sld.rerender();
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue