kopia lustrzana https://github.com/backface/turtlestitch
Polished filter field
rodzic
331e572b42
commit
37f1e1ba2a
47
blocks.js
47
blocks.js
|
@ -8894,7 +8894,8 @@ SymbolMorph.prototype.names = [
|
||||||
'arrowDownOutline',
|
'arrowDownOutline',
|
||||||
'arrowRight',
|
'arrowRight',
|
||||||
'arrowRightOutline',
|
'arrowRightOutline',
|
||||||
'robot'
|
'robot',
|
||||||
|
'magnifiyingGlass'
|
||||||
];
|
];
|
||||||
|
|
||||||
// SymbolMorph instance creation:
|
// SymbolMorph instance creation:
|
||||||
|
@ -9060,6 +9061,8 @@ SymbolMorph.prototype.symbolCanvasColored = function (aColor) {
|
||||||
return this.drawSymbolArrowRightOutline(canvas, aColor);
|
return this.drawSymbolArrowRightOutline(canvas, aColor);
|
||||||
case 'robot':
|
case 'robot':
|
||||||
return this.drawSymbolRobot(canvas, aColor);
|
return this.drawSymbolRobot(canvas, aColor);
|
||||||
|
case 'magnifiyingGlass':
|
||||||
|
return this.drawSymbolMagnifyingGlass(canvas, aColor);
|
||||||
default:
|
default:
|
||||||
return canvas;
|
return canvas;
|
||||||
}
|
}
|
||||||
|
@ -10146,6 +10149,48 @@ SymbolMorph.prototype.drawSymbolRobot = function (canvas, color) {
|
||||||
return canvas;
|
return canvas;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SymbolMorph.prototype.drawSymbolMagnifyingGlass = function (canvas, color) {
|
||||||
|
// answer a canvas showing a magnifying glass
|
||||||
|
var ctx = canvas.getContext('2d'),
|
||||||
|
gradient,
|
||||||
|
w = canvas.width,
|
||||||
|
h = canvas.height,
|
||||||
|
r = w * 0.3,
|
||||||
|
x = w * 2 / 3 - Math.sqrt(r),
|
||||||
|
y = h / 3 + Math.sqrt(r),
|
||||||
|
l = Math.max(w / 5, 0.5);
|
||||||
|
|
||||||
|
ctx.strokeStyle = color.toString();
|
||||||
|
|
||||||
|
gradient = ctx.createRadialGradient(
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
0,
|
||||||
|
x + r,
|
||||||
|
y + r,
|
||||||
|
w
|
||||||
|
);
|
||||||
|
|
||||||
|
gradient.addColorStop(0, color.inverted().lighter(50).toString());
|
||||||
|
gradient.addColorStop(1, color.inverted().darker(25).toString());
|
||||||
|
ctx.fillStyle = gradient;
|
||||||
|
ctx.arc(x, y, r, radians(0), radians(360), false);
|
||||||
|
ctx.fill();
|
||||||
|
|
||||||
|
ctx.lineWidth = l / 2;
|
||||||
|
ctx.arc(x, y, r, radians(0), radians(360), false);
|
||||||
|
ctx.stroke();
|
||||||
|
|
||||||
|
ctx.lineWidth = l;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(l / 2, h - l / 2);
|
||||||
|
ctx.lineTo(x - Math.sqrt(r + l), y + Math.sqrt(r + l));
|
||||||
|
ctx.closePath();
|
||||||
|
ctx.stroke();
|
||||||
|
|
||||||
|
return canvas;
|
||||||
|
};
|
||||||
|
|
||||||
// ColorSlotMorph //////////////////////////////////////////////////////
|
// ColorSlotMorph //////////////////////////////////////////////////////
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
68
gui.js
68
gui.js
|
@ -5192,6 +5192,8 @@ ProjectDialogMorph.prototype.init = function (ide, task) {
|
||||||
this.handle = null;
|
this.handle = null;
|
||||||
this.srcBar = null;
|
this.srcBar = null;
|
||||||
this.nameField = null;
|
this.nameField = null;
|
||||||
|
this.filterField = null;
|
||||||
|
this.magnifiyingGlass = null;
|
||||||
this.listField = null;
|
this.listField = null;
|
||||||
this.preview = null;
|
this.preview = null;
|
||||||
this.notesText = null;
|
this.notesText = null;
|
||||||
|
@ -5475,11 +5477,17 @@ ProjectDialogMorph.prototype.fixListFieldItemColors = function () {
|
||||||
ProjectDialogMorph.prototype.buildFilterField = function () {
|
ProjectDialogMorph.prototype.buildFilterField = function () {
|
||||||
var myself = this;
|
var myself = this;
|
||||||
|
|
||||||
// we reuse the nameField attribute
|
this.filterField = new InputFieldMorph('');
|
||||||
this.nameField = new InputFieldMorph(this.ide.projectName);
|
this.magnifiyingGlass =
|
||||||
this.body.add(this.nameField);
|
new SymbolMorph(
|
||||||
|
'magnifiyingGlass',
|
||||||
|
this.filterField.height(),
|
||||||
|
this.titleBarColor.darker(50));
|
||||||
|
|
||||||
this.nameField.reactToKeystroke = function (evt) {
|
this.body.add(this.magnifiyingGlass);
|
||||||
|
this.body.add(this.filterField);
|
||||||
|
|
||||||
|
this.filterField.reactToKeystroke = function (evt) {
|
||||||
var text = this.getValue();
|
var text = this.getValue();
|
||||||
|
|
||||||
myself.listField.elements =
|
myself.listField.elements =
|
||||||
|
@ -5499,6 +5507,10 @@ ProjectDialogMorph.prototype.buildFilterField = function () {
|
||||||
notes.toLowerCase().indexOf(text.toLowerCase()) > -1;
|
notes.toLowerCase().indexOf(text.toLowerCase()) > -1;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (myself.listField.elements.length === 0) {
|
||||||
|
myself.listField.elements.push('(no matches)')
|
||||||
|
}
|
||||||
|
|
||||||
myself.clearDetails();
|
myself.clearDetails();
|
||||||
myself.listField.buildListContents();
|
myself.listField.buildListContents();
|
||||||
myself.fixListFieldItemColors();
|
myself.fixListFieldItemColors();
|
||||||
|
@ -5548,11 +5560,7 @@ ProjectDialogMorph.prototype.setSource = function (source) {
|
||||||
this.projectList,
|
this.projectList,
|
||||||
this.projectList.length > 0 ?
|
this.projectList.length > 0 ?
|
||||||
function (element) {
|
function (element) {
|
||||||
if (element.name) {
|
return element.name || element;
|
||||||
return element.name;
|
|
||||||
} else {
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
} : null,
|
} : null,
|
||||||
null,
|
null,
|
||||||
function () {myself.ok(); }
|
function () {myself.ok(); }
|
||||||
|
@ -5670,11 +5678,7 @@ ProjectDialogMorph.prototype.installCloudProjectList = function (pl) {
|
||||||
this.projectList,
|
this.projectList,
|
||||||
this.projectList.length > 0 ?
|
this.projectList.length > 0 ?
|
||||||
function (element) {
|
function (element) {
|
||||||
if (element.ProjectName) {
|
return element.ProjectName || element;
|
||||||
return element.ProjectName;
|
|
||||||
} else {
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
} : null,
|
} : null,
|
||||||
[ // format: display shared project names bold
|
[ // format: display shared project names bold
|
||||||
[
|
[
|
||||||
|
@ -6030,6 +6034,8 @@ ProjectDialogMorph.prototype.unshareProject = function () {
|
||||||
ProjectDialogMorph.prototype.edit = function () {
|
ProjectDialogMorph.prototype.edit = function () {
|
||||||
if (this.nameField) {
|
if (this.nameField) {
|
||||||
this.nameField.edit();
|
this.nameField.edit();
|
||||||
|
} else if (this.filterField) {
|
||||||
|
this.filterField.edit();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6038,6 +6044,7 @@ ProjectDialogMorph.prototype.edit = function () {
|
||||||
ProjectDialogMorph.prototype.fixLayout = function () {
|
ProjectDialogMorph.prototype.fixLayout = function () {
|
||||||
var th = fontHeight(this.titleFontSize) + this.titlePadding * 2,
|
var th = fontHeight(this.titleFontSize) + this.titlePadding * 2,
|
||||||
thin = this.padding / 2,
|
thin = this.padding / 2,
|
||||||
|
inputField = this.nameField || this.filterField;
|
||||||
oldFlag = Morph.prototype.trackChanges;
|
oldFlag = Morph.prototype.trackChanges;
|
||||||
|
|
||||||
Morph.prototype.trackChanges = false;
|
Morph.prototype.trackChanges = false;
|
||||||
|
@ -6056,14 +6063,13 @@ ProjectDialogMorph.prototype.fixLayout = function () {
|
||||||
this.height() - this.padding * 3 - th - this.buttons.height()
|
this.height() - this.padding * 3 - th - this.buttons.height()
|
||||||
));
|
));
|
||||||
this.srcBar.setPosition(this.body.position());
|
this.srcBar.setPosition(this.body.position());
|
||||||
if (this.nameField) {
|
|
||||||
this.nameField.setWidth(
|
inputField.setWidth(
|
||||||
this.body.width() - this.srcBar.width() - this.padding * 6
|
this.body.width() - this.srcBar.width() - this.padding * 6
|
||||||
);
|
);
|
||||||
this.nameField.setLeft(this.srcBar.right() + this.padding * 3);
|
inputField.setLeft(this.srcBar.right() + this.padding * 3);
|
||||||
this.nameField.setTop(this.srcBar.top());
|
inputField.setTop(this.srcBar.top());
|
||||||
this.nameField.drawNew();
|
inputField.drawNew();
|
||||||
}
|
|
||||||
|
|
||||||
this.listField.setLeft(this.srcBar.right() + this.padding);
|
this.listField.setLeft(this.srcBar.right() + this.padding);
|
||||||
this.listField.setWidth(
|
this.listField.setWidth(
|
||||||
|
@ -6075,22 +6081,18 @@ ProjectDialogMorph.prototype.fixLayout = function () {
|
||||||
);
|
);
|
||||||
this.listField.contents.children[0].adjustWidths();
|
this.listField.contents.children[0].adjustWidths();
|
||||||
|
|
||||||
if (this.nameField) {
|
this.listField.setTop(inputField.bottom() + this.padding);
|
||||||
this.listField.setTop(this.nameField.bottom() + this.padding);
|
this.listField.setHeight(
|
||||||
this.listField.setHeight(
|
this.body.height() - inputField.height() - this.padding
|
||||||
this.body.height() - this.nameField.height() - this.padding
|
);
|
||||||
);
|
|
||||||
} else {
|
if (this.magnifiyingGlass) {
|
||||||
this.listField.setTop(this.body.top());
|
this.magnifiyingGlass.setTop(inputField.top());
|
||||||
this.listField.setHeight(this.body.height());
|
this.magnifiyingGlass.setLeft(this.listField.left());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.preview.setRight(this.body.right());
|
this.preview.setRight(this.body.right());
|
||||||
if (this.nameField) {
|
this.preview.setTop(inputField.bottom() + this.padding);
|
||||||
this.preview.setTop(this.nameField.bottom() + this.padding);
|
|
||||||
} else {
|
|
||||||
this.preview.setTop(this.body.top());
|
|
||||||
}
|
|
||||||
|
|
||||||
this.notesField.setTop(this.preview.bottom() + thin);
|
this.notesField.setTop(this.preview.bottom() + thin);
|
||||||
this.notesField.setLeft(this.preview.left());
|
this.notesField.setLeft(this.preview.left());
|
||||||
|
|
|
@ -1888,6 +1888,14 @@ Color.prototype.dansDarker = function () {
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Color.prototype.inverted = function () {
|
||||||
|
return new Color(
|
||||||
|
255 - this.r,
|
||||||
|
255 - this.g,
|
||||||
|
255 - this.b
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Points //////////////////////////////////////////////////////////////
|
// Points //////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Point instance creation:
|
// Point instance creation:
|
||||||
|
|
Ładowanie…
Reference in New Issue