Consolidate progress bar code, add different styles

This commit is contained in:
Asriel Camora
2024-07-27 12:56:57 -07:00
parent a4dd7d7aab
commit 83e7ca8cf1
7 changed files with 127 additions and 59 deletions
+1 -21
View File
@@ -265,7 +265,7 @@ public sealed unsafe class SynthHelper : Window, IDisposable
if (SolverRunning && SolverObject is { } solver)
{
ImGuiHelpers.ScaledDummy(5);
DrawHelperTaskProgress(solver);
DynamicBars.DrawProgressBar(solver);
}
}
@@ -429,26 +429,6 @@ public sealed unsafe class SynthHelper : Window, IDisposable
}
}
private void DrawHelperTaskProgress(Solver.Solver solver)
{
var spacing = ImGui.GetStyle().ItemSpacing.X;
var availSpace = ImGui.GetContentRegionAvail().X;
var percentWidth = ImGui.CalcTextSize("100%").X;
var progressWidth = availSpace - percentWidth - spacing;
var fraction = (float)solver.ProgressValue / solver.ProgressMax;
var progressColors = Colors.GetSolverProgressColors(solver.ProgressStage);
using (ImRaii.PushColor(ImGuiCol.FrameBg, progressColors.Background))
using (ImRaii.PushColor(ImGuiCol.PlotHistogram, progressColors.Foreground))
ImGui.ProgressBar(Math.Clamp(fraction, 0, 1), new(progressWidth, ImGui.GetFrameHeight()), string.Empty);
if (ImGui.IsItemHovered())
RecipeNote.DrawSolverTooltip(solver);
ImGui.SameLine(0, spacing);
ImGui.AlignTextToFramePadding();
ImGuiUtils.TextRight($"{fraction * 100:N0}%", percentWidth);
}
private void DrawMacroActions()
{
if (SolverRunning)