Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NioUI.cpp 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #include "NioUI.h"
  2. #include "../Nio/Nio.h"
  3. #include <cstdio>
  4. #include <iostream>
  5. #include <cstring>
  6. #include <FL/Fl_Pack.H>
  7. #include <FL/Fl_Spinner.H>
  8. #include <FL/Enumerations.H>
  9. #include <FL/Fl_Choice.H>
  10. #include <FL/Fl_Tabs.H>
  11. #include <FL/Fl_Group.H>
  12. #include <FL/Fl_Text_Display.H>
  13. using namespace std;
  14. NioUI::NioUI()
  15. :Fl_Window(200, 100, 400, 400, "New IO Controls")
  16. {
  17. //hm, I appear to be leaking memory
  18. Fl_Group *settings = new Fl_Group(0, 20, 400, 400 - 35, "Settings");
  19. {
  20. audio = new Fl_Choice(60, 80, 100, 25, "Audio");
  21. audio->callback(audioCallback);
  22. midi = new Fl_Choice(60, 100, 100, 25, "Midi");
  23. midi->callback(midiCallback);
  24. }
  25. settings->end();
  26. //initialize midi list
  27. {
  28. set<string> midiList = Nio::getSources();
  29. string source = Nio::getSource();
  30. int midival = 0;
  31. for(set<string>::iterator itr = midiList.begin();
  32. itr != midiList.end(); ++itr) {
  33. midi->add(itr->c_str());
  34. if(*itr == source)
  35. midival = midi->size() - 2;
  36. }
  37. midi->value(midival);
  38. }
  39. //initialize audio list
  40. {
  41. set<string> audioList = Nio::getSinks();
  42. string sink = Nio::getSink();
  43. int audioval = 0;
  44. for(set<string>::iterator itr = audioList.begin();
  45. itr != audioList.end(); ++itr) {
  46. audio->add(itr->c_str());
  47. if(*itr == sink)
  48. audioval = audio->size() - 2;
  49. }
  50. audio->value(audioval);
  51. }
  52. resizable(this);
  53. size_range(400, 300);
  54. }
  55. NioUI::~NioUI()
  56. {}
  57. void NioUI::refresh()
  58. {}
  59. void NioUI::midiCallback(Fl_Widget *c)
  60. {
  61. bool good = Nio::setSource(static_cast<Fl_Choice *>(c)->text());
  62. static_cast<Fl_Choice *>(c)->textcolor(fl_rgb_color(255 * !good, 0, 0));
  63. }
  64. void NioUI::audioCallback(Fl_Widget *c)
  65. {
  66. bool good = Nio::setSink(static_cast<Fl_Choice *>(c)->text());
  67. static_cast<Fl_Choice *>(c)->textcolor(fl_rgb_color(255 * !good, 0, 0));
  68. }