imgui-knobs
imgui-knobs copied to clipboard
Detect double-click?
First off, this is a great library. Thanks a ton for making it available.
This might be possible already, but I'd love to be able to detect a double-click on the knob. For example, in Ableton Live, double-clicking on a knob returns it to its default value.
While I'm talking about Ableton Live, there's another optional feature I'd love to see in ImGui. I can make this a separate issue if you want, but it's just an idea: Freezing the mouse cursor and making it invisible for the duration of the adjustment. This is good for sweeping knobs without losing your place. I can hack this behavior in to an extent but it would be nice to have as a real feature.
I have actually implemented this in my fork of dpf-widgets: https://github.com/DISTRHO/DPF-Widgets/compare/main...Wasted-Audio:DPF-Widgets:wstd_mods#diff-46806d8c1274d40596ae9550fc781589e30c63855e35de95f03b53e675b5ee0bR201-R204
Which then requires something like this in your code:
if (ImGui::IsItemActivated())
{
if (ImGui::IsMouseDoubleClicked(0))
<do_something>
}
Example plugin that uses this: https://github.com/Wasted-Audio/wstd-eq/blob/master/override/HeavyDPF_WSTD_EQ_UI.cpp#L145-L154
I've been away for a while, but better late than never I guess :)
Thank you for your suggestion! Like @dromer shows, you can implement double click to reset with standard imgui functionality. I've added it to the readme and to a demo in the repo.
I like the cursor freeze idea! I'll keep this issue open to track it :)
@altschuler well not entirely. I had to modify imgui-knobs to set k.value_changed = true; when this happens.
@altschuler well not entirely. I had to modify imgui-knobs to set
k.value_changed = true;when this happens.
Right, I see. Why is that? What's the reason you're setting the changed flag and then checking for double click inside the if again? I'm just curious whether there's a drawback to simply checking after drawing the knob as usual.
@altschuler it's been a while, but I think then the graphic doesn't update.
Freezing/hiding the mouse cursor would involve platform specific system code and libraries which I don't want to include by default. It's out of scope for now at least, so closing this.
@altschuler so to confirm: you don't want to add ImGuiKnobFlags_DoubleClickReset so that we can activate k.value_changed ?
@altschuler so to confirm: you don't want to add
ImGuiKnobFlags_DoubleClickResetso that we can activatek.value_changed?
If it’s needed sure! But I don’t understand why it’s needed. It seems to work as expected without it. Can you clarify what you mean by the graphics don’t update?
I need to check what the requirement for k.value_changed is.