From 7547cc65fdca09915fa8b4086258245a0be76ac8 Mon Sep 17 00:00:00 2001 From: EvanR Date: Tue, 26 May 2009 12:41:23 -0400 Subject: [PATCH] Dynamically updating controller widgets, and now in decimal! When volume, pan, or program change on a track, the widgets in the track settings module update to show the change. They also display the current value in decimal when you are editing them. This makes the program widget on the second panel actually useful. The bank does not update and needs more work before it can be fully functional (MSB/LSB). The pan widget now has a different display. --- src/seq.cpp | 9 ++++- src/seq.h | 9 +++++ src/trackinfo.cpp | 7 ++++ src/trackinfo.h | 1 + src/trackmodule.cpp | 107 ++++++++++++++++++++++++++++++++++++++++------------ src/trackmodule.h | 1 + src/uihelper.cpp | 7 ++++ 7 files changed, 116 insertions(+), 25 deletions(-) diff --git a/src/seq.cpp b/src/seq.cpp index 5d4871f..123ddda 100644 --- a/src/seq.cpp +++ b/src/seq.cpp @@ -170,7 +170,14 @@ switchblock: else if(i->e->type == MIDI_NOTE_OFF){ tracks[i->t]->onbits.set(i->e->value1, 0); } - + + if(i->e->type == MIDI_CONTROLLER_CHANGE){ + tracks[i->t]->contr[i->e->value1] = i->e->value2; + } + if(i->e->type == MIDI_PROGRAM_CHANGE){ + tracks[i->t]->prog = i->e->value1; + } + dispatch_event(i->e, i->t, i->s->tick); i++; diff --git a/src/seq.h b/src/seq.h index 699dd2d..744a1fc 100644 --- a/src/seq.h +++ b/src/seq.h @@ -300,6 +300,10 @@ struct track { OnBitArray onbits; + int contr[128]; + int pressure; + int pitchwheel; + int modified; void restate(); @@ -320,6 +324,11 @@ struct track { head->tick = 0; skip = head; modified = 0; + + pressure = 64; + pitchwheel = 0; + contr[7] = 64; + contr[10] = 64; } ~track(){ diff --git a/src/trackinfo.cpp b/src/trackinfo.cpp index 8b87840..75fc483 100644 --- a/src/trackinfo.cpp +++ b/src/trackinfo.cpp @@ -89,6 +89,13 @@ void TrackInfo::toggle_controls(){ } +void TrackInfo::dynamic_update(){ + //for each child cast to TrackModule and call update + for(int i=0; idynamic_update(); + } +} + void TrackInfo::update(){ //for each child cast to TrackModule and call update for(int i=0; iport = (int)o->value; } - } void chancb(fltk::Widget* w, long i){ @@ -147,8 +146,8 @@ void volcb(fltk::Widget* w, long i){ track* t = tracks[i]; t->vol = o->value; + t->contr[7] = o->value; midi_volume_controller(i, t->vol); - //perhaps record this } void pancb(fltk::Widget* w, long i){ @@ -156,6 +155,7 @@ void pancb(fltk::Widget* w, long i){ track* t = tracks[i]; t->pan = o->value; + t->contr[10] = o->value; midi_pan_controller(i, t->pan); } @@ -341,6 +341,26 @@ void TrackModule::set_rec(){ } +void TrackModule::dynamic_update(){ + track* t = tracks[index]; + int do_update = 0; + + if(t->prog != prog.value){ + prog.value = t->prog; + prog.redraw(); + } + + if(t->contr[7] != volume.value){ + volume.value = t->contr[7]; + volume.redraw(); + } + + if(t->contr[10] != pan.value){ + pan.value = t->contr[10]; + pan.redraw(); + } +} + void TrackModule::update(){ track* t = tracks[index]; name.text(t->name); @@ -392,7 +412,7 @@ Gauge::Gauge(int x, int y, int w, int h, const char* label) : label_flag = 0; label_always = 0; label_plusone = 0; - label_hex = 1; + label_hex = 0; gauge_off = 0; label_temp=0; sens=1; @@ -505,21 +525,37 @@ void VGauge::draw(){ fltk::fillrect(2,h()-2-H,w()-4,H); if(label_flag || label_always || label_temp){ - char buf[3]; + char buf[8]; int V = label_plusone ? value + 1 : value; if(label_hex){ - snprintf(buf,3,"%x",V); + snprintf(buf,8,"%x",V); } else{ - snprintf(buf,3,"%d",V); + snprintf(buf,8,"%d",V); } fltk::push_clip(2,2,w()-4,h()-4 - H); fltk::setcolor(fltk::color(R,G,B)); - fltk::setfont(fltk::HELVETICA,12); + int W = (int)fltk::getwidth(buf); - fltk::drawtext(buf,(w()-W)/2,h()-fltk::getascent()/2); + int X; + int Y; + + if(value > 99){ + fltk::setfont(fltk::HELVETICA,9); + X = 1; + Y = 13; + } + else{ + fltk::setfont(fltk::HELVETICA,12); + X = (w()-W)/2; + Y = 14; + } + + + //fltk::drawtext(buf,(w()-W)/2,h()-fltk::getascent()/2); + fltk::drawtext(buf,X,Y); fltk::pop_clip(); @@ -527,10 +563,13 @@ void VGauge::draw(){ if(!gauge_off){ fltk::setcolor(fltk::color(r,g,b)); } - fltk::setfont(fltk::HELVETICA,12); - fltk::drawtext(buf,(w()-W)/2,h()-fltk::getascent()/2); + //fltk::setfont(fltk::HELVETICA,12); + //fltk::drawtext(buf,(w()-W)/2,h()-fltk::getascent()/2); + fltk::drawtext(buf,X,Y); fltk::pop_clip(); } + + fltk::setfont(fltk::HELVETICA,12); } void HGauge::draw(){ @@ -539,26 +578,46 @@ void HGauge::draw(){ fltk::fillrect(2,2,w()-4,h()-4); fltk::setcolor(fltk::color(R,G,B)); - int V = value * (h()-4) / max; - fltk::fillrect(2,2,V,h()-4); + int V = value * (h()-5) / max; + //fltk::fillrect(2,2,V,h()-4); + fltk::drawline(V+2, 2, V+2, h()-3); if(label_flag || label_always || label_temp){ - char buf[3]; - snprintf(buf,3,"%x",value); + char buf[8]; + snprintf(buf,8,"%d",value); + - fltk::push_clip(V+2,2,w()-4-V,h()-4); - fltk::setcolor(fltk::color(R,G,B)); - fltk::setfont(fltk::HELVETICA,12); int W = (int)fltk::getwidth(buf); - fltk::drawtext(buf,(w()-W)/2,h()-fltk::getascent()/2); - fltk::pop_clip(); + int X; + int Y; + if(value > 99){ + fltk::setfont(fltk::HELVETICA,9); + X = 1; + Y = 13; + } + else{ + fltk::setfont(fltk::HELVETICA,12); + X = (w()-W)/2; + Y = 14; + } - fltk::push_clip(2,2,V,h()-4); - fltk::setcolor(fltk::color(r,g,b)); - fltk::setfont(fltk::HELVETICA,12); - fltk::drawtext(buf,(w()-W)/2,h()-fltk::getascent()/2); - fltk::pop_clip(); + //fltk::push_clip(V+2,2,w()-4-V,h()-4); + fltk::setcolor(fltk::color(R,G,B)); + //fltk::setfont(fltk::HELVETICA,12); + + //fltk::drawtext(buf,(w()-W)/2,h()-fltk::getascent()/2); + fltk::drawtext(buf,X,Y); + //fltk::pop_clip(); + + //fltk::push_clip(2,2,V,h()-4); + //fltk::setcolor(fltk::color(r,g,b)); + //fltk::setfont(fltk::HELVETICA,12); + //fltk::drawtext(buf,(w()-W)/2,h()-fltk::getascent()/2); + //fltk::drawtext(buf,X,Y); + //fltk::pop_clip(); } + + fltk::setfont(fltk::HELVETICA,12); } Toggle::Toggle(int x, int y, int w, int h, const char* label) : diff --git a/src/trackmodule.h b/src/trackmodule.h index bc153b0..edcfecc 100644 --- a/src/trackmodule.h +++ b/src/trackmodule.h @@ -128,6 +128,7 @@ class TrackModule : public fltk::Group { void set_rec(); void unset_solo(); + void dynamic_update(); void update(); }; diff --git a/src/uihelper.cpp b/src/uihelper.cpp index be632e7..b6fd9bc 100644 --- a/src/uihelper.cpp +++ b/src/uihelper.cpp @@ -461,6 +461,10 @@ void playing_timeout_cb(void* v){ } + //maybe do dynamic update of controller widgets + ui->track_info->dynamic_update(); + + if(is_backend_playing()){ fltk::repeat_timeout(0.005, playing_timeout_cb, NULL); } @@ -897,3 +901,6 @@ void shutdown_gui(){ ui->action_window->hide(); ui->scope_window->hide(); } + + + -- 2.11.4.GIT