kopia lustrzana https://github.com/backface/turtlestitch
Zoom Blocks
in the settings menu. also: Optional slider for numeric prompter, numberic prompters for watchers' sliderMin/Maxpull/3/merge
rodzic
957812e6f0
commit
ef170e9a28
68
blocks.js
68
blocks.js
|
@ -153,7 +153,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.blocks = '2013-March-19';
|
||||
modules.blocks = '2013-March-22';
|
||||
|
||||
var SyntaxElementMorph;
|
||||
var BlockMorph;
|
||||
|
@ -297,42 +297,42 @@ SyntaxElementMorph.uber = Morph.prototype;
|
|||
*/
|
||||
|
||||
SyntaxElementMorph.prototype.setScale = function (num) {
|
||||
var scale = Math.max(num, 1);
|
||||
SyntaxElementMorph.prototype.scale = scale;
|
||||
SyntaxElementMorph.prototype.corner = 3 * scale;
|
||||
SyntaxElementMorph.prototype.rounding = 9 * scale;
|
||||
SyntaxElementMorph.prototype.edge = 1.000001 * scale;
|
||||
SyntaxElementMorph.prototype.inset = 6 * scale;
|
||||
SyntaxElementMorph.prototype.hatHeight = 12 * scale;
|
||||
SyntaxElementMorph.prototype.hatWidth = 70 * scale;
|
||||
SyntaxElementMorph.prototype.rfBorder = 3 * scale;
|
||||
SyntaxElementMorph.prototype.minWidth = 0;
|
||||
SyntaxElementMorph.prototype.dent = 8 * scale;
|
||||
SyntaxElementMorph.prototype.bottomPadding = 3 * scale;
|
||||
SyntaxElementMorph.prototype.cSlotPadding = 4 * scale;
|
||||
SyntaxElementMorph.prototype.typeInPadding = scale;
|
||||
SyntaxElementMorph.prototype.labelPadding = 4 * scale;
|
||||
SyntaxElementMorph.prototype.labelFontName = 'Verdana';
|
||||
SyntaxElementMorph.prototype.labelFontStyle = 'sans-serif';
|
||||
SyntaxElementMorph.prototype.fontSize = 10 * scale;
|
||||
SyntaxElementMorph.prototype.embossing = new Point(
|
||||
var scale = Math.min(Math.max(num, 1), 25);
|
||||
this.scale = scale;
|
||||
this.corner = 3 * scale;
|
||||
this.rounding = 9 * scale;
|
||||
this.edge = 1.000001 * scale;
|
||||
this.inset = 6 * scale;
|
||||
this.hatHeight = 12 * scale;
|
||||
this.hatWidth = 70 * scale;
|
||||
this.rfBorder = 3 * scale;
|
||||
this.minWidth = 0;
|
||||
this.dent = 8 * scale;
|
||||
this.bottomPadding = 3 * scale;
|
||||
this.cSlotPadding = 4 * scale;
|
||||
this.typeInPadding = scale;
|
||||
this.labelPadding = 4 * scale;
|
||||
this.labelFontName = 'Verdana';
|
||||
this.labelFontStyle = 'sans-serif';
|
||||
this.fontSize = 10 * scale;
|
||||
this.embossing = new Point(
|
||||
-1 * Math.max(scale / 2, 1),
|
||||
-1 * Math.max(scale / 2, 1)
|
||||
);
|
||||
SyntaxElementMorph.prototype.labelWidth = 450 * scale;
|
||||
SyntaxElementMorph.prototype.labelWordWrap = true;
|
||||
SyntaxElementMorph.prototype.dynamicInputLabels = true;
|
||||
SyntaxElementMorph.prototype.feedbackColor = new Color(255, 255, 255);
|
||||
SyntaxElementMorph.prototype.feedbackMinHeight = 5;
|
||||
SyntaxElementMorph.prototype.minSnapDistance = 20;
|
||||
SyntaxElementMorph.prototype.reporterDropFeedbackPadding = 10 * scale;
|
||||
SyntaxElementMorph.prototype.contrast = 65;
|
||||
SyntaxElementMorph.prototype.labelContrast = 25;
|
||||
SyntaxElementMorph.prototype.activeHighlight = new Color(153, 255, 213);
|
||||
SyntaxElementMorph.prototype.errorHighlight = new Color(173, 15, 0);
|
||||
SyntaxElementMorph.prototype.activeBlur = 20;
|
||||
SyntaxElementMorph.prototype.activeBorder = 4;
|
||||
SyntaxElementMorph.prototype.rfColor = new Color(120, 120, 120);
|
||||
this.labelWidth = 450 * scale;
|
||||
this.labelWordWrap = true;
|
||||
this.dynamicInputLabels = true;
|
||||
this.feedbackColor = new Color(255, 255, 255);
|
||||
this.feedbackMinHeight = 5;
|
||||
this.minSnapDistance = 20;
|
||||
this.reporterDropFeedbackPadding = 10 * scale;
|
||||
this.contrast = 65;
|
||||
this.labelContrast = 25;
|
||||
this.activeHighlight = new Color(153, 255, 213);
|
||||
this.errorHighlight = new Color(173, 15, 0);
|
||||
this.activeBlur = 20;
|
||||
this.activeBorder = 4;
|
||||
this.rfColor = new Color(120, 120, 120);
|
||||
};
|
||||
|
||||
SyntaxElementMorph.prototype.setScale(1);
|
||||
|
|
2
cloud.js
2
cloud.js
|
@ -29,7 +29,7 @@
|
|||
|
||||
/*global modules, IDE_Morph, SnapSerializer, hex_sha512, alert, nop*/
|
||||
|
||||
modules.cloud = '2013-March-21';
|
||||
modules.cloud = '2013-March-22';
|
||||
|
||||
// Global stuff
|
||||
|
||||
|
|
78
gui.js
78
gui.js
|
@ -64,11 +64,11 @@ standardSettings, Sound, BlockMorph, ToggleMorph, InputSlotDialogMorph,
|
|||
ScriptsMorph, isNil, SymbolMorph, BlockExportDialogMorph,
|
||||
BlockImportDialogMorph, SnapTranslator, localize, List, InputSlotMorph,
|
||||
SnapCloud, Uint8Array, HandleMorph, SVG_Costume, fontHeight, hex_sha512,
|
||||
sb, CommentMorph*/
|
||||
sb, CommentMorph, CommandBlockMorph*/
|
||||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.gui = '2013-March-20';
|
||||
modules.gui = '2013-March-22';
|
||||
|
||||
// Declarations
|
||||
|
||||
|
@ -1704,14 +1704,10 @@ IDE_Morph.prototype.settingsMenu = function () {
|
|||
|
||||
menu = new MenuMorph(this);
|
||||
menu.addItem('Language...', 'languageMenu');
|
||||
if (shiftClicked) {
|
||||
menu.addItem(
|
||||
'Scale blocks...',
|
||||
'userSetBlocksScale',
|
||||
null,
|
||||
new Color(100, 0, 0)
|
||||
);
|
||||
}
|
||||
menu.addItem(
|
||||
'Zoom blocks...',
|
||||
'userSetBlocksScale'
|
||||
);
|
||||
menu.addLine();
|
||||
addPreference(
|
||||
'Blurred shadows',
|
||||
|
@ -2788,17 +2784,68 @@ IDE_Morph.prototype.reflectLanguage = function (lang) {
|
|||
// IDE_Morph blocks scaling
|
||||
|
||||
IDE_Morph.prototype.userSetBlocksScale = function () {
|
||||
var myself = this;
|
||||
var myself = this,
|
||||
scrpt,
|
||||
blck,
|
||||
shield,
|
||||
sample,
|
||||
action;
|
||||
|
||||
scrpt = new CommandBlockMorph();
|
||||
scrpt.color = SpriteMorph.prototype.blockColor.motion;
|
||||
scrpt.setSpec(localize('build'));
|
||||
blck = new CommandBlockMorph();
|
||||
blck.color = SpriteMorph.prototype.blockColor.sound;
|
||||
blck.setSpec(localize('your own'));
|
||||
scrpt.nextBlock(blck);
|
||||
blck = new CommandBlockMorph();
|
||||
blck.color = SpriteMorph.prototype.blockColor.operators;
|
||||
blck.setSpec(localize('blocks'));
|
||||
scrpt.bottomBlock().nextBlock(blck);
|
||||
/*
|
||||
blck = SpriteMorph.prototype.blockForSelector('doForever');
|
||||
blck.inputs()[0].nestedBlock(scrpt);
|
||||
*/
|
||||
|
||||
sample = new FrameMorph();
|
||||
sample.texture = 'scriptsPaneTexture.gif';
|
||||
sample.setExtent(new Point(250, 180));
|
||||
scrpt.setPosition(sample.position().add(10));
|
||||
sample.add(scrpt);
|
||||
|
||||
shield = new Morph();
|
||||
shield.alpha = 0;
|
||||
shield.setExtent(sample.extent());
|
||||
shield.setPosition(sample.position());
|
||||
sample.add(shield);
|
||||
|
||||
action = function (num) {
|
||||
/*
|
||||
var c;
|
||||
blck.setScale(num);
|
||||
blck.drawNew();
|
||||
blck.setSpec(blck.blockSpec);
|
||||
c = blck.inputs()[0];
|
||||
c.setScale(num);
|
||||
c.nestedBlock(scrpt);
|
||||
*/
|
||||
scrpt.blockSequence().forEach(function (block) {
|
||||
block.setScale(num);
|
||||
block.drawNew();
|
||||
block.setSpec(block.blockSpec);
|
||||
});
|
||||
};
|
||||
|
||||
new DialogBoxMorph(
|
||||
null,
|
||||
function (num) {
|
||||
myself.setBlocksScale(num);
|
||||
}
|
||||
).prompt(
|
||||
'Scale Blocks',
|
||||
'Zoom blocks',
|
||||
SyntaxElementMorph.prototype.scale.toString(),
|
||||
this.world(),
|
||||
null,
|
||||
sample, // pic
|
||||
{
|
||||
'normal (1)' : 1,
|
||||
'demo (1.2)' : 1.2,
|
||||
|
@ -2809,7 +2856,10 @@ IDE_Morph.prototype.userSetBlocksScale = function () {
|
|||
'monstrous (10)' : 10
|
||||
},
|
||||
false, // read only?
|
||||
true // numeric
|
||||
true, // numeric
|
||||
1, // slider min
|
||||
12, // slider max
|
||||
action // slider action
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -1549,4 +1549,10 @@ ______
|
|||
|
||||
130321
|
||||
------
|
||||
* Cloud: allow every XMLHttpRequest to transport cookies (withCredentials = true)
|
||||
* Cloud: allow every XMLHttpRequest to transport cookies (withCredentials = true)
|
||||
|
||||
130322
|
||||
------
|
||||
* Widgets: optional sliders and "lively" graphics for numerical prompters
|
||||
* Blocks, GUI: "Zoom blocks…" feature in the settings menu (no longer hidden)
|
||||
* Objects: numeric prompters for watcher's sliderMin/Max
|
14
objects.js
14
objects.js
|
@ -120,7 +120,7 @@ PrototypeHatBlockMorph*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.objects = '2013-March-12';
|
||||
modules.objects = '2013-March-22';
|
||||
|
||||
var SpriteMorph;
|
||||
var StageMorph;
|
||||
|
@ -5453,7 +5453,11 @@ WatcherMorph.prototype.userSetSliderMin = function () {
|
|||
).prompt(
|
||||
"Slider minimum value",
|
||||
this.sliderMorph.start.toString(),
|
||||
this.world()
|
||||
this.world(),
|
||||
null, // pic
|
||||
null, // choices
|
||||
null, // read only
|
||||
true // numeric
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -5465,7 +5469,11 @@ WatcherMorph.prototype.userSetSliderMax = function () {
|
|||
).prompt(
|
||||
"Slider maximum value",
|
||||
this.sliderMorph.stop.toString(),
|
||||
this.world()
|
||||
this.world(),
|
||||
null, // pic
|
||||
null, // choices
|
||||
null, // read only
|
||||
true // numeric
|
||||
);
|
||||
};
|
||||
|
||||
|
|
88
widgets.js
88
widgets.js
|
@ -71,9 +71,9 @@
|
|||
/*global TriggerMorph, modules, Color, Point, BoxMorph, radians,
|
||||
newCanvas, StringMorph, Morph, TextMorph, nop, detect, StringFieldMorph,
|
||||
HTMLCanvasElement, fontHeight, SymbolMorph, localize, SpeechBubbleMorph,
|
||||
ArrowMorph, MenuMorph, isString*/
|
||||
ArrowMorph, MenuMorph, isString, isNil, SliderMorph*/
|
||||
|
||||
modules.widgets = '2013-March-18';
|
||||
modules.widgets = '2013-March-22';
|
||||
|
||||
var PushButtonMorph;
|
||||
var ToggleButtonMorph;
|
||||
|
@ -1532,18 +1532,86 @@ DialogBoxMorph.prototype.prompt = function (
|
|||
pic,
|
||||
choices, // optional dictionary for drop-down of choices
|
||||
isReadOnly, // optional when using choices
|
||||
isNumeric // optional
|
||||
isNumeric, // optional
|
||||
sliderMin, // optional for numeric sliders
|
||||
sliderMax, // optional for numeric sliders
|
||||
sliderAction // optional single-arg function for numeric slider
|
||||
) {
|
||||
var txt = new InputFieldMorph(
|
||||
defaultString,
|
||||
isNumeric || false, // numeric?
|
||||
choices || null, // drop-down dict, optional
|
||||
choices ? isReadOnly || false : false
|
||||
);
|
||||
var sld,
|
||||
head,
|
||||
txt = new InputFieldMorph(
|
||||
defaultString,
|
||||
isNumeric || false, // numeric?
|
||||
choices || null, // drop-down dict, optional
|
||||
choices ? isReadOnly || false : false
|
||||
);
|
||||
txt.setWidth(250);
|
||||
if (isNumeric) {
|
||||
if (pic) {
|
||||
head = new AlignmentMorph('column', this.padding);
|
||||
pic.setPosition(head.position());
|
||||
head.add(pic);
|
||||
}
|
||||
if (!isNil(sliderMin) && !isNil(sliderMax)) {
|
||||
sld = new SliderMorph(
|
||||
sliderMin * 100,
|
||||
sliderMax * 100,
|
||||
parseFloat(defaultString) * 100,
|
||||
(sliderMax - sliderMin) / 10 * 100,
|
||||
'horizontal'
|
||||
);
|
||||
sld.alpha = 1;
|
||||
sld.color = this.color.lighter(50);
|
||||
sld.setHeight(txt.height() * 0.7);
|
||||
sld.setWidth(txt.width());
|
||||
sld.action = function (num) {
|
||||
if (sliderAction) {
|
||||
sliderAction(num / 100);
|
||||
}
|
||||
txt.setContents(num / 100);
|
||||
txt.edit();
|
||||
};
|
||||
if (!head) {
|
||||
head = new AlignmentMorph('column', this.padding);
|
||||
}
|
||||
head.add(sld);
|
||||
}
|
||||
if (head) {
|
||||
head.fixLayout();
|
||||
this.setPicture(head);
|
||||
head.fixLayout();
|
||||
}
|
||||
} else {
|
||||
if (pic) {this.setPicture(pic); }
|
||||
}
|
||||
|
||||
this.reactToChoice = function (inp) {
|
||||
if (sld) {
|
||||
sld.value = inp * 100;
|
||||
sld.drawNew();
|
||||
sld.changed();
|
||||
}
|
||||
if (sliderAction) {
|
||||
sliderAction(inp);
|
||||
}
|
||||
};
|
||||
|
||||
txt.reactToKeystroke = function () {
|
||||
var inp = txt.getValue();
|
||||
if (sld) {
|
||||
inp = Math.max(inp, sliderMin);
|
||||
sld.value = inp * 100;
|
||||
sld.drawNew();
|
||||
sld.changed();
|
||||
}
|
||||
if (sliderAction) {
|
||||
sliderAction(inp);
|
||||
}
|
||||
};
|
||||
|
||||
this.labelString = title;
|
||||
this.createLabel();
|
||||
if (pic) {this.setPicture(pic); }
|
||||
|
||||
this.addBody(txt);
|
||||
txt.drawNew();
|
||||
this.addButton('ok', 'OK');
|
||||
|
|
Ładowanie…
Reference in New Issue