UX improvements

This commit is contained in:
2026-02-28 00:57:11 -06:00
parent 6607bae2b5
commit f5378a55ed
6 changed files with 132 additions and 97 deletions

View File

@@ -46,12 +46,6 @@ static bool s_pool_settings_dirty = false;
static bool s_pool_state_loaded = false;
static bool s_show_pool_log = false; // Toggle: false=chart, true=log
// Chart smooth-scroll state
static size_t s_chart_last_n = 0;
static double s_chart_last_newest = -1.0;
static double s_chart_update_time = 0.0;
static float s_chart_interval = 1.0f; // measured seconds between data updates
// Get max threads based on hardware
static int GetMaxMiningThreads()
{
@@ -989,33 +983,15 @@ void RenderMiningTab(App* app)
float plotW = plotRight - plotLeft;
float plotH = std::max(1.0f, plotBottom - plotTop);
// --- Smooth scroll: detect new data and measure interval ---
// Build raw data points — evenly spaced across the plot.
// No smooth-scroll animation: the chart updates in-place
// when new data arrives without any interim compression.
size_t n = chartHistory.size();
double newestVal = chartHistory.back();
double nowTime = ImGui::GetTime();
bool dataChanged = (n != s_chart_last_n) || (newestVal != s_chart_last_newest);
if (dataChanged) {
float dt = (float)(nowTime - s_chart_update_time);
if (dt > 0.3f && dt < 10.0f)
s_chart_interval = s_chart_interval * 0.6f + dt * 0.4f; // smoothed
s_chart_last_n = n;
s_chart_last_newest = newestVal;
s_chart_update_time = nowTime;
}
float elapsed = (float)(nowTime - s_chart_update_time);
float scrollFrac = std::clamp(elapsed / s_chart_interval, 0.0f, 1.0f);
// Build raw data points with smooth scroll offset.
// Newest point is anchored at plotRight; as scrollFrac grows
// the spacing compresses by one virtual slot so the next
// incoming point will appear seamlessly at plotRight.
float virtualSlots = (float)(n - 1) + scrollFrac;
if (virtualSlots < 1.0f) virtualSlots = 1.0f;
float stepW = plotW / virtualSlots;
float stepW = (n > 1) ? plotW / (float)(n - 1) : plotW;
std::vector<ImVec2> rawPts(n);
for (size_t i = 0; i < n; i++) {
float x = plotRight - (float)(n - 1 - i) * stepW;
float x = plotLeft + (float)i * stepW;
float y = plotBottom - (float)((chartHistory[i] - yMin) / (yMax - yMin)) * plotH;
rawPts[i] = ImVec2(x, y);
}