Update jump heights only when necessary.
This method uses signaling (through a boolean) and I feel like it's extremely hacky, but I tested this and it (kind of?) works. Unfortunately I found this to potentially lag when resizing. I am not sure if this is guaranteed to work (as in, produce correct behaviour) or not, but to my understanding only LogicDialog uses LCanvas (grep out "LCanvas\|canvas" and see) so it will most likely work? I tested this and accidentally found an unrelated issue related to LCanvas.maxJumpsDrawn, but I hope this will be fixed in the near future.
This commit is contained in:
@@ -159,6 +159,7 @@ public class LCanvas extends Table{
|
|||||||
st.setupUI();
|
st.setupUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.statements.updateJumpHeights = true;
|
||||||
this.statements.layout();
|
this.statements.layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,6 +203,7 @@ public class LCanvas extends Table{
|
|||||||
boolean invalidated;
|
boolean invalidated;
|
||||||
public Group jumps = new WidgetGroup();
|
public Group jumps = new WidgetGroup();
|
||||||
private Seq<JumpCurve> processedJumps = new Seq<JumpCurve>();
|
private Seq<JumpCurve> processedJumps = new Seq<JumpCurve>();
|
||||||
|
public boolean updateJumpHeights = true;
|
||||||
|
|
||||||
{
|
{
|
||||||
setTransform(true);
|
setTransform(true);
|
||||||
@@ -257,7 +259,10 @@ public class LCanvas extends Table{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dynamicJumpHeights) setJumpHeights();
|
if(dynamicJumpHeights){
|
||||||
|
if(updateJumpHeights) setJumpHeights();
|
||||||
|
updateJumpHeights = false;
|
||||||
|
}
|
||||||
|
|
||||||
if(parent != null) parent.invalidateHierarchy();//don't invalid self
|
if(parent != null) parent.invalidateHierarchy();//don't invalid self
|
||||||
|
|
||||||
@@ -394,6 +399,7 @@ public class LCanvas extends Table{
|
|||||||
dragging = null;
|
dragging = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateJumpHeights = true;
|
||||||
layout();
|
layout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -430,6 +436,7 @@ public class LCanvas extends Table{
|
|||||||
t.button(Icon.cancel, Styles.logici, () -> {
|
t.button(Icon.cancel, Styles.logici, () -> {
|
||||||
remove();
|
remove();
|
||||||
dragging = null;
|
dragging = null;
|
||||||
|
statements.updateJumpHeights = true;
|
||||||
statements.layout();
|
statements.layout();
|
||||||
}).size(24f);
|
}).size(24f);
|
||||||
|
|
||||||
@@ -449,6 +456,7 @@ public class LCanvas extends Table{
|
|||||||
lasty = v.y;
|
lasty = v.y;
|
||||||
dragging = StatementElem.this;
|
dragging = StatementElem.this;
|
||||||
toFront();
|
toFront();
|
||||||
|
statements.updateJumpHeights = true;
|
||||||
statements.layout();
|
statements.layout();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -506,6 +514,7 @@ public class LCanvas extends Table{
|
|||||||
statements.layout();
|
statements.layout();
|
||||||
copy.elem = s;
|
copy.elem = s;
|
||||||
copy.setupUI();
|
copy.setupUI();
|
||||||
|
statements.updateJumpHeights = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -549,6 +558,7 @@ public class LCanvas extends Table{
|
|||||||
setter.get(null);
|
setter.get(null);
|
||||||
mx = x;
|
mx = x;
|
||||||
my = y;
|
my = y;
|
||||||
|
canvas.statements.updateJumpHeights = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,6 +579,7 @@ public class LCanvas extends Table{
|
|||||||
setter.get(null);
|
setter.get(null);
|
||||||
}
|
}
|
||||||
selecting = false;
|
selecting = false;
|
||||||
|
canvas.statements.updateJumpHeights = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -256,6 +256,8 @@ public class LogicDialog extends BaseDialog{
|
|||||||
dialog.addCloseButton();
|
dialog.addCloseButton();
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}).disabled(t -> canvas.statements.getChildren().size >= LExecutor.maxInstructions);
|
}).disabled(t -> canvas.statements.getChildren().size >= LExecutor.maxInstructions);
|
||||||
|
|
||||||
|
Core.app.post(canvas::rebuild);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show(String code, LExecutor executor, boolean privileged, Cons<String> modified){
|
public void show(String code, LExecutor executor, boolean privileged, Cons<String> modified){
|
||||||
|
|||||||
Reference in New Issue
Block a user