Nelarius / imnodes

A small, dependency-free node editor for dear imgui
MIT License
2.01k stars 244 forks source link

Suggestion: keep middle mouse scrolling always active, even when emulate_three_button_mouse is enabled #82

Closed francesco-cattoglio closed 3 years ago

francesco-cattoglio commented 3 years ago

Hi there, I have started testing imnodes on a laptop and realized how much useful the "emulate three button mouse" option is, thank you very much for it! However I noticed that enabling the option disables scrolling using the middle mouse. Would you mind adding the possibility of keeping both methods active?

Right now this is the code is in imnodes.cpp at line 1117:

    const bool started_panning =
        g.io.emulate_three_button_mouse.enabled
            ? (g.left_mouse_clicked && *g.io.emulate_three_button_mouse.modifier)
            : g.middle_mouse_clicked;

Instead of a ternary, one could just write

    const bool started_panning =
        (g.io.emulate_three_button_mouse.enabled && g.left_mouse_clicked && *g.io.emulate_three_button_mouse.modifier)
        || g.middle_mouse_clicked;

and similar change would be needed at around line 1424:

        const bool dragging =
            (g.io.emulate_three_button_mouse.enabled && g.left_mouse_dragging && *g.io.emulate_three_button_mouse.modifier)
            || g.middle_mouse_dragging;

If you want to retain exclusive behavior the expression might be a bit more complicated than that, and one would probably need another bool inside the EmulateThreeButtonMouse structure.

Nelarius commented 3 years ago

Hi @francesco-cattoglio and thanks for the suggestion! I don't see any particular reason to retain exclusive behavior. I added the feature originally because I was often on my laptop without a mouse and just wanted to pan around, simple as that 🙂 Keeping the middle mouse button active seems like a good thing for users on the laptop with a mouse plugged in.