imgui-knobs icon indicating copy to clipboard operation
imgui-knobs copied to clipboard

Detect double-click?

Open ci-bo opened this issue 2 years ago • 1 comments

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.

ci-bo avatar Apr 29 '23 10:04 ci-bo

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

dromer avatar Nov 17 '23 16:11 dromer

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 avatar Aug 30 '24 09:08 altschuler

@altschuler well not entirely. I had to modify imgui-knobs to set k.value_changed = true; when this happens.

dromer avatar Aug 30 '24 10:08 dromer

@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 avatar Aug 30 '24 19:08 altschuler

@altschuler it's been a while, but I think then the graphic doesn't update.

dromer avatar Aug 30 '24 20:08 dromer

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 avatar Aug 30 '24 21:08 altschuler

@altschuler so to confirm: you don't want to add ImGuiKnobFlags_DoubleClickReset so that we can activate k.value_changed ?

dromer avatar Sep 01 '24 15:09 dromer

@altschuler so to confirm: you don't want to add ImGuiKnobFlags_DoubleClickReset so that we can activate k.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?

altschuler avatar Sep 01 '24 15:09 altschuler

I need to check what the requirement for k.value_changed is.

dromer avatar Sep 01 '24 15:09 dromer