cjcliffe / CubicSDR

Cross-Platform Software-Defined Radio Application
http://www.cubicsdr.com
GNU General Public License v2.0
2.07k stars 256 forks source link

Mouse Wheel ranges for meter canvases #353

Closed cjcliffe closed 8 years ago

cjcliffe commented 8 years ago

Reference: #309 PR: #355

vsonnier commented 8 years ago

@cjcliffe I tried the https://github.com/cjcliffe/CubicSDR/tree/mousewheel_tweak branch (ce1cd2700724c77312dd42f61bf7f361c9730f38) and so far the pros and cons compared to master are:

I tried the folowing modification of MeterCanvas.cpp:

void MeterCanvas::OnMouseWheelMoved(wxMouseEvent& event) {
    InteractiveCanvas::OnMouseWheelMoved(event);
    float movement = 3.0 * (float)event.GetWheelRotation() ;

And it looked much more responsive that way: I counted 28 wheel-clicks now to cover a whole range, but I guess it may be much platform DPI dependent...

cjcliffe commented 8 years ago

@vsonnier thanks for the report -- I'll give your suggestion a go it looks simpler than mine -- and I haven't added support to gain yet but that's next on the list.

edit: yep that movement parameter is better on OSX too; I should perhaps try it elsewhere as well..

cjcliffe commented 8 years ago

@vsonnier I've pushed a few updates to mousewheel_tweak -- let me know how that works for you.

vsonnier commented 8 years ago

Retried the mousewheel_tweak branch, (https://github.com/cjcliffe/CubicSDR/commit/baa7501711690dc37a1de19d72e13622eef27981) everything is fine now on my side, with the Manual gain still to have mousewheel support. Thank you !

cjcliffe commented 8 years ago

@vsonnier hah; I forgot to actually add focus to the gain so that it works in Win7 -- I've pushed a fix for that now; likely going to merge to master shortly so I can keep working on the session loading bug (which I've reproduced here now in Win10 from your xml)

vsonnier commented 8 years ago

@cjcliffe Gain is working now, except the meter is escaping to +-infinity:)

That actually fixes it in GainCanvas.cpp:

void GainCanvas::OnMouseWheelMoved(wxMouseEvent& event) {
    InteractiveCanvas::OnMouseWheelMoved(event);
  ...
        gInfo->current = gInfo->current + ((movement / 100.0) * ((gInfo->high - gInfo->low) / 100.0));

        //BEGIN Clamp to prevent the meter to escape :)
        if (gInfo->current > gInfo->high) {
            gInfo->current = gInfo->high;
        }
        if (gInfo->current < gInfo->low) {
            gInfo->current = gInfo->low;
        }
        //END Clamp to prevent the meter to escape :)

        gInfo->changed = true;

        float levelVal = float(gInfo->current-gInfo->low)/float(gInfo->high-gInfo->low);
        gInfo->levelPanel.setSize(1.0, levelVal);
        gInfo->levelPanel.setPosition(0.0, levelVal-1.0);

        gInfo->valuePanel.setText(std::to_string(int(gInfo->current)));
    }