Fixed hang bug when visible work area got full of elements and a new one was attempted to be placed

This commit is contained in:
MatCat 2021-03-12 00:37:33 -08:00
parent bdd630e8d5
commit 1ccb5968e0
3 changed files with 11 additions and 4 deletions

View File

@ -77,9 +77,11 @@ class elementContainer {
this.Selected = false;
this.Inputs = new Array();
this.Outputs = new Array();
this.StaticImages = {};
this.ICOutputs = 0;
}
isSelected(element) {
if (this.Selected) {
for (let a = 0; a < this.Selected.length; a++) {

View File

@ -1379,10 +1379,15 @@ class InputSwitch extends inputElement {
}
}
drawElement(x, y, ctx) {
drawStatic(x, y, ctx) {
this.drawBorderBox(ctx, x,y,this.Width-20,this.Height,1,"#000","#f7e979",this.LogicEngine.Settings.ShadowColor);
//this.drawBorderBox(ctx,x+5,y+5,50,50,1,"#ccc","#777");
this.drawBorderBox(ctx,x+5,y+25,50,10,1,"#ccc","#777");
this.drawTextCentered(ctx,x,y+(this.Height-14),this.Width-(this.outputCircleRadius*2),12,this.Designator,"12px Console","#000");
}
drawElement(x, y, ctx) {
this.drawStatic(x, y, ctx);
if (this.getOutput()) {
this.drawBorderBox(ctx,x+15,y+5,30,25,1,"#ccc","#777");
this.drawTextCentered(ctx,x,y+this.Height - 30,this.Width-(this.outputCircleRadius*2)-20,12,"OFF","12px Console","#000");
@ -1390,7 +1395,6 @@ class InputSwitch extends inputElement {
this.drawBorderBox(ctx,x+15,y+30,30,25,1,"#ccc","#777");
this.drawTextCentered(ctx,x,y+7,this.Width-(this.outputCircleRadius*2)-20,12,"ON","12px Console","#000");
}
this.drawTextCentered(ctx,x,y+(this.Height-14),this.Width-(this.outputCircleRadius*2),12,this.Designator,"12px Console","#000");
this.drawOutputs(ctx,x,y);
}
}

View File

@ -12,7 +12,9 @@ function addElement(RestoreData = null,refClass,props) {
let height = newElement.Height;
let noclearspot = true;
while (noclearspot) {
let findattempt = 0;
while (noclearspot && findattempt < 100) {
findattempt++;
if (!logicEngine.ActiveContainer.checkOverlayBounds(x, y, width, height)) {
noclearspot = false;
} else {
@ -24,7 +26,6 @@ function addElement(RestoreData = null,refClass,props) {
if (y + height > logicEngine.Canvas.height) y = logicEngine.Canvas.height - height;
x = logicEngine.Settings.GridSize * Math.round(x/logicEngine.Settings.GridSize);
y = logicEngine.Settings.GridSize * Math.round(y/logicEngine.Settings.GridSize);
}
}
newElement.X = x;