zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit b97d2037fd02e7b88b4047b857992fb80b2953f6
parent 4a1ff9edd6ce9b485f59747dc1f8db935e33acb0
Author: fundamental <mark.d.mccurry@gmail.com>
Date:   Mon, 16 Jun 2014 14:57:38 -0400

EnvUI: Add Mousewheel Support

Another Commit in the Christopher Oliver patch set

Diffstat:
Msrc/UI/EnvelopeUI.fl | 35+++++++++++++++++++++++++++++++----
1 file changed, 31 insertions(+), 4 deletions(-)

diff --git a/src/UI/EnvelopeUI.fl b/src/UI/EnvelopeUI.fl @@ -50,7 +50,8 @@ pair=NULL;} {} oldx=-1; currentpoint=-1; cpx=0; -lastpoint=-1;} {} +lastpoint=-1; +ctrldown=false;} {} } Function {setpair(Fl_Box *pair_)} {} { code {pair=pair_;} {} @@ -140,23 +141,48 @@ if (env->Penvsustain>0){ //Show the envelope duration and the current line duration fl_font(FL_HELVETICA|FL_BOLD,10); float time=0.0; -if (currentpoint<=0){ +if (currentpoint<=0 && (!ctrldown||lastpoint <= 0)){ fl_color(alb); for (int i=1;i<npoints;i++) time+=env->getdt(i); } else { fl_color(255,0,0); - time=env->getdt(currentpoint); + time=env->getdt(lastpoint); }; char tmpstr[20]; if (time<1000.0) snprintf((char *)&tmpstr,20,"%.1fms",time); else snprintf((char *)&tmpstr,20,"%.2fs",time/1000.0); -fl_draw(tmpstr,ox+lx-20,oy+ly-10,20,10,FL_ALIGN_RIGHT,NULL,0);} {} +fl_draw(tmpstr,ox+lx-20,oy+ly-10,20,10,FL_ALIGN_RIGHT,NULL,0); +if (lastpoint>=0){ + snprintf((char *)&tmpstr,20,"%d", env->Penvval[lastpoint]); + fl_draw(tmpstr,ox+lx-20,oy+ly-23,20,10,FL_ALIGN_RIGHT,NULL,0); +}} {} } Function {handle(int event)} {return_type int } { code {int x_=Fl::event_x()-x(); int y_=Fl::event_y()-y(); +if ((event==FL_KEYDOWN || event==FL_KEYUP)){ + int key = Fl::event_key(); + if (key==FL_Control_L || key==FL_Control_R){ + ctrldown = (event==FL_KEYDOWN); + redraw(); + if (pair!=NULL) pair->redraw(); + } +} + +if (event==FL_MOUSEWHEEL && lastpoint>=0) { + if (!ctrldown) { + int ny=env->Penvval[lastpoint] - Fl::event_dy(); + env->Penvval[lastpoint]=ny < 0 ? 0 : ny > 127 ? 127 : ny; + } else if (lastpoint > 0) { + int newdt = Fl::event_dy() + env->Penvdt[lastpoint]; + env->Penvdt[lastpoint] = newdt < 0 ? 0 : newdt > 127 ? 127 : newdt; + } + redraw(); + if (pair!=NULL) pair->redraw(); +} + if (event==FL_PUSH) { currentpoint=getnearest(x_,y_); cpx=x_; @@ -196,6 +222,7 @@ return(1);} {} decl {int currentpoint,cpx,cpdt;} {} decl {int lastpoint;} {public } + decl {bool ctrldown;} {} } class EnvelopeUI {open : {public Fl_Group,PresetsUI_}