Unaccessible Magic Number in Viewport implementation


#1

There is a magic number in rescaleMouseWheelDistance.

This is a problem for me because my ListBox uses less than 10 items, but they’re all very tall and I would like to scroll through the listbox without making huge (3000px) jumps (one item is 840 px).

Maybe I’m just using listbox wrong?

This is a static method that is in juce_Viewport.cpp, there is no way to change the magic 14.0f, and I can’t counter it at all with the singleStepSize because it’s an int.

static int rescaleMouseWheelDistance (float distance, int singleStepSize) noexcept
{
    if (distance == 0)
        return 0;

    distance *= 14.0f * singleStepSize;

    return roundToInt (distance < 0 ? jmin (distance, -1.0f)
                                : jmax (distance,  1.0f));
}

OR I could just do as I always do when I run into these arbitrary implementations, roll my own and base it on the JUCE implementation, but I just want to change 1 number.

Is this possible to fix or should I just roll my own and get on with it?

EDIT: Seems like I cannot set singleStepSize at all. It’s always the ListBox row height.

EDIT2:
In ListBox::resized() there is a line:
viewport->setSingleStepSizes (20, getRowHeight());