Skip to content

bauhaus: fix scroll step calculation for large-range sliders - #21856

Open
kadykov wants to merge 1 commit into
darktable-org:masterfrom
kadykov:fix/bauhaus-slider-step-large-ranges
Open

bauhaus: fix scroll step calculation for large-range sliders#21856
kadykov wants to merge 1 commit into
darktable-org:masterfrom
kadykov:fix/bauhaus-slider-step-large-ranges

Conversation

@kadykov

@kadykov kadykov commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Problem

The dt_bauhaus_slider_get_step() function computes how much a slider value
changes per scroll-wheel tick. Since the February 2022 refactor
(commit f7561c5e79), the function contains this branch:

if(top >= 100)
    step = 1.f;

For any slider whose visible span (soft range) is ≥ 100, the step is always
hardcoded to 1 — bypassing the logarithmic formula that produces a proportional,
round-number step.

This is unnoticeable for sliders where "1 unit" is a natural granularity (e.g.
a 0–100 % slider, a 0–360° hue slider). However it produces unusable behaviour
for sliders measured in large-valued units. The clearest example is the
color temperature parameter in the color calibration module
(soft range 3000–7000 K, span = 4000):

  • Actual: 1 scroll tick = 1 K — 100 ticks needed to change by 100 K, barely perceptible.
  • Expected: a proportional step, comparable to how the sigmoid contrast
    slider (soft range ~0.7–3.0, span ~2.3) scrolls at 0.01 per tick (~0.4 % of span).

Root cause

The log formula correctly produces "~1 % of visible span, rounded to the nearest
1/2/5 × 10ⁿ". It was always intended to cover all ranges; the >= 100 guard
is an unnecessary short-circuit that happens to give the same answer as the
formula for spans 100–315, but diverges above that.

Fix

Remove the >= 100 guard. The formula now runs for all ranges:

// before
const float top = fminf(max-min, fmaxf(fabsf(min), fabsf(max)));
if(top >= 100)
{
    step = 1.f;
}
else
{
    step = top * fabsf(d->factor) / 100;
    // … log rounding …
}

// after
const float top = fminf(max-min, fmaxf(fabsf(min), fabsf(max)));
step = top * fabsf(d->factor) / 100;
// … log rounding …

Impact

Soft-range span Step (before) Step (after) Example
100 – 315 1 1 (no change) percentage 0-100 %, hue −180…+180°
316 – 794 1 5 0-360° hue (colorbalancergb), radius 0-500 px
795 – 3162 1 10 sigmoid white target 20-1600 nits
3163 + 1 50 / 100 / … temperature soft 3000-7000 K → 50 K

Modules that need a non-formula step can still call dt_bauhaus_slider_set_step()
to override (as contrastntexture.c already does for a very fine 0.0001 step).

Fix #21855

Testing

  • Color calibration temperature slider: scroll wheel now moves in 50 K increments
    (soft range 3000–7000 K active), comparable to Lightroom's default WB step.
  • Old white balance module temperature slider (hard range 1901–25000 K, no soft
    range): scroll moves in 100 K increments.
  • Sigmoid contrast slider (soft range 0.7–3.0): step unchanged at 0.01 ✓
  • Exposure compensation (range ±18 EV, span ≤ 36 < 100): step unchanged ✓
  • 0–100 % sliders: step unchanged at 1 ✓

The 2022 refactor of dt_bauhaus_slider_get_step() introduced a guard:
ranges >= 100 always produce step = 1, bypassing the logarithmic
formula that computes a proportional, round-number step.

This works for medium-range sliders (spans 100-315 still yield step = 1
via the formula anyway) but is far too fine for sliders with large
ranges. Most notably, the color calibration temperature slider (soft
range 3000-7000 K, span = 4000) gets step = 1 K per scroll tick,
requiring 100 scroll steps to move 100 K — barely perceptible.

Remove the guard and let the log formula run for all ranges:

  span 100-315  → step 1     (no change, same as the old guard)
  span 316-794  → step 5     (e.g. 0-360° hue: 72 steps per revolution)
  span 795-3162 → step 10    (e.g. radius 0-500 px, sigmoid white target)
  span 3163+    → step 50+   (e.g. temperature soft 3000-7000 K → 50 K)

Modules that genuinely need a non-formula step can still override via
dt_bauhaus_slider_set_step().
Copilot AI lite review requested due to automatic review settings August 15, 2026 13:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes mouse scroll-wheel step sizing for Bauhaus sliders with large visible (soft) ranges by removing a hard-coded step = 1 shortcut and always using the existing logarithmic “~1% of range” rounding logic. This improves usability for large-unit sliders like color temperature (Kelvin) while keeping behavior unchanged for common small-range sliders.

Changes:

  • Remove the top >= 100 guard that forced step = 1.f for large soft ranges.
  • Always compute the scroll step from the proportional/log-rounded formula for all ranges.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@TurboGit TurboGit added this to the 5.8 milestone Aug 15, 2026
@TurboGit TurboGit added bugfix pull request fixing a bug priority: medium core features are degraded in a way that is still mostly usable, software stutters ai:generated labels Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:generated bugfix pull request fixing a bug priority: medium core features are degraded in a way that is still mostly usable, software stutters

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Color temperature scroll-wheel step is too fine (1 K per tick)

3 participants