#include "NioUI.h" #include "../Nio/Nio.h" #include #include #include #include #include #include #include #include #include #include using namespace std; NioUI::NioUI() :Fl_Window(200, 100, 400, 400, "New IO Controls") { //hm, I appear to be leaking memory Fl_Group *settings = new Fl_Group(0, 20, 400, 400 - 35, "Settings"); { audio = new Fl_Choice(60, 80, 100, 25, "Audio"); audio->callback(audioCallback); midi = new Fl_Choice(60, 100, 100, 25, "Midi"); midi->callback(midiCallback); } settings->end(); //initialize midi list { set midiList = Nio::getSources(); string source = Nio::getSource(); int midival = 0; for(set::iterator itr = midiList.begin(); itr != midiList.end(); ++itr) { midi->add(itr->c_str()); if(*itr == source) midival = midi->size() - 2; } midi->value(midival); } //initialize audio list { set audioList = Nio::getSinks(); string sink = Nio::getSink(); int audioval = 0; for(set::iterator itr = audioList.begin(); itr != audioList.end(); ++itr) { audio->add(itr->c_str()); if(*itr == sink) audioval = audio->size() - 2; } audio->value(audioval); } resizable(this); size_range(400, 300); } NioUI::~NioUI() {} void NioUI::refresh() {} void NioUI::midiCallback(Fl_Widget *c) { bool good = Nio::setSource(static_cast(c)->text()); static_cast(c)->textcolor(fl_rgb_color(255 * !good, 0, 0)); } void NioUI::audioCallback(Fl_Widget *c) { bool good = Nio::setSink(static_cast(c)->text()); static_cast(c)->textcolor(fl_rgb_color(255 * !good, 0, 0)); }