Fixes #32
All checks were successful
Linux arm64 / Build (push) Successful in 41s

This commit is contained in:
2025-02-02 11:01:10 +01:00
parent 4b98341618
commit d806420d21
2 changed files with 18 additions and 3 deletions

View File

@@ -9,13 +9,22 @@ public class SmoothProgressBar {
private final float speed = 2.0f;
private final float clipConstant = 0.001f;
public void render(String label, ImVec2 size, float progress) {
float delta = progress - lastProgress;
private void updateProgress(float newProgress) {
float delta = newProgress - lastProgress;
if (Math.abs(delta) < clipConstant)
lastProgress = progress;
lastProgress = newProgress;
else
lastProgress = lastProgress + delta * ImGui.getIO().getDeltaTime() * speed;
}
public void render(String label, ImVec2 size, float progress) {
updateProgress(progress);
ImGui.progressBar(lastProgress, size, label);
}
public void render(float progress) {
updateProgress(progress);
ImGui.progressBar(lastProgress);
}
}

View File

@@ -37,10 +37,13 @@ public class SudokuSelector {
private Thread genThread = null;
private final SmoothProgressBar genProgressBar;
public SudokuSelector(boolean canGenEmptyGrid, String confirmMessage) {
this.canGenEmptyGrid = canGenEmptyGrid;
this.confirmMessage = confirmMessage;
initConstraints();
this.genProgressBar = new SmoothProgressBar();
}
private List<IConstraint> getConstraints() {
@@ -68,6 +71,9 @@ public class SudokuSelector {
private void renderGenProgress() {
if (ImGui.beginPopup("genProgress")) {
ImGui.text("Loading ...");
int filled = this.doku.getFilledCells().size();
int total = this.doku.getCells().size();
this.genProgressBar.render(filled / (float) total);
ImGui.endPopup();
} else {
stopGenThread();