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:
code-explorer786
2024-06-27 15:47:18 +07:00
parent 26105a64f1
commit 282d21db05
2 changed files with 14 additions and 1 deletions

View File

@@ -159,6 +159,7 @@ public class LCanvas extends Table{
st.setupUI();
}
this.statements.updateJumpHeights = true;
this.statements.layout();
}
@@ -202,6 +203,7 @@ public class LCanvas extends Table{
boolean invalidated;
public Group jumps = new WidgetGroup();
private Seq<JumpCurve> processedJumps = new Seq<JumpCurve>();
public boolean updateJumpHeights = 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
@@ -394,6 +399,7 @@ public class LCanvas extends Table{
dragging = null;
}
updateJumpHeights = true;
layout();
}
}
@@ -430,6 +436,7 @@ public class LCanvas extends Table{
t.button(Icon.cancel, Styles.logici, () -> {
remove();
dragging = null;
statements.updateJumpHeights = true;
statements.layout();
}).size(24f);
@@ -449,6 +456,7 @@ public class LCanvas extends Table{
lasty = v.y;
dragging = StatementElem.this;
toFront();
statements.updateJumpHeights = true;
statements.layout();
return true;
}
@@ -506,6 +514,7 @@ public class LCanvas extends Table{
statements.layout();
copy.elem = s;
copy.setupUI();
statements.updateJumpHeights = true;
}
}
@@ -549,6 +558,7 @@ public class LCanvas extends Table{
setter.get(null);
mx = x;
my = y;
canvas.statements.updateJumpHeights = true;
return true;
}
@@ -569,6 +579,7 @@ public class LCanvas extends Table{
setter.get(null);
}
selecting = false;
canvas.statements.updateJumpHeights = true;
}
});

View File

@@ -256,6 +256,8 @@ public class LogicDialog extends BaseDialog{
dialog.addCloseButton();
dialog.show();
}).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){