KnobEventHandler motion event handling broken when using log scale
If you set a knob to use a logarithmic scale, manipulating the knob value by clicking and dragging the mouse on the knob does not work correctly: The value remains on the minimum value or something very close to it. Changing the value using the mouse wheel works correctly.
Can be reproduced with the CairoUI example by inserting the following lines in the constructor:
fKnob->setRange(1.0f, 100.0f);
fKnob->setUsingLogScale(true);
thanks for the report. it is likely a regression from the recent changes to fix integer behaviour
I just ran into this and it looks like this commit got rid of some calls to invlogscale().
Adding a matching call to invlogscale() just above this seems to have fixed it, though I'm not familiar enough with the code to be confident that it's the Right Thing to do:
https://github.com/DISTRHO/DPF/blob/f5815166356e85a5fe244f6024c2e401f04b10fa/dgl/src/EventHandlers.cpp#L446-L450
I think I can confirm this on develop as of today.
Replacing line 505 of EventHandlers.cpp with this seems to fix:
valueTmp = invlogscale(logscale(valueTmp));
I think I can confirm this on
developas of today.Replacing line 505 of EventHandlers.cpp with this seems to fix:
valueTmp = invlogscale(logscale(valueTmp));
doesnt that simply revert the changes to valueTmp? or does the scaling and unscaling do some normalized scale in the end?
You're right, I just checked and the value before and after is actually the same.
While investigating this and testing with AidaKnob, which I had to modify a bit, I realised that setting it to log scale somehow breaks the display of the knob, even when replacing the texture by a rectangle, it just shows a blank space.
I have tried to take inspiration from the scrollEvent handler from a few lines below and did this to no avail, the value instantly jumps to NaN:
const float divisor = (ev.mod & kModifierControl) ? accel * 10.f : accel;
valueTmp = (usingLog ? invlogscale(valueTmp) : valueTmp)
+ ((maximum - minimum) / divisor * static_cast<float>(movDiff));
if (usingLog)
valueTmp = logscale(valueTmp);
The file has some comments like this: // NOTE: value is assumed to be scaled if using log so maybe my implementation is the issue.
I misunderstood the solution given above, changing to this fixes log scale as far as I can tell:
const float divisor = (ev.mod & kModifierControl) ? accel * 10.f : accel;
if (usingLog)
valueTmp = invlogscale(valueTmp);
valueTmp += (maximum - minimum) / divisor * static_cast<float>(movDiff);
if (usingLog)
valueTmp = logscale(valueTmp);