kopia lustrzana https://github.com/backface/turtlestitch
Widgets: new “promptVector” dialog box feature
lets you edit a Point object (numerical x and y), such as dimensions, positions, min/max etc.pull/3/merge
rodzic
2411ca3ebd
commit
2c7d747bfc
|
@ -2100,3 +2100,4 @@ ______
|
||||||
------
|
------
|
||||||
* GUI, Store: constrain minimum stage size to 480 x 180
|
* GUI, Store: constrain minimum stage size to 480 x 180
|
||||||
* GUI: Fixed #322, #324
|
* GUI: Fixed #322, #324
|
||||||
|
* Widgets: new “promptVector” dialog box feature
|
||||||
|
|
109
widgets.js
109
widgets.js
|
@ -74,7 +74,7 @@ HTMLCanvasElement, fontHeight, SymbolMorph, localize, SpeechBubbleMorph,
|
||||||
ArrowMorph, MenuMorph, isString, isNil, SliderMorph, MorphicPreferences,
|
ArrowMorph, MenuMorph, isString, isNil, SliderMorph, MorphicPreferences,
|
||||||
ScrollFrameMorph*/
|
ScrollFrameMorph*/
|
||||||
|
|
||||||
modules.widgets = '2014-January-09';
|
modules.widgets = '2014-February-13';
|
||||||
|
|
||||||
var PushButtonMorph;
|
var PushButtonMorph;
|
||||||
var ToggleButtonMorph;
|
var ToggleButtonMorph;
|
||||||
|
@ -1760,6 +1760,113 @@ DialogBoxMorph.prototype.promptCode = function (
|
||||||
text.edit();
|
text.edit();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DialogBoxMorph.prototype.promptVector = function (
|
||||||
|
title,
|
||||||
|
point,
|
||||||
|
deflt,
|
||||||
|
xLabel,
|
||||||
|
yLabel,
|
||||||
|
world,
|
||||||
|
pic,
|
||||||
|
msg
|
||||||
|
) {
|
||||||
|
var vec = new AlignmentMorph('row', 4),
|
||||||
|
xInp = new InputFieldMorph(point.x.toString(), true),
|
||||||
|
yInp = new InputFieldMorph(point.y.toString(), true),
|
||||||
|
xCol = new AlignmentMorph('column', 2),
|
||||||
|
yCol = new AlignmentMorph('column', 2),
|
||||||
|
inp = new AlignmentMorph('column', 2),
|
||||||
|
bdy = new AlignmentMorph('column', this.padding);
|
||||||
|
|
||||||
|
function labelText(string) {
|
||||||
|
return new TextMorph(
|
||||||
|
localize(string),
|
||||||
|
10,
|
||||||
|
null, // style
|
||||||
|
false, // bold
|
||||||
|
null, // italic
|
||||||
|
null, // alignment
|
||||||
|
null, // width
|
||||||
|
null, // font name
|
||||||
|
MorphicPreferences.isFlat ? null : new Point(1, 1),
|
||||||
|
new Color(255, 255, 255) // shadowColor
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
inp.alignment = 'left';
|
||||||
|
inp.setColor(this.color);
|
||||||
|
bdy.setColor(this.color);
|
||||||
|
xCol.alignment = 'left';
|
||||||
|
xCol.setColor(this.color);
|
||||||
|
yCol.alignment = 'left';
|
||||||
|
yCol.setColor(this.color);
|
||||||
|
|
||||||
|
xCol.add(labelText(xLabel));
|
||||||
|
xCol.add(xInp);
|
||||||
|
yCol.add(labelText(yLabel));
|
||||||
|
yCol.add(yInp);
|
||||||
|
vec.add(xCol);
|
||||||
|
vec.add(yCol);
|
||||||
|
inp.add(vec);
|
||||||
|
|
||||||
|
if (msg) {
|
||||||
|
bdy.add(labelText(msg));
|
||||||
|
}
|
||||||
|
|
||||||
|
bdy.add(inp);
|
||||||
|
|
||||||
|
vec.fixLayout();
|
||||||
|
xCol.fixLayout();
|
||||||
|
yCol.fixLayout();
|
||||||
|
inp.fixLayout();
|
||||||
|
bdy.fixLayout();
|
||||||
|
|
||||||
|
this.labelString = title;
|
||||||
|
this.createLabel();
|
||||||
|
if (pic) {this.setPicture(pic); }
|
||||||
|
|
||||||
|
this.addBody(bdy);
|
||||||
|
|
||||||
|
vec.drawNew();
|
||||||
|
xCol.drawNew();
|
||||||
|
xInp.drawNew();
|
||||||
|
yCol.drawNew();
|
||||||
|
yInp.drawNew();
|
||||||
|
bdy.fixLayout();
|
||||||
|
|
||||||
|
this.addButton('ok', 'OK');
|
||||||
|
|
||||||
|
if (deflt instanceof Point) {
|
||||||
|
this.addButton(
|
||||||
|
function () {
|
||||||
|
xInp.setContents(deflt.x.toString());
|
||||||
|
yInp.setContents(deflt.y.toString());
|
||||||
|
},
|
||||||
|
'Default'
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.addButton('cancel', 'Cancel');
|
||||||
|
this.fixLayout();
|
||||||
|
this.drawNew();
|
||||||
|
this.fixLayout();
|
||||||
|
|
||||||
|
this.edit = function () {
|
||||||
|
xInp.edit();
|
||||||
|
};
|
||||||
|
|
||||||
|
this.getInput = function () {
|
||||||
|
return new Point(xInp.getValue(), yInp.getValue());
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!this.key) {
|
||||||
|
this.key = 'vector' + title;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.popUp(world);
|
||||||
|
};
|
||||||
|
|
||||||
DialogBoxMorph.prototype.promptCredentials = function (
|
DialogBoxMorph.prototype.promptCredentials = function (
|
||||||
title,
|
title,
|
||||||
purpose,
|
purpose,
|
||||||
|
|
Ładowanie…
Reference in New Issue